mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestTemplateProgramManagerImpl.java
@Test
    public void testLoadMissionTemplate() throws IllegalArgumentException, PersistenceFailedException
    {
        m_SUT.activate(context);
        
        //template to add
        MissionProgramTemplate template = new MissionProgramTemplate().withName("MyTemplate").withSource("Source");
        m_SUT.loadMissionTemplate(template);
        ArgumentCaptor<byte[]> templateCap = ArgumentCaptor.forClass(byte[].class);
        verify(m_PersistentDataStore).persist(eq(TemplateProgramManagerImpl.class), Mockito.any(UUID.class), 
            eq("MyTemplate"), templateCap.capture());
         
        //verify
        MissionProgramTemplate templateAgain = (MissionProgramTemplate)XmlUtils.fromXML(templateCap.getValue(), 
            MissionProgramTemplate.class);
        assertThat(templateAgain.getSource(), is("Source"));
        
        //change source, but not name
        templateAgain.setSource("DifferentSource");
        //try adding the template again
        m_SUT.loadMissionTemplate(templateAgain);
        
        //verify
        verify(m_PersistentDataStore, times(2)).persist(eq(TemplateProgramManagerImpl.class), Mockito.any(UUID.class), 
            eq("MyTemplate"), templateCap.capture());
        
        //verify that template was updated
        template = (MissionProgramTemplate)XmlUtils.fromXML(templateCap.getValue(), 
            MissionProgramTemplate.class);
        assertThat(template.getSource(), is("DifferentSource"));
    }
/**
     * Test the loading of templates. Also testing that the mission program manager can activate without
     * templates to restore.
     */
Test the loading of templates. Also testing that the mission program manager can activate without
templates to restore.
Test the loading of templates . Also testing that the mission program manager can activate without templates to restore .
@Test
    public void testLoadMissionTemplate() throws IllegalArgumentException, PersistenceFailedException
    {
        m_SUT.activate(context);
        MissionProgramTemplate template = new MissionProgramTemplate().withName("MyTemplate").withSource("Source");
        m_SUT.loadMissionTemplate(template);
        ArgumentCaptor<byte[]> templateCap = ArgumentCaptor.forClass(byte[].class);
        verify(m_PersistentDataStore).persist(eq(TemplateProgramManagerImpl.class), Mockito.any(UUID.class), 
            eq("MyTemplate"), templateCap.capture());
        MissionProgramTemplate templateAgain = (MissionProgramTemplate)XmlUtils.fromXML(templateCap.getValue(), 
            MissionProgramTemplate.class);
        assertThat(templateAgain.getSource(), is("Source"));
        templateAgain.setSource("DifferentSource");
        m_SUT.loadMissionTemplate(templateAgain);
        verify(m_PersistentDataStore, times(2)).persist(eq(TemplateProgramManagerImpl.class), Mockito.any(UUID.class), 
            eq("MyTemplate"), templateCap.capture());
         that template was updated
        template = (MissionProgramTemplate)XmlUtils.fromXML(templateCap.getValue(), 
            MissionProgramTemplate.class);
        assertThat(template.getSource(), is("DifferentSource"));
    }
@ Test public void testLoadMissionTemplate ( ) throws IllegalArgumentException , PersistenceFailedException { m_SUT . activate ( context ) ; MissionProgramTemplate template = new MissionProgramTemplate ( ) . withName ( "MyTemplate" ) . withSource ( "Source" ) ; m_SUT . loadMissionTemplate ( template ) ; ArgumentCaptor < byte [ ] > templateCap = ArgumentCaptor . forClass ( byte [ ] . class ) ; verify ( m_PersistentDataStore ) . persist ( eq ( TemplateProgramManagerImpl . class ) , Mockito . any ( UUID . class ) , eq ( "MyTemplate" ) , templateCap . capture ( ) ) ; MissionProgramTemplate templateAgain = ( MissionProgramTemplate ) XmlUtils . fromXML ( templateCap . getValue ( ) , MissionProgramTemplate . class ) ; assertThat ( templateAgain . getSource ( ) , is ( "Source" ) ) ; templateAgain . setSource ( "DifferentSource" ) ; m_SUT . loadMissionTemplate ( templateAgain ) ; verify ( m_PersistentDataStore , times ( 2 ) ) . persist ( eq ( TemplateProgramManagerImpl . class ) , Mockito . any ( UUID . class ) , eq ( "MyTemplate" ) , templateCap . capture ( ) ) ; template = ( MissionProgramTemplate ) XmlUtils . fromXML ( templateCap . getValue ( ) , MissionProgramTemplate . class ) ; assertThat ( template . getSource ( ) , is ( "DifferentSource" ) ) ; }
Test the loading of templates.
Test the loading of templates .
//template to add //verify //change source, but not name //try adding the template again //verify //verify that template was updated