mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestTemplateProgramManagerImpl.java
private void mockTemplateProgramManagerTemplates()
    {
        // variable metadata
        MissionVariableMetaData varMeta =  new MissionVariableMetaData().withName("assetX").withType(
                MissionVariableTypesEnum.ASSET);
        MissionVariableMetaData varMeta2 =  new MissionVariableMetaData().withName("assetZ").withType(
                MissionVariableTypesEnum.ASSET);
        MissionVariableMetaData varMeta3 =  new MissionVariableMetaData().withName("tl7").withType(
                    MissionVariableTypesEnum.TRANSPORT_LAYER);
        MissionVariableMetaData varMeta5 =  new MissionVariableMetaData().withName("saved-program5").
            withType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        MissionVariableMetaData varMeta6 =  new MissionVariableMetaData().withName("pl5").withType(
                    MissionVariableTypesEnum.PHYSICAL_LINK);
        MissionVariableMetaData varMeta9 =  new MissionVariableMetaData().withName("asset3").withType(
                MissionVariableTypesEnum.ASSET);
        MissionVariableMetaData varMeta10 =  new MissionVariableMetaData().withName("bogus-program").
            withType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        MissionVariableMetaData varMeta11 =  new MissionVariableMetaData().withName("ll1").
            withType(MissionVariableTypesEnum.LINK_LAYER);
        MissionVariableMetaData varMeta12 =  new MissionVariableMetaData().withName("saved-program3").
            withType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        
        //mission templates
        MissionProgramTemplate programData1 = new MissionProgramTemplate().withSource("test").
            withVariableMetaData(varMeta, varMeta2, varMeta3, varMeta5 ).withName("saved-program1");
           
        MissionProgramTemplate programData2 = new MissionProgramTemplate().withSource("blah").
            withName("saved-program2").withVariableMetaData(varMeta6, varMeta11);
        
        MissionProgramTemplate programData3 = new MissionProgramTemplate().withSource("something").
            withName("saved-program3").withVariableMetaData(varMeta9);
        
        MissionProgramTemplate programData4 = new MissionProgramTemplate().withSource("blahblah").
            withName("saved-program4").withVariableMetaData(varMeta10);
        
        MissionProgramTemplate programData5 = new MissionProgramTemplate().withSource("huh").
            withName("saved-program5").withVariableMetaData(varMeta12);
        
        //mock the template data
        List<PersistentData> perData = new ArrayList<PersistentData>(); 
        PersistentData dataTemplate1 = mock(PersistentData.class);
        PersistentData dataTemplate2 = mock(PersistentData.class);
        PersistentData dataTemplate3 = mock(PersistentData.class);
        PersistentData dataTemplate4 = mock(PersistentData.class);
        PersistentData dataTemplate5 = mock(PersistentData.class);
                
        when(dataTemplate1.getDescription()).thenReturn("saved-program1");
        when(dataTemplate2.getDescription()).thenReturn("saved-program2");
        when(dataTemplate3.getDescription()).thenReturn("saved-program3");
        when(dataTemplate4.getDescription()).thenReturn("saved-program4");
        when(dataTemplate5.getDescription()).thenReturn("saved-program5");
        
        when((byte[])dataTemplate1.getEntity()).thenReturn(XmlUtils.toXML(programData1, true));
        when((byte[])dataTemplate2.getEntity()).thenReturn(XmlUtils.toXML(programData2, true));
        when((byte[])dataTemplate3.getEntity()).thenReturn(XmlUtils.toXML(programData3, true));
        when((byte[])dataTemplate4.getEntity()).thenReturn(XmlUtils.toXML(programData4, true));
        when((byte[])dataTemplate5.getEntity()).thenReturn(XmlUtils.toXML(programData5, true));
        
        UUID uuid1 = UUID.randomUUID();
        UUID uuid2 = UUID.randomUUID();
        UUID uuid3 = UUID.randomUUID();
        UUID uuid4 = UUID.randomUUID();
        UUID uuid5 = UUID.randomUUID();
        
        when(dataTemplate1.getUUID()).thenReturn(uuid1);
        when(dataTemplate2.getUUID()).thenReturn(uuid2);
        when(dataTemplate3.getUUID()).thenReturn(uuid3);
        when(dataTemplate4.getUUID()).thenReturn(uuid4);
        when(dataTemplate5.getUUID()).thenReturn(uuid5);
        
        perData.add(dataTemplate1);
        perData.add(dataTemplate2);
        perData.add(dataTemplate3);
        perData.add(dataTemplate4);
        perData.add(dataTemplate5);
        
        //mocked response when data store is queried 
        doReturn(perData).when(m_PersistentDataStore).query(TemplateProgramManagerImpl.class);
        when(m_PersistentDataStore.find(uuid1)).thenReturn(dataTemplate1);
        when(m_PersistentDataStore.find(uuid2)).thenReturn(dataTemplate2);
        when(m_PersistentDataStore.find(uuid3)).thenReturn(dataTemplate3);
        when(m_PersistentDataStore.find(uuid4)).thenReturn(dataTemplate4);
        when(m_PersistentDataStore.find(uuid5)).thenReturn(dataTemplate5);
    }
/*
     * Mock templates that are in the {@link PersistentDataStore}.
     */
Mock templates that are in the  PersistentDataStore.
Mock templates that are in the PersistentDataStore .
private void mockTemplateProgramManagerTemplates()
    {
        MissionVariableMetaData varMeta =  new MissionVariableMetaData().withName("assetX").withType(
                MissionVariableTypesEnum.ASSET);
        MissionVariableMetaData varMeta2 =  new MissionVariableMetaData().withName("assetZ").withType(
                MissionVariableTypesEnum.ASSET);
        MissionVariableMetaData varMeta3 =  new MissionVariableMetaData().withName("tl7").withType(
                    MissionVariableTypesEnum.TRANSPORT_LAYER);
        MissionVariableMetaData varMeta5 =  new MissionVariableMetaData().withName("saved-program5").
            withType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        MissionVariableMetaData varMeta6 =  new MissionVariableMetaData().withName("pl5").withType(
                    MissionVariableTypesEnum.PHYSICAL_LINK);
        MissionVariableMetaData varMeta9 =  new MissionVariableMetaData().withName("asset3").withType(
                MissionVariableTypesEnum.ASSET);
        MissionVariableMetaData varMeta10 =  new MissionVariableMetaData().withName("bogus-program").
            withType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        MissionVariableMetaData varMeta11 =  new MissionVariableMetaData().withName("ll1").
            withType(MissionVariableTypesEnum.LINK_LAYER);
        MissionVariableMetaData varMeta12 =  new MissionVariableMetaData().withName("saved-program3").
            withType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        MissionProgramTemplate programData1 = new MissionProgramTemplate().withSource("test").
            withVariableMetaData(varMeta, varMeta2, varMeta3, varMeta5 ).withName("saved-program1");
        MissionProgramTemplate programData2 = new MissionProgramTemplate().withSource("blah").
            withName("saved-program2").withVariableMetaData(varMeta6, varMeta11);
        MissionProgramTemplate programData3 = new MissionProgramTemplate().withSource("something").
            withName("saved-program3").withVariableMetaData(varMeta9);
        MissionProgramTemplate programData4 = new MissionProgramTemplate().withSource("blahblah").
            withName("saved-program4").withVariableMetaData(varMeta10);
        MissionProgramTemplate programData5 = new MissionProgramTemplate().withSource("huh").
            withName("saved-program5").withVariableMetaData(varMeta12);
        List<PersistentData> perData = new ArrayList<PersistentData>(); 
        PersistentData dataTemplate1 = mock(PersistentData.class);
        PersistentData dataTemplate2 = mock(PersistentData.class);
        PersistentData dataTemplate3 = mock(PersistentData.class);
        PersistentData dataTemplate4 = mock(PersistentData.class);
        PersistentData dataTemplate5 = mock(PersistentData.class);
        when(dataTemplate1.getDescription()).thenReturn("saved-program1");
        when(dataTemplate2.getDescription()).thenReturn("saved-program2");
        when(dataTemplate3.getDescription()).thenReturn("saved-program3");
        when(dataTemplate4.getDescription()).thenReturn("saved-program4");
        when(dataTemplate5.getDescription()).thenReturn("saved-program5");
        when((byte[])dataTemplate1.getEntity()).thenReturn(XmlUtils.toXML(programData1, true));
        when((byte[])dataTemplate2.getEntity()).thenReturn(XmlUtils.toXML(programData2, true));
        when((byte[])dataTemplate3.getEntity()).thenReturn(XmlUtils.toXML(programData3, true));
        when((byte[])dataTemplate4.getEntity()).thenReturn(XmlUtils.toXML(programData4, true));
        when((byte[])dataTemplate5.getEntity()).thenReturn(XmlUtils.toXML(programData5, true));
        UUID uuid1 = UUID.randomUUID();
        UUID uuid2 = UUID.randomUUID();
        UUID uuid3 = UUID.randomUUID();
        UUID uuid4 = UUID.randomUUID();
        UUID uuid5 = UUID.randomUUID();
        when(dataTemplate1.getUUID()).thenReturn(uuid1);
        when(dataTemplate2.getUUID()).thenReturn(uuid2);
        when(dataTemplate3.getUUID()).thenReturn(uuid3);
        when(dataTemplate4.getUUID()).thenReturn(uuid4);
        when(dataTemplate5.getUUID()).thenReturn(uuid5);
        perData.add(dataTemplate1);
        perData.add(dataTemplate2);
        perData.add(dataTemplate3);
        perData.add(dataTemplate4);
        perData.add(dataTemplate5);
        doReturn(perData).when(m_PersistentDataStore).query(TemplateProgramManagerImpl.class);
        when(m_PersistentDataStore.find(uuid1)).thenReturn(dataTemplate1);
        when(m_PersistentDataStore.find(uuid2)).thenReturn(dataTemplate2);
        when(m_PersistentDataStore.find(uuid3)).thenReturn(dataTemplate3);
        when(m_PersistentDataStore.find(uuid4)).thenReturn(dataTemplate4);
        when(m_PersistentDataStore.find(uuid5)).thenReturn(dataTemplate5);
    }
private void mockTemplateProgramManagerTemplates ( ) { MissionVariableMetaData varMeta = new MissionVariableMetaData ( ) . withName ( "assetX" ) . withType ( MissionVariableTypesEnum . ASSET ) ; MissionVariableMetaData varMeta2 = new MissionVariableMetaData ( ) . withName ( "assetZ" ) . withType ( MissionVariableTypesEnum . ASSET ) ; MissionVariableMetaData varMeta3 = new MissionVariableMetaData ( ) . withName ( "tl7" ) . withType ( MissionVariableTypesEnum . TRANSPORT_LAYER ) ; MissionVariableMetaData varMeta5 = new MissionVariableMetaData ( ) . withName ( "saved-program5" ) . withType ( MissionVariableTypesEnum . PROGRAM_DEPENDENCIES ) ; MissionVariableMetaData varMeta6 = new MissionVariableMetaData ( ) . withName ( "pl5" ) . withType ( MissionVariableTypesEnum . PHYSICAL_LINK ) ; MissionVariableMetaData varMeta9 = new MissionVariableMetaData ( ) . withName ( "asset3" ) . withType ( MissionVariableTypesEnum . ASSET ) ; MissionVariableMetaData varMeta10 = new MissionVariableMetaData ( ) . withName ( "bogus-program" ) . withType ( MissionVariableTypesEnum . PROGRAM_DEPENDENCIES ) ; MissionVariableMetaData varMeta11 = new MissionVariableMetaData ( ) . withName ( "ll1" ) . withType ( MissionVariableTypesEnum . LINK_LAYER ) ; MissionVariableMetaData varMeta12 = new MissionVariableMetaData ( ) . withName ( "saved-program3" ) . withType ( MissionVariableTypesEnum . PROGRAM_DEPENDENCIES ) ; MissionProgramTemplate programData1 = new MissionProgramTemplate ( ) . withSource ( "test" ) . withVariableMetaData ( varMeta , varMeta2 , varMeta3 , varMeta5 ) . withName ( "saved-program1" ) ; MissionProgramTemplate programData2 = new MissionProgramTemplate ( ) . withSource ( "blah" ) . withName ( "saved-program2" ) . withVariableMetaData ( varMeta6 , varMeta11 ) ; MissionProgramTemplate programData3 = new MissionProgramTemplate ( ) . withSource ( "something" ) . withName ( "saved-program3" ) . withVariableMetaData ( varMeta9 ) ; MissionProgramTemplate programData4 = new MissionProgramTemplate ( ) . withSource ( "blahblah" ) . withName ( "saved-program4" ) . withVariableMetaData ( varMeta10 ) ; MissionProgramTemplate programData5 = new MissionProgramTemplate ( ) . withSource ( "huh" ) . withName ( "saved-program5" ) . withVariableMetaData ( varMeta12 ) ; List < PersistentData > perData = new ArrayList < PersistentData > ( ) ; PersistentData dataTemplate1 = mock ( PersistentData . class ) ; PersistentData dataTemplate2 = mock ( PersistentData . class ) ; PersistentData dataTemplate3 = mock ( PersistentData . class ) ; PersistentData dataTemplate4 = mock ( PersistentData . class ) ; PersistentData dataTemplate5 = mock ( PersistentData . class ) ; when ( dataTemplate1 . getDescription ( ) ) . thenReturn ( "saved-program1" ) ; when ( dataTemplate2 . getDescription ( ) ) . thenReturn ( "saved-program2" ) ; when ( dataTemplate3 . getDescription ( ) ) . thenReturn ( "saved-program3" ) ; when ( dataTemplate4 . getDescription ( ) ) . thenReturn ( "saved-program4" ) ; when ( dataTemplate5 . getDescription ( ) ) . thenReturn ( "saved-program5" ) ; when ( ( byte [ ] ) dataTemplate1 . getEntity ( ) ) . thenReturn ( XmlUtils . toXML ( programData1 , true ) ) ; when ( ( byte [ ] ) dataTemplate2 . getEntity ( ) ) . thenReturn ( XmlUtils . toXML ( programData2 , true ) ) ; when ( ( byte [ ] ) dataTemplate3 . getEntity ( ) ) . thenReturn ( XmlUtils . toXML ( programData3 , true ) ) ; when ( ( byte [ ] ) dataTemplate4 . getEntity ( ) ) . thenReturn ( XmlUtils . toXML ( programData4 , true ) ) ; when ( ( byte [ ] ) dataTemplate5 . getEntity ( ) ) . thenReturn ( XmlUtils . toXML ( programData5 , true ) ) ; UUID uuid1 = UUID . randomUUID ( ) ; UUID uuid2 = UUID . randomUUID ( ) ; UUID uuid3 = UUID . randomUUID ( ) ; UUID uuid4 = UUID . randomUUID ( ) ; UUID uuid5 = UUID . randomUUID ( ) ; when ( dataTemplate1 . getUUID ( ) ) . thenReturn ( uuid1 ) ; when ( dataTemplate2 . getUUID ( ) ) . thenReturn ( uuid2 ) ; when ( dataTemplate3 . getUUID ( ) ) . thenReturn ( uuid3 ) ; when ( dataTemplate4 . getUUID ( ) ) . thenReturn ( uuid4 ) ; when ( dataTemplate5 . getUUID ( ) ) . thenReturn ( uuid5 ) ; perData . add ( dataTemplate1 ) ; perData . add ( dataTemplate2 ) ; perData . add ( dataTemplate3 ) ; perData . add ( dataTemplate4 ) ; perData . add ( dataTemplate5 ) ; doReturn ( perData ) . when ( m_PersistentDataStore ) . query ( TemplateProgramManagerImpl . class ) ; when ( m_PersistentDataStore . find ( uuid1 ) ) . thenReturn ( dataTemplate1 ) ; when ( m_PersistentDataStore . find ( uuid2 ) ) . thenReturn ( dataTemplate2 ) ; when ( m_PersistentDataStore . find ( uuid3 ) ) . thenReturn ( dataTemplate3 ) ; when ( m_PersistentDataStore . find ( uuid4 ) ) . thenReturn ( dataTemplate4 ) ; when ( m_PersistentDataStore . find ( uuid5 ) ) . thenReturn ( dataTemplate5 ) ; }
Mock templates that are in the {@link PersistentDataStore}.
Mock templates that are in the { @link PersistentDataStore } .
// variable metadata //mission templates //mock the template data //mocked response when data store is queried 