mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramManagerImpl.java
@Test
    public void testPersistPrograms() 
        throws IllegalArgumentException, PersistenceFailedException, MissionProgramException
    {   
        mockMissionProgramPersistentData();
        mockTemplates();
        // mock
        setScriptEngineAndActivate();
        
        //program to add
        Map<String, Object> arguments = new HashMap<String, Object>();
        arguments.put("arg1", "test-value");
        arguments.put("arg2", 5);
        MissionProgramTemplate program = new MissionProgramTemplate().withName("test").withSource("something");
        MissionProgramSchedule schedule = new MissionProgramSchedule().withImmediately(false).
            withIndefiniteInterval(false);
        MissionProgramParameters params = new MissionProgramParameters().withTemplateName("test").
            withParameters(MapTranslator.translateMap(arguments)).withSchedule(schedule).withProgramName("asdf");
        
        //mocking
        Set<String> templateNames = new HashSet<String>();
        templateNames.add("test");
        when(m_TemplateManager.getMissionTemplateNames()).thenReturn(templateNames);
        doReturn(program).when(m_TemplateManager).getTemplate("test");
        //load params and schedule
        m_SUT.loadParameters(params);
        
        // verify
        ArgumentCaptor<byte[]> serCaptor = ArgumentCaptor.forClass(byte[].class);
        ArgumentCaptor<UUID> uuid = ArgumentCaptor.forClass(UUID.class);        
        verify(m_PersistentDataStore).persist(eq(MissionProgramManagerImpl.class), uuid.capture(), eq("test"), 
                serCaptor.capture());
        assertThat(XmlUtils.fromXML(serCaptor.getValue(), MissionProgramParameters.class), 
                is(instanceOf(MissionProgramParameters.class))); 
    }
/**
     * Verify persisted programs are loaded.
     */
Verify persisted programs are loaded.
Verify persisted programs are loaded .
@Test
    public void testPersistPrograms() 
        throws IllegalArgumentException, PersistenceFailedException, MissionProgramException
    {   
        mockMissionProgramPersistentData();
        mockTemplates();
        setScriptEngineAndActivate();
        Map<String, Object> arguments = new HashMap<String, Object>();
        arguments.put("arg1", "test-value");
        arguments.put("arg2", 5);
        MissionProgramTemplate program = new MissionProgramTemplate().withName("test").withSource("something");
        MissionProgramSchedule schedule = new MissionProgramSchedule().withImmediately(false).
            withIndefiniteInterval(false);
        MissionProgramParameters params = new MissionProgramParameters().withTemplateName("test").
            withParameters(MapTranslator.translateMap(arguments)).withSchedule(schedule).withProgramName("asdf");
        Set<String> templateNames = new HashSet<String>();
        templateNames.add("test");
        when(m_TemplateManager.getMissionTemplateNames()).thenReturn(templateNames);
        doReturn(program).when(m_TemplateManager).getTemplate("test");
        m_SUT.loadParameters(params);
        ArgumentCaptor<byte[]> serCaptor = ArgumentCaptor.forClass(byte[].class);
        ArgumentCaptor<UUID> uuid = ArgumentCaptor.forClass(UUID.class);        
        verify(m_PersistentDataStore).persist(eq(MissionProgramManagerImpl.class), uuid.capture(), eq("test"), 
                serCaptor.capture());
        assertThat(XmlUtils.fromXML(serCaptor.getValue(), MissionProgramParameters.class), 
                is(instanceOf(MissionProgramParameters.class))); 
    }
@ Test public void testPersistPrograms ( ) throws IllegalArgumentException , PersistenceFailedException , MissionProgramException { mockMissionProgramPersistentData ( ) ; mockTemplates ( ) ; setScriptEngineAndActivate ( ) ; Map < String , Object > arguments = new HashMap < String , Object > ( ) ; arguments . put ( "arg1" , "test-value" ) ; arguments . put ( "arg2" , 5 ) ; MissionProgramTemplate program = new MissionProgramTemplate ( ) . withName ( "test" ) . withSource ( "something" ) ; MissionProgramSchedule schedule = new MissionProgramSchedule ( ) . withImmediately ( false ) . withIndefiniteInterval ( false ) ; MissionProgramParameters params = new MissionProgramParameters ( ) . withTemplateName ( "test" ) . withParameters ( MapTranslator . translateMap ( arguments ) ) . withSchedule ( schedule ) . withProgramName ( "asdf" ) ; Set < String > templateNames = new HashSet < String > ( ) ; templateNames . add ( "test" ) ; when ( m_TemplateManager . getMissionTemplateNames ( ) ) . thenReturn ( templateNames ) ; doReturn ( program ) . when ( m_TemplateManager ) . getTemplate ( "test" ) ; m_SUT . loadParameters ( params ) ; ArgumentCaptor < byte [ ] > serCaptor = ArgumentCaptor . forClass ( byte [ ] . class ) ; ArgumentCaptor < UUID > uuid = ArgumentCaptor . forClass ( UUID . class ) ; verify ( m_PersistentDataStore ) . persist ( eq ( MissionProgramManagerImpl . class ) , uuid . capture ( ) , eq ( "test" ) , serCaptor . capture ( ) ) ; assertThat ( XmlUtils . fromXML ( serCaptor . getValue ( ) , MissionProgramParameters . class ) , is ( instanceOf ( MissionProgramParameters . class ) ) ) ; }
Verify persisted programs are loaded.
Verify persisted programs are loaded .
// mock //program to add //mocking //load params and schedule // verify