mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestCustomCommsMessageService.java
@Test
    public void testGetLayerNameResponse() throws IOException, IllegalArgumentException
    {
        GetLayerNameResponseData response = GetLayerNameResponseData.newBuilder().
            setCommType(CommType.Linklayer).
            setLayerName("name").
            setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)).build();
        CustomCommsNamespace namespace = CustomCommsNamespace.newBuilder().
                setData(response.toByteString()).
                setType(CustomCommsMessageType.GetLayerNameResponse).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((CustomCommsNamespace)event.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE),
                is(namespace));
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(CustomCommsMessageType.GetLayerNameResponse.toString()));
        assertThat((GetLayerNameResponseData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(response));
    }
/**
     * Test get name for layer response.
     * Verify that expected event is posted.
     */
Test get name for layer response.
Verify that expected event is posted.
Test get name for layer response . Verify that expected event is posted .
@Test
    public void testGetLayerNameResponse() throws IOException, IllegalArgumentException
    {
        GetLayerNameResponseData response = GetLayerNameResponseData.newBuilder().
            setCommType(CommType.Linklayer).
            setLayerName("name").
            setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)).build();
        CustomCommsNamespace namespace = CustomCommsNamespace.newBuilder().
                setData(response.toByteString()).
                setType(CustomCommsMessageType.GetLayerNameResponse).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((CustomCommsNamespace)event.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE),
                is(namespace));
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(CustomCommsMessageType.GetLayerNameResponse.toString()));
        assertThat((GetLayerNameResponseData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(response));
    }
@ Test public void testGetLayerNameResponse ( ) throws IOException , IllegalArgumentException { GetLayerNameResponseData response = GetLayerNameResponseData . newBuilder ( ) . setCommType ( CommType . Linklayer ) . setLayerName ( "name" ) . setUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . build ( ) ; CustomCommsNamespace namespace = CustomCommsNamespace . newBuilder ( ) . setData ( response . toByteString ( ) ) . setType ( CustomCommsMessageType . GetLayerNameResponse ) . 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 ( ( CustomCommsNamespace ) event . getProperty ( RemoteConstants . EVENT_PROP_NAMESPACE_MESSAGE ) , is ( namespace ) ) ; assertThat ( ( String ) event . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( CustomCommsMessageType . GetLayerNameResponse . toString ( ) ) ) ; assertThat ( ( GetLayerNameResponseData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( response ) ) ; }
Test get name for layer response.
Test get name for layer response .
//mock remote channel //handle message //capture event //verify