use of org.folio.rest.jaxrs.model.User in project raml-module-builder by folio-org.
the class PgUtilIT method assertStatusAndUser.
/**
* Assert that response has the httpStatus and its result is a User with expected username and uuid.
* uuid=null accepts any uuid. Returns the uuid of the User in response.
*/
private String assertStatusAndUser(TestContext testContext, AsyncResult<Response> result, int httpStatus, String username, String uuid) {
testContext.assertTrue(result.succeeded(), "succeeded()");
Response response = result.result();
testContext.assertEquals(httpStatus, response.getStatus(), "status of entity=" + response.getEntity());
if (response.getEntity() == null) {
testContext.fail("Expected response with a User instance but it was null");
return null;
}
if (!(response.getEntity() instanceof User)) {
testContext.fail("Expected response with a User instance but type was " + response.getEntity().getClass().getName());
return null;
}
User user = (User) response.getEntity();
testContext.assertEquals(username, user.getUsername(), "getUsername()");
if (uuid != null) {
testContext.assertEquals(uuid, user.getId(), "User::getId()");
}
return user.getId();
}
use of org.folio.rest.jaxrs.model.User in project raml-module-builder by folio-org.
the class PgUtilIT method responseValueWithNullsFailResponseMethod.
@Test
public void responseValueWithNullsFailResponseMethod(TestContext testContext) throws Exception {
Method respond200 = ResponseImpl.class.getMethod("respond200WithApplicationJson", User.class);
Future<Response> future = PgUtil.response(new User(), respond200, null);
assertTrue(future.failed());
assertThat(future.cause(), is(instanceOf(NullPointerException.class)));
}
use of org.folio.rest.jaxrs.model.User in project raml-module-builder by folio-org.
the class PgUtilIT method postResponseWithUser201MethodAndTrigger.
@Test
public void postResponseWithUser201MethodAndTrigger(TestContext testContext) {
String uuid = randomUuid();
PgUtil.post("users", new User().withUsername("dummy").withId(uuid), okapiHeaders, vertx.getOrCreateContext(), ResponseWithUserFor201Method.class, testContext.asyncAssertSuccess(result -> {
assertThat(result.getStatus(), is(201));
assertThat(((User) result.getEntity()).getDummy(), is(DUMMY_VAL));
}));
}
use of org.folio.rest.jaxrs.model.User in project raml-module-builder by folio-org.
the class PgUtilIT method responseLocation3Nulls.
@Test
public void responseLocation3Nulls(TestContext testContext) throws Exception {
Method respond500 = ResponseImpl.class.getMethod("respond500WithTextPlain", Object.class);
Future<Response> future = PgUtil.response(new User(), "localhost", null, null, null, respond500);
assertTrue(future.succeeded());
assertThat(future.result().getStatus(), is(500));
}
use of org.folio.rest.jaxrs.model.User in project raml-module-builder by folio-org.
the class PgUtilIT method responseValueWithExceptionInFailResponseMethod.
@Test
public void responseValueWithExceptionInFailResponseMethod(TestContext testContext) throws Exception {
Method exceptionMethod = PgUtilIT.class.getMethod("exceptionMethod", Object.class);
Future<Response> future = PgUtil.response(new User(), exceptionMethod, exceptionMethod);
assertTrue(future.failed());
assertThat(future.cause().getCause().getMessage(), is("some runtime exception"));
}
Aggregations