mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetCommandMgrImpl.java
@Test
    public void testGetAssetCommands() throws SecurityException, IllegalArgumentException
    {
        UUID assetUuid1 = UUID.randomUUID();
        AssetModel model1 = mock(AssetModel.class);
        when(model1.getControllerId()).thenReturn(CONTROLLER_ID);
        when(model1.getUuid()).thenReturn(assetUuid1);  
        
        AssetSyncableCommandModel commandModel1 = m_SUT.getAssetCommands(model1);
        assertThat(commandModel1.getUuid(), is(assetUuid1));
        SetPanTiltCommand panTilt = 
                (SetPanTiltCommand)commandModel1.getCommandByType(CommandTypeEnum.SET_PAN_TILT_COMMAND);

        panTilt.setPanTilt(SpatialTypesFactory.newOrientationOffset(5.5, 2.11));
        
        commandModel1 = m_SUT.getAssetCommands(model1);
        assertThat(commandModel1.getUuid(), is(assetUuid1));
        panTilt = (SetPanTiltCommand)commandModel1.getCommandByType(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        OrientationOffset ptOffset = panTilt.getPanTilt();
        assertThat(ptOffset.getAzimuth().getValue(), is(5.5));
        assertThat(ptOffset.getElevation().getValue(), is(2.11));
        
        UUID assetUuid2 = UUID.randomUUID();
        AssetModel model2 = mock(AssetModel.class);
        when(model2.getControllerId()).thenReturn(CONTROLLER_ID);
        when(model2.getUuid()).thenReturn(assetUuid2);
        
        AssetSyncableCommandModel commandModel2 = m_SUT.getAssetCommands(model2);
        assertThat(commandModel2.getUuid(), is(assetUuid2));
        
        //Mock command caps.
        List<CommandTypeEnum> commandTypes = new ArrayList<CommandTypeEnum>();
        for (CommandTypeEnum type: CommandTypeEnum.values())
        {
            if (!type.equals(CommandTypeEnum.SET_POINTING_LOCATION_COMMAND) 
                    && !type.equals(CommandTypeEnum.GET_POINTING_LOCATION_COMMAND)
                    && !type.equals(CommandTypeEnum.SET_PAN_TILT_COMMAND)
                    && !type.equals(CommandTypeEnum.GET_PAN_TILT_COMMAND))
            {
                commandTypes.add(type);
            }
        }
        m_Capabilities = mock(CommandCapabilities.class);
        when(m_Capabilities.getSupportedCommands()).thenReturn(commandTypes);
        when(m_AssetTypesMgr.getAssetFactoryForClassAsync(
                eq(CONTROLLER_ID), Mockito.anyString())).thenReturn(m_AssetFactory);
        when(m_AssetFactory.getFactoryCaps()).thenReturn(m_AssetCaps);
        when(m_AssetCaps.getCommandCapabilities()).thenReturn(m_Capabilities);
        
        commandModel1 = m_SUT.getAssetCommands(model1);
        assertThat(commandModel1.getUuid(), is(assetUuid1));
        panTilt = (SetPanTiltCommand)commandModel1.getCommandByType(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        assertThat(panTilt, is(nullValue()));
    }
/**
     * Test the get asset commands method.
     * Verify that the appropriate asset command models are returned.
     */
Test the get asset commands method.
Verify that the appropriate asset command models are returned.
Test the get asset commands method . Verify that the appropriate asset command models are returned .
@Test
    public void testGetAssetCommands() throws SecurityException, IllegalArgumentException
    {
        UUID assetUuid1 = UUID.randomUUID();
        AssetModel model1 = mock(AssetModel.class);
        when(model1.getControllerId()).thenReturn(CONTROLLER_ID);
        when(model1.getUuid()).thenReturn(assetUuid1);  
        AssetSyncableCommandModel commandModel1 = m_SUT.getAssetCommands(model1);
        assertThat(commandModel1.getUuid(), is(assetUuid1));
        SetPanTiltCommand panTilt = 
                (SetPanTiltCommand)commandModel1.getCommandByType(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        panTilt.setPanTilt(SpatialTypesFactory.newOrientationOffset(5.5, 2.11));
        commandModel1 = m_SUT.getAssetCommands(model1);
        assertThat(commandModel1.getUuid(), is(assetUuid1));
        panTilt = (SetPanTiltCommand)commandModel1.getCommandByType(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        OrientationOffset ptOffset = panTilt.getPanTilt();
        assertThat(ptOffset.getAzimuth().getValue(), is(5.5));
        assertThat(ptOffset.getElevation().getValue(), is(2.11));
        UUID assetUuid2 = UUID.randomUUID();
        AssetModel model2 = mock(AssetModel.class);
        when(model2.getControllerId()).thenReturn(CONTROLLER_ID);
        when(model2.getUuid()).thenReturn(assetUuid2);
        AssetSyncableCommandModel commandModel2 = m_SUT.getAssetCommands(model2);
        assertThat(commandModel2.getUuid(), is(assetUuid2));
        List<CommandTypeEnum> commandTypes = new ArrayList<CommandTypeEnum>();
        for (CommandTypeEnum type: CommandTypeEnum.values())
        {
            if (!type.equals(CommandTypeEnum.SET_POINTING_LOCATION_COMMAND) 
                    && !type.equals(CommandTypeEnum.GET_POINTING_LOCATION_COMMAND)
                    && !type.equals(CommandTypeEnum.SET_PAN_TILT_COMMAND)
                    && !type.equals(CommandTypeEnum.GET_PAN_TILT_COMMAND))
            {
                commandTypes.add(type);
            }
        }
        m_Capabilities = mock(CommandCapabilities.class);
        when(m_Capabilities.getSupportedCommands()).thenReturn(commandTypes);
        when(m_AssetTypesMgr.getAssetFactoryForClassAsync(
                eq(CONTROLLER_ID), Mockito.anyString())).thenReturn(m_AssetFactory);
        when(m_AssetFactory.getFactoryCaps()).thenReturn(m_AssetCaps);
        when(m_AssetCaps.getCommandCapabilities()).thenReturn(m_Capabilities);
        commandModel1 = m_SUT.getAssetCommands(model1);
        assertThat(commandModel1.getUuid(), is(assetUuid1));
        panTilt = (SetPanTiltCommand)commandModel1.getCommandByType(CommandTypeEnum.SET_PAN_TILT_COMMAND);
        assertThat(panTilt, is(nullValue()));
    }
@ Test public void testGetAssetCommands ( ) throws SecurityException , IllegalArgumentException { UUID assetUuid1 = UUID . randomUUID ( ) ; AssetModel model1 = mock ( AssetModel . class ) ; when ( model1 . getControllerId ( ) ) . thenReturn ( CONTROLLER_ID ) ; when ( model1 . getUuid ( ) ) . thenReturn ( assetUuid1 ) ; AssetSyncableCommandModel commandModel1 = m_SUT . getAssetCommands ( model1 ) ; assertThat ( commandModel1 . getUuid ( ) , is ( assetUuid1 ) ) ; SetPanTiltCommand panTilt = ( SetPanTiltCommand ) commandModel1 . getCommandByType ( CommandTypeEnum . SET_PAN_TILT_COMMAND ) ; panTilt . setPanTilt ( SpatialTypesFactory . newOrientationOffset ( 5.5 , 2.11 ) ) ; commandModel1 = m_SUT . getAssetCommands ( model1 ) ; assertThat ( commandModel1 . getUuid ( ) , is ( assetUuid1 ) ) ; panTilt = ( SetPanTiltCommand ) commandModel1 . getCommandByType ( CommandTypeEnum . SET_PAN_TILT_COMMAND ) ; OrientationOffset ptOffset = panTilt . getPanTilt ( ) ; assertThat ( ptOffset . getAzimuth ( ) . getValue ( ) , is ( 5.5 ) ) ; assertThat ( ptOffset . getElevation ( ) . getValue ( ) , is ( 2.11 ) ) ; UUID assetUuid2 = UUID . randomUUID ( ) ; AssetModel model2 = mock ( AssetModel . class ) ; when ( model2 . getControllerId ( ) ) . thenReturn ( CONTROLLER_ID ) ; when ( model2 . getUuid ( ) ) . thenReturn ( assetUuid2 ) ; AssetSyncableCommandModel commandModel2 = m_SUT . getAssetCommands ( model2 ) ; assertThat ( commandModel2 . getUuid ( ) , is ( assetUuid2 ) ) ; List < CommandTypeEnum > commandTypes = new ArrayList < CommandTypeEnum > ( ) ; for ( CommandTypeEnum type : CommandTypeEnum . values ( ) ) { if ( ! type . equals ( CommandTypeEnum . SET_POINTING_LOCATION_COMMAND ) && ! type . equals ( CommandTypeEnum . GET_POINTING_LOCATION_COMMAND ) && ! type . equals ( CommandTypeEnum . SET_PAN_TILT_COMMAND ) && ! type . equals ( CommandTypeEnum . GET_PAN_TILT_COMMAND ) ) { commandTypes . add ( type ) ; } } m_Capabilities = mock ( CommandCapabilities . class ) ; when ( m_Capabilities . getSupportedCommands ( ) ) . thenReturn ( commandTypes ) ; when ( m_AssetTypesMgr . getAssetFactoryForClassAsync ( eq ( CONTROLLER_ID ) , Mockito . anyString ( ) ) ) . thenReturn ( m_AssetFactory ) ; when ( m_AssetFactory . getFactoryCaps ( ) ) . thenReturn ( m_AssetCaps ) ; when ( m_AssetCaps . getCommandCapabilities ( ) ) . thenReturn ( m_Capabilities ) ; commandModel1 = m_SUT . getAssetCommands ( model1 ) ; assertThat ( commandModel1 . getUuid ( ) , is ( assetUuid1 ) ) ; panTilt = ( SetPanTiltCommand ) commandModel1 . getCommandByType ( CommandTypeEnum . SET_PAN_TILT_COMMAND ) ; assertThat ( panTilt , is ( nullValue ( ) ) ) ; }
Test the get asset commands method.
Test the get asset commands method .
//Mock command caps.