edu.udayton.udri.asset.novatel/test/edu/udayton/udri/asset/novatel/TestNovatelAsset.java
@Test
    public void testHandleInsPvaStatusException() throws AssetException, IOException, 
        FactoryException, NovatelMessageException, ValidationFailedException
    {
        //activate to set the status
        final Map<String, Object> configProps = createConfigProps();
        configProps.put(NovatelAssetAttributes.CONFIG_PROP_HANDLE_MESSAGE_FREQUENCY, 1);
        m_SUT.updated(configProps);
        m_SUT.onActivate();
        
        //mock message exception
        when(m_Parser.parseInsMessage(m_InsData)).thenThrow(new NovatelMessageException(
                "gere", FormatProblem.INS_STATUS_NOT_GOOD));
        
        //now handle the ins message a few times
        m_SUT.handleDataString(m_InsData);
        m_SUT.handleDataString(m_InsData);
        m_SUT.handleDataString(m_InsData);
        m_SUT.handleDataString(m_InsData);
        m_SUT.handleDataString(m_InsData);
        
        //capture the status
        ArgumentCaptor<ComponentStatus> statusCap = ArgumentCaptor.forClass(ComponentStatus.class);
        verify(m_NovatelStatusService, times(8)).getStatus(Mockito.any(Observation.class), statusCap.capture());
        
        //get the message readers component status
        ComponentStatus capStatus = statusCap.getValue();
        assertThat(capStatus.getStatus().getSummary(), is(SummaryStatusEnum.DEGRADED));
    }
/**
     * Verify bad status if there is a {@link NovatelMessageException}.
     * Verify that the asset's status is not updated multiple times.
     */
Verify bad status if there is a  NovatelMessageException.
Verify that the asset's status is not updated multiple times.
Verify bad status if there is a NovatelMessageException . Verify that the asset ' s status is not updated multiple times .
@Test
    public void testHandleInsPvaStatusException() throws AssetException, IOException, 
        FactoryException, NovatelMessageException, ValidationFailedException
    {
        final Map<String, Object> configProps = createConfigProps();
        configProps.put(NovatelAssetAttributes.CONFIG_PROP_HANDLE_MESSAGE_FREQUENCY, 1);
        m_SUT.updated(configProps);
        m_SUT.onActivate();
        when(m_Parser.parseInsMessage(m_InsData)).thenThrow(new NovatelMessageException(
                "gere", FormatProblem.INS_STATUS_NOT_GOOD));
        m_SUT.handleDataString(m_InsData);
        m_SUT.handleDataString(m_InsData);
        m_SUT.handleDataString(m_InsData);
        m_SUT.handleDataString(m_InsData);
        m_SUT.handleDataString(m_InsData);
        ArgumentCaptor<ComponentStatus> statusCap = ArgumentCaptor.forClass(ComponentStatus.class);
        verify(m_NovatelStatusService, times(8)).getStatus(Mockito.any(Observation.class), statusCap.capture());
        ComponentStatus capStatus = statusCap.getValue();
        assertThat(capStatus.getStatus().getSummary(), is(SummaryStatusEnum.DEGRADED));
    }
@ Test public void testHandleInsPvaStatusException ( ) throws AssetException , IOException , FactoryException , NovatelMessageException , ValidationFailedException { final Map < String , Object > configProps = createConfigProps ( ) ; configProps . put ( NovatelAssetAttributes . CONFIG_PROP_HANDLE_MESSAGE_FREQUENCY , 1 ) ; m_SUT . updated ( configProps ) ; m_SUT . onActivate ( ) ; when ( m_Parser . parseInsMessage ( m_InsData ) ) . thenThrow ( new NovatelMessageException ( "gere" , FormatProblem . INS_STATUS_NOT_GOOD ) ) ; m_SUT . handleDataString ( m_InsData ) ; m_SUT . handleDataString ( m_InsData ) ; m_SUT . handleDataString ( m_InsData ) ; m_SUT . handleDataString ( m_InsData ) ; m_SUT . handleDataString ( m_InsData ) ; ArgumentCaptor < ComponentStatus > statusCap = ArgumentCaptor . forClass ( ComponentStatus . class ) ; verify ( m_NovatelStatusService , times ( 8 ) ) . getStatus ( Mockito . any ( Observation . class ) , statusCap . capture ( ) ) ; ComponentStatus capStatus = statusCap . getValue ( ) ; assertThat ( capStatus . getStatus ( ) . getSummary ( ) , is ( SummaryStatusEnum . DEGRADED ) ) ; }
Verify bad status if there is a {@link NovatelMessageException}.
Verify bad status if there is a { @link NovatelMessageException } .
//activate to set the status //mock message exception //now handle the ins message a few times //capture the status //get the message readers component status