use of org.jboss.resteasy.spi.ResteasyUriInfo in project microservice_framework by CJSCommonPlatform.
the class EventPageResourceTest 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<EventEntry> page = new Page<>(emptyList(), pagingLinksBuilder(fixedUrl, fixedUrl).build());
when(eventsPageService.pageEvents(UUID.fromString(streamId), FIRST, BACKWARD, 10, uriInfo)).thenReturn(page);
resource.events(streamId, FIRST, BACKWARD.toString(), 10, uriInfo);
}
use of org.jboss.resteasy.spi.ResteasyUriInfo in project microservice_framework by CJSCommonPlatform.
the class EventPageResourceTest method shouldReturnFeedReturnedByService.
@Test
public void shouldReturnFeedReturnedByService() throws Exception {
final UUID streamId = randomUUID();
final String position = "2";
final String positionValue = "2";
final int pageSize = 10;
final UriInfo uriInfo = new ResteasyUriInfo("" + "/" + streamId, "", "");
final URL fixedUrl = new URL("http://localhost:8080/rest/fixed");
final Page<EventEntry> page = new Page<>(emptyList(), pagingLinksBuilder(fixedUrl, fixedUrl).build());
when(eventsPageService.pageEvents(streamId, position, FORWARD, pageSize, uriInfo)).thenReturn(page);
final JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder();
jsonObjectBuilder.add("key", "value");
when(converter.convert(page)).thenReturn(jsonObjectBuilder.build());
resource.events(streamId.toString(), positionValue, FORWARD.toString(), pageSize, uriInfo);
final ArgumentCaptor<UUID> uuidArgumentCaptor = ArgumentCaptor.forClass(UUID.class);
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(eventsPageService).pageEvents(uuidArgumentCaptor.capture(), positionCaptor.capture(), directionCaptor.capture(), pageSizeCaptor.capture(), uriInfoCaptor.capture());
assertThat(positionCaptor.getValue(), is(position));
assertThat(pageSizeCaptor.getValue(), is(pageSize));
assertThat(uriInfoCaptor.getValue(), is(uriInfo));
assertThat(directionCaptor.getValue(), is(FORWARD));
assertThat(uuidArgumentCaptor.getValue(), is(streamId));
}
use of org.jboss.resteasy.spi.ResteasyUriInfo in project microservice_framework by CJSCommonPlatform.
the class EventPageResourceTest 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<EventEntry> page = new Page<>(emptyList(), pagingLinksBuilder(fixedUrl, fixedUrl).build());
when(eventsPageService.pageEvents(UUID.fromString(streamId), HEAD, FORWARD, 10, uriInfo)).thenReturn(page);
resource.events(streamId, HEAD, FORWARD.toString(), 10, uriInfo);
}
use of org.jboss.resteasy.spi.ResteasyUriInfo in project dubbo by alibaba.
the class DubboSwaggerApiListingResourceTest method test.
@Test
public void test() throws Exception {
DubboSwaggerApiListingResource resource = new DubboSwaggerApiListingResource();
app = mock(Application.class);
sc = mock(ServletConfig.class);
Set<Class<?>> sets = new HashSet<Class<?>>();
sets.add(SwaggerService.class);
when(sc.getServletContext()).thenReturn(mock(ServletContext.class));
when(app.getClasses()).thenReturn(sets);
Response response = resource.getListingJson(app, sc, null, new ResteasyUriInfo(new URI("http://rest.test")));
Assertions.assertNotNull(response);
Swagger swagger = (Swagger) response.getEntity();
Assertions.assertEquals("SwaggerService", swagger.getTags().get(0).getName());
Assertions.assertEquals("/demoService/hello", swagger.getPaths().keySet().toArray()[0].toString());
}
Aggregations