mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestTerraHarvestMessageUtil.java
@Test
    public final void testBuildErrorResponseMessage() throws InvalidProtocolBufferException
    {
        //build the data first
        final GenericErrorResponseData genericErrorResponseMessage = GenericErrorResponseData.newBuilder().
                setError(ErrorCode.ILLEGAL_STATE).
                setErrorDescription("errorrrrrr").
                build();
    
    // build a base namespace message
        final BaseNamespace baseMessage = BaseNamespace.newBuilder().
                setType(BaseMessageType.GenericErrorResponse).
                setData(genericErrorResponseMessage.toByteString()).
                build();
       //build a TerraHarvestPayLoad message
        final TerraHarvestPayload payLoad = TerraHarvestPayload.newBuilder().
                setNamespace(Namespace.Base).
                setNamespaceMessage(baseMessage.toByteString()).
                build();
       
        TerraHarvestMessage requestMessage = TerraHarvestMessageUtil.getPartialMessage().
                setSourceId(0).
                setDestId(1).
                setMessageId(100).             
                setTerraHarvestPayload(payLoad.toByteString()).
                build();
        
        TerraHarvestMessage testMessage = TerraHarvestMessageUtil.buildErrorResponseMessage(requestMessage, 
                ErrorCode.ILLEGAL_STATE, "errorrrrrr");

        TerraHarvestPayload payLoadTest = TerraHarvestPayload.parseFrom(testMessage.getTerraHarvestPayload());
        BaseNamespace baseTest = BaseNamespace.parseFrom(payLoadTest.getNamespaceMessage()); 
        GenericErrorResponseData genericErrorResponseTest = GenericErrorResponseData.parseFrom(baseTest.getData());
        
        assertThat(testMessage.getVersion(), is(RemoteConstants.SPEC_VERSION));
        assertThat(genericErrorResponseTest.getError(), is(ErrorCode.ILLEGAL_STATE));
        assertThat(genericErrorResponseTest.getErrorDescription(), is("errorrrrrr"));
        assertThat(testMessage.getSourceId(), is(1));
        assertThat(testMessage.getDestId(), is(requestMessage.getSourceId()));
        assertThat(testMessage.getMessageId(), is(requestMessage.getMessageId()));
        assertThat(payLoadTest.getNamespace(), is(Namespace.Base));
        assertThat(payLoadTest.getNamespaceMessage(), is(baseMessage.toByteString()));
    }
/**
     * Verify that a error response message can be built, and has the correct values from the util class.
     * 
     */
Verify that a error response message can be built, and has the correct values from the util class.
Verify that a error response message can be built and has the correct values from the util class .
@Test
    public final void testBuildErrorResponseMessage() throws InvalidProtocolBufferException
    {
        final GenericErrorResponseData genericErrorResponseMessage = GenericErrorResponseData.newBuilder().
                setError(ErrorCode.ILLEGAL_STATE).
                setErrorDescription("errorrrrrr").
                build();
        final BaseNamespace baseMessage = BaseNamespace.newBuilder().
                setType(BaseMessageType.GenericErrorResponse).
                setData(genericErrorResponseMessage.toByteString()).
                build();
        final TerraHarvestPayload payLoad = TerraHarvestPayload.newBuilder().
                setNamespace(Namespace.Base).
                setNamespaceMessage(baseMessage.toByteString()).
                build();
        TerraHarvestMessage requestMessage = TerraHarvestMessageUtil.getPartialMessage().
                setSourceId(0).
                setDestId(1).
                setMessageId(100).             
                setTerraHarvestPayload(payLoad.toByteString()).
                build();
        TerraHarvestMessage testMessage = TerraHarvestMessageUtil.buildErrorResponseMessage(requestMessage, 
                ErrorCode.ILLEGAL_STATE, "errorrrrrr");
        TerraHarvestPayload payLoadTest = TerraHarvestPayload.parseFrom(testMessage.getTerraHarvestPayload());
        BaseNamespace baseTest = BaseNamespace.parseFrom(payLoadTest.getNamespaceMessage()); 
        GenericErrorResponseData genericErrorResponseTest = GenericErrorResponseData.parseFrom(baseTest.getData());
        assertThat(testMessage.getVersion(), is(RemoteConstants.SPEC_VERSION));
        assertThat(genericErrorResponseTest.getError(), is(ErrorCode.ILLEGAL_STATE));
        assertThat(genericErrorResponseTest.getErrorDescription(), is("errorrrrrr"));
        assertThat(testMessage.getSourceId(), is(1));
        assertThat(testMessage.getDestId(), is(requestMessage.getSourceId()));
        assertThat(testMessage.getMessageId(), is(requestMessage.getMessageId()));
        assertThat(payLoadTest.getNamespace(), is(Namespace.Base));
        assertThat(payLoadTest.getNamespaceMessage(), is(baseMessage.toByteString()));
    }
@ Test public final void testBuildErrorResponseMessage ( ) throws InvalidProtocolBufferException { final GenericErrorResponseData genericErrorResponseMessage = GenericErrorResponseData . newBuilder ( ) . setError ( ErrorCode . ILLEGAL_STATE ) . setErrorDescription ( "errorrrrrr" ) . build ( ) ; final BaseNamespace baseMessage = BaseNamespace . newBuilder ( ) . setType ( BaseMessageType . GenericErrorResponse ) . setData ( genericErrorResponseMessage . toByteString ( ) ) . build ( ) ; final TerraHarvestPayload payLoad = TerraHarvestPayload . newBuilder ( ) . setNamespace ( Namespace . Base ) . setNamespaceMessage ( baseMessage . toByteString ( ) ) . build ( ) ; TerraHarvestMessage requestMessage = TerraHarvestMessageUtil . getPartialMessage ( ) . setSourceId ( 0 ) . setDestId ( 1 ) . setMessageId ( 100 ) . setTerraHarvestPayload ( payLoad . toByteString ( ) ) . build ( ) ; TerraHarvestMessage testMessage = TerraHarvestMessageUtil . buildErrorResponseMessage ( requestMessage , ErrorCode . ILLEGAL_STATE , "errorrrrrr" ) ; TerraHarvestPayload payLoadTest = TerraHarvestPayload . parseFrom ( testMessage . getTerraHarvestPayload ( ) ) ; BaseNamespace baseTest = BaseNamespace . parseFrom ( payLoadTest . getNamespaceMessage ( ) ) ; GenericErrorResponseData genericErrorResponseTest = GenericErrorResponseData . parseFrom ( baseTest . getData ( ) ) ; assertThat ( testMessage . getVersion ( ) , is ( RemoteConstants . SPEC_VERSION ) ) ; assertThat ( genericErrorResponseTest . getError ( ) , is ( ErrorCode . ILLEGAL_STATE ) ) ; assertThat ( genericErrorResponseTest . getErrorDescription ( ) , is ( "errorrrrrr" ) ) ; assertThat ( testMessage . getSourceId ( ) , is ( 1 ) ) ; assertThat ( testMessage . getDestId ( ) , is ( requestMessage . getSourceId ( ) ) ) ; assertThat ( testMessage . getMessageId ( ) , is ( requestMessage . getMessageId ( ) ) ) ; assertThat ( payLoadTest . getNamespace ( ) , is ( Namespace . Base ) ) ; assertThat ( payLoadTest . getNamespaceMessage ( ) , is ( baseMessage . toByteString ( ) ) ) ; }
Verify that a error response message can be built, and has the correct values from the util class.
Verify that a error response message can be built and has the correct values from the util class .
//build the data first // build a base namespace message //build a TerraHarvestPayLoad message