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.GlobalUconnectExtTheftAlarmNotify;
import com.fca.uconnect.global.SDPExampleForTheftAlarm;
import com.fca.uconnect.global.TBMExampleForTheftAlarm;



public class TheftAlarmTest {
	static SDPExampleForTheftAlarm referenceService = new SDPExampleForTheftAlarm();
	static TBMExampleForTheftAlarm referenceClient =new TBMExampleForTheftAlarm();

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

	 
	@Test
	public void testTheftAlarmNotifyDelivered() throws Exception{
		    List<UconnectAny> messages = referenceClient.process();
		    for(UconnectAny message:messages){
	 			if(message.hasExtension(GlobalUconnectExtTheftAlarmNotify.theftAlarmNotificationResponse)) {	
	 				GlobalUconnectExtTheftAlarmNotify.TheftAlarmNotificationResponse.TheftAlarmResponseEnum responseForTheftAlarm = message.getExtension(GlobalUconnectExtTheftAlarmNotify.theftAlarmNotificationResponse).getResponse();
					if(responseForTheftAlarm!=null && responseForTheftAlarm.equals( GlobalUconnectExtTheftAlarmNotify.TheftAlarmNotificationResponse.TheftAlarmResponseEnum.SUCCESS)){
						assertEquals(GlobalUconnectExtTheftAlarmNotify.TheftAlarmNotificationResponse.TheftAlarmResponseEnum.SUCCESS,responseForTheftAlarm);
						break;
					}
	 			}
		    }
	}
	@AfterClass
	public  static  void disconnectClass(){
		try {
			referenceService.disconnect();
			referenceClient.disconnect();
		} catch (Exception e) {
			e.printStackTrace();
		}				
	}	 
}
