mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/controller/TestControllerFilter.java
@Test
    public void testGetFilteredList()
    {
        //mock controllers that will have different statuses
        ControllerModel model1 = mock(ControllerModel.class);
        ControllerModel model2 = mock(ControllerModel.class);
        ControllerModel model3 = mock(ControllerModel.class);
        
        List<ControllerModel> controllerList = new ArrayList<ControllerModel>();
        
        controllerList.add(model1);
        controllerList.add(model2);
        controllerList.add(model3);
        
        when(m_ControllerMgr.getAllControllers()).thenReturn(controllerList);
        
        when(model1.getId()).thenReturn(111);
        when(model2.getId()).thenReturn(222);
        when(model3.getId()).thenReturn(333);
        
        //set a different status for each controller
        when(m_ChannelMgr.getStatusForController(111)).thenReturn(ControllerStatus.Good);
        when(m_ChannelMgr.getStatusForController(222)).thenReturn(ControllerStatus.Bad);
        when(m_ChannelMgr.getStatusForController(333)).thenReturn(ControllerStatus.Degraded);
        
        //verify default all filter value was set and returns all controllers
        controllerList = m_SUT.getFilterList();
        assertThat(controllerList.size(), is(3));
        assertThat(controllerList.contains(model1), is(true));
        
        //verify filter option of comms up returns controllers with good status
        m_SUT.setFilter(ControllerFilter.Filter.CommsUp);
        controllerList = m_SUT.getFilterList();
        assertThat(controllerList.size(), is(1));
        assertThat(controllerList.contains(model1), is(true));
        
        //verify filter option of comms down returns controllers with bad status
        m_SUT.setFilter(ControllerFilter.Filter.CommsDown);
        controllerList = m_SUT.getFilterList();
        assertThat(controllerList.size(), is(1));
        assertThat(controllerList.contains(model2), is(true));
        
        //verify filter option of degraded returns controller with degraded status
        m_SUT.setFilter(ControllerFilter.Filter.Degraded);
        controllerList = m_SUT.getFilterList();
        assertThat(controllerList.size(), is(1));
        assertThat(controllerList.contains(model3), is(true));
        
        //verify filter option of all returns all controllers
        m_SUT.setFilter(ControllerFilter.Filter.All);
        controllerList = m_SUT.getFilterList();
        assertThat(controllerList.size(), is(3));
        assertThat(controllerList.contains(model1), is(true));
    }
/**
    * Verify that the expected list of controllers is returned when getting the filtered list.
    */
Verify that the expected list of controllers is returned when getting the filtered list.
Verify that the expected list of controllers is returned when getting the filtered list .
@Test
    public void testGetFilteredList()
    {
        ControllerModel model1 = mock(ControllerModel.class);
        ControllerModel model2 = mock(ControllerModel.class);
        ControllerModel model3 = mock(ControllerModel.class);
        List<ControllerModel> controllerList = new ArrayList<ControllerModel>();
        controllerList.add(model1);
        controllerList.add(model2);
        controllerList.add(model3);
        when(m_ControllerMgr.getAllControllers()).thenReturn(controllerList);
        when(model1.getId()).thenReturn(111);
        when(model2.getId()).thenReturn(222);
        when(model3.getId()).thenReturn(333);
        when(m_ChannelMgr.getStatusForController(111)).thenReturn(ControllerStatus.Good);
        when(m_ChannelMgr.getStatusForController(222)).thenReturn(ControllerStatus.Bad);
        when(m_ChannelMgr.getStatusForController(333)).thenReturn(ControllerStatus.Degraded);
        controllerList = m_SUT.getFilterList();
        assertThat(controllerList.size(), is(3));
        assertThat(controllerList.contains(model1), is(true));
        m_SUT.setFilter(ControllerFilter.Filter.CommsUp);
        controllerList = m_SUT.getFilterList();
        assertThat(controllerList.size(), is(1));
        assertThat(controllerList.contains(model1), is(true));
        m_SUT.setFilter(ControllerFilter.Filter.CommsDown);
        controllerList = m_SUT.getFilterList();
        assertThat(controllerList.size(), is(1));
        assertThat(controllerList.contains(model2), is(true));
        m_SUT.setFilter(ControllerFilter.Filter.Degraded);
        controllerList = m_SUT.getFilterList();
        assertThat(controllerList.size(), is(1));
        assertThat(controllerList.contains(model3), is(true));
        m_SUT.setFilter(ControllerFilter.Filter.All);
        controllerList = m_SUT.getFilterList();
        assertThat(controllerList.size(), is(3));
        assertThat(controllerList.contains(model1), is(true));
    }
@ Test public void testGetFilteredList ( ) { ControllerModel model1 = mock ( ControllerModel . class ) ; ControllerModel model2 = mock ( ControllerModel . class ) ; ControllerModel model3 = mock ( ControllerModel . class ) ; List < ControllerModel > controllerList = new ArrayList < ControllerModel > ( ) ; controllerList . add ( model1 ) ; controllerList . add ( model2 ) ; controllerList . add ( model3 ) ; when ( m_ControllerMgr . getAllControllers ( ) ) . thenReturn ( controllerList ) ; when ( model1 . getId ( ) ) . thenReturn ( 111 ) ; when ( model2 . getId ( ) ) . thenReturn ( 222 ) ; when ( model3 . getId ( ) ) . thenReturn ( 333 ) ; when ( m_ChannelMgr . getStatusForController ( 111 ) ) . thenReturn ( ControllerStatus . Good ) ; when ( m_ChannelMgr . getStatusForController ( 222 ) ) . thenReturn ( ControllerStatus . Bad ) ; when ( m_ChannelMgr . getStatusForController ( 333 ) ) . thenReturn ( ControllerStatus . Degraded ) ; controllerList = m_SUT . getFilterList ( ) ; assertThat ( controllerList . size ( ) , is ( 3 ) ) ; assertThat ( controllerList . contains ( model1 ) , is ( true ) ) ; m_SUT . setFilter ( ControllerFilter . Filter . CommsUp ) ; controllerList = m_SUT . getFilterList ( ) ; assertThat ( controllerList . size ( ) , is ( 1 ) ) ; assertThat ( controllerList . contains ( model1 ) , is ( true ) ) ; m_SUT . setFilter ( ControllerFilter . Filter . CommsDown ) ; controllerList = m_SUT . getFilterList ( ) ; assertThat ( controllerList . size ( ) , is ( 1 ) ) ; assertThat ( controllerList . contains ( model2 ) , is ( true ) ) ; m_SUT . setFilter ( ControllerFilter . Filter . Degraded ) ; controllerList = m_SUT . getFilterList ( ) ; assertThat ( controllerList . size ( ) , is ( 1 ) ) ; assertThat ( controllerList . contains ( model3 ) , is ( true ) ) ; m_SUT . setFilter ( ControllerFilter . Filter . All ) ; controllerList = m_SUT . getFilterList ( ) ; assertThat ( controllerList . size ( ) , is ( 3 ) ) ; assertThat ( controllerList . contains ( model1 ) , is ( true ) ) ; }
Verify that the expected list of controllers is returned when getting the filtered list.
Verify that the expected list of controllers is returned when getting the filtered list .
//mock controllers that will have different statuses //set a different status for each controller //verify default all filter value was set and returns all controllers //verify filter option of comms up returns controllers with good status //verify filter option of comms down returns controllers with bad status //verify filter option of degraded returns controller with degraded status //verify filter option of all returns all controllers