mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/ccomm/link/TestLinkLayerImpl.java
@Test
    public void testPerformBit() throws CCommException
    {
        //test default
        assertThat(m_SUT.isPerformingBit(), is(false));

        //mock behavior
        when(m_LinkLayerProxy.onPerformBit()).thenReturn(LinkStatus.OK);
        doReturn(LinkLayerProxy.class.getName()).when(m_LinkLayerFactoryInternal).getProductType();
        when(m_Caps.isPerformBITSupported()).thenReturn(true);
        
        //perform the built in test
        LinkStatus status = m_SUT.performBit();
        assertThat(status, is(LinkStatus.OK));

        //verify
        verify(m_WakeLock).activate();
        verify(m_LinkLayerProxy).onPerformBit();
        verify(m_WakeLock).cancel();
        
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(1)).postEvent(eventCaptor.capture());
        
        Event event = EventAdminVerifier.assertEventByTopicOnly(eventCaptor, LinkLayer.TOPIC_STATUS_CHANGED);
        assertThat((LinkLayerImpl)event.getProperty(FactoryDescriptor.EVENT_PROP_OBJ), is(m_SUT));
        assertThat((String)event.getProperty(FactoryDescriptor.EVENT_PROP_OBJ_TYPE), 
                is(m_SUT.getFactory().getProductType()));
        assertThat((String)event.getProperty(FactoryDescriptor.EVENT_PROP_OBJ_NAME), is(m_Name));
        assertThat((LinkStatus)event.getProperty(LinkLayer.EVENT_PROP_LINK_STATUS), is(LinkStatus.OK));
        assertThat((String)event.getProperty(FactoryDescriptor.EVENT_PROP_OBJ_PID), is(m_Pid));
        assertThat((String)event.getProperty(FactoryDescriptor.EVENT_PROP_OBJ_BASE_TYPE), 
                is(m_BaseType));
    }
/** 
    * Test perform BIT for a link layer.
    */
Test perform BIT for a link layer.
Test perform BIT for a link layer .
@Test
    public void testPerformBit() throws CCommException
    {
        assertThat(m_SUT.isPerformingBit(), is(false));
        when(m_LinkLayerProxy.onPerformBit()).thenReturn(LinkStatus.OK);
        doReturn(LinkLayerProxy.class.getName()).when(m_LinkLayerFactoryInternal).getProductType();
        when(m_Caps.isPerformBITSupported()).thenReturn(true);
        LinkStatus status = m_SUT.performBit();
        assertThat(status, is(LinkStatus.OK));
        verify(m_WakeLock).activate();
        verify(m_LinkLayerProxy).onPerformBit();
        verify(m_WakeLock).cancel();
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(1)).postEvent(eventCaptor.capture());
        Event event = EventAdminVerifier.assertEventByTopicOnly(eventCaptor, LinkLayer.TOPIC_STATUS_CHANGED);
        assertThat((LinkLayerImpl)event.getProperty(FactoryDescriptor.EVENT_PROP_OBJ), is(m_SUT));
        assertThat((String)event.getProperty(FactoryDescriptor.EVENT_PROP_OBJ_TYPE), 
                is(m_SUT.getFactory().getProductType()));
        assertThat((String)event.getProperty(FactoryDescriptor.EVENT_PROP_OBJ_NAME), is(m_Name));
        assertThat((LinkStatus)event.getProperty(LinkLayer.EVENT_PROP_LINK_STATUS), is(LinkStatus.OK));
        assertThat((String)event.getProperty(FactoryDescriptor.EVENT_PROP_OBJ_PID), is(m_Pid));
        assertThat((String)event.getProperty(FactoryDescriptor.EVENT_PROP_OBJ_BASE_TYPE), 
                is(m_BaseType));
    }
@ Test public void testPerformBit ( ) throws CCommException { assertThat ( m_SUT . isPerformingBit ( ) , is ( false ) ) ; when ( m_LinkLayerProxy . onPerformBit ( ) ) . thenReturn ( LinkStatus . OK ) ; doReturn ( LinkLayerProxy . class . getName ( ) ) . when ( m_LinkLayerFactoryInternal ) . getProductType ( ) ; when ( m_Caps . isPerformBITSupported ( ) ) . thenReturn ( true ) ; LinkStatus status = m_SUT . performBit ( ) ; assertThat ( status , is ( LinkStatus . OK ) ) ; verify ( m_WakeLock ) . activate ( ) ; verify ( m_LinkLayerProxy ) . onPerformBit ( ) ; verify ( m_WakeLock ) . cancel ( ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , times ( 1 ) ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = EventAdminVerifier . assertEventByTopicOnly ( eventCaptor , LinkLayer . TOPIC_STATUS_CHANGED ) ; assertThat ( ( LinkLayerImpl ) event . getProperty ( FactoryDescriptor . EVENT_PROP_OBJ ) , is ( m_SUT ) ) ; assertThat ( ( String ) event . getProperty ( FactoryDescriptor . EVENT_PROP_OBJ_TYPE ) , is ( m_SUT . getFactory ( ) . getProductType ( ) ) ) ; assertThat ( ( String ) event . getProperty ( FactoryDescriptor . EVENT_PROP_OBJ_NAME ) , is ( m_Name ) ) ; assertThat ( ( LinkStatus ) event . getProperty ( LinkLayer . EVENT_PROP_LINK_STATUS ) , is ( LinkStatus . OK ) ) ; assertThat ( ( String ) event . getProperty ( FactoryDescriptor . EVENT_PROP_OBJ_PID ) , is ( m_Pid ) ) ; assertThat ( ( String ) event . getProperty ( FactoryDescriptor . EVENT_PROP_OBJ_BASE_TYPE ) , is ( m_BaseType ) ) ; }
Test perform BIT for a link layer.
Test perform BIT for a link layer .
//test default //mock behavior //perform the built in test //verify