mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetSyncableCommandModel.java
@Test
    public void testUpdateCapabilities() throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
        //Get the pan tilt command and set fields for later verification.
        Command command = m_SUT.getCommandByType(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        assertThat(command.getClass(), is((Object)SetPanTiltCommand.class));
        SetPanTiltCommand panTilt = (SetPanTiltCommand)command;
        panTilt.setPanTilt(SpatialTypesFactory.newOrientationOffset(5.2, 12.1));
        
        //Verify that the correct set of initial commands is returned.
        List<CommandTypeEnum> commands = m_SUT.getSupportedCommands();
        assertThat(commands, containsInAnyOrder(CommandTypeEnum.CAPTURE_IMAGE_COMMAND, 
                CommandTypeEnum.DETECT_TARGET_COMMAND, CommandTypeEnum.SET_TUNE_SETTINGS_COMMAND, 
                CommandTypeEnum.SET_POINTING_LOCATION_COMMAND, CommandTypeEnum.SET_PAN_TILT_COMMAND, 
                CommandTypeEnum.SET_CAMERA_SETTINGS_COMMAND, CommandTypeEnum.CONFIGURE_PROFILE_COMMAND,
                CommandTypeEnum.SET_MODE_COMMAND, CommandTypeEnum.CREATE_ACTION_LIST_COMMAND, 
                CommandTypeEnum.TARGET_REFINEMENT_COMMAND, CommandTypeEnum.START_RECORDING_COMMAND,
                CommandTypeEnum.STOP_RECORDING_COMMAND, CommandTypeEnum.SET_LIFT_COMMAND,
                CommandTypeEnum.ZEROIZE_COMMAND));
        
        List<CommandTypeEnum> supportedCommands = new ArrayList<CommandTypeEnum>();
        supportedCommands.add(CommandTypeEnum.GET_PAN_TILT_COMMAND);
        supportedCommands.add(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        supportedCommands.add(CommandTypeEnum.GET_VERSION_COMMAND);
        
        final CommandCapabilities caps = mock(CommandCapabilities.class);
        when(caps.getSupportedCommands()).thenReturn(supportedCommands);
        
        //Update the capabilities for the model
        m_SUT.updateCapabilities(caps);
        
        //Verify that no longer supported commands are removed.
        commands = m_SUT.getSupportedCommands();
        assertThat(commands, containsInAnyOrder(CommandTypeEnum.SET_PAN_TILT_COMMAND));
        
        //Verify that the set pan tilt command still contains the values set earlier. Updating the capabilities should
        //not erase stored values for commands that are still supported.
        command = m_SUT.getCommandByType(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        assertThat(command.getClass(), is((Object)SetPanTiltCommand.class));
        panTilt = (SetPanTiltCommand)command;
        OrientationOffset ptValues = panTilt.getPanTilt();
        assertThat(panTilt.isSetPanTilt(), is(true));
        assertThat(ptValues.isSetElevation(), is(true));
        assertThat(ptValues.isSetAzimuth(), is(true));
        assertThat(ptValues.getAzimuth().getValue(), is(5.2));
        assertThat(ptValues.getElevation().getValue(), is(12.1));
        
        supportedCommands.clear();
        supportedCommands.add(CommandTypeEnum.GET_PAN_TILT_COMMAND);
        supportedCommands.add(CommandTypeEnum.GET_VERSION_COMMAND);
        supportedCommands.add(CommandTypeEnum.DETECT_TARGET_COMMAND);
        supportedCommands.add(CommandTypeEnum.GET_PROFILES_COMMAND);
        supportedCommands.add(CommandTypeEnum.TARGET_REFINEMENT_COMMAND);
        
        //Update the capabilities again, this time adding as well as removing.
        m_SUT.updateCapabilities(caps);
        
        //Verify add commands are present and removed commands are not.
        commands = m_SUT.getSupportedCommands();
        assertThat(commands, containsInAnyOrder(CommandTypeEnum.DETECT_TARGET_COMMAND, 
                CommandTypeEnum.TARGET_REFINEMENT_COMMAND));
    }
/**
     * Verify that the update capabilities method updates the model appropriately.
     */
Verify that the update capabilities method updates the model appropriately.
Verify that the update capabilities method updates the model appropriately .
@Test
    public void testUpdateCapabilities() throws ClassNotFoundException, InstantiationException, IllegalAccessException
    {
        Command command = m_SUT.getCommandByType(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        assertThat(command.getClass(), is((Object)SetPanTiltCommand.class));
        SetPanTiltCommand panTilt = (SetPanTiltCommand)command;
        panTilt.setPanTilt(SpatialTypesFactory.newOrientationOffset(5.2, 12.1));
        List<CommandTypeEnum> commands = m_SUT.getSupportedCommands();
        assertThat(commands, containsInAnyOrder(CommandTypeEnum.CAPTURE_IMAGE_COMMAND, 
                CommandTypeEnum.DETECT_TARGET_COMMAND, CommandTypeEnum.SET_TUNE_SETTINGS_COMMAND, 
                CommandTypeEnum.SET_POINTING_LOCATION_COMMAND, CommandTypeEnum.SET_PAN_TILT_COMMAND, 
                CommandTypeEnum.SET_CAMERA_SETTINGS_COMMAND, CommandTypeEnum.CONFIGURE_PROFILE_COMMAND,
                CommandTypeEnum.SET_MODE_COMMAND, CommandTypeEnum.CREATE_ACTION_LIST_COMMAND, 
                CommandTypeEnum.TARGET_REFINEMENT_COMMAND, CommandTypeEnum.START_RECORDING_COMMAND,
                CommandTypeEnum.STOP_RECORDING_COMMAND, CommandTypeEnum.SET_LIFT_COMMAND,
                CommandTypeEnum.ZEROIZE_COMMAND));
        List<CommandTypeEnum> supportedCommands = new ArrayList<CommandTypeEnum>();
        supportedCommands.add(CommandTypeEnum.GET_PAN_TILT_COMMAND);
        supportedCommands.add(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        supportedCommands.add(CommandTypeEnum.GET_VERSION_COMMAND);
        final CommandCapabilities caps = mock(CommandCapabilities.class);
        when(caps.getSupportedCommands()).thenReturn(supportedCommands);
        m_SUT.updateCapabilities(caps);
        commands = m_SUT.getSupportedCommands();
        assertThat(commands, containsInAnyOrder(CommandTypeEnum.SET_PAN_TILT_COMMAND));
        command = m_SUT.getCommandByType(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        assertThat(command.getClass(), is((Object)SetPanTiltCommand.class));
        panTilt = (SetPanTiltCommand)command;
        OrientationOffset ptValues = panTilt.getPanTilt();
        assertThat(panTilt.isSetPanTilt(), is(true));
        assertThat(ptValues.isSetElevation(), is(true));
        assertThat(ptValues.isSetAzimuth(), is(true));
        assertThat(ptValues.getAzimuth().getValue(), is(5.2));
        assertThat(ptValues.getElevation().getValue(), is(12.1));
        supportedCommands.clear();
        supportedCommands.add(CommandTypeEnum.GET_PAN_TILT_COMMAND);
        supportedCommands.add(CommandTypeEnum.GET_VERSION_COMMAND);
        supportedCommands.add(CommandTypeEnum.DETECT_TARGET_COMMAND);
        supportedCommands.add(CommandTypeEnum.GET_PROFILES_COMMAND);
        supportedCommands.add(CommandTypeEnum.TARGET_REFINEMENT_COMMAND);
        m_SUT.updateCapabilities(caps);
        commands = m_SUT.getSupportedCommands();
        assertThat(commands, containsInAnyOrder(CommandTypeEnum.DETECT_TARGET_COMMAND, 
                CommandTypeEnum.TARGET_REFINEMENT_COMMAND));
    }
@ Test public void testUpdateCapabilities ( ) throws ClassNotFoundException , InstantiationException , IllegalAccessException { Command command = m_SUT . getCommandByType ( CommandTypeEnum . SET_PAN_TILT_COMMAND ) ; assertThat ( command . getClass ( ) , is ( ( Object ) SetPanTiltCommand . class ) ) ; SetPanTiltCommand panTilt = ( SetPanTiltCommand ) command ; panTilt . setPanTilt ( SpatialTypesFactory . newOrientationOffset ( 5.2 , 12.1 ) ) ; List < CommandTypeEnum > commands = m_SUT . getSupportedCommands ( ) ; assertThat ( commands , containsInAnyOrder ( CommandTypeEnum . CAPTURE_IMAGE_COMMAND , CommandTypeEnum . DETECT_TARGET_COMMAND , CommandTypeEnum . SET_TUNE_SETTINGS_COMMAND , CommandTypeEnum . SET_POINTING_LOCATION_COMMAND , CommandTypeEnum . SET_PAN_TILT_COMMAND , CommandTypeEnum . SET_CAMERA_SETTINGS_COMMAND , CommandTypeEnum . CONFIGURE_PROFILE_COMMAND , CommandTypeEnum . SET_MODE_COMMAND , CommandTypeEnum . CREATE_ACTION_LIST_COMMAND , CommandTypeEnum . TARGET_REFINEMENT_COMMAND , CommandTypeEnum . START_RECORDING_COMMAND , CommandTypeEnum . STOP_RECORDING_COMMAND , CommandTypeEnum . SET_LIFT_COMMAND , CommandTypeEnum . ZEROIZE_COMMAND ) ) ; List < CommandTypeEnum > supportedCommands = new ArrayList < CommandTypeEnum > ( ) ; supportedCommands . add ( CommandTypeEnum . GET_PAN_TILT_COMMAND ) ; supportedCommands . add ( CommandTypeEnum . SET_PAN_TILT_COMMAND ) ; supportedCommands . add ( CommandTypeEnum . GET_VERSION_COMMAND ) ; final CommandCapabilities caps = mock ( CommandCapabilities . class ) ; when ( caps . getSupportedCommands ( ) ) . thenReturn ( supportedCommands ) ; m_SUT . updateCapabilities ( caps ) ; commands = m_SUT . getSupportedCommands ( ) ; assertThat ( commands , containsInAnyOrder ( CommandTypeEnum . SET_PAN_TILT_COMMAND ) ) ; command = m_SUT . getCommandByType ( CommandTypeEnum . SET_PAN_TILT_COMMAND ) ; assertThat ( command . getClass ( ) , is ( ( Object ) SetPanTiltCommand . class ) ) ; panTilt = ( SetPanTiltCommand ) command ; OrientationOffset ptValues = panTilt . getPanTilt ( ) ; assertThat ( panTilt . isSetPanTilt ( ) , is ( true ) ) ; assertThat ( ptValues . isSetElevation ( ) , is ( true ) ) ; assertThat ( ptValues . isSetAzimuth ( ) , is ( true ) ) ; assertThat ( ptValues . getAzimuth ( ) . getValue ( ) , is ( 5.2 ) ) ; assertThat ( ptValues . getElevation ( ) . getValue ( ) , is ( 12.1 ) ) ; supportedCommands . clear ( ) ; supportedCommands . add ( CommandTypeEnum . GET_PAN_TILT_COMMAND ) ; supportedCommands . add ( CommandTypeEnum . GET_VERSION_COMMAND ) ; supportedCommands . add ( CommandTypeEnum . DETECT_TARGET_COMMAND ) ; supportedCommands . add ( CommandTypeEnum . GET_PROFILES_COMMAND ) ; supportedCommands . add ( CommandTypeEnum . TARGET_REFINEMENT_COMMAND ) ; m_SUT . updateCapabilities ( caps ) ; commands = m_SUT . getSupportedCommands ( ) ; assertThat ( commands , containsInAnyOrder ( CommandTypeEnum . DETECT_TARGET_COMMAND , CommandTypeEnum . TARGET_REFINEMENT_COMMAND ) ) ; }
Verify that the update capabilities method updates the model appropriately.
Verify that the update capabilities method updates the model appropriately .
//Get the pan tilt command and set fields for later verification. //Verify that the correct set of initial commands is returned. //Update the capabilities for the model //Verify that no longer supported commands are removed. //Verify that the set pan tilt command still contains the values set earlier. Updating the capabilities should //not erase stored values for commands that are still supported. //Update the capabilities again, this time adding as well as removing. //Verify add commands are present and removed commands are not.