Search in sources :

Example 1 with CakeView

use of uk.gov.justice.services.example.cakeshop.query.view.response.CakeView in project microservice_framework by CJSCommonPlatform.

the class CakesQueryViewTest method shouldReturnCakes.

@Test
public void shouldReturnCakes() throws Exception {
    final UUID id1 = randomUUID();
    final String name1 = "Chocolate cake";
    final JsonEnvelope query = envelope().with(metadataWithDefaults()).build();
    final UUID id2 = randomUUID();
    final String name2 = "Cheese cake";
    when(service.cakes()).thenReturn(new CakesView(asList(new CakeView(id1, name1), new CakeView(id2, name2))));
    final JsonEnvelope response = queryView.cakes(query);
    assertThat(response, jsonEnvelope().withPayloadOf(payloadIsJson(allOf(withJsonPath("$.cakes[0].id", equalTo(id1.toString())), withJsonPath("$.cakes[0].name", equalTo(name1)), withJsonPath("$.cakes[1].id", equalTo(id2.toString())), withJsonPath("$.cakes[1].name", equalTo(name2))))));
}
Also used : CakeView(uk.gov.justice.services.example.cakeshop.query.view.response.CakeView) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) CakesView(uk.gov.justice.services.example.cakeshop.query.view.response.CakesView) Test(org.junit.Test)

Aggregations

UUID (java.util.UUID)1 UUID.randomUUID (java.util.UUID.randomUUID)1 Test (org.junit.Test)1 CakeView (uk.gov.justice.services.example.cakeshop.query.view.response.CakeView)1 CakesView (uk.gov.justice.services.example.cakeshop.query.view.response.CakesView)1 JsonEnvelope (uk.gov.justice.services.messaging.JsonEnvelope)1