mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestCustomCommsMessageService.java
@Test
    public void testTransLayersGetLayerName() throws IOException
    {
        //mock behavior
        TransportLayer trans = mock(TransportLayer.class);
        when(trans.getName()).thenReturn("name");
        when(trans.getUuid()).thenReturn(testUuid);

        //list returned
        List<TransportLayer> layers = new ArrayList<TransportLayer>();
        layers.add(trans);
        
        when(m_CustomCommsService.getTransportLayers()).thenReturn(layers);

        //request to get the name of a transport layer
        GetLayerNameRequestData request = GetLayerNameRequestData.newBuilder().
            setCommType(CommType.TransportLayer).
            setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)).build();
        CustomCommsNamespace namespace = CustomCommsNamespace.newBuilder().
                setData(request.toByteString()).
                setType(CustomCommsMessageType.GetLayerNameRequest).build();
        TerraHarvestPayload payload = createPayload(namespace);
        TerraHarvestMessage message = createCustomCommsMessage(namespace);

        //mock remote channel
        RemoteChannel channel = mock(RemoteChannel.class);

        //handle message
        m_SUT.handleMessage(message, payload, channel);
        
        //capture event
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        
        //verify
        assertThat((GetLayerNameRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        
        ArgumentCaptor<GetLayerNameResponseData> response = ArgumentCaptor.forClass(GetLayerNameResponseData.class);
        verify(m_MessageFactory).createCustomCommsResponseMessage(eq(message), 
            eq(CustomCommsMessageType.GetLayerNameResponse), response.capture());
        verify(m_ResponseWrapper).queue(channel);
        
        GetLayerNameResponseData data = response.getValue();
        assertThat(data.getCommType(), is(CommType.TransportLayer));
        assertThat(data.getLayerName(), is("name"));
        assertThat(data.getUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)));
    }
/**
     * Test get name for transport layers.
     * Verify that expected name is returned.
     */
Test get name for transport layers.
Verify that expected name is returned.
Test get name for transport layers . Verify that expected name is returned .
@Test
    public void testTransLayersGetLayerName() throws IOException
    {
        TransportLayer trans = mock(TransportLayer.class);
        when(trans.getName()).thenReturn("name");
        when(trans.getUuid()).thenReturn(testUuid);
        List<TransportLayer> layers = new ArrayList<TransportLayer>();
        layers.add(trans);
        when(m_CustomCommsService.getTransportLayers()).thenReturn(layers);
        GetLayerNameRequestData request = GetLayerNameRequestData.newBuilder().
            setCommType(CommType.TransportLayer).
            setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)).build();
        CustomCommsNamespace namespace = CustomCommsNamespace.newBuilder().
                setData(request.toByteString()).
                setType(CustomCommsMessageType.GetLayerNameRequest).build();
        TerraHarvestPayload payload = createPayload(namespace);
        TerraHarvestMessage message = createCustomCommsMessage(namespace);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event event = eventCaptor.getValue();
        assertThat((GetLayerNameRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        ArgumentCaptor<GetLayerNameResponseData> response = ArgumentCaptor.forClass(GetLayerNameResponseData.class);
        verify(m_MessageFactory).createCustomCommsResponseMessage(eq(message), 
            eq(CustomCommsMessageType.GetLayerNameResponse), response.capture());
        verify(m_ResponseWrapper).queue(channel);
        GetLayerNameResponseData data = response.getValue();
        assertThat(data.getCommType(), is(CommType.TransportLayer));
        assertThat(data.getLayerName(), is("name"));
        assertThat(data.getUuid(), is(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)));
    }
@ Test public void testTransLayersGetLayerName ( ) throws IOException { TransportLayer trans = mock ( TransportLayer . class ) ; when ( trans . getName ( ) ) . thenReturn ( "name" ) ; when ( trans . getUuid ( ) ) . thenReturn ( testUuid ) ; List < TransportLayer > layers = new ArrayList < TransportLayer > ( ) ; layers . add ( trans ) ; when ( m_CustomCommsService . getTransportLayers ( ) ) . thenReturn ( layers ) ; GetLayerNameRequestData request = GetLayerNameRequestData . newBuilder ( ) . setCommType ( CommType . TransportLayer ) . setUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . build ( ) ; CustomCommsNamespace namespace = CustomCommsNamespace . newBuilder ( ) . setData ( request . toByteString ( ) ) . setType ( CustomCommsMessageType . GetLayerNameRequest ) . build ( ) ; TerraHarvestPayload payload = createPayload ( namespace ) ; TerraHarvestMessage message = createCustomCommsMessage ( namespace ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event event = eventCaptor . getValue ( ) ; assertThat ( ( GetLayerNameRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( request ) ) ; ArgumentCaptor < GetLayerNameResponseData > response = ArgumentCaptor . forClass ( GetLayerNameResponseData . class ) ; verify ( m_MessageFactory ) . createCustomCommsResponseMessage ( eq ( message ) , eq ( CustomCommsMessageType . GetLayerNameResponse ) , response . capture ( ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; GetLayerNameResponseData data = response . getValue ( ) ; assertThat ( data . getCommType ( ) , is ( CommType . TransportLayer ) ) ; assertThat ( data . getLayerName ( ) , is ( "name" ) ) ; assertThat ( data . getUuid ( ) , is ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) ) ; }
Test get name for transport layers.
Test get name for transport layers .
//mock behavior //list returned //request to get the name of a transport layer //mock remote channel //handle message //capture event //verify