mil.dod.th.ose.core/test/mil/dod/th/ose/core/factory/api/TestFactoryRegistry.java
@Test
    public void testRetrieveDeps()
    {
        UUID uuid = UUID.randomUUID();

        RegistryDependency foundDep1 = new RegistryDependency("dep1", true)
        {
            @Override
            public Object findDependency(String objectName)
            {
                //return something other than null
                return "And Jelly";
            }
        };
        RegistryDependency foundDep2 = new RegistryDependency("dep2", true)
        {
            @Override
            public Object findDependency(String objectName)
            {
                //return something other than null
                return "And Jelly";
            }
        };
        RegistryDependency missingDep1 = new RegistryDependency("dep1", true)
        {
            @Override
            public Object findDependency(String objectName)
            {
                return null;
            }
        };
        RegistryDependency missingDep2 = new RegistryDependency("dep2", true)
        {
            @Override
            public Object findDependency(String objectName)
            {
                return null;
            }
        };

        // have call back always say dep is missing
        when(m_Callback.retrieveRegistryDependencies()).thenReturn(Lists.newArrayList(missingDep1, missingDep2));
        m_SUT.initialize(m_FactoryService, m_ServiceProxy, m_Callback);

        final Dictionary<String, Object> props = new Hashtable<>();

        // should be unknown because one prop is missing, the other empty (both should be ignored)
        props.put("dep1", "");
        assertThat(m_SUT.isSatisfied(uuid, props), is(DependencyState.INVALID));

        // should be unknown or unsatisfied (based on which dep is checked first) because dep1 is empty, even though
        // dep2 is unsatisfied
        props.put("dep2", "some name");
        assertThat(m_SUT.isSatisfied(uuid, props), anyOf(is(DependencyState.UNSATISFIED), is(DependencyState.INVALID)));

        // now have call back have one missing, one available
        when(m_Callback.retrieveRegistryDependencies()).thenReturn(Lists.newArrayList(foundDep1, missingDep2));
        m_SUT.initialize(m_FactoryService, m_ServiceProxy, m_Callback);

        //set both deps, 1 is missing
        props.put("dep1", "some name");
        assertThat(m_SUT.isSatisfied(uuid, props), is(DependencyState.UNSATISFIED));

        // now have call back always say dep is there
        when(m_Callback.retrieveRegistryDependencies()).thenReturn(Lists.newArrayList(foundDep1, foundDep2));
        m_SUT.initialize(m_FactoryService, m_ServiceProxy, m_Callback);

        //assert that the reg is now satisfied
        assertThat(m_SUT.isSatisfied(uuid, props), is(DependencyState.SATISFIED));
    }
/**
     * Verify that retrieve deps is called during construction.
     */
Verify that retrieve deps is called during construction.
Verify that retrieve deps is called during construction .
@Test
    public void testRetrieveDeps()
    {
        UUID uuid = UUID.randomUUID();
        RegistryDependency foundDep1 = new RegistryDependency("dep1", true)
        {
            @Override
            public Object findDependency(String objectName)
            {
                return "And Jelly";
            }
        };
        RegistryDependency foundDep2 = new RegistryDependency("dep2", true)
        {
            @Override
            public Object findDependency(String objectName)
            {
                return "And Jelly";
            }
        };
        RegistryDependency missingDep1 = new RegistryDependency("dep1", true)
        {
            @Override
            public Object findDependency(String objectName)
            {
                return null;
            }
        };
        RegistryDependency missingDep2 = new RegistryDependency("dep2", true)
        {
            @Override
            public Object findDependency(String objectName)
            {
                return null;
            }
        };
        when(m_Callback.retrieveRegistryDependencies()).thenReturn(Lists.newArrayList(missingDep1, missingDep2));
        m_SUT.initialize(m_FactoryService, m_ServiceProxy, m_Callback);
        final Dictionary<String, Object> props = new Hashtable<>();
        props.put("dep1", "");
        assertThat(m_SUT.isSatisfied(uuid, props), is(DependencyState.INVALID));
        props.put("dep2", "some name");
        assertThat(m_SUT.isSatisfied(uuid, props), anyOf(is(DependencyState.UNSATISFIED), is(DependencyState.INVALID)));
        when(m_Callback.retrieveRegistryDependencies()).thenReturn(Lists.newArrayList(foundDep1, missingDep2));
        m_SUT.initialize(m_FactoryService, m_ServiceProxy, m_Callback);
        props.put("dep1", "some name");
        assertThat(m_SUT.isSatisfied(uuid, props), is(DependencyState.UNSATISFIED));
        when(m_Callback.retrieveRegistryDependencies()).thenReturn(Lists.newArrayList(foundDep1, foundDep2));
        m_SUT.initialize(m_FactoryService, m_ServiceProxy, m_Callback);
        assertThat(m_SUT.isSatisfied(uuid, props), is(DependencyState.SATISFIED));
    }
@ Test public void testRetrieveDeps ( ) { UUID uuid = UUID . randomUUID ( ) ; RegistryDependency foundDep1 = new RegistryDependency ( "dep1" , true ) { @ Override public Object findDependency ( String objectName ) { return "And Jelly" ; } } ; RegistryDependency foundDep2 = new RegistryDependency ( "dep2" , true ) { @ Override public Object findDependency ( String objectName ) { return "And Jelly" ; } } ; RegistryDependency missingDep1 = new RegistryDependency ( "dep1" , true ) { @ Override public Object findDependency ( String objectName ) { return null ; } } ; RegistryDependency missingDep2 = new RegistryDependency ( "dep2" , true ) { @ Override public Object findDependency ( String objectName ) { return null ; } } ; when ( m_Callback . retrieveRegistryDependencies ( ) ) . thenReturn ( Lists . newArrayList ( missingDep1 , missingDep2 ) ) ; m_SUT . initialize ( m_FactoryService , m_ServiceProxy , m_Callback ) ; final Dictionary < String , Object > props = new Hashtable < > ( ) ; props . put ( "dep1" , "" ) ; assertThat ( m_SUT . isSatisfied ( uuid , props ) , is ( DependencyState . INVALID ) ) ; props . put ( "dep2" , "some name" ) ; assertThat ( m_SUT . isSatisfied ( uuid , props ) , anyOf ( is ( DependencyState . UNSATISFIED ) , is ( DependencyState . INVALID ) ) ) ; when ( m_Callback . retrieveRegistryDependencies ( ) ) . thenReturn ( Lists . newArrayList ( foundDep1 , missingDep2 ) ) ; m_SUT . initialize ( m_FactoryService , m_ServiceProxy , m_Callback ) ; props . put ( "dep1" , "some name" ) ; assertThat ( m_SUT . isSatisfied ( uuid , props ) , is ( DependencyState . UNSATISFIED ) ) ; when ( m_Callback . retrieveRegistryDependencies ( ) ) . thenReturn ( Lists . newArrayList ( foundDep1 , foundDep2 ) ) ; m_SUT . initialize ( m_FactoryService , m_ServiceProxy , m_Callback ) ; assertThat ( m_SUT . isSatisfied ( uuid , props ) , is ( DependencyState . SATISFIED ) ) ; }
Verify that retrieve deps is called during construction.
Verify that retrieve deps is called during construction .
//return something other than null //return something other than null // have call back always say dep is missing // should be unknown because one prop is missing, the other empty (both should be ignored) // should be unknown or unsatisfied (based on which dep is checked first) because dep1 is empty, even though // dep2 is unsatisfied // now have call back have one missing, one available //set both deps, 1 is missing // now have call back always say dep is there //assert that the reg is now satisfied