mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetCommandMgrImpl.java
@SuppressWarnings({"rawtypes", "unchecked"})
    @Test
    public void testSyncCall() throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
        //SYNCABLE COMMAND - Those which have set/get pairs
        Class smodeClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetModeCommandGen$SetModeCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_MODE_COMMAND))
            .thenReturn(smodeClazz);
        
        Class gmodeClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetModeCommandGen$GetModeCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_MODE_COMMAND))
            .thenReturn(gmodeClazz);
        
        Class scamClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetCameraSettingsCommandGen$SetCameraSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_CAMERA_SETTINGS_COMMAND))
            .thenReturn(scamClazz);
        
        Class camClazz = Class.forName(PROTO_COMMAND_PACKAGE 
                + "GetCameraSettingsCommandGen$GetCameraSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_CAMERA_SETTINGS_COMMAND))
            .thenReturn(camClazz);

        Class sptClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetPanTiltCommandGen$SetPanTiltCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_PAN_TILT_COMMAND))
            .thenReturn(sptClazz);
        
        Class ptClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetPanTiltCommandGen$GetPanTiltCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_PAN_TILT_COMMAND))
            .thenReturn(ptClazz);
        
        //NON-SYNCABLE commands
        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 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 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);

        CommandCapabilities cmndCaps = mock(CommandCapabilities.class);
        when(cmndCaps.isSetCameraSettings()).thenReturn(true);
        when(cmndCaps.isSetPanTilt()).thenReturn(true);
        
        UUID assetUuid = UUID.randomUUID();
        AssetSyncableCommandModel model = new AssetSyncableCommandModel(assetUuid, m_Capabilities);
        m_SUT.syncCall(CONTROLLER_ID, model);
        
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        
        //Should send message for the number of Get/Set pairs exist in the syncable commands denoted above
        verify(m_MessageFactory, times(3)).createAssetMessage(eq(AssetMessageType.ExecuteCommandRequest), 
                messageCaptor.capture());
        verify(m_MessageWrapper, times(3)).queue(eq(CONTROLLER_ID), Mockito.any(ResponseHandler.class));
        
        List<CommandTypesGen.CommandType.Enum> commandEnums = new ArrayList<>();
        for (Message message : messageCaptor.getAllValues())
        {
            commandEnums.add(((ExecuteCommandRequestData)message).getCommandType());
        }
        
        assertThat(commandEnums, containsInAnyOrder(CommandTypesGen.CommandType.Enum.GET_CAMERA_SETTINGS_COMMAND,
                CommandTypesGen.CommandType.Enum.GET_PAN_TILT_COMMAND,
                CommandTypesGen.CommandType.Enum.GET_MODE_COMMAND));        
    }
/**
     * Test the sync call method.
     * Verify that the appropriate remote messages are sent.
     */
Test the sync call method.
Verify that the appropriate remote messages are sent.
Test the sync call method . Verify that the appropriate remote messages are sent .
@SuppressWarnings({"rawtypes", "unchecked"})
    @Test
    public void testSyncCall() throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
        Class smodeClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetModeCommandGen$SetModeCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_MODE_COMMAND))
            .thenReturn(smodeClazz);
        Class gmodeClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetModeCommandGen$GetModeCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_MODE_COMMAND))
            .thenReturn(gmodeClazz);
        Class scamClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetCameraSettingsCommandGen$SetCameraSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_CAMERA_SETTINGS_COMMAND))
            .thenReturn(scamClazz);
        Class camClazz = Class.forName(PROTO_COMMAND_PACKAGE 
                + "GetCameraSettingsCommandGen$GetCameraSettingsCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_CAMERA_SETTINGS_COMMAND))
            .thenReturn(camClazz);
        Class sptClazz = Class.forName(PROTO_COMMAND_PACKAGE + "SetPanTiltCommandGen$SetPanTiltCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.SET_PAN_TILT_COMMAND))
            .thenReturn(sptClazz);
        Class ptClazz = Class.forName(PROTO_COMMAND_PACKAGE + "GetPanTiltCommandGen$GetPanTiltCommand");
        when(m_CommandConverter.retrieveProtoClass(CommandTypeEnum.GET_PAN_TILT_COMMAND))
            .thenReturn(ptClazz);
        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 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 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);
        CommandCapabilities cmndCaps = mock(CommandCapabilities.class);
        when(cmndCaps.isSetCameraSettings()).thenReturn(true);
        when(cmndCaps.isSetPanTilt()).thenReturn(true);
        UUID assetUuid = UUID.randomUUID();
        AssetSyncableCommandModel model = new AssetSyncableCommandModel(assetUuid, m_Capabilities);
        m_SUT.syncCall(CONTROLLER_ID, model);
        ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
        verify(m_MessageFactory, times(3)).createAssetMessage(eq(AssetMessageType.ExecuteCommandRequest), 
                messageCaptor.capture());
        verify(m_MessageWrapper, times(3)).queue(eq(CONTROLLER_ID), Mockito.any(ResponseHandler.class));
        List<CommandTypesGen.CommandType.Enum> commandEnums = new ArrayList<>();
        for (Message message : messageCaptor.getAllValues())
        {
            commandEnums.add(((ExecuteCommandRequestData)message).getCommandType());
        }
        assertThat(commandEnums, containsInAnyOrder(CommandTypesGen.CommandType.Enum.GET_CAMERA_SETTINGS_COMMAND,
                CommandTypesGen.CommandType.Enum.GET_PAN_TILT_COMMAND,
                CommandTypesGen.CommandType.Enum.GET_MODE_COMMAND));        
    }
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ Test public void testSyncCall ( ) throws ClassNotFoundException , InstantiationException , IllegalAccessException { Class smodeClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "SetModeCommandGen$SetModeCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . SET_MODE_COMMAND ) ) . thenReturn ( smodeClazz ) ; Class gmodeClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "GetModeCommandGen$GetModeCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . GET_MODE_COMMAND ) ) . thenReturn ( gmodeClazz ) ; Class scamClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "SetCameraSettingsCommandGen$SetCameraSettingsCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . SET_CAMERA_SETTINGS_COMMAND ) ) . thenReturn ( scamClazz ) ; Class camClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "GetCameraSettingsCommandGen$GetCameraSettingsCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . GET_CAMERA_SETTINGS_COMMAND ) ) . thenReturn ( camClazz ) ; Class sptClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "SetPanTiltCommandGen$SetPanTiltCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . SET_PAN_TILT_COMMAND ) ) . thenReturn ( sptClazz ) ; Class ptClazz = Class . forName ( PROTO_COMMAND_PACKAGE + "GetPanTiltCommandGen$GetPanTiltCommand" ) ; when ( m_CommandConverter . retrieveProtoClass ( CommandTypeEnum . GET_PAN_TILT_COMMAND ) ) . thenReturn ( ptClazz ) ; 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 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 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 ) ; CommandCapabilities cmndCaps = mock ( CommandCapabilities . class ) ; when ( cmndCaps . isSetCameraSettings ( ) ) . thenReturn ( true ) ; when ( cmndCaps . isSetPanTilt ( ) ) . thenReturn ( true ) ; UUID assetUuid = UUID . randomUUID ( ) ; AssetSyncableCommandModel model = new AssetSyncableCommandModel ( assetUuid , m_Capabilities ) ; m_SUT . syncCall ( CONTROLLER_ID , model ) ; ArgumentCaptor < Message > messageCaptor = ArgumentCaptor . forClass ( Message . class ) ; verify ( m_MessageFactory , times ( 3 ) ) . createAssetMessage ( eq ( AssetMessageType . ExecuteCommandRequest ) , messageCaptor . capture ( ) ) ; verify ( m_MessageWrapper , times ( 3 ) ) . queue ( eq ( CONTROLLER_ID ) , Mockito . any ( ResponseHandler . class ) ) ; List < CommandTypesGen . CommandType . Enum > commandEnums = new ArrayList < > ( ) ; for ( Message message : messageCaptor . getAllValues ( ) ) { commandEnums . add ( ( ( ExecuteCommandRequestData ) message ) . getCommandType ( ) ) ; } assertThat ( commandEnums , containsInAnyOrder ( CommandTypesGen . CommandType . Enum . GET_CAMERA_SETTINGS_COMMAND , CommandTypesGen . CommandType . Enum . GET_PAN_TILT_COMMAND , CommandTypesGen . CommandType . Enum . GET_MODE_COMMAND ) ) ; }
Test the sync call method.
Test the sync call method .
//SYNCABLE COMMAND - Those which have set/get pairs //NON-SYNCABLE commands //Should send message for the number of Get/Set pairs exist in the syncable commands denoted above