mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetMgrImpl.java
@Test
    public void testHandleRemoteEventActivatedAsset()
    {
        //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 "Active status not set"
        assertThat(m_SUT.getAssetsForControllerAsync(systemId1).size(), is(2));
        List<AssetModel> models = m_SUT.getAssetsForControllerAsync(systemId1);
        for (AssetModel model : models)
        {
            assertThat(model.getActiveStatus(), is(nullValue()));
        }
                
        //mock event that an asset was activated
        Event assetActivated = mockEventAssetActivated(systemId1);
        
        m_EventHelper.handleEvent(assetActivated);
        
        models = m_SUT.getAssetsForControllerAsync(systemId1);
        //variable to hold boolean verifying the value was indeed checked
        boolean checked = false;
        for (AssetModel model : models)
        {
            if (model.getUuid().equals(uuid2))
            {
                assertThat(model.getActiveStatus(), is(AssetActiveStatus.ACTIVATED));
                checked = true;
            }
        }
        assertThat(checked, is(true));
        
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        
        Event pushEvent = eventCaptor.getValue();
        assertThat(pushEvent, notNullValue());
        assertThat(pushEvent.getTopic(), is(AssetMgr.TOPIC_ASSET_ACTIVATION_STATUS_UPDATED));
        assertThat((String)pushEvent.getProperty(AssetMgr.EVENT_PROP_ACTIVE_STATUS_SUMMARY), 
                is(AssetActiveStatus.ACTIVATED.toString()));
        assertThat((String)pushEvent.getProperty(AssetModel.EVENT_PROP_UUID), is(uuid2.toString()));
    }
/**
     * Test the handling of activated asset event.
     * Verify asset status is updated to active.
     */
Test the handling of activated asset event.
Verify asset status is updated to active.
Test the handling of activated asset event . Verify asset status is updated to active .
@Test
    public void testHandleRemoteEventActivatedAsset()
    {
        Event getAssetsReponse = mockGetAssetsResponse(systemId1);
        m_AssetDirHelper.handleEvent(getAssetsReponse);
        assertThat(m_SUT.getAssetsForControllerAsync(systemId1).size(), is(2));
        List<AssetModel> models = m_SUT.getAssetsForControllerAsync(systemId1);
        for (AssetModel model : models)
        {
            assertThat(model.getActiveStatus(), is(nullValue()));
        }
        Event assetActivated = mockEventAssetActivated(systemId1);
        m_EventHelper.handleEvent(assetActivated);
        models = m_SUT.getAssetsForControllerAsync(systemId1);
        boolean checked = false;
        for (AssetModel model : models)
        {
            if (model.getUuid().equals(uuid2))
            {
                assertThat(model.getActiveStatus(), is(AssetActiveStatus.ACTIVATED));
                checked = true;
            }
        }
        assertThat(checked, is(true));
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event pushEvent = eventCaptor.getValue();
        assertThat(pushEvent, notNullValue());
        assertThat(pushEvent.getTopic(), is(AssetMgr.TOPIC_ASSET_ACTIVATION_STATUS_UPDATED));
        assertThat((String)pushEvent.getProperty(AssetMgr.EVENT_PROP_ACTIVE_STATUS_SUMMARY), 
                is(AssetActiveStatus.ACTIVATED.toString()));
        assertThat((String)pushEvent.getProperty(AssetModel.EVENT_PROP_UUID), is(uuid2.toString()));
    }
@ Test public void testHandleRemoteEventActivatedAsset ( ) { Event getAssetsReponse = mockGetAssetsResponse ( systemId1 ) ; m_AssetDirHelper . handleEvent ( getAssetsReponse ) ; assertThat ( m_SUT . getAssetsForControllerAsync ( systemId1 ) . size ( ) , is ( 2 ) ) ; List < AssetModel > models = m_SUT . getAssetsForControllerAsync ( systemId1 ) ; for ( AssetModel model : models ) { assertThat ( model . getActiveStatus ( ) , is ( nullValue ( ) ) ) ; } Event assetActivated = mockEventAssetActivated ( systemId1 ) ; m_EventHelper . handleEvent ( assetActivated ) ; models = m_SUT . getAssetsForControllerAsync ( systemId1 ) ; boolean checked = false ; for ( AssetModel model : models ) { if ( model . getUuid ( ) . equals ( uuid2 ) ) { assertThat ( model . getActiveStatus ( ) , is ( AssetActiveStatus . ACTIVATED ) ) ; checked = true ; } } assertThat ( checked , is ( true ) ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event pushEvent = eventCaptor . getValue ( ) ; assertThat ( pushEvent , notNullValue ( ) ) ; assertThat ( pushEvent . getTopic ( ) , is ( AssetMgr . TOPIC_ASSET_ACTIVATION_STATUS_UPDATED ) ) ; assertThat ( ( String ) pushEvent . getProperty ( AssetMgr . EVENT_PROP_ACTIVE_STATUS_SUMMARY ) , is ( AssetActiveStatus . ACTIVATED . toString ( ) ) ) ; assertThat ( ( String ) pushEvent . getProperty ( AssetModel . EVENT_PROP_UUID ) , is ( uuid2 . toString ( ) ) ) ; }
Test the handling of activated asset event.
Test the handling of activated asset event .
//load assets for one system //this should render two assets for the system id //verify assets added, get status, should be default of "Active status not set" //mock event that an asset was activated //variable to hold boolean verifying the value was indeed checked