mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestCustomCommsMessageService.java
@Test
    public void testCreateTransportLayer_NoLinkLayer() throws IOException, CCommException
    {
        CreateTransportLayerRequestData request = CreateTransportLayerRequestData.newBuilder()
                .setTransportLayerProductType("rawr")
                .setTransportLayerName("chirp")
                .build();
        
        CustomCommsNamespace ccommMessage = CustomCommsNamespace.newBuilder()
                .setType(CustomCommsMessageType.CreateTransportLayerRequest)
                .setData(request.toByteString())
                .build();
        
        TerraHarvestPayload payload = createPayload(ccommMessage);
        TerraHarvestMessage message = createCustomCommsMessage(ccommMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        final TransportLayer createdTransportLayer = mock(TransportLayer.class);
        when(createdTransportLayer.getUuid()).thenReturn(testUuid);
        when(createdTransportLayer.getPid()).thenReturn("transPid");
        when(createdTransportLayer.getFactory()).thenReturn(m_TransportLayerFactory);
        
        when(m_CustomCommsService.createTransportLayer(anyString(), anyString(), anyString()))
            .thenReturn(createdTransportLayer);
        
        m_SUT.handleMessage(message, payload, channel);
        
        verify(m_CustomCommsService).createTransportLayer("rawr", "chirp", (String)null);
    }
/**
     * Verify if the link layer UUID field is empty, the transport layer is still created.
     */
Verify if the link layer UUID field is empty, the transport layer is still created.
Verify if the link layer UUID field is empty the transport layer is still created .
@Test
    public void testCreateTransportLayer_NoLinkLayer() throws IOException, CCommException
    {
        CreateTransportLayerRequestData request = CreateTransportLayerRequestData.newBuilder()
                .setTransportLayerProductType("rawr")
                .setTransportLayerName("chirp")
                .build();
        CustomCommsNamespace ccommMessage = CustomCommsNamespace.newBuilder()
                .setType(CustomCommsMessageType.CreateTransportLayerRequest)
                .setData(request.toByteString())
                .build();
        TerraHarvestPayload payload = createPayload(ccommMessage);
        TerraHarvestMessage message = createCustomCommsMessage(ccommMessage);
        RemoteChannel channel = mock(RemoteChannel.class);
        final TransportLayer createdTransportLayer = mock(TransportLayer.class);
        when(createdTransportLayer.getUuid()).thenReturn(testUuid);
        when(createdTransportLayer.getPid()).thenReturn("transPid");
        when(createdTransportLayer.getFactory()).thenReturn(m_TransportLayerFactory);
        when(m_CustomCommsService.createTransportLayer(anyString(), anyString(), anyString()))
            .thenReturn(createdTransportLayer);
        m_SUT.handleMessage(message, payload, channel);
        verify(m_CustomCommsService).createTransportLayer("rawr", "chirp", (String)null);
    }
@ Test public void testCreateTransportLayer_NoLinkLayer ( ) throws IOException , CCommException { CreateTransportLayerRequestData request = CreateTransportLayerRequestData . newBuilder ( ) . setTransportLayerProductType ( "rawr" ) . setTransportLayerName ( "chirp" ) . build ( ) ; CustomCommsNamespace ccommMessage = CustomCommsNamespace . newBuilder ( ) . setType ( CustomCommsMessageType . CreateTransportLayerRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( ccommMessage ) ; TerraHarvestMessage message = createCustomCommsMessage ( ccommMessage ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; final TransportLayer createdTransportLayer = mock ( TransportLayer . class ) ; when ( createdTransportLayer . getUuid ( ) ) . thenReturn ( testUuid ) ; when ( createdTransportLayer . getPid ( ) ) . thenReturn ( "transPid" ) ; when ( createdTransportLayer . getFactory ( ) ) . thenReturn ( m_TransportLayerFactory ) ; when ( m_CustomCommsService . createTransportLayer ( anyString ( ) , anyString ( ) , anyString ( ) ) ) . thenReturn ( createdTransportLayer ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( m_CustomCommsService ) . createTransportLayer ( "rawr" , "chirp" , ( String ) null ) ; }
Verify if the link layer UUID field is empty, the transport layer is still created.
Verify if the link layer UUID field is empty the transport layer is still created .
// mock the channel the message came from