mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/asset/TestAssetImpl.java
@Test
    public void testPerformBitInvalidObs()
            throws AssetException, IllegalArgumentException, PersistenceFailedException, ValidationFailedException
    {
        Status retStatus = new Status().withSummaryStatus(
                new OperatingStatus().withDescription("New description").withSummary(SummaryStatusEnum.GOOD));
        when(m_Proxy.onPerformBit()).thenReturn(retStatus);
        // throw exception for first obs which is bit obs, then do nothing for subsequent bad status
        doThrow(new ValidationFailedException()).doNothing().when(m_ObservationStore).persist(
                Mockito.any(Observation.class));

        m_SUT.performBit();

        verify(m_WakeLock).activate();
        verify(m_WakeLock).cancel();

        // last event should be bad status
        Map<String, Object> map = new HashMap<>();
        map.put(Asset.EVENT_PROP_ASSET_STATUS_DESCRIPTION, "Invalid data received from perform BIT");
        map.put(Asset.EVENT_PROP_ASSET_STATUS_SUMMARY, SummaryStatusEnum.BAD.toString());
        EventAdminVerifier.assertLastEvent(m_EventAdmin, Asset.TOPIC_STATUS_CHANGED, map);
    }
/**
     * Verify bad status if perform bit obs is invalid.
     */
Verify bad status if perform bit obs is invalid.
Verify bad status if perform bit obs is invalid .
@Test
    public void testPerformBitInvalidObs()
            throws AssetException, IllegalArgumentException, PersistenceFailedException, ValidationFailedException
    {
        Status retStatus = new Status().withSummaryStatus(
                new OperatingStatus().withDescription("New description").withSummary(SummaryStatusEnum.GOOD));
        when(m_Proxy.onPerformBit()).thenReturn(retStatus);
        doThrow(new ValidationFailedException()).doNothing().when(m_ObservationStore).persist(
                Mockito.any(Observation.class));
        m_SUT.performBit();
        verify(m_WakeLock).activate();
        verify(m_WakeLock).cancel();
        Map<String, Object> map = new HashMap<>();
        map.put(Asset.EVENT_PROP_ASSET_STATUS_DESCRIPTION, "Invalid data received from perform BIT");
        map.put(Asset.EVENT_PROP_ASSET_STATUS_SUMMARY, SummaryStatusEnum.BAD.toString());
        EventAdminVerifier.assertLastEvent(m_EventAdmin, Asset.TOPIC_STATUS_CHANGED, map);
    }
@ Test public void testPerformBitInvalidObs ( ) throws AssetException , IllegalArgumentException , PersistenceFailedException , ValidationFailedException { Status retStatus = new Status ( ) . withSummaryStatus ( new OperatingStatus ( ) . withDescription ( "New description" ) . withSummary ( SummaryStatusEnum . GOOD ) ) ; when ( m_Proxy . onPerformBit ( ) ) . thenReturn ( retStatus ) ; doThrow ( new ValidationFailedException ( ) ) . doNothing ( ) . when ( m_ObservationStore ) . persist ( Mockito . any ( Observation . class ) ) ; m_SUT . performBit ( ) ; verify ( m_WakeLock ) . activate ( ) ; verify ( m_WakeLock ) . cancel ( ) ; Map < String , Object > map = new HashMap < > ( ) ; map . put ( Asset . EVENT_PROP_ASSET_STATUS_DESCRIPTION , "Invalid data received from perform BIT" ) ; map . put ( Asset . EVENT_PROP_ASSET_STATUS_SUMMARY , SummaryStatusEnum . BAD . toString ( ) ) ; EventAdminVerifier . assertLastEvent ( m_EventAdmin , Asset . TOPIC_STATUS_CHANGED , map ) ; }
Verify bad status if perform bit obs is invalid.
Verify bad status if perform bit obs is invalid .
// throw exception for first obs which is bit obs, then do nothing for subsequent bad status // last event should be bad status