mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/messaging/TestMessageFactoryImpl.java
@Test
    public void testQueueGenericExceptionResponse() throws IOException
    {
        // create the original request message that the response will be based on
        // required to be set Don't care what it is though
        TerraHarvestMessage request =  createRequestFiller();
        
        Exception exception = new Exception("blah");
        MessageResponseWrapper response = m_SUT.createBaseErrorResponse(request, exception, "description");

        //request to send over mock channel
        RemoteChannel channel = mock(RemoteChannel.class);
        response.queue(channel);
        
        //capture the payload constructed in the message factory
        ArgumentCaptor<TerraHarvestPayload> payloadCap = ArgumentCaptor.forClass(TerraHarvestPayload.class);
        verify(m_MessageSender).queueMessageResponse(eq(request), payloadCap.capture(), eq(channel));
        
        //verify Payload
        TerraHarvestPayload payloadCaptured = payloadCap.getValue();
        assertThat(payloadCaptured.getNamespace(), is(Namespace.Base));
        
        //namespace
        BaseNamespace baseResponseMessage = BaseNamespace.parseFrom(payloadCaptured.getNamespaceMessage());
        assertThat(baseResponseMessage.getType(), is(BaseMessageType.GenericErrorResponse));
        
        //specific message
        GenericErrorResponseData errorData = GenericErrorResponseData.parseFrom(baseResponseMessage.getData());
        assertThat(errorData.getError(), is(ErrorCode.INTERNAL_ERROR));
        assertThat(errorData.getErrorDescription(), is("description: java.lang.Exception: blah"));
        
        // verify the error condition was logged including the exception as is
        verify(m_Logging).error(exception, "description");
    }
/**
     * Verify the message response wrapper returned contains the expected error message contents for a generic error.
     * Verify the exception condition is logged too.
     */
Verify the message response wrapper returned contains the expected error message contents for a generic error.
Verify the exception condition is logged too.
Verify the message response wrapper returned contains the expected error message contents for a generic error . Verify the exception condition is logged too .
@Test
    public void testQueueGenericExceptionResponse() throws IOException
    {
        TerraHarvestMessage request =  createRequestFiller();
        Exception exception = new Exception("blah");
        MessageResponseWrapper response = m_SUT.createBaseErrorResponse(request, exception, "description");
        RemoteChannel channel = mock(RemoteChannel.class);
        response.queue(channel);
        ArgumentCaptor<TerraHarvestPayload> payloadCap = ArgumentCaptor.forClass(TerraHarvestPayload.class);
        verify(m_MessageSender).queueMessageResponse(eq(request), payloadCap.capture(), eq(channel));
        TerraHarvestPayload payloadCaptured = payloadCap.getValue();
        assertThat(payloadCaptured.getNamespace(), is(Namespace.Base));
        BaseNamespace baseResponseMessage = BaseNamespace.parseFrom(payloadCaptured.getNamespaceMessage());
        assertThat(baseResponseMessage.getType(), is(BaseMessageType.GenericErrorResponse));
        GenericErrorResponseData errorData = GenericErrorResponseData.parseFrom(baseResponseMessage.getData());
        assertThat(errorData.getError(), is(ErrorCode.INTERNAL_ERROR));
        assertThat(errorData.getErrorDescription(), is("description: java.lang.Exception: blah"));
        verify(m_Logging).error(exception, "description");
    }
@ Test public void testQueueGenericExceptionResponse ( ) throws IOException { TerraHarvestMessage request = createRequestFiller ( ) ; Exception exception = new Exception ( "blah" ) ; MessageResponseWrapper response = m_SUT . createBaseErrorResponse ( request , exception , "description" ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; response . queue ( channel ) ; ArgumentCaptor < TerraHarvestPayload > payloadCap = ArgumentCaptor . forClass ( TerraHarvestPayload . class ) ; verify ( m_MessageSender ) . queueMessageResponse ( eq ( request ) , payloadCap . capture ( ) , eq ( channel ) ) ; TerraHarvestPayload payloadCaptured = payloadCap . getValue ( ) ; assertThat ( payloadCaptured . getNamespace ( ) , is ( Namespace . Base ) ) ; BaseNamespace baseResponseMessage = BaseNamespace . parseFrom ( payloadCaptured . getNamespaceMessage ( ) ) ; assertThat ( baseResponseMessage . getType ( ) , is ( BaseMessageType . GenericErrorResponse ) ) ; GenericErrorResponseData errorData = GenericErrorResponseData . parseFrom ( baseResponseMessage . getData ( ) ) ; assertThat ( errorData . getError ( ) , is ( ErrorCode . INTERNAL_ERROR ) ) ; assertThat ( errorData . getErrorDescription ( ) , is ( "description: java.lang.Exception: blah" ) ) ; verify ( m_Logging ) . error ( exception , "description" ) ; }
Verify the message response wrapper returned contains the expected error message contents for a generic error.
Verify the message response wrapper returned contains the expected error message contents for a generic error .
// create the original request message that the response will be based on // required to be set Don't care what it is though //request to send over mock channel //capture the payload constructed in the message factory //verify Payload //namespace //specific message // verify the error condition was logged including the exception as is