Search in sources :

Example 6 with Envelope

use of uk.gov.justice.services.messaging.Envelope in project microservice_framework by CJSCommonPlatform.

the class HandlerMethodTest method shouldHandlePojoSynchronously.

@Test
public void shouldHandlePojoSynchronously() {
    final TestPojo testPojo = new TestPojo();
    final String payloadId = "3f47ab7e-aecc-4cec-9246-c32066ef5ba1";
    final String payloadName = "payload name";
    final long payloadVersion = 200L;
    testPojo.setPayloadId(payloadId);
    testPojo.setPayloadName(payloadName);
    testPojo.setPayloadVersion(payloadVersion);
    final Metadata metadata = Envelope.metadataBuilder().withId(UUID.randomUUID()).withName("test").build();
    final Envelope<TestPojo> requestPojoEnvelope = Envelope.envelopeFrom(metadata, testPojo);
    final Envelope<TestPojo> result = syncPojoHandlerInstance().execute(requestPojoEnvelope);
    verify(synchronousPojoCommandHandler).handles(any(Envelope.class));
    final TestPojo resultPojo = result.payload();
    assertThat(resultPojo.getPayloadId(), is(payloadId));
    assertThat(resultPojo.getPayloadName(), is(payloadName));
    assertThat(resultPojo.getPayloadVersion(), is(payloadVersion));
}
Also used : Metadata(uk.gov.justice.services.messaging.Metadata) Envelope(uk.gov.justice.services.messaging.Envelope) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 Envelope (uk.gov.justice.services.messaging.Envelope)6 JsonEnvelope (uk.gov.justice.services.messaging.JsonEnvelope)6 JsonValue (javax.json.JsonValue)5 Metadata (uk.gov.justice.services.messaging.Metadata)1