use of uk.gov.justice.services.example.cakeshop.query.view.response.CakesView 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))))));
}
use of uk.gov.justice.services.example.cakeshop.query.view.response.CakesView in project microservice_framework by CJSCommonPlatform.
the class CakeServiceTest method shouldReturnCakes.
@Test
public void shouldReturnCakes() throws Exception {
final UUID id = randomUUID();
final UUID id2 = randomUUID();
final String name = "Xmass Cake";
final String name2 = "Easter Cake";
when(cakeRepository.findAll()).thenReturn(asList(new Cake(id, name), new Cake(id2, name2)));
final CakesView cakes = cakeService.cakes();
assertThat(cakes.getCakes().get(0).getId(), is(id));
assertThat(cakes.getCakes().get(0).getName(), is(name));
assertThat(cakes.getCakes().get(1).getId(), is(id2));
assertThat(cakes.getCakes().get(1).getName(), is(name2));
}
Aggregations