mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/controller/TestObservationCountMgrImpl.java
@Test
    public void testObservationEventHandler()
    {   
        //Test handling observation persisted event.
        Event persistEvent = mockObsPersisted();
        m_ObsEventHandler.handleEvent(persistEvent);
        assertThat(m_SUT.getObservationCount(CONTROLLER_ID), is(1));
        
        //Test handling observation merged event.
        Event mergedEvent = mockObsMerged();
        m_ObsEventHandler.handleEvent(mergedEvent);
        assertThat(m_SUT.getObservationCount(CONTROLLER_ID), is(2));
        
        //Verify an observation count updated event was posted for the persisted and merged events.
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(2)).postEvent(eventCaptor.capture());
        
        Event firstPush = eventCaptor.getAllValues().get(0);
        Event secondPush = eventCaptor.getAllValues().get(1);
        assertThat(firstPush.getTopic(), is(ObservationCountMgr.TOPIC_OBSERVATION_COUNT_UPDATED));
        assertThat((int)firstPush.getProperty(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID), is(CONTROLLER_ID));
        assertThat((int)firstPush.getProperty(ObservationCountMgr.EVENT_PROP_OBS_COUNT), is(1));
        
        assertThat(secondPush.getTopic(), is(ObservationCountMgr.TOPIC_OBSERVATION_COUNT_UPDATED));
        assertThat((int)secondPush.getProperty(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID), is(CONTROLLER_ID));
        assertThat((int)secondPush.getProperty(ObservationCountMgr.EVENT_PROP_OBS_COUNT), is(2));
    }
/**
     * Test the observation event handlers handle event method.
     * Verify that the specified controllers observation count is incremented by one and an obs count updated event
     * is posted.
     */
Test the observation event handlers handle event method.
Verify that the specified controllers observation count is incremented by one and an obs count updated event
is posted.
Test the observation event handlers handle event method . Verify that the specified controllers observation count is incremented by one and an obs count updated event is posted .
@Test
    public void testObservationEventHandler()
    {   
        Event persistEvent = mockObsPersisted();
        m_ObsEventHandler.handleEvent(persistEvent);
        assertThat(m_SUT.getObservationCount(CONTROLLER_ID), is(1));
        Event mergedEvent = mockObsMerged();
        m_ObsEventHandler.handleEvent(mergedEvent);
        assertThat(m_SUT.getObservationCount(CONTROLLER_ID), is(2));
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(2)).postEvent(eventCaptor.capture());
        Event firstPush = eventCaptor.getAllValues().get(0);
        Event secondPush = eventCaptor.getAllValues().get(1);
        assertThat(firstPush.getTopic(), is(ObservationCountMgr.TOPIC_OBSERVATION_COUNT_UPDATED));
        assertThat((int)firstPush.getProperty(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID), is(CONTROLLER_ID));
        assertThat((int)firstPush.getProperty(ObservationCountMgr.EVENT_PROP_OBS_COUNT), is(1));
        assertThat(secondPush.getTopic(), is(ObservationCountMgr.TOPIC_OBSERVATION_COUNT_UPDATED));
        assertThat((int)secondPush.getProperty(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID), is(CONTROLLER_ID));
        assertThat((int)secondPush.getProperty(ObservationCountMgr.EVENT_PROP_OBS_COUNT), is(2));
    }
@ Test public void testObservationEventHandler ( ) { Event persistEvent = mockObsPersisted ( ) ; m_ObsEventHandler . handleEvent ( persistEvent ) ; assertThat ( m_SUT . getObservationCount ( CONTROLLER_ID ) , is ( 1 ) ) ; Event mergedEvent = mockObsMerged ( ) ; m_ObsEventHandler . handleEvent ( mergedEvent ) ; assertThat ( m_SUT . getObservationCount ( CONTROLLER_ID ) , is ( 2 ) ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , times ( 2 ) ) . postEvent ( eventCaptor . capture ( ) ) ; Event firstPush = eventCaptor . getAllValues ( ) . get ( 0 ) ; Event secondPush = eventCaptor . getAllValues ( ) . get ( 1 ) ; assertThat ( firstPush . getTopic ( ) , is ( ObservationCountMgr . TOPIC_OBSERVATION_COUNT_UPDATED ) ) ; assertThat ( ( int ) firstPush . getProperty ( SharedPropertyConstants . EVENT_PROP_CONTROLLER_ID ) , is ( CONTROLLER_ID ) ) ; assertThat ( ( int ) firstPush . getProperty ( ObservationCountMgr . EVENT_PROP_OBS_COUNT ) , is ( 1 ) ) ; assertThat ( secondPush . getTopic ( ) , is ( ObservationCountMgr . TOPIC_OBSERVATION_COUNT_UPDATED ) ) ; assertThat ( ( int ) secondPush . getProperty ( SharedPropertyConstants . EVENT_PROP_CONTROLLER_ID ) , is ( CONTROLLER_ID ) ) ; assertThat ( ( int ) secondPush . getProperty ( ObservationCountMgr . EVENT_PROP_OBS_COUNT ) , is ( 2 ) ) ; }
Test the observation event handlers handle event method.
Test the observation event handlers handle event method .
//Test handling observation persisted event. //Test handling observation merged event. //Verify an observation count updated event was posted for the persisted and merged events.