mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/base/TestBaseMessageService.java
@Test
    public void testGenericHandleErrorResponse() throws IOException
    {
        // construct a single message containing data within a namespace message
        GenericErrorResponseData genericError = GenericErrorResponseData.newBuilder()
                .setError(ErrorCode.INTERNAL_ERROR)
                .setErrorDescription("OH NO! AN INTERNAL ERROR!").build();
        
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.GenericErrorResponse)
                .setData(genericError.toByteString())
                .build();
        
        TerraHarvestMessage message = createBaseMessage(baseNamespaceMessage);
        TerraHarvestPayload payload = createPayload(baseNamespaceMessage);
                
        // 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(baseNamespaceMessage.getType().toString()));
        assertThat((BaseNamespace)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(baseNamespaceMessage));
        assertThat((GenericErrorResponseData)postedEvent.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE), 
                is(genericError));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));
    }
/**
     * Verify that a generic error response message is handled and that the event posted contains the appropriate
     * information.
     */
Verify that a generic error response message is handled and that the event posted contains the appropriate
information.
Verify that a generic error response message is handled and that the event posted contains the appropriate information .
@Test
    public void testGenericHandleErrorResponse() throws IOException
    {
        GenericErrorResponseData genericError = GenericErrorResponseData.newBuilder()
                .setError(ErrorCode.INTERNAL_ERROR)
                .setErrorDescription("OH NO! AN INTERNAL ERROR!").build();
        BaseNamespace baseNamespaceMessage = BaseNamespace.newBuilder()
                .setType(BaseMessageType.GenericErrorResponse)
                .setData(genericError.toByteString())
                .build();
        TerraHarvestMessage message = createBaseMessage(baseNamespaceMessage);
        TerraHarvestPayload payload = createPayload(baseNamespaceMessage);
        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(baseNamespaceMessage.getType().toString()));
        assertThat((BaseNamespace)postedEvent.getProperty(RemoteConstants.EVENT_PROP_NAMESPACE_MESSAGE), 
                is(baseNamespaceMessage));
        assertThat((GenericErrorResponseData)postedEvent.getProperty(RemoteConstants.EVENT_PROP_DATA_MESSAGE), 
                is(genericError));
        assertThat((RemoteChannel)postedEvent.getProperty(RemoteConstants.EVENT_PROP_CHANNEL), is(channel));
    }
@ Test public void testGenericHandleErrorResponse ( ) throws IOException { GenericErrorResponseData genericError = GenericErrorResponseData . newBuilder ( ) . setError ( ErrorCode . INTERNAL_ERROR ) . setErrorDescription ( "OH NO! AN INTERNAL ERROR!" ) . build ( ) ; BaseNamespace baseNamespaceMessage = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . GenericErrorResponse ) . setData ( genericError . toByteString ( ) ) . build ( ) ; TerraHarvestMessage message = createBaseMessage ( baseNamespaceMessage ) ; TerraHarvestPayload payload = createPayload ( baseNamespaceMessage ) ; 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 ( baseNamespaceMessage . getType ( ) . toString ( ) ) ) ; assertThat ( ( BaseNamespace ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_NAMESPACE_MESSAGE ) , is ( baseNamespaceMessage ) ) ; assertThat ( ( GenericErrorResponseData ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_DATA_MESSAGE ) , is ( genericError ) ) ; assertThat ( ( RemoteChannel ) postedEvent . getProperty ( RemoteConstants . EVENT_PROP_CHANNEL ) , is ( channel ) ) ; }
Verify that a generic error response message is handled and that the event posted contains the appropriate
 information.
Verify that a generic error response message is handled and that the event posted contains the appropriate information .
// construct a single message containing data within a namespace message // mock the channel the message came from // replay // verify event is posted