mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/controller/TestObservationCountMgrImpl.java
@SuppressWarnings("unchecked")
    @Test
    public void testControllerEventHandler() throws SecurityException, NoSuchFieldException, IllegalArgumentException, 
        IllegalAccessException
    {
        //Add controller and verify existence.
        Event persistEvent = mockObsPersisted();
        m_ObsEventHandler.handleEvent(persistEvent);
        assertThat(m_SUT.getObservationCount(CONTROLLER_ID), is(1));
        
        //Setup event.
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID, 5);
        Event controllerRemoved = new Event(ControllerMgr.TOPIC_CONTROLLER_REMOVED, props);
        
        //Handle event.
        m_ControllerEventHandler.handleEvent(controllerRemoved);
        
        //Verify nothing happens if a controller removed event is received for an unknown controller.
        m_ControllerEventHandler.handleEvent(controllerRemoved);
        
        //Retrieve map using reflections.
        Field mapField = m_SUT.getClass().getDeclaredField("m_ControllerObsCount");
        mapField.setAccessible(true);
        Map<Integer, Integer> obsCntMap = (Map<Integer, Integer>)mapField.get(m_SUT);
        
        //Verify controller ID is not contained within the map.
        assertThat(obsCntMap.containsKey(CONTROLLER_ID), is(false));
    }
/**
     * Test the controller event handlers handle event method.
     * Verify that the specified controller is removed from the list know controllers. 
     */
Test the controller event handlers handle event method.
Verify that the specified controller is removed from the list know controllers.
Test the controller event handlers handle event method . Verify that the specified controller is removed from the list know controllers .
@SuppressWarnings("unchecked")
    @Test
    public void testControllerEventHandler() throws SecurityException, NoSuchFieldException, IllegalArgumentException, 
        IllegalAccessException
    {
        Event persistEvent = mockObsPersisted();
        m_ObsEventHandler.handleEvent(persistEvent);
        assertThat(m_SUT.getObservationCount(CONTROLLER_ID), is(1));
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID, 5);
        Event controllerRemoved = new Event(ControllerMgr.TOPIC_CONTROLLER_REMOVED, props);
        m_ControllerEventHandler.handleEvent(controllerRemoved);
        m_ControllerEventHandler.handleEvent(controllerRemoved);
        Field mapField = m_SUT.getClass().getDeclaredField("m_ControllerObsCount");
        mapField.setAccessible(true);
        Map<Integer, Integer> obsCntMap = (Map<Integer, Integer>)mapField.get(m_SUT);
        assertThat(obsCntMap.containsKey(CONTROLLER_ID), is(false));
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testControllerEventHandler ( ) throws SecurityException , NoSuchFieldException , IllegalArgumentException , IllegalAccessException { Event persistEvent = mockObsPersisted ( ) ; m_ObsEventHandler . handleEvent ( persistEvent ) ; assertThat ( m_SUT . getObservationCount ( CONTROLLER_ID ) , is ( 1 ) ) ; Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( SharedPropertyConstants . EVENT_PROP_CONTROLLER_ID , 5 ) ; Event controllerRemoved = new Event ( ControllerMgr . TOPIC_CONTROLLER_REMOVED , props ) ; m_ControllerEventHandler . handleEvent ( controllerRemoved ) ; m_ControllerEventHandler . handleEvent ( controllerRemoved ) ; Field mapField = m_SUT . getClass ( ) . getDeclaredField ( "m_ControllerObsCount" ) ; mapField . setAccessible ( true ) ; Map < Integer , Integer > obsCntMap = ( Map < Integer , Integer > ) mapField . get ( m_SUT ) ; assertThat ( obsCntMap . containsKey ( CONTROLLER_ID ) , is ( false ) ) ; }
Test the controller event handlers handle event method.
Test the controller event handlers handle event method .
//Add controller and verify existence. //Setup event. //Handle event. //Verify nothing happens if a controller removed event is received for an unknown controller. //Retrieve map using reflections. //Verify controller ID is not contained within the map.