use of org.killbill.billing.jaxrs.util.JaxrsUriBuilder in project killbill by killbill.
the class TestBuildResponse method testUriBuilderWithPathLikeUrlAndNonRoot.
@Test(groups = "fast", description = "Tests Uri Builder with Path Like URL and non root Location")
public void testUriBuilderWithPathLikeUrlAndNonRoot() throws Exception {
UUID objectId = UUID.randomUUID();
final UriInfo uriInfo = mock(UriInfo.class);
URI uri = URI.create("http://localhost:8080/killbill");
when(uriInfo.getBaseUri()).thenReturn(uri);
JaxrsConfig jaxrsConfig = mock(JaxrsConfig.class);
when(jaxrsConfig.isJaxrsLocationFullUrl()).thenReturn(false);
JaxrsUriBuilder uriBuilder = new JaxrsUriBuilder(jaxrsConfig);
Response response = uriBuilder.buildResponse(uriInfo, AccountResource.class, "getAccount", objectId, mockRequest(uriInfo));
assertEquals(response.getStatus(), Status.CREATED.getStatusCode());
assertEquals(response.getMetadata().get("Location").get(0), "/killbill/1.0/kb/accounts/" + objectId.toString());
}
use of org.killbill.billing.jaxrs.util.JaxrsUriBuilder in project killbill by killbill.
the class TestBuildResponse method testUriBuilderWithPathLikeUrlAndRoot.
@Test(groups = "fast", description = "Tests Uri Builder with Path Like URL and root Location")
public void testUriBuilderWithPathLikeUrlAndRoot() throws Exception {
UUID objectId = UUID.randomUUID();
final UriInfo uriInfo = mock(UriInfo.class);
URI uri = URI.create("http://localhost:8080");
when(uriInfo.getBaseUri()).thenReturn(uri);
JaxrsConfig jaxrsConfig = mock(JaxrsConfig.class);
when(jaxrsConfig.isJaxrsLocationFullUrl()).thenReturn(false);
JaxrsUriBuilder uriBuilder = new JaxrsUriBuilder(jaxrsConfig);
Response response = uriBuilder.buildResponse(uriInfo, AccountResource.class, "getAccount", objectId, mockRequest(uriInfo));
assertEquals(response.getStatus(), Status.CREATED.getStatusCode());
assertEquals(response.getMetadata().get("Location").get(0), "/1.0/kb/accounts/" + objectId.toString());
}
use of org.killbill.billing.jaxrs.util.JaxrsUriBuilder in project killbill by killbill.
the class TestBuildResponse method testUriBuilderWithoutPathLikeUrlAndRoot.
@Test(groups = "fast", description = "Tests Uri Builder with Full URL and root Location")
public void testUriBuilderWithoutPathLikeUrlAndRoot() throws Exception {
UUID objectId = UUID.randomUUID();
final UriInfo uriInfo = mock(UriInfo.class);
URI uri = URI.create("http://localhost:8080");
when(uriInfo.getBaseUri()).thenReturn(uri);
when(uriInfo.getAbsolutePath()).thenReturn(uri);
JaxrsConfig jaxrsConfig = mock(JaxrsConfig.class);
when(jaxrsConfig.isJaxrsLocationFullUrl()).thenReturn(true);
JaxrsUriBuilder uriBuilder = new JaxrsUriBuilder(jaxrsConfig);
Response response = uriBuilder.buildResponse(uriInfo, AccountResource.class, "getAccount", objectId, mockRequest(uriInfo));
assertEquals(response.getStatus(), Status.CREATED.getStatusCode());
assertEquals(response.getMetadata().get("Location").get(0).toString(), uri.toString() + "/1.0/kb/accounts/" + objectId.toString());
}
use of org.killbill.billing.jaxrs.util.JaxrsUriBuilder in project killbill by killbill.
the class TestBuildResponse method testUriBuilderWithoutPathLikeUrlAndNonRoot.
@Test(groups = "fast", description = "Tests Uri Builder with Full URL and non root Location")
public void testUriBuilderWithoutPathLikeUrlAndNonRoot() throws Exception {
UUID objectId = UUID.randomUUID();
final UriInfo uriInfo = mock(UriInfo.class);
URI uri = URI.create("http://localhost:8080/killbill");
when(uriInfo.getBaseUri()).thenReturn(uri);
when(uriInfo.getAbsolutePath()).thenReturn(uri);
JaxrsConfig jaxrsConfig = mock(JaxrsConfig.class);
when(jaxrsConfig.isJaxrsLocationFullUrl()).thenReturn(true);
JaxrsUriBuilder uriBuilder = new JaxrsUriBuilder(jaxrsConfig);
Response response = uriBuilder.buildResponse(uriInfo, AccountResource.class, "getAccount", objectId, mockRequest(uriInfo));
assertEquals(response.getStatus(), Status.CREATED.getStatusCode());
assertEquals(response.getMetadata().get("Location").get(0).toString(), uri.toString() + "/1.0/kb/accounts/" + objectId.toString());
}
Aggregations