mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/controller/TestObservationCountMgrImpl.java
@Test
    public void testClearObsCount()
    {
        //Test calling clear obs count for unknown controller. Should not post an event.
        m_SUT.clearObsCount(5);
        
        //Increment obs count for controller.
        Event persistEvent = mockObsPersisted();
        m_ObsEventHandler.handleEvent(persistEvent);
        assertThat(m_SUT.getObservationCount(CONTROLLER_ID), is(1));
        
        //Clear obs count for controller and verify that it is zero.
        m_SUT.clearObsCount(CONTROLLER_ID);
        assertThat(m_SUT.getObservationCount(CONTROLLER_ID), is(0));
        
        //Verify that two observation count updated events were posted. One for incrementing and one for clearing.
        //Should not be three since the first clear obs count call should have done nothing.
        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(0));
    }
/**
     * Test the method used to clear the observation count for a controller.
     * Verify that the observation count for a controller is set to zero once the clear method is called.
     */
Test the method used to clear the observation count for a controller.
Verify that the observation count for a controller is set to zero once the clear method is called.
Test the method used to clear the observation count for a controller . Verify that the observation count for a controller is set to zero once the clear method is called .
@Test
    public void testClearObsCount()
    {
        m_SUT.clearObsCount(5);
        Event persistEvent = mockObsPersisted();
        m_ObsEventHandler.handleEvent(persistEvent);
        assertThat(m_SUT.getObservationCount(CONTROLLER_ID), is(1));
        m_SUT.clearObsCount(CONTROLLER_ID);
        assertThat(m_SUT.getObservationCount(CONTROLLER_ID), is(0));
        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(0));
    }
@ Test public void testClearObsCount ( ) { m_SUT . clearObsCount ( 5 ) ; Event persistEvent = mockObsPersisted ( ) ; m_ObsEventHandler . handleEvent ( persistEvent ) ; assertThat ( m_SUT . getObservationCount ( CONTROLLER_ID ) , is ( 1 ) ) ; m_SUT . clearObsCount ( CONTROLLER_ID ) ; assertThat ( m_SUT . getObservationCount ( CONTROLLER_ID ) , is ( 0 ) ) ; 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 ( 0 ) ) ; }
Test the method used to clear the observation count for a controller.
Test the method used to clear the observation count for a controller .
//Test calling clear obs count for unknown controller. Should not post an event. //Increment obs count for controller. //Clear obs count for controller and verify that it is zero. //Verify that two observation count updated events were posted. One for incrementing and one for clearing. //Should not be three since the first clear obs count call should have done nothing.