mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/datastream/store/TestDataStreamStoreMessageService.java
@Test
    public void testGenericHandleMessage() throws IOException
    {
        GetArchivePeriodsRequestData request = GetArchivePeriodsRequestData.newBuilder()
                .setStreamProfileUuid(SharedMessages.UUID.newBuilder()
                        .setLeastSignificantBits(testProfileUuid.getLeastSignificantBits())
                        .setMostSignificantBits(testProfileUuid.getMostSignificantBits()).build()).build();
        DataStreamStoreNamespace dataStreamStoreMessage = DataStreamStoreNamespace.newBuilder()
                .setType(DataStreamStoreMessageType.GetArchivePeriodsRequest)
                .setData(request.toByteString()).build();
        TerraHarvestPayload payload = createPayload(dataStreamStoreMessage);
        TerraHarvestMessage message = createMessage(dataStreamStoreMessage);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        // replay
        m_SUT.handleMessage(message, 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(message));
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(dataStreamStoreMessage.getType().toString()));
        assertThat((DataStreamStoreNamespace)postedEvent.
                getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), is(dataStreamStoreMessage));
        assertThat((GetArchivePeriodsRequestData)postedEvent.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));   
    }
/**
     * Verify generic handling of message (posts an event locally)
     */
Verify generic handling of message (posts an event locally)
Verify generic handling of message ( posts an event locally )
@Test
    public void testGenericHandleMessage() throws IOException
    {
        GetArchivePeriodsRequestData request = GetArchivePeriodsRequestData.newBuilder()
                .setStreamProfileUuid(SharedMessages.UUID.newBuilder()
                        .setLeastSignificantBits(testProfileUuid.getLeastSignificantBits())
                        .setMostSignificantBits(testProfileUuid.getMostSignificantBits()).build()).build();
        DataStreamStoreNamespace dataStreamStoreMessage = DataStreamStoreNamespace.newBuilder()
                .setType(DataStreamStoreMessageType.GetArchivePeriodsRequest)
                .setData(request.toByteString()).build();
        TerraHarvestPayload payload = createPayload(dataStreamStoreMessage);
        TerraHarvestMessage message = createMessage(dataStreamStoreMessage);
        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 postedEvent = eventCaptor.getValue();
        assertThat(postedEvent.getTopic(), is(RemoteConstants.TOPIC_MESSAGE_RECEIVED));
        assertThat((TerraHarvestMessage)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE), is(message));
        assertThat((String)postedEvent.getProperty(RemoteConstants.EVENT_PROP_MESSAGE_TYPE),
                is(dataStreamStoreMessage.getType().toString()));
        assertThat((DataStreamStoreNamespace)postedEvent.
                getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), is(dataStreamStoreMessage));
        assertThat((GetArchivePeriodsRequestData)postedEvent.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE),
                is(request));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));   
    }
@ Test public void testGenericHandleMessage ( ) throws IOException { GetArchivePeriodsRequestData request = GetArchivePeriodsRequestData . newBuilder ( ) . setStreamProfileUuid ( SharedMessages . UUID . newBuilder ( ) . setLeastSignificantBits ( testProfileUuid . getLeastSignificantBits ( ) ) . setMostSignificantBits ( testProfileUuid . getMostSignificantBits ( ) ) . build ( ) ) . build ( ) ; DataStreamStoreNamespace dataStreamStoreMessage = DataStreamStoreNamespace . newBuilder ( ) . setType ( DataStreamStoreMessageType . GetArchivePeriodsRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( dataStreamStoreMessage ) ; TerraHarvestMessage message = createMessage ( dataStreamStoreMessage ) ; 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 postedEvent = eventCaptor . getValue ( ) ; assertThat ( postedEvent . getTopic ( ) , is ( RemoteConstants . TOPIC_MESSAGE_RECEIVED ) ) ; assertThat ( ( TerraHarvestMessage ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE ) , is ( message ) ) ; assertThat ( ( String ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_MESSAGE_TYPE ) , is ( dataStreamStoreMessage . getType ( ) . toString ( ) ) ) ; assertThat ( ( DataStreamStoreNamespace ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_NAMESPACE_MESSAGE ) , is ( dataStreamStoreMessage ) ) ; assertThat ( ( GetArchivePeriodsRequestData ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( request ) ) ; assertThat ( ( RemoteChannel ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_CHANNEL ) , is ( channel ) ) ; }
Verify generic handling of message (posts an event locally)
Verify generic handling of message ( posts an event locally )
// mock the channel the message came from // replay // verify event is posted