mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetMgrImpl.java
@Test
    public void testHandleRemoteEventActivationFailed()
    {
        //load assets for one system
        Event getAssetsReponse = mockGetAssetsResponse(systemId1);
        
        //this should render two assets for the system id
        m_AssetDirHelper.handleEvent(getAssetsReponse);
        
        //verify assets added, get status, should be default of deactivated
        List<AssetModel> models = m_SUT.getAssetsForControllerAsync(systemId1);
        assertThat(models.size(), is(2));
        
        //set the asset models activation status to deactivated
        m_EventHelper.handleEvent(mockEventAssetDeactivated(systemId1));

        AssetModel modelWithStatusChange = m_SUT.getAssetModelByUuid(uuid2, systemId1);
        assertThat(modelWithStatusChange.getActiveStatus(), is(AssetActiveStatus.DEACTIVATED));
        
        //mock event that an asset has failed to be activated
        m_EventHelper.handleEvent(mockEventActivationFailed(systemId1));
        
        AssetModel modelAfterStatusChange = m_SUT.getAssetModelByUuid(uuid2, systemId1);
        assertThat(modelWithStatusChange.getUuid(), is (modelAfterStatusChange.getUuid()));
        assertThat(modelAfterStatusChange.getActiveStatus(), is(AssetActiveStatus.DEACTIVATED));
        
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(2)).postEvent(eventCaptor.capture());
        
        assertThat(eventCaptor.getAllValues().size(), is(2));
        
        Event firstPushEvent = eventCaptor.getAllValues().get(0);
        Event secondPushEvent = eventCaptor.getAllValues().get(1);
        assertThat(firstPushEvent, notNullValue());
        assertThat(firstPushEvent.getTopic(), is(AssetMgr.TOPIC_ASSET_ACTIVATION_STATUS_UPDATED));
        assertThat((String)firstPushEvent.getProperty(AssetMgr.EVENT_PROP_ACTIVE_STATUS_SUMMARY), 
                is(AssetActiveStatus.DEACTIVATED.toString()));
        assertThat((String)firstPushEvent.getProperty(AssetModel.EVENT_PROP_UUID), is(uuid2.toString()));
        
        assertThat(secondPushEvent, notNullValue());
        assertThat(secondPushEvent.getTopic(), is(AssetMgr.TOPIC_ASSET_ACTIVATION_STATUS_UPDATED));
        assertThat((String)secondPushEvent.getProperty(AssetMgr.EVENT_PROP_ACTIVE_STATUS_SUMMARY), 
                is(AssetActiveStatus.DEACTIVATED.toString()));
        assertThat((String)secondPushEvent.getProperty(AssetModel.EVENT_PROP_UUID), is(uuid2.toString()));
    }
/**
     * Test the handling of asset activation failed event
     */
Test the handling of asset activation failed event
Test the handling of asset activation failed event
@Test
    public void testHandleRemoteEventActivationFailed()
    {
        Event getAssetsReponse = mockGetAssetsResponse(systemId1);
        m_AssetDirHelper.handleEvent(getAssetsReponse);
        List<AssetModel> models = m_SUT.getAssetsForControllerAsync(systemId1);
        assertThat(models.size(), is(2));
        m_EventHelper.handleEvent(mockEventAssetDeactivated(systemId1));
        AssetModel modelWithStatusChange = m_SUT.getAssetModelByUuid(uuid2, systemId1);
        assertThat(modelWithStatusChange.getActiveStatus(), is(AssetActiveStatus.DEACTIVATED));
        m_EventHelper.handleEvent(mockEventActivationFailed(systemId1));
        AssetModel modelAfterStatusChange = m_SUT.getAssetModelByUuid(uuid2, systemId1);
        assertThat(modelWithStatusChange.getUuid(), is (modelAfterStatusChange.getUuid()));
        assertThat(modelAfterStatusChange.getActiveStatus(), is(AssetActiveStatus.DEACTIVATED));
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(2)).postEvent(eventCaptor.capture());
        assertThat(eventCaptor.getAllValues().size(), is(2));
        Event firstPushEvent = eventCaptor.getAllValues().get(0);
        Event secondPushEvent = eventCaptor.getAllValues().get(1);
        assertThat(firstPushEvent, notNullValue());
        assertThat(firstPushEvent.getTopic(), is(AssetMgr.TOPIC_ASSET_ACTIVATION_STATUS_UPDATED));
        assertThat((String)firstPushEvent.getProperty(AssetMgr.EVENT_PROP_ACTIVE_STATUS_SUMMARY), 
                is(AssetActiveStatus.DEACTIVATED.toString()));
        assertThat((String)firstPushEvent.getProperty(AssetModel.EVENT_PROP_UUID), is(uuid2.toString()));
        assertThat(secondPushEvent, notNullValue());
        assertThat(secondPushEvent.getTopic(), is(AssetMgr.TOPIC_ASSET_ACTIVATION_STATUS_UPDATED));
        assertThat((String)secondPushEvent.getProperty(AssetMgr.EVENT_PROP_ACTIVE_STATUS_SUMMARY), 
                is(AssetActiveStatus.DEACTIVATED.toString()));
        assertThat((String)secondPushEvent.getProperty(AssetModel.EVENT_PROP_UUID), is(uuid2.toString()));
    }
@ Test public void testHandleRemoteEventActivationFailed ( ) { Event getAssetsReponse = mockGetAssetsResponse ( systemId1 ) ; m_AssetDirHelper . handleEvent ( getAssetsReponse ) ; List < AssetModel > models = m_SUT . getAssetsForControllerAsync ( systemId1 ) ; assertThat ( models . size ( ) , is ( 2 ) ) ; m_EventHelper . handleEvent ( mockEventAssetDeactivated ( systemId1 ) ) ; AssetModel modelWithStatusChange = m_SUT . getAssetModelByUuid ( uuid2 , systemId1 ) ; assertThat ( modelWithStatusChange . getActiveStatus ( ) , is ( AssetActiveStatus . DEACTIVATED ) ) ; m_EventHelper . handleEvent ( mockEventActivationFailed ( systemId1 ) ) ; AssetModel modelAfterStatusChange = m_SUT . getAssetModelByUuid ( uuid2 , systemId1 ) ; assertThat ( modelWithStatusChange . getUuid ( ) , is ( modelAfterStatusChange . getUuid ( ) ) ) ; assertThat ( modelAfterStatusChange . getActiveStatus ( ) , is ( AssetActiveStatus . DEACTIVATED ) ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , times ( 2 ) ) . postEvent ( eventCaptor . capture ( ) ) ; assertThat ( eventCaptor . getAllValues ( ) . size ( ) , is ( 2 ) ) ; Event firstPushEvent = eventCaptor . getAllValues ( ) . get ( 0 ) ; Event secondPushEvent = eventCaptor . getAllValues ( ) . get ( 1 ) ; assertThat ( firstPushEvent , notNullValue ( ) ) ; assertThat ( firstPushEvent . getTopic ( ) , is ( AssetMgr . TOPIC_ASSET_ACTIVATION_STATUS_UPDATED ) ) ; assertThat ( ( String ) firstPushEvent . getProperty ( AssetMgr . EVENT_PROP_ACTIVE_STATUS_SUMMARY ) , is ( AssetActiveStatus . DEACTIVATED . toString ( ) ) ) ; assertThat ( ( String ) firstPushEvent . getProperty ( AssetModel . EVENT_PROP_UUID ) , is ( uuid2 . toString ( ) ) ) ; assertThat ( secondPushEvent , notNullValue ( ) ) ; assertThat ( secondPushEvent . getTopic ( ) , is ( AssetMgr . TOPIC_ASSET_ACTIVATION_STATUS_UPDATED ) ) ; assertThat ( ( String ) secondPushEvent . getProperty ( AssetMgr . EVENT_PROP_ACTIVE_STATUS_SUMMARY ) , is ( AssetActiveStatus . DEACTIVATED . toString ( ) ) ) ; assertThat ( ( String ) secondPushEvent . getProperty ( AssetModel . EVENT_PROP_UUID ) , is ( uuid2 . toString ( ) ) ) ; }
Test the handling of asset activation failed event
Test the handling of asset activation failed event
//load assets for one system //this should render two assets for the system id //verify assets added, get status, should be default of deactivated //set the asset models activation status to deactivated //mock event that an asset has failed to be activated