mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetGetCommandMgrImpl.java
@Test
    public void testCommandResponseHandlerNullModel()
    {
        AsyncCommandResponseEventHandler eventHandler = m_SUT.new AsyncCommandResponseEventHandler();
        
        AssetModel asset = mock(AssetModel.class);
        UUID uuid = UUID.randomUUID();
        when(asset.getControllerId()).thenReturn(CONTROLLER_ID);
        when(asset.getUuid()).thenReturn(uuid);
        
        //set up the command map
        AssetCapabilities assetCaps = mock(AssetCapabilities.class);
        CommandCapabilities capabilities = mock(CommandCapabilities.class);
        AssetFactoryModel fModel = mock(AssetFactoryModel.class);
        when(m_AssetTypesMgr.getAssetFactoryForClassAsync(eq(CONTROLLER_ID), Mockito.anyString()))
            .thenReturn(fModel);
        
        when(fModel.getFactoryCaps()).thenReturn(assetCaps);
        when(assetCaps.getCommandCapabilities()).thenReturn(capabilities);
        
        List<CommandTypeEnum> list = new ArrayList<CommandTypeEnum>();
        list.add(CommandTypeEnum.GET_VERSION_COMMAND);
        when(capabilities.getSupportedCommands()).thenReturn(list);
        
        //initializing system lookup map
        m_SUT.getAssetCommands(asset);
        
        GetVersionResponse versionResponse = new GetVersionResponse(null, null, "version");
        Map<String, Object> map = new HashMap<>();
        map.put(RemoteConstants.REMOTE_EVENT_PROP_CONTROLLER_ID, CONTROLLER_ID);
        map.put(FactoryDescriptor.EVENT_PROP_OBJ_UUID, UUID.randomUUID().toString());
        map.put(Asset.EVENT_PROP_ASSET_COMMAND_RESPONSE_TYPE, GetVersionResponse.class.getName());
        map.put(Asset.EVENT_PROP_ASSET_COMMAND_RESPONSE, versionResponse);
        
        Event event = new Event("topic", map);
        
        eventHandler.handleEvent(event);
        
        //verify no interactions
        verify(m_CommandConverter, never()).getCommandResponseEnumFromClassName(anyString());
    }
/**
     * Verify no action taken if the system collection of models is not null, but the given asset UUID is unknown.
     */
Verify no action taken if the system collection of models is not null, but the given asset UUID is unknown.
Verify no action taken if the system collection of models is not null but the given asset UUID is unknown .
@Test
    public void testCommandResponseHandlerNullModel()
    {
        AsyncCommandResponseEventHandler eventHandler = m_SUT.new AsyncCommandResponseEventHandler();
        AssetModel asset = mock(AssetModel.class);
        UUID uuid = UUID.randomUUID();
        when(asset.getControllerId()).thenReturn(CONTROLLER_ID);
        when(asset.getUuid()).thenReturn(uuid);
        AssetCapabilities assetCaps = mock(AssetCapabilities.class);
        CommandCapabilities capabilities = mock(CommandCapabilities.class);
        AssetFactoryModel fModel = mock(AssetFactoryModel.class);
        when(m_AssetTypesMgr.getAssetFactoryForClassAsync(eq(CONTROLLER_ID), Mockito.anyString()))
            .thenReturn(fModel);
        when(fModel.getFactoryCaps()).thenReturn(assetCaps);
        when(assetCaps.getCommandCapabilities()).thenReturn(capabilities);
        List<CommandTypeEnum> list = new ArrayList<CommandTypeEnum>();
        list.add(CommandTypeEnum.GET_VERSION_COMMAND);
        when(capabilities.getSupportedCommands()).thenReturn(list);
        m_SUT.getAssetCommands(asset);
        GetVersionResponse versionResponse = new GetVersionResponse(null, null, "version");
        Map<String, Object> map = new HashMap<>();
        map.put(RemoteConstants.REMOTE_EVENT_PROP_CONTROLLER_ID, CONTROLLER_ID);
        map.put(FactoryDescriptor.EVENT_PROP_OBJ_UUID, UUID.randomUUID().toString());
        map.put(Asset.EVENT_PROP_ASSET_COMMAND_RESPONSE_TYPE, GetVersionResponse.class.getName());
        map.put(Asset.EVENT_PROP_ASSET_COMMAND_RESPONSE, versionResponse);
        Event event = new Event("topic", map);
        eventHandler.handleEvent(event);
        verify(m_CommandConverter, never()).getCommandResponseEnumFromClassName(anyString());
    }
@ Test public void testCommandResponseHandlerNullModel ( ) { AsyncCommandResponseEventHandler eventHandler = m_SUT . new AsyncCommandResponseEventHandler ( ) ; AssetModel asset = mock ( AssetModel . class ) ; UUID uuid = UUID . randomUUID ( ) ; when ( asset . getControllerId ( ) ) . thenReturn ( CONTROLLER_ID ) ; when ( asset . getUuid ( ) ) . thenReturn ( uuid ) ; AssetCapabilities assetCaps = mock ( AssetCapabilities . class ) ; CommandCapabilities capabilities = mock ( CommandCapabilities . class ) ; AssetFactoryModel fModel = mock ( AssetFactoryModel . class ) ; when ( m_AssetTypesMgr . getAssetFactoryForClassAsync ( eq ( CONTROLLER_ID ) , Mockito . anyString ( ) ) ) . thenReturn ( fModel ) ; when ( fModel . getFactoryCaps ( ) ) . thenReturn ( assetCaps ) ; when ( assetCaps . getCommandCapabilities ( ) ) . thenReturn ( capabilities ) ; List < CommandTypeEnum > list = new ArrayList < CommandTypeEnum > ( ) ; list . add ( CommandTypeEnum . GET_VERSION_COMMAND ) ; when ( capabilities . getSupportedCommands ( ) ) . thenReturn ( list ) ; m_SUT . getAssetCommands ( asset ) ; GetVersionResponse versionResponse = new GetVersionResponse ( null , null , "version" ) ; Map < String , Object > map = new HashMap < > ( ) ; map . put ( RemoteConstants . REMOTE_EVENT_PROP_CONTROLLER_ID , CONTROLLER_ID ) ; map . put ( FactoryDescriptor . EVENT_PROP_OBJ_UUID , UUID . randomUUID ( ) . toString ( ) ) ; map . put ( Asset . EVENT_PROP_ASSET_COMMAND_RESPONSE_TYPE , GetVersionResponse . class . getName ( ) ) ; map . put ( Asset . EVENT_PROP_ASSET_COMMAND_RESPONSE , versionResponse ) ; Event event = new Event ( "topic" , map ) ; eventHandler . handleEvent ( event ) ; verify ( m_CommandConverter , never ( ) ) . getCommandResponseEnumFromClassName ( anyString ( ) ) ; }
Verify no action taken if the system collection of models is not null, but the given asset UUID is unknown.
Verify no action taken if the system collection of models is not null but the given asset UUID is unknown .
//set up the command map //initializing system lookup map //verify no interactions