use of uk.gov.justice.services.eventsourcing.source.api.service.EventStreamPageEntry in project microservice_framework by CJSCommonPlatform.
the class EventStreamPageResourceTest method shouldReturnBadRequestWhenFirstEventsRequestedWithBackwardDirection.
@Test(expected = BadRequestException.class)
public void shouldReturnBadRequestWhenFirstEventsRequestedWithBackwardDirection() throws Exception {
final String streamId = randomUUID().toString();
final UriInfo uriInfo = new ResteasyUriInfo("" + "/" + streamId, "", "");
final URL fixedUrl = new URL("http://localhost:8080/rest/fixed");
final Page<EventStreamPageEntry> page = new Page<>(emptyList(), pagingLinksBuilder(fixedUrl, fixedUrl).build());
when(eventsStreamPageService.pageOfEventStream(FIRST, BACKWARD, PAGE_SIZE, uriInfo)).thenReturn(page);
resource.events(FIRST, BACKWARD.toString(), PAGE_SIZE, uriInfo);
}
use of uk.gov.justice.services.eventsourcing.source.api.service.EventStreamPageEntry in project microservice_framework by CJSCommonPlatform.
the class EventStreamPageResourceTest method shouldReturnFeedReturnedByService.
@Test
public void shouldReturnFeedReturnedByService() throws Exception {
final UUID streamId = randomUUID();
final UriInfo uriInfo = new ResteasyUriInfo("" + "/" + streamId, "", "");
final URL fixedUrl = new URL("http://localhost:8080/rest/fixed");
final Page<EventStreamPageEntry> page = new Page<>(emptyList(), pagingLinksBuilder(fixedUrl, fixedUrl).build());
final String position = FIRST;
when(eventsStreamPageService.pageOfEventStream(position, FORWARD, PAGE_SIZE, uriInfo)).thenReturn(page);
final JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder();
jsonObjectBuilder.add("key", "value");
when(converter.convert(page)).thenReturn(jsonObjectBuilder.build());
resource.events(FIRST, FORWARD.toString(), PAGE_SIZE, uriInfo);
final ArgumentCaptor<String> positionCaptor = ArgumentCaptor.forClass(String.class);
final ArgumentCaptor<Integer> pageSizeCaptor = ArgumentCaptor.forClass(Integer.class);
final ArgumentCaptor<UriInfo> uriInfoCaptor = ArgumentCaptor.forClass(UriInfo.class);
final ArgumentCaptor<Direction> directionCaptor = ArgumentCaptor.forClass(Direction.class);
verify(eventsStreamPageService).pageOfEventStream(positionCaptor.capture(), directionCaptor.capture(), pageSizeCaptor.capture(), uriInfoCaptor.capture());
assertThat(positionCaptor.getValue(), is(position));
assertThat(pageSizeCaptor.getValue(), is(PAGE_SIZE));
assertThat(uriInfoCaptor.getValue(), is(uriInfo));
assertThat(directionCaptor.getValue(), is(FORWARD));
}
use of uk.gov.justice.services.eventsourcing.source.api.service.EventStreamPageEntry in project microservice_framework by CJSCommonPlatform.
the class EventStreamPageResourceTest method shouldReturnBadRequestWhenHeadEventsRequestedWithForwardDirection.
@Test(expected = BadRequestException.class)
public void shouldReturnBadRequestWhenHeadEventsRequestedWithForwardDirection() throws Exception {
final String streamId = randomUUID().toString();
final UriInfo uriInfo = new ResteasyUriInfo("" + "/" + streamId, "", "");
final URL fixedUrl = new URL("http://localhost:8080/rest/fixed");
final Page<EventStreamPageEntry> page = new Page<>(emptyList(), pagingLinksBuilder(fixedUrl, fixedUrl).build());
when(eventsStreamPageService.pageOfEventStream(HEAD, FORWARD, PAGE_SIZE, uriInfo)).thenReturn(page);
resource.events(HEAD, FORWARD.toString(), PAGE_SIZE, uriInfo);
}
Aggregations