mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/messaging/TestMessageFactoryImpl.java
@Test
    public void testQueueSpecificExceptionResponse() throws IOException
    {
        TerraHarvestMessage request =  createRequestFiller();
        RemoteChannel channel = mock(RemoteChannel.class);
        
        m_SUT.createBaseErrorResponse(request, new AssetException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new CCommException(FormatProblem.ADDRESS_MISMATCH),
                "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new ObjectConverterException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new IllegalStateException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new IllegalArgumentException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new MarshalException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new UnmarshalException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new PersistenceFailedException("blah"), "description").queue(channel);

        //capture the payload constructed in the message factory
        ArgumentCaptor<TerraHarvestPayload> payloadCap = ArgumentCaptor.forClass(TerraHarvestPayload.class);
        verify(m_MessageSender, times(8)).queueMessageResponse(eq(request), payloadCap.capture(), eq(channel));

        List<ErrorCode> errorCodes = new ArrayList<>();
        for (TerraHarvestPayload payload : payloadCap.getAllValues())
        {
            BaseNamespace baseResponseMessage = BaseNamespace.parseFrom(payload.getNamespaceMessage());
            GenericErrorResponseData errorData = GenericErrorResponseData.parseFrom(baseResponseMessage.getData());
            errorCodes.add(errorData.getError());
        }
        assertThat(errorCodes.get(0), is(ErrorCode.ASSET_ERROR));
        assertThat(errorCodes.get(1), is(ErrorCode.CCOMM_ERROR));
        assertThat(errorCodes.get(2), is(ErrorCode.CONVERTER_ERROR));
        assertThat(errorCodes.get(3), is(ErrorCode.ILLEGAL_STATE));
        assertThat(errorCodes.get(4), is(ErrorCode.INVALID_VALUE));
        assertThat(errorCodes.get(5), is(ErrorCode.JAXB_ERROR));
        assertThat(errorCodes.get(6), is(ErrorCode.JAXB_ERROR));
        assertThat(errorCodes.get(7), is(ErrorCode.PERSIST_ERROR));
    }
/**
     * Verify the message response wrapper returned contains the expected error message contents for specific 
     * exceptions.
     */
Verify the message response wrapper returned contains the expected error message contents for specific
exceptions.
Verify the message response wrapper returned contains the expected error message contents for specific exceptions .
@Test
    public void testQueueSpecificExceptionResponse() throws IOException
    {
        TerraHarvestMessage request =  createRequestFiller();
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.createBaseErrorResponse(request, new AssetException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new CCommException(FormatProblem.ADDRESS_MISMATCH),
                "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new ObjectConverterException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new IllegalStateException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new IllegalArgumentException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new MarshalException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new UnmarshalException("blah"), "description").queue(channel);
        m_SUT.createBaseErrorResponse(request, new PersistenceFailedException("blah"), "description").queue(channel);
        ArgumentCaptor<TerraHarvestPayload> payloadCap = ArgumentCaptor.forClass(TerraHarvestPayload.class);
        verify(m_MessageSender, times(8)).queueMessageResponse(eq(request), payloadCap.capture(), eq(channel));
        List<ErrorCode> errorCodes = new ArrayList<>();
        for (TerraHarvestPayload payload : payloadCap.getAllValues())
        {
            BaseNamespace baseResponseMessage = BaseNamespace.parseFrom(payload.getNamespaceMessage());
            GenericErrorResponseData errorData = GenericErrorResponseData.parseFrom(baseResponseMessage.getData());
            errorCodes.add(errorData.getError());
        }
        assertThat(errorCodes.get(0), is(ErrorCode.ASSET_ERROR));
        assertThat(errorCodes.get(1), is(ErrorCode.CCOMM_ERROR));
        assertThat(errorCodes.get(2), is(ErrorCode.CONVERTER_ERROR));
        assertThat(errorCodes.get(3), is(ErrorCode.ILLEGAL_STATE));
        assertThat(errorCodes.get(4), is(ErrorCode.INVALID_VALUE));
        assertThat(errorCodes.get(5), is(ErrorCode.JAXB_ERROR));
        assertThat(errorCodes.get(6), is(ErrorCode.JAXB_ERROR));
        assertThat(errorCodes.get(7), is(ErrorCode.PERSIST_ERROR));
    }
@ Test public void testQueueSpecificExceptionResponse ( ) throws IOException { TerraHarvestMessage request = createRequestFiller ( ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . createBaseErrorResponse ( request , new AssetException ( "blah" ) , "description" ) . queue ( channel ) ; m_SUT . createBaseErrorResponse ( request , new CCommException ( FormatProblem . ADDRESS_MISMATCH ) , "description" ) . queue ( channel ) ; m_SUT . createBaseErrorResponse ( request , new ObjectConverterException ( "blah" ) , "description" ) . queue ( channel ) ; m_SUT . createBaseErrorResponse ( request , new IllegalStateException ( "blah" ) , "description" ) . queue ( channel ) ; m_SUT . createBaseErrorResponse ( request , new IllegalArgumentException ( "blah" ) , "description" ) . queue ( channel ) ; m_SUT . createBaseErrorResponse ( request , new MarshalException ( "blah" ) , "description" ) . queue ( channel ) ; m_SUT . createBaseErrorResponse ( request , new UnmarshalException ( "blah" ) , "description" ) . queue ( channel ) ; m_SUT . createBaseErrorResponse ( request , new PersistenceFailedException ( "blah" ) , "description" ) . queue ( channel ) ; ArgumentCaptor < TerraHarvestPayload > payloadCap = ArgumentCaptor . forClass ( TerraHarvestPayload . class ) ; verify ( m_MessageSender , times ( 8 ) ) . queueMessageResponse ( eq ( request ) , payloadCap . capture ( ) , eq ( channel ) ) ; List < ErrorCode > errorCodes = new ArrayList < > ( ) ; for ( TerraHarvestPayload payload : payloadCap . getAllValues ( ) ) { BaseNamespace baseResponseMessage = BaseNamespace . parseFrom ( payload . getNamespaceMessage ( ) ) ; GenericErrorResponseData errorData = GenericErrorResponseData . parseFrom ( baseResponseMessage . getData ( ) ) ; errorCodes . add ( errorData . getError ( ) ) ; } assertThat ( errorCodes . get ( 0 ) , is ( ErrorCode . ASSET_ERROR ) ) ; assertThat ( errorCodes . get ( 1 ) , is ( ErrorCode . CCOMM_ERROR ) ) ; assertThat ( errorCodes . get ( 2 ) , is ( ErrorCode . CONVERTER_ERROR ) ) ; assertThat ( errorCodes . get ( 3 ) , is ( ErrorCode . ILLEGAL_STATE ) ) ; assertThat ( errorCodes . get ( 4 ) , is ( ErrorCode . INVALID_VALUE ) ) ; assertThat ( errorCodes . get ( 5 ) , is ( ErrorCode . JAXB_ERROR ) ) ; assertThat ( errorCodes . get ( 6 ) , is ( ErrorCode . JAXB_ERROR ) ) ; assertThat ( errorCodes . get ( 7 ) , is ( ErrorCode . PERSIST_ERROR ) ) ; }
Verify the message response wrapper returned contains the expected error message contents for specific
 exceptions.
Verify the message response wrapper returned contains the expected error message contents for specific exceptions .
//capture the payload constructed in the message factory