mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/asset/TestAssetMgrImpl.java
@Test
    public void testHandlePerformBitResponseException() throws ObjectConverterException
    {
        //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 appropriate event for the asset status update
        Event bitUpdate = mockPerformBITResponse(systemId1);

        //mock converter behavior
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).
            thenThrow(new ObjectConverterException("Exception"));
        
        //handle event
        m_AssetHelper.handleEvent(bitUpdate);

        verify(m_GrowlUtil, never()).createGlobalFacesMessage(eq(FacesMessage.SEVERITY_INFO), anyString(), anyString());

        //verify
        List<AssetModel> models = m_SUT.getAssetsForControllerAsync(systemId1);
        
        //verify that the asset with uuid1 is updated with appropriate status
        boolean verified = false;
        boolean verified2 = false;
        for (AssetModel model : models)
        {
            if (model.getUuid().equals(uuid1))
            {
                assertThat(model.getPid(), is(pid1));
                assertThat(model.getSummaryStatus(), is(nullValue()));
                verified = true;
            }
            //check that the default is unknown, as only asset with uuid1 is updated with the event
            else
            {
                assertThat(model.getUuid(), is(uuid2));
                assertThat(model.getPid(), is(pid2));
                assertThat(model.getSummaryStatus(), is(nullValue()));
                verified2 = true;
            }
        }
        
        //verify both assets were checked
        assertThat(verified, is(true));
        assertThat(verified2, is(true));
        
        verify(m_EventAdmin, never()).postEvent(Mockito.any(Event.class));
    }
/**
     * Test the handling of perform BIT request event and the status cannot be converted.
     */
Test the handling of perform BIT request event and the status cannot be converted.
Test the handling of perform BIT request event and the status cannot be converted .
@Test
    public void testHandlePerformBitResponseException() throws ObjectConverterException
    {
        Event getAssetsReponse = mockGetAssetsResponse(systemId1);
        m_AssetDirHelper.handleEvent(getAssetsReponse);
        assertThat(m_SUT.getAssetsForControllerAsync(systemId1).size(), is(2));
        Event bitUpdate = mockPerformBITResponse(systemId1);
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).
            thenThrow(new ObjectConverterException("Exception"));
        m_AssetHelper.handleEvent(bitUpdate);
        verify(m_GrowlUtil, never()).createGlobalFacesMessage(eq(FacesMessage.SEVERITY_INFO), anyString(), anyString());
        List<AssetModel> models = m_SUT.getAssetsForControllerAsync(systemId1);
         that the asset with uuid1 is updated with appropriate status
        boolean verified = false;
        boolean verified2 = false;
        for (AssetModel model : models)
        {
            if (model.getUuid().equals(uuid1))
            {
                assertThat(model.getPid(), is(pid1));
                assertThat(model.getSummaryStatus(), is(nullValue()));
                verified = true;
            }
            else
            {
                assertThat(model.getUuid(), is(uuid2));
                assertThat(model.getPid(), is(pid2));
                assertThat(model.getSummaryStatus(), is(nullValue()));
                verified2 = true;
            }
        }
         both assets were checked
        assertThat(verified, is(true));
        assertThat(verified2, is(true));
        verify(m_EventAdmin, never()).postEvent(Mockito.any(Event.class));
    }
@ Test public void testHandlePerformBitResponseException ( ) throws ObjectConverterException { Event getAssetsReponse = mockGetAssetsResponse ( systemId1 ) ; m_AssetDirHelper . handleEvent ( getAssetsReponse ) ; assertThat ( m_SUT . getAssetsForControllerAsync ( systemId1 ) . size ( ) , is ( 2 ) ) ; Event bitUpdate = mockPerformBITResponse ( systemId1 ) ; when ( m_Converter . convertToJaxb ( Mockito . any ( Message . class ) ) ) . thenThrow ( new ObjectConverterException ( "Exception" ) ) ; m_AssetHelper . handleEvent ( bitUpdate ) ; verify ( m_GrowlUtil , never ( ) ) . createGlobalFacesMessage ( eq ( FacesMessage . SEVERITY_INFO ) , anyString ( ) , anyString ( ) ) ; List < AssetModel > models = m_SUT . getAssetsForControllerAsync ( systemId1 ) ; boolean verified = false ; boolean verified2 = false ; for ( AssetModel model : models ) { if ( model . getUuid ( ) . equals ( uuid1 ) ) { assertThat ( model . getPid ( ) , is ( pid1 ) ) ; assertThat ( model . getSummaryStatus ( ) , is ( nullValue ( ) ) ) ; verified = true ; } else { assertThat ( model . getUuid ( ) , is ( uuid2 ) ) ; assertThat ( model . getPid ( ) , is ( pid2 ) ) ; assertThat ( model . getSummaryStatus ( ) , is ( nullValue ( ) ) ) ; verified2 = true ; } } assertThat ( verified , is ( true ) ) ; assertThat ( verified2 , is ( true ) ) ; verify ( m_EventAdmin , never ( ) ) . postEvent ( Mockito . any ( Event . class ) ) ; }
Test the handling of perform BIT request event and the status cannot be converted.
Test the handling of perform BIT request event and the status cannot be converted .
//make some assets //this should render two assets for the system id //verify assets added //create asset appropriate event for the asset status update //mock converter behavior //handle event //verify //verify that the asset with uuid1 is updated with appropriate status //check that the default is unknown, as only asset with uuid1 is updated with the event //verify both assets were checked