mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetCommandMgrImpl.java
@SuppressWarnings({"unchecked", "rawtypes"})
    @Test
    public void testDoSync() throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
        Class capClazz = Class.forName(PROTO_COMMAND_PACKAGE + "CaptureImageCommandGen$CaptureImageCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.CAPTURE_IMAGE_COMMAND))
            .thenReturn(capClazz);
        
        Class tgtClazz = Class.forName(PROTO_COMMAND_PACKAGE + "DetectTargetCommandGen$DetectTargetCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.DETECT_TARGET_COMMAND))
            .thenReturn(tgtClazz);
        
        Class camClazz = Class.forName(PROTO_COMMAND_PACKAGE 
                + "GetCameraSettingsCommandGen$GetCameraSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_CAMERA_SETTINGS_COMMAND))
            .thenReturn(camClazz);
        
        Class ptClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetPanTiltCommandGen$GetPanTiltCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_PAN_TILT_COMMAND))
            .thenReturn(ptClazz);
        
        Class posClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetPositionCommandGen$GetPositionCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_POSITION_COMMAND))
            .thenReturn(posClazz);
        
        Class tuneClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetTuneSettingsCommandGen$GetTuneSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_TUNE_SETTINGS_COMMAND))
            .thenReturn(tuneClazz);
        
        Class verClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetVersionCommandGen$GetVersionCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_VERSION_COMMAND))
            .thenReturn(verClazz);
        
        Class scamClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetCameraSettingsCommandGen$SetCameraSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_CAMERA_SETTINGS_COMMAND))
            .thenReturn(scamClazz);
        
        Class sptClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetPanTiltCommandGen$SetPanTiltCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_PAN_TILT_COMMAND))
            .thenReturn(sptClazz);
        
        Class sposClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetPositionCommandGen$SetPositionCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_POSITION_COMMAND))
            .thenReturn(sposClazz);
        
        Class stuneClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetTuneSettingsCommandGen$SetTuneSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_TUNE_SETTINGS_COMMAND))
            .thenReturn(stuneClazz);
        
        UUID assetUuid = UUID.randomUUID();
        
        //Test do sync for camera settings command.
        AssetSyncableCommandModel commandModel = new AssetSyncableCommandModel(assetUuid, m_Capabilities);
        m_SUT.doSync(CONTROLLER_ID, commandModel, CommandTypeEnum.SET_CAMERA_SETTINGS_COMMAND);
        
        //Test do sync for pan/tilt command.
        m_SUT.doSync(CONTROLLER_ID, commandModel, CommandTypeEnum.SET_PAN_TILT_COMMAND);
        
        //Capture messages being sent out by remote message sender.
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        
        //Verify two messages were sent out and that the information contained by the messages are appropriate.
        verify(m_MessageFactory, times(2)).createAssetMessage(eq(AssetMessageType.ExecuteCommandRequest), 
                messageCaptor.capture());
        verify(m_MessageWrapper, times(2)).queue(eq(CONTROLLER_ID), Mockito.any(ResponseHandler.class));
        
        ExecuteCommandRequestData msg = (ExecuteCommandRequestData)messageCaptor.getAllValues().get(0);
        assertThat(msg.getCommandType(), is(CommandTypesGen.CommandType.Enum.GET_CAMERA_SETTINGS_COMMAND));
        msg = (ExecuteCommandRequestData)messageCaptor.getAllValues().get(1);
        assertThat(msg.getCommandType(), is(CommandTypesGen.CommandType.Enum.GET_PAN_TILT_COMMAND));
    }
/**
     * Test the do sync method.
     * Verify that the method sends the appropriate remote messages for each of the command types that can be synced.
     */
Test the do sync method.
Verify that the method sends the appropriate remote messages for each of the command types that can be synced.
Test the do sync method . Verify that the method sends the appropriate remote messages for each of the command types that can be synced .
@SuppressWarnings({"unchecked", "rawtypes"})
    @Test
    public void testDoSync() throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
        Class capClazz = Class.forName(PROTO_COMMAND_PACKAGE + "CaptureImageCommandGen$CaptureImageCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.CAPTURE_IMAGE_COMMAND))
            .thenReturn(capClazz);
        Class tgtClazz = Class.forName(PROTO_COMMAND_PACKAGE + "DetectTargetCommandGen$DetectTargetCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.DETECT_TARGET_COMMAND))
            .thenReturn(tgtClazz);
        Class camClazz = Class.forName(PROTO_COMMAND_PACKAGE 
                + "GetCameraSettingsCommandGen$GetCameraSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_CAMERA_SETTINGS_COMMAND))
            .thenReturn(camClazz);
        Class ptClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetPanTiltCommandGen$GetPanTiltCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_PAN_TILT_COMMAND))
            .thenReturn(ptClazz);
        Class posClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetPositionCommandGen$GetPositionCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_POSITION_COMMAND))
            .thenReturn(posClazz);
        Class tuneClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetTuneSettingsCommandGen$GetTuneSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_TUNE_SETTINGS_COMMAND))
            .thenReturn(tuneClazz);
        Class verClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetVersionCommandGen$GetVersionCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_VERSION_COMMAND))
            .thenReturn(verClazz);
        Class scamClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetCameraSettingsCommandGen$SetCameraSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_CAMERA_SETTINGS_COMMAND))
            .thenReturn(scamClazz);
        Class sptClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetPanTiltCommandGen$SetPanTiltCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_PAN_TILT_COMMAND))
            .thenReturn(sptClazz);
        Class sposClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetPositionCommandGen$SetPositionCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_POSITION_COMMAND))
            .thenReturn(sposClazz);
        Class stuneClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetTuneSettingsCommandGen$SetTuneSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_TUNE_SETTINGS_COMMAND))
            .thenReturn(stuneClazz);
        UUID assetUuid = UUID.randomUUID();
        AssetSyncableCommandModel commandModel = new AssetSyncableCommandModel(assetUuid, m_Capabilities);
        m_SUT.doSync(CONTROLLER_ID, commandModel, CommandTypeEnum.SET_CAMERA_SETTINGS_COMMAND);
        m_SUT.doSync(CONTROLLER_ID, commandModel, CommandTypeEnum.SET_PAN_TILT_COMMAND);
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        verify(m_MessageFactory, times(2)).createAssetMessage(eq(AssetMessageType.ExecuteCommandRequest), 
                messageCaptor.capture());
        verify(m_MessageWrapper, times(2)).queue(eq(CONTROLLER_ID), Mockito.any(ResponseHandler.class));
        ExecuteCommandRequestData msg = (ExecuteCommandRequestData)messageCaptor.getAllValues().get(0);
        assertThat(msg.getCommandType(), is(CommandTypesGen.CommandType.Enum.GET_CAMERA_SETTINGS_COMMAND));
        msg = (ExecuteCommandRequestData)messageCaptor.getAllValues().get(1);
        assertThat(msg.getCommandType(), is(CommandTypesGen.CommandType.Enum.GET_PAN_TILT_COMMAND));
    }
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ Test public void testDoSync ( ) throws ClassNotFoundException , InstantiationException , IllegalAccessException { Class capClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "CaptureImageCommandGen$CaptureImageCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . CAPTURE_IMAGE_COMMAND ) ) . thenReturn ( capClazz ) ; Class tgtClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "DetectTargetCommandGen$DetectTargetCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . DETECT_TARGET_COMMAND ) ) . thenReturn ( tgtClazz ) ; Class camClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "GetCameraSettingsCommandGen$GetCameraSettingsCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . GET_CAMERA_SETTINGS_COMMAND ) ) . thenReturn ( camClazz ) ; Class ptClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "GetPanTiltCommandGen$GetPanTiltCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . GET_PAN_TILT_COMMAND ) ) . thenReturn ( ptClazz ) ; Class posClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "GetPositionCommandGen$GetPositionCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . GET_POSITION_COMMAND ) ) . thenReturn ( posClazz ) ; Class tuneClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "GetTuneSettingsCommandGen$GetTuneSettingsCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . GET_TUNE_SETTINGS_COMMAND ) ) . thenReturn ( tuneClazz ) ; Class verClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "GetVersionCommandGen$GetVersionCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . GET_VERSION_COMMAND ) ) . thenReturn ( verClazz ) ; Class scamClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "SetCameraSettingsCommandGen$SetCameraSettingsCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . SET_CAMERA_SETTINGS_COMMAND ) ) . thenReturn ( scamClazz ) ; Class sptClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "SetPanTiltCommandGen$SetPanTiltCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . SET_PAN_TILT_COMMAND ) ) . thenReturn ( sptClazz ) ; Class sposClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "SetPositionCommandGen$SetPositionCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . SET_POSITION_COMMAND ) ) . thenReturn ( sposClazz ) ; Class stuneClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "SetTuneSettingsCommandGen$SetTuneSettingsCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . SET_TUNE_SETTINGS_COMMAND ) ) . thenReturn ( stuneClazz ) ; UUID assetUuid = UUID . randomUUID ( ) ; AssetSyncableCommandModel commandModel = new AssetSyncableCommandModel ( assetUuid , m_Capabilities ) ; m_SUT . doSync ( CONTROLLER_ID , commandModel , CommandTypeEnum . SET_CAMERA_SETTINGS_COMMAND ) ; m_SUT . doSync ( CONTROLLER_ID , commandModel , CommandTypeEnum . SET_PAN_TILT_COMMAND ) ; ArgumentCaptor < Message > messageCaptor = ArgumentCaptor . forClass ( Message . class ) ; verify ( m_MessageFactory , times ( 2 ) ) . createAssetMessage ( eq ( AssetMessageType . ExecuteCommandRequest ) , messageCaptor . capture ( ) ) ; verify ( m_MessageWrapper , times ( 2 ) ) . queue ( eq ( CONTROLLER_ID ) , Mockito . any ( ResponseHandler . class ) ) ; ExecuteCommandRequestData msg = ( ExecuteCommandRequestData ) messageCaptor . getAllValues ( ) . get ( 0 ) ; assertThat ( msg . getCommandType ( ) , is ( CommandTypesGen . CommandType . Enum . GET_CAMERA_SETTINGS_COMMAND ) ) ; msg = ( ExecuteCommandRequestData ) messageCaptor . getAllValues ( ) . get ( 1 ) ; assertThat ( msg . getCommandType ( ) , is ( CommandTypesGen . CommandType . Enum . GET_PAN_TILT_COMMAND ) ) ; }
Test the do sync method.
Test the do sync method .
//Test do sync for camera settings command. //Test do sync for pan/tilt command. //Capture messages being sent out by remote message sender. //Verify two messages were sent out and that the information contained by the messages are appropriate.