mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/ccomm/TestLinkLayerRegistryCallback.java
@Test
    public void testPostObjectInitialize() throws FactoryException, AssetException, InterruptedException
    {
        LinkLayerInternal mockLayer = mock(LinkLayerInternal.class);
        LinkLayerAttributes attrs = mock(LinkLayerAttributes.class);
        String name = "link1";

        when(mockLayer.getConfig()).thenReturn(attrs);
        when(mockLayer.getName()).thenReturn(name);

        when(attrs.activateOnStartup()).thenReturn(false);
        when(m_FactRegistry.isObjectCreated(name)).thenReturn(false);
        
        m_SUT.postObjectInitialize(mockLayer);

        Thread.sleep(250);
        verify(mockLayer, never()).activateLayer();

        when(attrs.activateOnStartup()).thenReturn(true);
        when(m_FactRegistry.isObjectCreated(name)).thenReturn(true);
        
        m_SUT.postObjectInitialize(mockLayer);

        Thread.sleep(250);
        verify(mockLayer, never()).activateLayer();

        when(attrs.activateOnStartup()).thenReturn(true);
        when(m_FactRegistry.isObjectCreated(name)).thenReturn(false);
        
        m_SUT.postObjectInitialize(mockLayer);

        verify(mockLayer, timeout(250)).activateLayer();
    }
/**
     * Verify checking if a new object should be activated at startup.
     */
Verify checking if a new object should be activated at startup.
Verify checking if a new object should be activated at startup .
@Test
    public void testPostObjectInitialize() throws FactoryException, AssetException, InterruptedException
    {
        LinkLayerInternal mockLayer = mock(LinkLayerInternal.class);
        LinkLayerAttributes attrs = mock(LinkLayerAttributes.class);
        String name = "link1";
        when(mockLayer.getConfig()).thenReturn(attrs);
        when(mockLayer.getName()).thenReturn(name);
        when(attrs.activateOnStartup()).thenReturn(false);
        when(m_FactRegistry.isObjectCreated(name)).thenReturn(false);
        m_SUT.postObjectInitialize(mockLayer);
        Thread.sleep(250);
        verify(mockLayer, never()).activateLayer();
        when(attrs.activateOnStartup()).thenReturn(true);
        when(m_FactRegistry.isObjectCreated(name)).thenReturn(true);
        m_SUT.postObjectInitialize(mockLayer);
        Thread.sleep(250);
        verify(mockLayer, never()).activateLayer();
        when(attrs.activateOnStartup()).thenReturn(true);
        when(m_FactRegistry.isObjectCreated(name)).thenReturn(false);
        m_SUT.postObjectInitialize(mockLayer);
        verify(mockLayer, timeout(250)).activateLayer();
    }
@ Test public void testPostObjectInitialize ( ) throws FactoryException , AssetException , InterruptedException { LinkLayerInternal mockLayer = mock ( LinkLayerInternal . class ) ; LinkLayerAttributes attrs = mock ( LinkLayerAttributes . class ) ; String name = "link1" ; when ( mockLayer . getConfig ( ) ) . thenReturn ( attrs ) ; when ( mockLayer . getName ( ) ) . thenReturn ( name ) ; when ( attrs . activateOnStartup ( ) ) . thenReturn ( false ) ; when ( m_FactRegistry . isObjectCreated ( name ) ) . thenReturn ( false ) ; m_SUT . postObjectInitialize ( mockLayer ) ; Thread . sleep ( 250 ) ; verify ( mockLayer , never ( ) ) . activateLayer ( ) ; when ( attrs . activateOnStartup ( ) ) . thenReturn ( true ) ; when ( m_FactRegistry . isObjectCreated ( name ) ) . thenReturn ( true ) ; m_SUT . postObjectInitialize ( mockLayer ) ; Thread . sleep ( 250 ) ; verify ( mockLayer , never ( ) ) . activateLayer ( ) ; when ( attrs . activateOnStartup ( ) ) . thenReturn ( true ) ; when ( m_FactRegistry . isObjectCreated ( name ) ) . thenReturn ( false ) ; m_SUT . postObjectInitialize ( mockLayer ) ; verify ( mockLayer , timeout ( 250 ) ) . activateLayer ( ) ; }
Verify checking if a new object should be activated at startup.
Verify checking if a new object should be activated at startup .