mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestCustomCommsMessageService.java
@Test
    public void testTransLayerssetLayerName() throws IOException, IllegalArgumentException, FactoryException
    {
        //mock behavior
        TransportLayer trans = mock(TransportLayer.class);
        when(trans.getUuid()).thenReturn(testUuid);

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

        //request to set the name of a transport layer
        SetLayerNameRequestData request = SetLayerNameRequestData.newBuilder().
            setCommType(CommType.TransportLayer).
            setLayerName("name").
            setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)).build();
        CustomCommsNamespace namespace = CustomCommsNamespace.newBuilder().
                setData(request.toByteString()).
                setType(CustomCommsMessageType.SetLayerNameRequest).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 name set
        verify(trans).setName("name");
        
        //verify
        assertThat((SetLayerNameRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        
        verify(m_MessageFactory).createCustomCommsResponseMessage(eq(message), 
            eq(CustomCommsMessageType.SetLayerNameResponse), eq((Message)null));
        verify(m_ResponseWrapper).queue(channel);
    }
/**
     * Test set name for transport layers.
     * Verify that expected name is set.
     */
Test set name for transport layers.
Verify that expected name is set.
Test set name for transport layers . Verify that expected name is set .
@Test
    public void testTransLayerssetLayerName() throws IOException, IllegalArgumentException, FactoryException
    {
        TransportLayer trans = mock(TransportLayer.class);
        when(trans.getUuid()).thenReturn(testUuid);
        List<TransportLayer> layers = new ArrayList<TransportLayer>();
        layers.add(trans);
        when(m_CustomCommsService.getTransportLayers()).thenReturn(layers);
        SetLayerNameRequestData request = SetLayerNameRequestData.newBuilder().
            setCommType(CommType.TransportLayer).
            setLayerName("name").
            setUuid(SharedMessageUtils.convertUUIDToProtoUUID(testUuid)).build();
        CustomCommsNamespace namespace = CustomCommsNamespace.newBuilder().
                setData(request.toByteString()).
                setType(CustomCommsMessageType.SetLayerNameRequest).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();
        verify(trans).setName("name");
        assertThat((SetLayerNameRequestData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        verify(m_MessageFactory).createCustomCommsResponseMessage(eq(message), 
            eq(CustomCommsMessageType.SetLayerNameResponse), eq((Message)null));
        verify(m_ResponseWrapper).queue(channel);
    }
@ Test public void testTransLayerssetLayerName ( ) throws IOException , IllegalArgumentException , FactoryException { TransportLayer trans = mock ( TransportLayer . class ) ; when ( trans . getUuid ( ) ) . thenReturn ( testUuid ) ; List < TransportLayer > layers = new ArrayList < TransportLayer > ( ) ; layers . add ( trans ) ; when ( m_CustomCommsService . getTransportLayers ( ) ) . thenReturn ( layers ) ; SetLayerNameRequestData request = SetLayerNameRequestData . newBuilder ( ) . setCommType ( CommType . TransportLayer ) . setLayerName ( "name" ) . setUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( testUuid ) ) . build ( ) ; CustomCommsNamespace namespace = CustomCommsNamespace . newBuilder ( ) . setData ( request . toByteString ( ) ) . setType ( CustomCommsMessageType . SetLayerNameRequest ) . 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 ( ) ; verify ( trans ) . setName ( "name" ) ; assertThat ( ( SetLayerNameRequestData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( request ) ) ; verify ( m_MessageFactory ) . createCustomCommsResponseMessage ( eq ( message ) , eq ( CustomCommsMessageType . SetLayerNameResponse ) , eq ( ( Message ) null ) ) ; verify ( m_ResponseWrapper ) . queue ( channel ) ; }
Test set name for transport layers.
Test set name for transport layers .
//mock behavior //list returned //request to set the name of a transport layer //mock remote channel //handle message //capture event //verify name set //verify