mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestMissionProgramManagerImpl.java
private void mockMissionProgramPersistentData()
    {
        //mock the persistent data store for mission programs
        List<PersistentData> missionPrograms = new ArrayList<PersistentData>();
        //these are used by all templates
        Map<String, Object> executeArgs = new HashMap<String, Object>();
        executeArgs.put("argA", 88);
        executeArgs.put("argB", "arg-b-value");
        
        //schedule that all the missions use
        MissionProgramSchedule schedule1 = new MissionProgramSchedule().withIndefiniteInterval(false).
            withImmediately(true).withAtReset(true).withActive(true);
        //schedule for mission that does not run after restart
        MissionProgramSchedule schedule2 = new MissionProgramSchedule().withIndefiniteInterval(false).
                withImmediately(true).withAtReset(false).withActive(true);
        
        //create params individually for each template, note that although these values are the same
        //in an actual program they need not be, the key is the name of the variable, the value is the 
        //is the variables value, ie I might have a variable named asset, but with a value of ExampleAsset.
        Map<String, Object> paramArgs = new HashMap<String, Object>();
        paramArgs.putAll(executeArgs);
        paramArgs.put("assetX", "assetX");
        paramArgs.put("assetZ", "assetZ");
        paramArgs.put("tl7", "tl7");
        paramArgs.put("saved-program5", "saved-program5");
        MissionProgramParameters params1 = new MissionProgramParameters().withSchedule(schedule1).
            withProgramName("saved-program1").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program1");
        
        paramArgs.clear();
        paramArgs.putAll(executeArgs);
        paramArgs.put("pl5", "pl5");
        paramArgs.put("iso0", "iso0");
        paramArgs.put("iso1", "iso1");
        paramArgs.put("ll1", "ll1");
        MissionProgramParameters params2 = new MissionProgramParameters().withSchedule(schedule1).
            withProgramName("saved-program2").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program2");
        
        paramArgs.clear();
        paramArgs.putAll(executeArgs);
        paramArgs.put("asset3", "asset3");
        MissionProgramParameters params3 = new MissionProgramParameters().withSchedule(schedule1).
            withProgramName("saved-program3").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program3");
        
        paramArgs.clear();
        paramArgs.putAll(executeArgs);
        paramArgs.put("bogus-program", "bogus-program");
        MissionProgramParameters params4 = new MissionProgramParameters().withSchedule(schedule1).
            withProgramName("saved-program4").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program4");
        
        paramArgs.clear();
        paramArgs.putAll(executeArgs);
        paramArgs.put("saved-program3", "saved-program3");
        MissionProgramParameters params5 = new MissionProgramParameters().withSchedule(schedule1).
            withProgramName("saved-program5").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program5");
        
        paramArgs.clear();
        paramArgs.putAll(executeArgs);
        paramArgs.put("saved-program3", "saved-program3");
        MissionProgramParameters params6 = new MissionProgramParameters().withSchedule(schedule2).
            withProgramName("saved-program6").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program6");
        
        //mock the schedule and parameter values
        PersistentData dataParam1 = mock(PersistentData.class);
        PersistentData dataParam2 = mock(PersistentData.class);
        PersistentData dataParam3 = mock(PersistentData.class);
        PersistentData dataParam4 = mock(PersistentData.class);
        PersistentData dataParam5 = mock(PersistentData.class);
        PersistentData dataParam6 = mock(PersistentData.class);
        
        //mock response from data store when iterating over query results        
        when((byte[])dataParam1.getEntity()).thenReturn(XmlUtils.toXML(params1, true));
        when((byte[])dataParam2.getEntity()).thenReturn(XmlUtils.toXML(params2, true));
        when((byte[])dataParam3.getEntity()).thenReturn(XmlUtils.toXML(params3, true));
        when((byte[])dataParam4.getEntity()).thenReturn(XmlUtils.toXML(params4, true));
        when((byte[])dataParam5.getEntity()).thenReturn(XmlUtils.toXML(params5, true));
        when((byte[])dataParam6.getEntity()).thenReturn(XmlUtils.toXML(params6, true));
        
        //Add the mocked PersistantData to the list
        missionPrograms.add(dataParam1);
        missionPrograms.add(dataParam2);
        missionPrograms.add(dataParam3);
        missionPrograms.add(dataParam4);
        missionPrograms.add(dataParam5);
        missionPrograms.add(dataParam6);
        
        
        //mocked response when data store is queried 
        doReturn(missionPrograms).when(m_PersistentDataStore).query(MissionProgramManagerImpl.class);        
        
        //mock responses for get UUID
        when(dataParam1.getDescription()).thenReturn("saved-program1");
        when(dataParam2.getDescription()).thenReturn("saved-program2");
        when(dataParam3.getDescription()).thenReturn("saved-program3");
        when(dataParam4.getDescription()).thenReturn("saved-program4");
        when(dataParam5.getDescription()).thenReturn("saved-program5");
        when(dataParam6.getDescription()).thenReturn("saved-program6");
    }
/*
     * Mission parameters that join with mission templates to create mission programs. 
     */
Mission parameters that join with mission templates to create mission programs.
Mission parameters that join with mission templates to create mission programs .
private void mockMissionProgramPersistentData()
    {
        List<PersistentData> missionPrograms = new ArrayList<PersistentData>();
        Map<String, Object> executeArgs = new HashMap<String, Object>();
        executeArgs.put("argA", 88);
        executeArgs.put("argB", "arg-b-value");
        MissionProgramSchedule schedule1 = new MissionProgramSchedule().withIndefiniteInterval(false).
            withImmediately(true).withAtReset(true).withActive(true);
        MissionProgramSchedule schedule2 = new MissionProgramSchedule().withIndefiniteInterval(false).
                withImmediately(true).withAtReset(false).withActive(true);
        Map<String, Object> paramArgs = new HashMap<String, Object>();
        paramArgs.putAll(executeArgs);
        paramArgs.put("assetX", "assetX");
        paramArgs.put("assetZ", "assetZ");
        paramArgs.put("tl7", "tl7");
        paramArgs.put("saved-program5", "saved-program5");
        MissionProgramParameters params1 = new MissionProgramParameters().withSchedule(schedule1).
            withProgramName("saved-program1").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program1");
        paramArgs.clear();
        paramArgs.putAll(executeArgs);
        paramArgs.put("pl5", "pl5");
        paramArgs.put("iso0", "iso0");
        paramArgs.put("iso1", "iso1");
        paramArgs.put("ll1", "ll1");
        MissionProgramParameters params2 = new MissionProgramParameters().withSchedule(schedule1).
            withProgramName("saved-program2").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program2");
        paramArgs.clear();
        paramArgs.putAll(executeArgs);
        paramArgs.put("asset3", "asset3");
        MissionProgramParameters params3 = new MissionProgramParameters().withSchedule(schedule1).
            withProgramName("saved-program3").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program3");
        paramArgs.clear();
        paramArgs.putAll(executeArgs);
        paramArgs.put("bogus-program", "bogus-program");
        MissionProgramParameters params4 = new MissionProgramParameters().withSchedule(schedule1).
            withProgramName("saved-program4").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program4");
        paramArgs.clear();
        paramArgs.putAll(executeArgs);
        paramArgs.put("saved-program3", "saved-program3");
        MissionProgramParameters params5 = new MissionProgramParameters().withSchedule(schedule1).
            withProgramName("saved-program5").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program5");
        paramArgs.clear();
        paramArgs.putAll(executeArgs);
        paramArgs.put("saved-program3", "saved-program3");
        MissionProgramParameters params6 = new MissionProgramParameters().withSchedule(schedule2).
            withProgramName("saved-program6").withParameters(MapTranslator.translateMap(paramArgs)).
                withTemplateName("saved-program6");
        PersistentData dataParam1 = mock(PersistentData.class);
        PersistentData dataParam2 = mock(PersistentData.class);
        PersistentData dataParam3 = mock(PersistentData.class);
        PersistentData dataParam4 = mock(PersistentData.class);
        PersistentData dataParam5 = mock(PersistentData.class);
        PersistentData dataParam6 = mock(PersistentData.class);
        when((byte[])dataParam1.getEntity()).thenReturn(XmlUtils.toXML(params1, true));
        when((byte[])dataParam2.getEntity()).thenReturn(XmlUtils.toXML(params2, true));
        when((byte[])dataParam3.getEntity()).thenReturn(XmlUtils.toXML(params3, true));
        when((byte[])dataParam4.getEntity()).thenReturn(XmlUtils.toXML(params4, true));
        when((byte[])dataParam5.getEntity()).thenReturn(XmlUtils.toXML(params5, true));
        when((byte[])dataParam6.getEntity()).thenReturn(XmlUtils.toXML(params6, true));
        missionPrograms.add(dataParam1);
        missionPrograms.add(dataParam2);
        missionPrograms.add(dataParam3);
        missionPrograms.add(dataParam4);
        missionPrograms.add(dataParam5);
        missionPrograms.add(dataParam6);
        doReturn(missionPrograms).when(m_PersistentDataStore).query(MissionProgramManagerImpl.class);        
        when(dataParam1.getDescription()).thenReturn("saved-program1");
        when(dataParam2.getDescription()).thenReturn("saved-program2");
        when(dataParam3.getDescription()).thenReturn("saved-program3");
        when(dataParam4.getDescription()).thenReturn("saved-program4");
        when(dataParam5.getDescription()).thenReturn("saved-program5");
        when(dataParam6.getDescription()).thenReturn("saved-program6");
    }
private void mockMissionProgramPersistentData ( ) { List < PersistentData > missionPrograms = new ArrayList < PersistentData > ( ) ; Map < String , Object > executeArgs = new HashMap < String , Object > ( ) ; executeArgs . put ( "argA" , 88 ) ; executeArgs . put ( "argB" , "arg-b-value" ) ; MissionProgramSchedule schedule1 = new MissionProgramSchedule ( ) . withIndefiniteInterval ( false ) . withImmediately ( true ) . withAtReset ( true ) . withActive ( true ) ; MissionProgramSchedule schedule2 = new MissionProgramSchedule ( ) . withIndefiniteInterval ( false ) . withImmediately ( true ) . withAtReset ( false ) . withActive ( true ) ; Map < String , Object > paramArgs = new HashMap < String , Object > ( ) ; paramArgs . putAll ( executeArgs ) ; paramArgs . put ( "assetX" , "assetX" ) ; paramArgs . put ( "assetZ" , "assetZ" ) ; paramArgs . put ( "tl7" , "tl7" ) ; paramArgs . put ( "saved-program5" , "saved-program5" ) ; MissionProgramParameters params1 = new MissionProgramParameters ( ) . withSchedule ( schedule1 ) . withProgramName ( "saved-program1" ) . withParameters ( MapTranslator . translateMap ( paramArgs ) ) . withTemplateName ( "saved-program1" ) ; paramArgs . clear ( ) ; paramArgs . putAll ( executeArgs ) ; paramArgs . put ( "pl5" , "pl5" ) ; paramArgs . put ( "iso0" , "iso0" ) ; paramArgs . put ( "iso1" , "iso1" ) ; paramArgs . put ( "ll1" , "ll1" ) ; MissionProgramParameters params2 = new MissionProgramParameters ( ) . withSchedule ( schedule1 ) . withProgramName ( "saved-program2" ) . withParameters ( MapTranslator . translateMap ( paramArgs ) ) . withTemplateName ( "saved-program2" ) ; paramArgs . clear ( ) ; paramArgs . putAll ( executeArgs ) ; paramArgs . put ( "asset3" , "asset3" ) ; MissionProgramParameters params3 = new MissionProgramParameters ( ) . withSchedule ( schedule1 ) . withProgramName ( "saved-program3" ) . withParameters ( MapTranslator . translateMap ( paramArgs ) ) . withTemplateName ( "saved-program3" ) ; paramArgs . clear ( ) ; paramArgs . putAll ( executeArgs ) ; paramArgs . put ( "bogus-program" , "bogus-program" ) ; MissionProgramParameters params4 = new MissionProgramParameters ( ) . withSchedule ( schedule1 ) . withProgramName ( "saved-program4" ) . withParameters ( MapTranslator . translateMap ( paramArgs ) ) . withTemplateName ( "saved-program4" ) ; paramArgs . clear ( ) ; paramArgs . putAll ( executeArgs ) ; paramArgs . put ( "saved-program3" , "saved-program3" ) ; MissionProgramParameters params5 = new MissionProgramParameters ( ) . withSchedule ( schedule1 ) . withProgramName ( "saved-program5" ) . withParameters ( MapTranslator . translateMap ( paramArgs ) ) . withTemplateName ( "saved-program5" ) ; paramArgs . clear ( ) ; paramArgs . putAll ( executeArgs ) ; paramArgs . put ( "saved-program3" , "saved-program3" ) ; MissionProgramParameters params6 = new MissionProgramParameters ( ) . withSchedule ( schedule2 ) . withProgramName ( "saved-program6" ) . withParameters ( MapTranslator . translateMap ( paramArgs ) ) . withTemplateName ( "saved-program6" ) ; PersistentData dataParam1 = mock ( PersistentData . class ) ; PersistentData dataParam2 = mock ( PersistentData . class ) ; PersistentData dataParam3 = mock ( PersistentData . class ) ; PersistentData dataParam4 = mock ( PersistentData . class ) ; PersistentData dataParam5 = mock ( PersistentData . class ) ; PersistentData dataParam6 = mock ( PersistentData . class ) ; when ( ( byte [ ] ) dataParam1 . getEntity ( ) ) . thenReturn ( XmlUtils . toXML ( params1 , true ) ) ; when ( ( byte [ ] ) dataParam2 . getEntity ( ) ) . thenReturn ( XmlUtils . toXML ( params2 , true ) ) ; when ( ( byte [ ] ) dataParam3 . getEntity ( ) ) . thenReturn ( XmlUtils . toXML ( params3 , true ) ) ; when ( ( byte [ ] ) dataParam4 . getEntity ( ) ) . thenReturn ( XmlUtils . toXML ( params4 , true ) ) ; when ( ( byte [ ] ) dataParam5 . getEntity ( ) ) . thenReturn ( XmlUtils . toXML ( params5 , true ) ) ; when ( ( byte [ ] ) dataParam6 . getEntity ( ) ) . thenReturn ( XmlUtils . toXML ( params6 , true ) ) ; missionPrograms . add ( dataParam1 ) ; missionPrograms . add ( dataParam2 ) ; missionPrograms . add ( dataParam3 ) ; missionPrograms . add ( dataParam4 ) ; missionPrograms . add ( dataParam5 ) ; missionPrograms . add ( dataParam6 ) ; doReturn ( missionPrograms ) . when ( m_PersistentDataStore ) . query ( MissionProgramManagerImpl . class ) ; when ( dataParam1 . getDescription ( ) ) . thenReturn ( "saved-program1" ) ; when ( dataParam2 . getDescription ( ) ) . thenReturn ( "saved-program2" ) ; when ( dataParam3 . getDescription ( ) ) . thenReturn ( "saved-program3" ) ; when ( dataParam4 . getDescription ( ) ) . thenReturn ( "saved-program4" ) ; when ( dataParam5 . getDescription ( ) ) . thenReturn ( "saved-program5" ) ; when ( dataParam6 . getDescription ( ) ) . thenReturn ( "saved-program6" ) ; }
Mission parameters that join with mission templates to create mission programs.
Mission parameters that join with mission templates to create mission programs .
//mock the persistent data store for mission programs //these are used by all templates //schedule that all the missions use //schedule for mission that does not run after restart //create params individually for each template, note that although these values are the same //in an actual program they need not be, the key is the name of the variable, the value is the  //is the variables value, ie I might have a variable named asset, but with a value of ExampleAsset. //mock the schedule and parameter values //mock response from data store when iterating over query results         //Add the mocked PersistantData to the list //mocked response when data store is queried  //mock responses for get UUID