mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetModel.java
@Test
    public void testCapabilitiesSupport()
    {
        List<CommandTypeEnum> supportedCommands = new ArrayList<CommandTypeEnum>();
        supportedCommands.add(CommandTypeEnum.GET_POSITION_COMMAND);
        supportedCommands.add(CommandTypeEnum.SET_POSITION_COMMAND);
        
        CommandCapabilities commandCapabils = mock(CommandCapabilities.class);
        when(commandCapabils.isCaptureData()).thenReturn(true);
        when(commandCapabils.isPerformBIT()).thenReturn(true);
        when(commandCapabils.getSupportedCommands()).thenReturn(supportedCommands);
        
        AssetCapabilities ac = new AssetCapabilities();
        ac.setCommandCapabilities(commandCapabils);
        
        AssetFactoryModel afm = mock(AssetFactoryModel.class);
        when(afm.getFactoryCaps()).thenReturn(null);
        when(m_AssetTypesMgr.getAssetFactoryForClassAsync(anyInt(), anyString())).thenReturn(afm);
        when(afm.getFactoryCaps()).thenReturn(ac);
        
        //create asset model and mocked objects
        AssetModel model = new AssetModel(123, m_Uuid, ASSET_PID, Asset.class.getName(), 
                m_FactoryMgr, m_ConfigWrapper, m_AssetTypesMgr, m_AssetImageInterface);
        AssetFactoryModel factoryModel = mock(AssetFactoryModel.class);
        AssetCapabilities assetCapabils = mock(AssetCapabilities.class);
        
        when(m_AssetTypesMgr.getAssetFactoryForClassAsync(123, Asset.class.getName())).thenReturn(factoryModel);
        when(factoryModel.getFactoryCaps()).thenReturn(assetCapabils);
        when(assetCapabils.getCommandCapabilities()).thenReturn(commandCapabils);
        when(commandCapabils.isPerformBIT()).thenReturn(true);
        when(commandCapabils.isCaptureData()).thenReturn(true);
        
        assertThat(model.isDataCaptureSupportAsync(), is(true));
        assertThat(model.isBitSupportAsync(), is(true));
        assertThat(model.isReadableAsync(), is(true));
        assertThat(model.isEditableAsync(), is(true));
    }
/**
     * Verify that the capabilities are retrieved from the asset types manager every time the methods are called.
     */
Verify that the capabilities are retrieved from the asset types manager every time the methods are called.
Verify that the capabilities are retrieved from the asset types manager every time the methods are called .
@Test
    public void testCapabilitiesSupport()
    {
        List<CommandTypeEnum> supportedCommands = new ArrayList<CommandTypeEnum>();
        supportedCommands.add(CommandTypeEnum.GET_POSITION_COMMAND);
        supportedCommands.add(CommandTypeEnum.SET_POSITION_COMMAND);
        CommandCapabilities commandCapabils = mock(CommandCapabilities.class);
        when(commandCapabils.isCaptureData()).thenReturn(true);
        when(commandCapabils.isPerformBIT()).thenReturn(true);
        when(commandCapabils.getSupportedCommands()).thenReturn(supportedCommands);
        AssetCapabilities ac = new AssetCapabilities();
        ac.setCommandCapabilities(commandCapabils);
        AssetFactoryModel afm = mock(AssetFactoryModel.class);
        when(afm.getFactoryCaps()).thenReturn(null);
        when(m_AssetTypesMgr.getAssetFactoryForClassAsync(anyInt(), anyString())).thenReturn(afm);
        when(afm.getFactoryCaps()).thenReturn(ac);
        AssetModel model = new AssetModel(123, m_Uuid, ASSET_PID, Asset.class.getName(), 
                m_FactoryMgr, m_ConfigWrapper, m_AssetTypesMgr, m_AssetImageInterface);
        AssetFactoryModel factoryModel = mock(AssetFactoryModel.class);
        AssetCapabilities assetCapabils = mock(AssetCapabilities.class);
        when(m_AssetTypesMgr.getAssetFactoryForClassAsync(123, Asset.class.getName())).thenReturn(factoryModel);
        when(factoryModel.getFactoryCaps()).thenReturn(assetCapabils);
        when(assetCapabils.getCommandCapabilities()).thenReturn(commandCapabils);
        when(commandCapabils.isPerformBIT()).thenReturn(true);
        when(commandCapabils.isCaptureData()).thenReturn(true);
        assertThat(model.isDataCaptureSupportAsync(), is(true));
        assertThat(model.isBitSupportAsync(), is(true));
        assertThat(model.isReadableAsync(), is(true));
        assertThat(model.isEditableAsync(), is(true));
    }
@ Test public void testCapabilitiesSupport ( ) { List < CommandTypeEnum > supportedCommands = new ArrayList < CommandTypeEnum > ( ) ; supportedCommands . add ( CommandTypeEnum . GET_POSITION_COMMAND ) ; supportedCommands . add ( CommandTypeEnum . SET_POSITION_COMMAND ) ; CommandCapabilities commandCapabils = mock ( CommandCapabilities . class ) ; when ( commandCapabils . isCaptureData ( ) ) . thenReturn ( true ) ; when ( commandCapabils . isPerformBIT ( ) ) . thenReturn ( true ) ; when ( commandCapabils . getSupportedCommands ( ) ) . thenReturn ( supportedCommands ) ; AssetCapabilities ac = new AssetCapabilities ( ) ; ac . setCommandCapabilities ( commandCapabils ) ; AssetFactoryModel afm = mock ( AssetFactoryModel . class ) ; when ( afm . getFactoryCaps ( ) ) . thenReturn ( null ) ; when ( m_AssetTypesMgr . getAssetFactoryForClassAsync ( anyInt ( ) , anyString ( ) ) ) . thenReturn ( afm ) ; when ( afm . getFactoryCaps ( ) ) . thenReturn ( ac ) ; AssetModel model = new AssetModel ( 123 , m_Uuid , ASSET_PID , Asset . class . getName ( ) , m_FactoryMgr , m_ConfigWrapper , m_AssetTypesMgr , m_AssetImageInterface ) ; AssetFactoryModel factoryModel = mock ( AssetFactoryModel . class ) ; AssetCapabilities assetCapabils = mock ( AssetCapabilities . class ) ; when ( m_AssetTypesMgr . getAssetFactoryForClassAsync ( 123 , Asset . class . getName ( ) ) ) . thenReturn ( factoryModel ) ; when ( factoryModel . getFactoryCaps ( ) ) . thenReturn ( assetCapabils ) ; when ( assetCapabils . getCommandCapabilities ( ) ) . thenReturn ( commandCapabils ) ; when ( commandCapabils . isPerformBIT ( ) ) . thenReturn ( true ) ; when ( commandCapabils . isCaptureData ( ) ) . thenReturn ( true ) ; assertThat ( model . isDataCaptureSupportAsync ( ) , is ( true ) ) ; assertThat ( model . isBitSupportAsync ( ) , is ( true ) ) ; assertThat ( model . isReadableAsync ( ) , is ( true ) ) ; assertThat ( model . isEditableAsync ( ) , is ( true ) ) ; }
Verify that the capabilities are retrieved from the asset types manager every time the methods are called.
Verify that the capabilities are retrieved from the asset types manager every time the methods are called .
//create asset model and mocked objects