mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/mp/TestTemplateProgramManagerImpl.java
private void mockTemplatesFromDir() throws IOException, UnmarshalException, URISyntaxException
    {           
        // variable metadata
        MissionVariableMetaData varMeta =  new MissionVariableMetaData().withName("asset").withType(
                MissionVariableTypesEnum.ASSET);
        MissionVariableMetaData varMeta1 =  new MissionVariableMetaData().withName("progs").
            withType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        MissionVariableMetaData varMeta2 =  new MissionVariableMetaData().withName("phys").withType(
            MissionVariableTypesEnum.PHYSICAL_LINK);
        MissionVariableMetaData varMeta4 =  new MissionVariableMetaData().withName("link").
            withType(MissionVariableTypesEnum.LINK_LAYER);
        MissionVariableMetaData varMeta5 =  new MissionVariableMetaData().withName("pros2").
            withType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        
        //mission templates
        MissionProgramTemplate template1 = new MissionProgramTemplate().withSource("SourceMcSporty").
            withVariableMetaData(varMeta, varMeta1, varMeta5).withName("template-from-dir1");
        
        MissionProgramTemplate template2 = new MissionProgramTemplate().withSource("LinkingLog").
            withName("template-from-dir2").withVariableMetaData(varMeta2, varMeta4);
        
        // return true so directory is scanned
        when(templateDirectory.exists()).thenReturn(true);
        
        //child files
        File childFile1 = mock(File.class);
        URL childUrl1 = new URL("file:asdfs1");
        when(childFile1.toURI()).thenReturn(childUrl1.toURI());
        
        File childFile2 = mock(File.class);
        URL childUrl2 = new URL("file:asdfs2");
        when(childFile2.toURI()).thenReturn(childUrl2.toURI());
        
        //directory behavior
        File[] children = new File[]{childFile1, childFile2};
        
        when(templateDirectory.listFiles()).thenReturn(children);
        when(m_UnmarshalService.getXmlObject(MissionProgramTemplate.class, childUrl1)).thenReturn(template1);
        when(m_UnmarshalService.getXmlObject(MissionProgramTemplate.class, childUrl2)).thenReturn(template2);
    }
/**
     * Mock templates that would be loaded from a directory.
     */
Mock templates that would be loaded from a directory.
Mock templates that would be loaded from a directory .
private void mockTemplatesFromDir() throws IOException, UnmarshalException, URISyntaxException
    {           
        MissionVariableMetaData varMeta =  new MissionVariableMetaData().withName("asset").withType(
                MissionVariableTypesEnum.ASSET);
        MissionVariableMetaData varMeta1 =  new MissionVariableMetaData().withName("progs").
            withType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        MissionVariableMetaData varMeta2 =  new MissionVariableMetaData().withName("phys").withType(
            MissionVariableTypesEnum.PHYSICAL_LINK);
        MissionVariableMetaData varMeta4 =  new MissionVariableMetaData().withName("link").
            withType(MissionVariableTypesEnum.LINK_LAYER);
        MissionVariableMetaData varMeta5 =  new MissionVariableMetaData().withName("pros2").
            withType(MissionVariableTypesEnum.PROGRAM_DEPENDENCIES);
        MissionProgramTemplate template1 = new MissionProgramTemplate().withSource("SourceMcSporty").
            withVariableMetaData(varMeta, varMeta1, varMeta5).withName("template-from-dir1");
        MissionProgramTemplate template2 = new MissionProgramTemplate().withSource("LinkingLog").
            withName("template-from-dir2").withVariableMetaData(varMeta2, varMeta4);
        when(templateDirectory.exists()).thenReturn(true);
        File childFile1 = mock(File.class);
        URL childUrl1 = new URL("file:asdfs1");
        when(childFile1.toURI()).thenReturn(childUrl1.toURI());
        File childFile2 = mock(File.class);
        URL childUrl2 = new URL("file:asdfs2");
        when(childFile2.toURI()).thenReturn(childUrl2.toURI());
        File[] children = new File[]{childFile1, childFile2};
        when(templateDirectory.listFiles()).thenReturn(children);
        when(m_UnmarshalService.getXmlObject(MissionProgramTemplate.class, childUrl1)).thenReturn(template1);
        when(m_UnmarshalService.getXmlObject(MissionProgramTemplate.class, childUrl2)).thenReturn(template2);
    }
private void mockTemplatesFromDir ( ) throws IOException , UnmarshalException , URISyntaxException { MissionVariableMetaData varMeta = new MissionVariableMetaData ( ) . withName ( "asset" ) . withType ( MissionVariableTypesEnum . ASSET ) ; MissionVariableMetaData varMeta1 = new MissionVariableMetaData ( ) . withName ( "progs" ) . withType ( MissionVariableTypesEnum . PROGRAM_DEPENDENCIES ) ; MissionVariableMetaData varMeta2 = new MissionVariableMetaData ( ) . withName ( "phys" ) . withType ( MissionVariableTypesEnum . PHYSICAL_LINK ) ; MissionVariableMetaData varMeta4 = new MissionVariableMetaData ( ) . withName ( "link" ) . withType ( MissionVariableTypesEnum . LINK_LAYER ) ; MissionVariableMetaData varMeta5 = new MissionVariableMetaData ( ) . withName ( "pros2" ) . withType ( MissionVariableTypesEnum . PROGRAM_DEPENDENCIES ) ; MissionProgramTemplate template1 = new MissionProgramTemplate ( ) . withSource ( "SourceMcSporty" ) . withVariableMetaData ( varMeta , varMeta1 , varMeta5 ) . withName ( "template-from-dir1" ) ; MissionProgramTemplate template2 = new MissionProgramTemplate ( ) . withSource ( "LinkingLog" ) . withName ( "template-from-dir2" ) . withVariableMetaData ( varMeta2 , varMeta4 ) ; when ( templateDirectory . exists ( ) ) . thenReturn ( true ) ; File childFile1 = mock ( File . class ) ; URL childUrl1 = new URL ( "file:asdfs1" ) ; when ( childFile1 . toURI ( ) ) . thenReturn ( childUrl1 . toURI ( ) ) ; File childFile2 = mock ( File . class ) ; URL childUrl2 = new URL ( "file:asdfs2" ) ; when ( childFile2 . toURI ( ) ) . thenReturn ( childUrl2 . toURI ( ) ) ; File [ ] children = new File [ ] { childFile1 , childFile2 } ; when ( templateDirectory . listFiles ( ) ) . thenReturn ( children ) ; when ( m_UnmarshalService . getXmlObject ( MissionProgramTemplate . class , childUrl1 ) ) . thenReturn ( template1 ) ; when ( m_UnmarshalService . getXmlObject ( MissionProgramTemplate . class , childUrl2 ) ) . thenReturn ( template2 ) ; }
Mock templates that would be loaded from a directory.
Mock templates that would be loaded from a directory .
// variable metadata //mission templates // return true so directory is scanned //child files //directory behavior