package com.fca.uconnect.global.test;

import static org.junit.Assert.assertEquals;

import java.util.List;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.fca.uconnect.global.GlobalUconnectControl.UconnectAny;
import com.fca.uconnect.global.GlobalUconnectExtActivation;
import com.fca.uconnect.global.GlobalUconnectExtProvision;
import com.fca.uconnect.global.SDPExampleForActivation;
import com.fca.uconnect.global.TBMExampleForActivation;



public class ActivationTest {
	static SDPExampleForActivation referenceService = new SDPExampleForActivation();
	static TBMExampleForActivation referenceClient =new TBMExampleForActivation();

	@BeforeClass
	public  static  void setUpClass(){
		try {
			  referenceService.process();
			  Thread.sleep(1000);
			  //referenceClient.process();
		} catch (Exception e) {
			e.printStackTrace();
		}				
	}	 

	 
	@Test
	public void testActivtionSuccess() throws Exception{
		    List<UconnectAny> messages = referenceClient.process();
		    for(UconnectAny message:messages){
	 			if(message.hasExtension(GlobalUconnectExtActivation.activationResponse)) {	
	 				GlobalUconnectExtActivation.ActivationResponse.ResponseEnum responseForActivation = message.getExtension(GlobalUconnectExtActivation.activationResponse).getResponse();
						assertEquals(GlobalUconnectExtActivation.ActivationResponse.ResponseEnum.ACTIVATED,responseForActivation);
	 			}else if(message.hasExtension(GlobalUconnectExtProvision.provisioningPush)){
	 				GlobalUconnectExtProvision.ProvisioningPush provPush = message.getExtension(GlobalUconnectExtProvision.provisioningPush);
	 				//assertEquals(provPush.getServiceSubscriptionInfo().getServicesCount(),2);
	 			}
		    }
	}
	@AfterClass
	public  static  void disconnectClass(){
		try {
			referenceService.disconnect();
			referenceClient.disconnect();
		} catch (Exception e) {
			e.printStackTrace();
		}				
	}	 
}
