mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/observation/TestObservationMessageService.java
@Test
    public void testGenericHandleMessage() throws IOException
    {
        FindObservationByUUIDResponseData message = FindObservationByUUIDResponseData.newBuilder()
            .addObservationNative(TerraHarvestMessageHelper.getProtoObs()).build();
        ObservationStoreNamespace namespace = ObservationStoreNamespace.newBuilder().
            setData(message.toByteString()).
            setType(ObservationStoreMessageType.FindObservationByUUIDResponse).build();
        TerraHarvestPayload payload = createPayload(namespace);
        TerraHarvestMessage thMessage = createMessageObservationStore(namespace);

        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);

        // replay
        m_SUT.handleMessage(thMessage, payload, channel);

        // verify event is posted
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event postedEvent = eventCaptor.getValue();

        assertThat(postedEvent.getTopic(), is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        assertThat((TerraHarvestMessage)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE), is(thMessage));
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(ObservationStoreMessageType.FindObservationByUUIDResponse.toString()));
        assertThat((ObservationStoreNamespace)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(namespace));
        assertThat((FindObservationByUUIDResponseData)postedEvent.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE), 
                is(message));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));
    }
/**
     * Test generic handling of messages.
     * Verify that it posts an event locally.
     */
Test generic handling of messages.
Verify that it posts an event locally.
Test generic handling of messages . Verify that it posts an event locally .
@Test
    public void testGenericHandleMessage() throws IOException
    {
        FindObservationByUUIDResponseData message = FindObservationByUUIDResponseData.newBuilder()
            .addObservationNative(TerraHarvestMessageHelper.getProtoObs()).build();
        ObservationStoreNamespace namespace = ObservationStoreNamespace.newBuilder().
            setData(message.toByteString()).
            setType(ObservationStoreMessageType.FindObservationByUUIDResponse).build();
        TerraHarvestPayload payload = createPayload(namespace);
        TerraHarvestMessage thMessage = createMessageObservationStore(namespace);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(thMessage, payload, channel);
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        Event postedEvent = eventCaptor.getValue();
        assertThat(postedEvent.getTopic(), is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        assertThat((TerraHarvestMessage)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE), is(thMessage));
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE), 
                is(ObservationStoreMessageType.FindObservationByUUIDResponse.toString()));
        assertThat((ObservationStoreNamespace)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(namespace));
        assertThat((FindObservationByUUIDResponseData)postedEvent.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE), 
                is(message));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));
    }
@ Test public void testGenericHandleMessage ( ) throws IOException { FindObservationByUUIDResponseData message = FindObservationByUUIDResponseData . newBuilder ( ) . addObservationNative ( TerraHarvestMessageHelper . getProtoObs ( ) ) . build ( ) ; ObservationStoreNamespace namespace = ObservationStoreNamespace . newBuilder ( ) . setData ( message . toByteString ( ) ) . setType ( ObservationStoreMessageType . FindObservationByUUIDResponse ) . build ( ) ; TerraHarvestPayload payload = createPayload ( namespace ) ; TerraHarvestMessage thMessage = createMessageObservationStore ( namespace ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( thMessage , payload , channel ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; Event postedEvent = eventCaptor . getValue ( ) ; assertThat ( postedEvent . getTopic ( ) , is ( RemoteConstants . TOPIC_MESSAGE_RECEIVED ) ) ; assertThat ( ( TerraHarvestMessage ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE ) , is ( thMessage ) ) ; assertThat ( ( String ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( ObservationStoreMessageType . FindObservationByUUIDResponse . toString ( ) ) ) ; assertThat ( ( ObservationStoreNamespace ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_NAMESPACE_MESSAGE ) , is ( namespace ) ) ; assertThat ( ( FindObservationByUUIDResponseData ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( message ) ) ; assertThat ( ( RemoteChannel ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_CHANNEL ) , is ( channel ) ) ; }
Test generic handling of messages.
Test generic handling of messages .
// mock the channel the message came from // replay // verify event is posted