mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/mp/TestMissionProgramMgrImpl.java
@Test
    public void testGetTemplatesPersistenceFail() throws ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException
    {
        //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);
        
        //template manager behavior
        doThrow(new PersistenceFailedException("asdfsa")).when(m_TemplateManager).loadMissionTemplate(template1);

        m_ListenerMission.handleEvent(event);

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

        //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"));
    }
/**
     * Test handling of GetTemplates response with a template being unable to be persisted.
     * 
     * Verify that the list of templates retrieved for the system still contains all templates.
     * 
     */
Test handling of GetTemplates response with a template being unable to be persisted.

Verify that the list of templates retrieved for the system still contains all templates.
Test handling of GetTemplates response with a template being unable to be persisted . Verify that the list of templates retrieved for the system still contains all templates .
@Test
    public void testGetTemplatesPersistenceFail() throws ObjectConverterException, IllegalArgumentException, 
        PersistenceFailedException
    {
        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);
        doThrow(new PersistenceFailedException("asdfsa")).when(m_TemplateManager).loadMissionTemplate(template1);
        m_ListenerMission.handleEvent(event);
        verify(m_GrowlUtil).createLocalFacesMessage(eq(FacesMessage.SEVERITY_WARN), eq("Syncing Templates Info"), 
            eq("A template from controller 0x0000038f wasn't able to be stored locally."), 
                Mockito.any(PersistenceFailedException.class));
        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"));
    }
@ Test public void testGetTemplatesPersistenceFail ( ) throws ObjectConverterException , IllegalArgumentException , PersistenceFailedException { 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 ) ; doThrow ( new PersistenceFailedException ( "asdfsa" ) ) . when ( m_TemplateManager ) . loadMissionTemplate ( template1 ) ; m_ListenerMission . handleEvent ( event ) ; verify ( m_GrowlUtil ) . createLocalFacesMessage ( eq ( FacesMessage . SEVERITY_WARN ) , eq ( "Syncing Templates Info" ) , eq ( "A template from controller 0x0000038f wasn't able to be stored locally." ) , Mockito . any ( PersistenceFailedException . class ) ) ; 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" ) ) ; }
Test handling of GetTemplates response with a template being unable to be persisted.
Test handling of GetTemplates response with a template being unable to be persisted .
//mock controller //active controller behavior //behavior for converter //template manager behavior //verify growl message of a template failing //verify that the templates were added