mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/mp/TestMissionProgramMgrImpl.java
@Test
    public void testGetTemplatesResponseObjConvertException() 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
        MissionProgramTemplateGen.MissionProgramTemplate genTemp1 = 
            MissionProgramTemplateGen.MissionProgramTemplate.newBuilder().
                setName("name1").
                setSource("source1").build();
        MissionProgramTemplateGen.MissionProgramTemplate genTemp2 = 
            MissionProgramTemplateGen.MissionProgramTemplate.newBuilder().
                 setName("name2").
                 setSource("source2").build();
        MissionProgramTemplateGen.MissionProgramTemplate genTemp3 = 
            MissionProgramTemplateGen.MissionProgramTemplate.newBuilder().
                setName("name3").
                setSource("source3").build();
        MissionProgramTemplate template1 = mock(MissionProgramTemplate.class);
        when(template1.getName()).thenReturn("I am a name");
        MissionProgramTemplate template3 = mock(MissionProgramTemplate.class);
        when(template3.getName()).thenReturn("I am a name three");
        when(m_Converter.convertToJaxb(genTemp1)).thenReturn(template1);
        when(m_Converter.convertToJaxb(genTemp3)).thenReturn(template3);
        when(m_Converter.convertToJaxb(genTemp2)).thenThrow(new ObjectConverterException("ABORTTTTT"));

        m_ListenerMission.handleEvent(event);

        //verify growl message of a template failing
        verify(m_GrowlUtil).createLocalFacesMessage(eq(FacesMessage.SEVERITY_WARN), eq("Syncing Templates Warning"), 
            eq("A template from controller 0x0000038f wasn't able to be processed."), 
                Mockito.any(ObjectConverterException.class));

        //verify that the templates were added
        assertThat(m_SUT.getRemoteTemplateNames(911).size(), is(2));
    }
/**
     * Test handling of GetTemplates response when one template cannot be converted.
     * 
     * Verify other templates are still loaded.
     * 
     */
Test handling of GetTemplates response when one template cannot be converted.

Verify other templates are still loaded.
Test handling of GetTemplates response when one template cannot be converted . Verify other templates are still loaded .
@Test
    public void testGetTemplatesResponseObjConvertException() 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);
        MissionProgramTemplateGen.MissionProgramTemplate genTemp1 = 
            MissionProgramTemplateGen.MissionProgramTemplate.newBuilder().
                setName("name1").
                setSource("source1").build();
        MissionProgramTemplateGen.MissionProgramTemplate genTemp2 = 
            MissionProgramTemplateGen.MissionProgramTemplate.newBuilder().
                 setName("name2").
                 setSource("source2").build();
        MissionProgramTemplateGen.MissionProgramTemplate genTemp3 = 
            MissionProgramTemplateGen.MissionProgramTemplate.newBuilder().
                setName("name3").
                setSource("source3").build();
        MissionProgramTemplate template1 = mock(MissionProgramTemplate.class);
        when(template1.getName()).thenReturn("I am a name");
        MissionProgramTemplate template3 = mock(MissionProgramTemplate.class);
        when(template3.getName()).thenReturn("I am a name three");
        when(m_Converter.convertToJaxb(genTemp1)).thenReturn(template1);
        when(m_Converter.convertToJaxb(genTemp3)).thenReturn(template3);
        when(m_Converter.convertToJaxb(genTemp2)).thenThrow(new ObjectConverterException("ABORTTTTT"));
        m_ListenerMission.handleEvent(event);
        verify(m_GrowlUtil).createLocalFacesMessage(eq(FacesMessage.SEVERITY_WARN), eq("Syncing Templates Warning"), 
            eq("A template from controller 0x0000038f wasn't able to be processed."), 
                Mockito.any(ObjectConverterException.class));
        assertThat(m_SUT.getRemoteTemplateNames(911).size(), is(2));
    }
@ Test public void testGetTemplatesResponseObjConvertException ( ) 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 ) ; MissionProgramTemplateGen . MissionProgramTemplate genTemp1 = MissionProgramTemplateGen . MissionProgramTemplate . newBuilder ( ) . setName ( "name1" ) . setSource ( "source1" ) . build ( ) ; MissionProgramTemplateGen . MissionProgramTemplate genTemp2 = MissionProgramTemplateGen . MissionProgramTemplate . newBuilder ( ) . setName ( "name2" ) . setSource ( "source2" ) . build ( ) ; MissionProgramTemplateGen . MissionProgramTemplate genTemp3 = MissionProgramTemplateGen . MissionProgramTemplate . newBuilder ( ) . setName ( "name3" ) . setSource ( "source3" ) . build ( ) ; MissionProgramTemplate template1 = mock ( MissionProgramTemplate . class ) ; when ( template1 . getName ( ) ) . thenReturn ( "I am a name" ) ; MissionProgramTemplate template3 = mock ( MissionProgramTemplate . class ) ; when ( template3 . getName ( ) ) . thenReturn ( "I am a name three" ) ; when ( m_Converter . convertToJaxb ( genTemp1 ) ) . thenReturn ( template1 ) ; when ( m_Converter . convertToJaxb ( genTemp3 ) ) . thenReturn ( template3 ) ; when ( m_Converter . convertToJaxb ( genTemp2 ) ) . thenThrow ( new ObjectConverterException ( "ABORTTTTT" ) ) ; m_ListenerMission . handleEvent ( event ) ; verify ( m_GrowlUtil ) . createLocalFacesMessage ( eq ( FacesMessage . SEVERITY_WARN ) , eq ( "Syncing Templates Warning" ) , eq ( "A template from controller 0x0000038f wasn't able to be processed." ) , Mockito . any ( ObjectConverterException . class ) ) ; assertThat ( m_SUT . getRemoteTemplateNames ( 911 ) . size ( ) , is ( 2 ) ) ; }
Test handling of GetTemplates response when one template cannot be converted.
Test handling of GetTemplates response when one template cannot be converted .
//mock controller //active controller behavior //behavior for converter //verify growl message of a template failing //verify that the templates were added