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));
}
Aggregations