mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetMgrImpl.java
@Test
    public void testHandleGetAssetStatusResponse()
    {
        //make some assets
        Event getAssetsReponse = mockGetAssetsResponse(systemId1);
        
        //this should render two assets for the system id
        m_AssetDirHelper.handleEvent(getAssetsReponse);

        //verify assets added
        assertThat(m_SUT.getAssetsForControllerAsync(systemId1).size(), is(2));

        //create asset directory appropriate event for the asset status update
        Event getStatusResponse = mockGetAssetStatusResponseActive(systemId1);

        //handle event
        m_AssetHelper.handleEvent(getStatusResponse);

        //verify
        List<AssetModel> models = m_SUT.getAssetsForControllerAsync(systemId1);
        
         //verify that the asset with uuid1 is updated with appropriate status
        boolean verified = false;
        for (AssetModel model : models)
        {
            if (model.getUuid().equals(uuid1))
            {
                assertThat(model.getPid(), is(pid1));
                assertThat(model.getActiveStatus(), is(Asset.AssetActiveStatus.ACTIVATED));
                verified = true;
            }
        }
        assertThat(verified, is(true));
        
        //change status
        getStatusResponse = mockGetAssetStatusResponseDeactived(systemId1);

        //handle event
        m_AssetHelper.handleEvent(getStatusResponse);

        //verify
        models = m_SUT.getAssetsForControllerAsync(systemId1);
        
        //verify that the asset with uuid1 is updated with appropriate status
        verified = false;
        for (AssetModel model : models)
        {
            if (model.getUuid().equals(uuid1))
            {
                assertThat(model.getPid(), is(pid1));
                assertThat(model.getActiveStatus(), is(Asset.AssetActiveStatus.DEACTIVATED));
                verified = true;
            }
        }
        assertThat(verified, is(true));
        
        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.ACTIVATED.toString()));
        assertThat((String)firstPushEvent.getProperty(AssetModel.EVENT_PROP_UUID), is(uuid1.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(uuid1.toString()));
    }
/**
     * Test the handling of get status for asset request event.
     * Verify the status is updated. (The mock message only updates the asset with uuid1).
     */
Test the handling of get status for asset request event.
Verify the status is updated. (The mock message only updates the asset with uuid1).
Test the handling of get status for asset request event . Verify the status is updated . ( The mock message only updates the asset with uuid1 ) .
@Test
    public void testHandleGetAssetStatusResponse()
    {
        Event getAssetsReponse = mockGetAssetsResponse(systemId1);
        m_AssetDirHelper.handleEvent(getAssetsReponse);
        assertThat(m_SUT.getAssetsForControllerAsync(systemId1).size(), is(2));
        Event getStatusResponse = mockGetAssetStatusResponseActive(systemId1);
        m_AssetHelper.handleEvent(getStatusResponse);
        List<AssetModel> models = m_SUT.getAssetsForControllerAsync(systemId1);
          that the asset with uuid1 is updated with appropriate status
        boolean verified = false;
        for (AssetModel model : models)
        {
            if (model.getUuid().equals(uuid1))
            {
                assertThat(model.getPid(), is(pid1));
                assertThat(model.getActiveStatus(), is(Asset.AssetActiveStatus.ACTIVATED));
                verified = true;
            }
        }
        assertThat(verified, is(true));
        getStatusResponse = mockGetAssetStatusResponseDeactived(systemId1);
        m_AssetHelper.handleEvent(getStatusResponse);
        models = m_SUT.getAssetsForControllerAsync(systemId1);
         that the asset with uuid1 is updated with appropriate status
        verified = false;
        for (AssetModel model : models)
        {
            if (model.getUuid().equals(uuid1))
            {
                assertThat(model.getPid(), is(pid1));
                assertThat(model.getActiveStatus(), is(Asset.AssetActiveStatus.DEACTIVATED));
                verified = true;
            }
        }
        assertThat(verified, is(true));
        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.ACTIVATED.toString()));
        assertThat((String)firstPushEvent.getProperty(AssetModel.EVENT_PROP_UUID), is(uuid1.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(uuid1.toString()));
    }
@ Test public void testHandleGetAssetStatusResponse ( ) { Event getAssetsReponse = mockGetAssetsResponse ( systemId1 ) ; m_AssetDirHelper . handleEvent ( getAssetsReponse ) ; assertThat ( m_SUT . getAssetsForControllerAsync ( systemId1 ) . size ( ) , is ( 2 ) ) ; Event getStatusResponse = mockGetAssetStatusResponseActive ( systemId1 ) ; m_AssetHelper . handleEvent ( getStatusResponse ) ; List < AssetModel > models = m_SUT . getAssetsForControllerAsync ( systemId1 ) ; boolean verified = false ; for ( AssetModel model : models ) { if ( model . getUuid ( ) . equals ( uuid1 ) ) { assertThat ( model . getPid ( ) , is ( pid1 ) ) ; assertThat ( model . getActiveStatus ( ) , is ( Asset . AssetActiveStatus . ACTIVATED ) ) ; verified = true ; } } assertThat ( verified , is ( true ) ) ; getStatusResponse = mockGetAssetStatusResponseDeactived ( systemId1 ) ; m_AssetHelper . handleEvent ( getStatusResponse ) ; models = m_SUT . getAssetsForControllerAsync ( systemId1 ) ; verified = false ; for ( AssetModel model : models ) { if ( model . getUuid ( ) . equals ( uuid1 ) ) { assertThat ( model . getPid ( ) , is ( pid1 ) ) ; assertThat ( model . getActiveStatus ( ) , is ( Asset . AssetActiveStatus . DEACTIVATED ) ) ; verified = true ; } } assertThat ( verified , is ( true ) ) ; 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 . ACTIVATED . toString ( ) ) ) ; assertThat ( ( String ) firstPushEvent . getProperty ( AssetModel . EVENT_PROP_UUID ) , is ( uuid1 . 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 ( uuid1 . toString ( ) ) ) ; }
Test the handling of get status for asset request event.
Test the handling of get status for asset request event .
//make some assets //this should render two assets for the system id //verify assets added //create asset directory appropriate event for the asset status update //handle event //verify //verify that the asset with uuid1 is updated with appropriate status //change status //handle event //verify //verify that the asset with uuid1 is updated with appropriate status