mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestCommandHandlerMgrImpl.java
@Test
    public void testCommandEventHandler()
    {
        String summary = "Asset Command Executed:";
        UUID assetUuid = UUID.randomUUID();
        mil.dod.th.core.remote.proto.SharedMessages.UUID assetUuidProto = 
                SharedMessageUtils.convertUUIDToProtoUUID(assetUuid);
        
        ExecuteCommandResponseData testResponse = ExecuteCommandResponseData.newBuilder().setUuid(
            assetUuidProto).setResponseType(CommandTypesGen.CommandResponse.Enum.SET_PAN_TILT_RESPONSE).setResponse(
                        ByteString.copyFrom(new byte[] {0 ,1 ,2})).build();
        
        when(m_CommandConverter.getCommandTypeFromResponseType(CommandResponseEnum.SET_PAN_TILT_RESPONSE))
            .thenReturn(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(RemoteConstants.EVENT_PROP_DATA_MESSAGE, testResponse);
        props.put(RemoteConstants.EVENT_PROP_SOURCE_ID, CONTROLLER_ID);
        Event testEvent = new Event(RemoteConstants.TOPIC_MESSAGE_RECEIVED, props);
        
        //Test set pan tilt response.
        m_SUT.handleEvent(testEvent);
        
        //Verify growl message was posted and that its content is correct.
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, summary, 
                "SetPanTiltCommand executed for asset with uuid: " + assetUuid);
        
        //Test set camera settings response.
        testResponse = testResponse.toBuilder().setResponseType(
                CommandTypesGen.CommandResponse.Enum.SET_CAMERA_SETTINGS_RESPONSE).build();
        when(m_CommandConverter.getCommandTypeFromResponseType(CommandResponseEnum.SET_CAMERA_SETTINGS_RESPONSE))
            .thenReturn(CommandTypeEnum.SET_CAMERA_SETTINGS_COMMAND);
        props.put(RemoteConstants.EVENT_PROP_DATA_MESSAGE, testResponse);
        props.put(RemoteConstants.EVENT_PROP_SOURCE_ID, CONTROLLER_ID);
        testEvent = new Event(RemoteConstants.TOPIC_MESSAGE_RECEIVED, props);
        m_SUT.handleEvent(testEvent);
        
        //Verify growl message was posted and that its content is correct.
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, summary, 
                "SetCameraSettingsCommand executed for asset with uuid: " + assetUuid);
        
        //Test capture image command.
        testResponse = testResponse.toBuilder().setResponseType(
                CommandTypesGen.CommandResponse.Enum.CAPTURE_IMAGE_RESPONSE).build();
        when(m_CommandConverter.getCommandTypeFromResponseType(CommandResponseEnum.CAPTURE_IMAGE_RESPONSE))
            .thenReturn(CommandTypeEnum.CAPTURE_IMAGE_COMMAND);
        
        props.put(RemoteConstants.EVENT_PROP_DATA_MESSAGE, testResponse);
        props.put(RemoteConstants.EVENT_PROP_SOURCE_ID, CONTROLLER_ID);
        testEvent = new Event(RemoteConstants.TOPIC_MESSAGE_RECEIVED, props);
        m_SUT.handleEvent(testEvent);
        
        //Verify growl message was posted and that its content is correct.
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, summary, 
                "CaptureImageCommand executed for asset with uuid: " + assetUuid);

        //Test detect target command.
        testResponse = testResponse.toBuilder().setResponseType(
                CommandTypesGen.CommandResponse.Enum.DETECT_TARGET_RESPONSE).build();
        when(m_CommandConverter.getCommandTypeFromResponseType(CommandResponseEnum.DETECT_TARGET_RESPONSE))
            .thenReturn(CommandTypeEnum.DETECT_TARGET_COMMAND);
        props.put(RemoteConstants.EVENT_PROP_DATA_MESSAGE, testResponse);
        props.put(RemoteConstants.EVENT_PROP_SOURCE_ID, CONTROLLER_ID);
        testEvent = new Event(RemoteConstants.TOPIC_MESSAGE_RECEIVED, props);
        m_SUT.handleEvent(testEvent);
        
        //Verify growl message was posted and that its content is correct.
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, summary, 
                "DetectTargetCommand executed for asset with uuid: " + assetUuid);
    }
/**
     * Test the command event handler.
     * Verify that a responses for each of the four command types is handled appropriately.
     */
Test the command event handler.
Verify that a responses for each of the four command types is handled appropriately.
Test the command event handler . Verify that a responses for each of the four command types is handled appropriately .
@Test
    public void testCommandEventHandler()
    {
        String summary = "Asset Command Executed:";
        UUID assetUuid = UUID.randomUUID();
        mil.dod.th.core.remote.proto.SharedMessages.UUID assetUuidProto = 
                SharedMessageUtils.convertUUIDToProtoUUID(assetUuid);
        ExecuteCommandResponseData testResponse = ExecuteCommandResponseData.newBuilder().setUuid(
            assetUuidProto).setResponseType(CommandTypesGen.CommandResponse.Enum.SET_PAN_TILT_RESPONSE).setResponse(
                        ByteString.copyFrom(new byte[] {0 ,1 ,2})).build();
        when(m_CommandConverter.getCommandTypeFromResponseType(CommandResponseEnum.SET_PAN_TILT_RESPONSE))
            .thenReturn(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(RemoteConstants.EVENT_PROP_DATA_MESSAGE, testResponse);
        props.put(RemoteConstants.EVENT_PROP_SOURCE_ID, CONTROLLER_ID);
        Event testEvent = new Event(RemoteConstants.TOPIC_MESSAGE_RECEIVED, props);
        m_SUT.handleEvent(testEvent);
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, summary, 
                "SetPanTiltCommand executed for asset with uuid: " + assetUuid);
        testResponse = testResponse.toBuilder().setResponseType(
                CommandTypesGen.CommandResponse.Enum.SET_CAMERA_SETTINGS_RESPONSE).build();
        when(m_CommandConverter.getCommandTypeFromResponseType(CommandResponseEnum.SET_CAMERA_SETTINGS_RESPONSE))
            .thenReturn(CommandTypeEnum.SET_CAMERA_SETTINGS_COMMAND);
        props.put(RemoteConstants.EVENT_PROP_DATA_MESSAGE, testResponse);
        props.put(RemoteConstants.EVENT_PROP_SOURCE_ID, CONTROLLER_ID);
        testEvent = new Event(RemoteConstants.TOPIC_MESSAGE_RECEIVED, props);
        m_SUT.handleEvent(testEvent);
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, summary, 
                "SetCameraSettingsCommand executed for asset with uuid: " + assetUuid);
        testResponse = testResponse.toBuilder().setResponseType(
                CommandTypesGen.CommandResponse.Enum.CAPTURE_IMAGE_RESPONSE).build();
        when(m_CommandConverter.getCommandTypeFromResponseType(CommandResponseEnum.CAPTURE_IMAGE_RESPONSE))
            .thenReturn(CommandTypeEnum.CAPTURE_IMAGE_COMMAND);
        props.put(RemoteConstants.EVENT_PROP_DATA_MESSAGE, testResponse);
        props.put(RemoteConstants.EVENT_PROP_SOURCE_ID, CONTROLLER_ID);
        testEvent = new Event(RemoteConstants.TOPIC_MESSAGE_RECEIVED, props);
        m_SUT.handleEvent(testEvent);
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, summary, 
                "CaptureImageCommand executed for asset with uuid: " + assetUuid);
        testResponse = testResponse.toBuilder().setResponseType(
                CommandTypesGen.CommandResponse.Enum.DETECT_TARGET_RESPONSE).build();
        when(m_CommandConverter.getCommandTypeFromResponseType(CommandResponseEnum.DETECT_TARGET_RESPONSE))
            .thenReturn(CommandTypeEnum.DETECT_TARGET_COMMAND);
        props.put(RemoteConstants.EVENT_PROP_DATA_MESSAGE, testResponse);
        props.put(RemoteConstants.EVENT_PROP_SOURCE_ID, CONTROLLER_ID);
        testEvent = new Event(RemoteConstants.TOPIC_MESSAGE_RECEIVED, props);
        m_SUT.handleEvent(testEvent);
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, summary, 
                "DetectTargetCommand executed for asset with uuid: " + assetUuid);
    }
@ Test public void testCommandEventHandler ( ) { String summary = "Asset Command Executed:" ; UUID assetUuid = UUID . randomUUID ( ) ; mil . dod . th . core . remote . proto . SharedMessages . UUID assetUuidProto = SharedMessageUtils . convertUUIDToProtoUUID ( assetUuid ) ; ExecuteCommandResponseData testResponse = ExecuteCommandResponseData . newBuilder ( ) . setUuid ( assetUuidProto ) . setResponseType ( CommandTypesGen . CommandResponse . Enum . SET_PAN_TILT_RESPONSE ) . setResponse ( ByteString . copyFrom ( new byte [ ] { 0 , 1 , 2 } ) ) . build ( ) ; when ( m_CommandConverter . getCommandTypeFromResponseType ( CommandResponseEnum . SET_PAN_TILT_RESPONSE ) ) . thenReturn ( CommandTypeEnum . SET_PAN_TILT_COMMAND ) ; Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( RemoteConstants . EVENT_PROP_DATA_MESSAGE , testResponse ) ; props . put ( RemoteConstants . EVENT_PROP_SOURCE_ID , CONTROLLER_ID ) ; Event testEvent = new Event ( RemoteConstants . TOPIC_MESSAGE_RECEIVED , props ) ; m_SUT . handleEvent ( testEvent ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( FacesMessage . SEVERITY_INFO , summary , "SetPanTiltCommand executed for asset with uuid: " + assetUuid ) ; testResponse = testResponse . toBuilder ( ) . setResponseType ( CommandTypesGen . CommandResponse . Enum . SET_CAMERA_SETTINGS_RESPONSE ) . build ( ) ; when ( m_CommandConverter . getCommandTypeFromResponseType ( CommandResponseEnum . SET_CAMERA_SETTINGS_RESPONSE ) ) . thenReturn ( CommandTypeEnum . SET_CAMERA_SETTINGS_COMMAND ) ; props . put ( RemoteConstants . EVENT_PROP_DATA_MESSAGE , testResponse ) ; props . put ( RemoteConstants . EVENT_PROP_SOURCE_ID , CONTROLLER_ID ) ; testEvent = new Event ( RemoteConstants . TOPIC_MESSAGE_RECEIVED , props ) ; m_SUT . handleEvent ( testEvent ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( FacesMessage . SEVERITY_INFO , summary , "SetCameraSettingsCommand executed for asset with uuid: " + assetUuid ) ; testResponse = testResponse . toBuilder ( ) . setResponseType ( CommandTypesGen . CommandResponse . Enum . CAPTURE_IMAGE_RESPONSE ) . build ( ) ; when ( m_CommandConverter . getCommandTypeFromResponseType ( CommandResponseEnum . CAPTURE_IMAGE_RESPONSE ) ) . thenReturn ( CommandTypeEnum . CAPTURE_IMAGE_COMMAND ) ; props . put ( RemoteConstants . EVENT_PROP_DATA_MESSAGE , testResponse ) ; props . put ( RemoteConstants . EVENT_PROP_SOURCE_ID , CONTROLLER_ID ) ; testEvent = new Event ( RemoteConstants . TOPIC_MESSAGE_RECEIVED , props ) ; m_SUT . handleEvent ( testEvent ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( FacesMessage . SEVERITY_INFO , summary , "CaptureImageCommand executed for asset with uuid: " + assetUuid ) ; testResponse = testResponse . toBuilder ( ) . setResponseType ( CommandTypesGen . CommandResponse . Enum . DETECT_TARGET_RESPONSE ) . build ( ) ; when ( m_CommandConverter . getCommandTypeFromResponseType ( CommandResponseEnum . DETECT_TARGET_RESPONSE ) ) . thenReturn ( CommandTypeEnum . DETECT_TARGET_COMMAND ) ; props . put ( RemoteConstants . EVENT_PROP_DATA_MESSAGE , testResponse ) ; props . put ( RemoteConstants . EVENT_PROP_SOURCE_ID , CONTROLLER_ID ) ; testEvent = new Event ( RemoteConstants . TOPIC_MESSAGE_RECEIVED , props ) ; m_SUT . handleEvent ( testEvent ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( FacesMessage . SEVERITY_INFO , summary , "DetectTargetCommand executed for asset with uuid: " + assetUuid ) ; }
Test the command event handler.
Test the command event handler .
//Test set pan tilt response. //Verify growl message was posted and that its content is correct. //Test set camera settings response. //Verify growl message was posted and that its content is correct. //Test capture image command. //Verify growl message was posted and that its content is correct. //Test detect target command. //Verify growl message was posted and that its content is correct.