mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/util/TestRemoteInterfaceUtilities.java
@Test
    public final void testCreateMessageReceivedEvent() throws InvalidProtocolBufferException
    {
        // construct a single message containing data within a namespace message
        ControllerInfoData systemInfoData = ControllerInfoData.newBuilder()
                .setName("test-name")
                .build();
        
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.ControllerInfo)
                .setData(systemInfoData.toByteString())
                .build();
        
        TerraHarvestMessage message = 
                TerraHarvestMessageHelper.createTerraHarvestMessage(0, 1, Namespace.Base, 100, baseNamespaceMessage);
        TerraHarvestPayload payload = TerraHarvestPayload.newBuilder().
                setNamespace(Namespace.Base).
                setNamespaceMessage(baseNamespaceMessage.toByteString()).
                build();
        RemoteChannel channel = mock(RemoteChannel.class);
        
        Event event = RemoteInterfaceUtilities.createMessageReceivedEvent(message, payload, baseNamespaceMessage,
                BaseMessageType.ControllerInfo, systemInfoData, channel);
        
        // now test all properties and the topic
        assertThat(event.getTopic(), is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        assertThat((TerraHarvestMessage)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE), is(message));
        assertThat((Integer)event.getProperty(RemoteConstants.EVENT_PROP_SOURCE_ID), is(0));
        assertThat((Integer)event.getProperty(RemoteConstants.EVENT_PROP_DEST_ID), is(1));
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE), is(Namespace.Base.toString()));
        assertThat((BaseNamespace)event.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(baseNamespaceMessage));
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(BaseMessageType.ControllerInfo.toString()));
        assertThat((ControllerInfoData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE), 
                is(systemInfoData));
        assertThat((Boolean)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_RESPONSE), 
                is(false));
        assertThat((RemoteChannel)event.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));
    }
/**
     * Verify the event is created with the proper topic and properties.
     */
Verify the event is created with the proper topic and properties.
Verify the event is created with the proper topic and properties .
@Test
    public final void testCreateMessageReceivedEvent() throws InvalidProtocolBufferException
    {
        ControllerInfoData systemInfoData = ControllerInfoData.newBuilder()
                .setName("test-name")
                .build();
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.ControllerInfo)
                .setData(systemInfoData.toByteString())
                .build();
        TerraHarvestMessage message = 
                TerraHarvestMessageHelper.createTerraHarvestMessage(0, 1, Namespace.Base, 100, baseNamespaceMessage);
        TerraHarvestPayload payload = TerraHarvestPayload.newBuilder().
                setNamespace(Namespace.Base).
                setNamespaceMessage(baseNamespaceMessage.toByteString()).
                build();
        RemoteChannel channel = mock(RemoteChannel.class);
        Event event = RemoteInterfaceUtilities.createMessageReceivedEvent(message, payload, baseNamespaceMessage,
                BaseMessageType.ControllerInfo, systemInfoData, channel);
        assertThat(event.getTopic(), is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        assertThat((TerraHarvestMessage)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE), is(message));
        assertThat((Integer)event.getProperty(RemoteConstants.EVENT_PROP_SOURCE_ID), is(0));
        assertThat((Integer)event.getProperty(RemoteConstants.EVENT_PROP_DEST_ID), is(1));
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE), is(Namespace.Base.toString()));
        assertThat((BaseNamespace)event.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(baseNamespaceMessage));
        assertThat((String)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(BaseMessageType.ControllerInfo.toString()));
        assertThat((ControllerInfoData)event.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE), 
                is(systemInfoData));
        assertThat((Boolean)event.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_RESPONSE), 
                is(false));
        assertThat((RemoteChannel)event.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));
    }
@ Test public final void testCreateMessageReceivedEvent ( ) throws InvalidProtocolBufferException { ControllerInfoData systemInfoData = ControllerInfoData . newBuilder ( ) . setName ( "test-name" ) . build ( ) ; BaseNamespace baseNamespaceMessage = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . ControllerInfo ) . setData ( systemInfoData . toByteString ( ) ) . build ( ) ; TerraHarvestMessage message = TerraHarvestMessageHelper . createTerraHarvestMessage ( 0 , 1 , Namespace . Base , 100 , baseNamespaceMessage ) ; TerraHarvestPayload payload = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . Base ) . setNamespaceMessage ( baseNamespaceMessage . toByteString ( ) ) . build ( ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; Event event = RemoteInterfaceUtilities . createMessageReceivedEvent ( message , payload , baseNamespaceMessage , BaseMessageType . ControllerInfo , systemInfoData , channel ) ; assertThat ( event . getTopic ( ) , is ( RemoteConstants . TOPIC_MESSAGE_RECEIVED ) ) ; assertThat ( ( TerraHarvestMessage ) event . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE ) , is ( message ) ) ; assertThat ( ( Integer ) event . getProperty ( RemoteConstants . EVENT_PROP_SOURCE_ID ) , is ( 0 ) ) ; assertThat ( ( Integer ) event . getProperty ( RemoteConstants . EVENT_PROP_DEST_ID ) , is ( 1 ) ) ; assertThat ( ( String ) event . getProperty ( RemoteConstants . EVENT_PROP_NAMESPACE ) , is ( Namespace . Base . toString ( ) ) ) ; assertThat ( ( BaseNamespace ) event . getProperty ( RemoteConstants . EVENT_PROP_NAMESPACE_MESSAGE ) , is ( baseNamespaceMessage ) ) ; assertThat ( ( String ) event . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( BaseMessageType . ControllerInfo . toString ( ) ) ) ; assertThat ( ( ControllerInfoData ) event . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( systemInfoData ) ) ; assertThat ( ( Boolean ) event . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_RESPONSE ) , is ( false ) ) ; assertThat ( ( RemoteChannel ) event . getProperty ( RemoteConstants . EVENT_PROP_CHANNEL ) , is ( channel ) ) ; }
Verify the event is created with the proper topic and properties.
Verify the event is created with the proper topic and properties .
// construct a single message containing data within a namespace message // now test all properties and the topic