mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/mp/TestMissionProgramMgrImpl.java
@Test
    public void testGetTemplatesResponseUpdate() throws ObjectConverterException
    {
        //mock controller
        ControllerModel model = mock(ControllerModel.class);
        when(model.getId()).thenReturn(911);
        
        //active controller behavior
        when(m_ActiveController.isActiveControllerSet()).thenReturn(true);
        when(m_ActiveController.getActiveController()).thenReturn(model);

        Event event = mockGetTemplatesRequestMutiples(911);

        //behavior for converter
        MissionProgramTemplate template1 = mock(MissionProgramTemplate.class);
        when(template1.getName()).thenReturn("I am a name");
        MissionProgramTemplate template2 = mock(MissionProgramTemplate.class);
        when(template2.getName()).thenReturn("I am a name too");
        MissionProgramTemplate template3 = mock(MissionProgramTemplate.class);
        when(template3.getName()).thenReturn("I am a name three");
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).thenReturn(template1, template2, template3);

        m_ListenerMission.handleEvent(event);

        //verify that the templates were added
        assertThat(m_SUT.getRemoteTemplateNames(911).size(), is(3));
        assertThat(m_SUT.getRemoteTemplateNames(911), hasItems("I am a name", "I am a name too", "I am a name three"));

        //this event will return only one template
        event = mockGetTemplatesRequest(911);
        m_ListenerMission.handleEvent(event);

        //verify update
        assertThat(m_SUT.getRemoteTemplateNames(911).size(), is(1));
    }
/**
     * Test handling of GetTemplates response in the context of the event being an update.
     * 
     * Verify that the list of templates is emptied out.
     * 
     */
Test handling of GetTemplates response in the context of the event being an update.

Verify that the list of templates is emptied out.
Test handling of GetTemplates response in the context of the event being an update . Verify that the list of templates is emptied out .
@Test
    public void testGetTemplatesResponseUpdate() throws ObjectConverterException
    {
        ControllerModel model = mock(ControllerModel.class);
        when(model.getId()).thenReturn(911);
        when(m_ActiveController.isActiveControllerSet()).thenReturn(true);
        when(m_ActiveController.getActiveController()).thenReturn(model);
        Event event = mockGetTemplatesRequestMutiples(911);
        MissionProgramTemplate template1 = mock(MissionProgramTemplate.class);
        when(template1.getName()).thenReturn("I am a name");
        MissionProgramTemplate template2 = mock(MissionProgramTemplate.class);
        when(template2.getName()).thenReturn("I am a name too");
        MissionProgramTemplate template3 = mock(MissionProgramTemplate.class);
        when(template3.getName()).thenReturn("I am a name three");
        when(m_Converter.convertToJaxb(Mockito.any(Message.class))).thenReturn(template1, template2, template3);
        m_ListenerMission.handleEvent(event);
        assertThat(m_SUT.getRemoteTemplateNames(911).size(), is(3));
        assertThat(m_SUT.getRemoteTemplateNames(911), hasItems("I am a name", "I am a name too", "I am a name three"));
        event = mockGetTemplatesRequest(911);
        m_ListenerMission.handleEvent(event);
        assertThat(m_SUT.getRemoteTemplateNames(911).size(), is(1));
    }
@ Test public void testGetTemplatesResponseUpdate ( ) throws ObjectConverterException { ControllerModel model = mock ( ControllerModel . class ) ; when ( model . getId ( ) ) . thenReturn ( 911 ) ; when ( m_ActiveController . isActiveControllerSet ( ) ) . thenReturn ( true ) ; when ( m_ActiveController . getActiveController ( ) ) . thenReturn ( model ) ; Event event = mockGetTemplatesRequestMutiples ( 911 ) ; MissionProgramTemplate template1 = mock ( MissionProgramTemplate . class ) ; when ( template1 . getName ( ) ) . thenReturn ( "I am a name" ) ; MissionProgramTemplate template2 = mock ( MissionProgramTemplate . class ) ; when ( template2 . getName ( ) ) . thenReturn ( "I am a name too" ) ; MissionProgramTemplate template3 = mock ( MissionProgramTemplate . class ) ; when ( template3 . getName ( ) ) . thenReturn ( "I am a name three" ) ; when ( m_Converter . convertToJaxb ( Mockito . any ( Message . class ) ) ) . thenReturn ( template1 , template2 , template3 ) ; m_ListenerMission . handleEvent ( event ) ; assertThat ( m_SUT . getRemoteTemplateNames ( 911 ) . size ( ) , is ( 3 ) ) ; assertThat ( m_SUT . getRemoteTemplateNames ( 911 ) , hasItems ( "I am a name" , "I am a name too" , "I am a name three" ) ) ; event = mockGetTemplatesRequest ( 911 ) ; m_ListenerMission . handleEvent ( event ) ; assertThat ( m_SUT . getRemoteTemplateNames ( 911 ) . size ( ) , is ( 1 ) ) ; }
Test handling of GetTemplates response in the context of the event being an update.
Test handling of GetTemplates response in the context of the event being an update .
//mock controller //active controller behavior //behavior for converter //verify that the templates were added //this event will return only one template //verify update