use of org.folio.rest.jaxrs.model.User in project raml-module-builder by folio-org.
the class PgUtilIT method responseValueWithExceptionInValueMethod.
@Test
public void responseValueWithExceptionInValueMethod(TestContext testContext) throws Exception {
Method exceptionMethod = PgUtilIT.class.getMethod("exceptionMethod", Object.class);
Method respond500 = ResponseImpl.class.getMethod("respond500WithTextPlain", Object.class);
Future<Response> future = PgUtil.response(new User(), exceptionMethod, respond500);
assertTrue(future.succeeded());
Response response = future.result();
assertThat(response.getStatus(), is(500));
assertThat(response.getEntity(), is("some runtime exception"));
}
use of org.folio.rest.jaxrs.model.User in project raml-module-builder by folio-org.
the class PgUtilIT method responseLocation4Nulls.
@Test
public void responseLocation4Nulls(TestContext testContext) {
Future<Response> future = PgUtil.response(new User(), "localhost", null, null, null, 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 postDuplicateId422.
@Test
public void postDuplicateId422(TestContext testContext) {
String uuid = randomUuid();
post(testContext, "Snow-White", uuid, 201);
PgUtil.post("users", new User().withUsername("Rose-Red").withId(uuid), okapiHeaders, vertx.getOrCreateContext(), ResponseWith422.class, asyncAssertSuccess(testContext, 422, response -> {
Errors errors = (Errors) response.result().getEntity();
assertThat(errors.getErrors(), hasSize(1));
Error error = errors.getErrors().get(0);
assertThat(error.getMessage(), containsString("id value already exists in table users: " + uuid));
assertThat(error.getParameters(), hasSize(1));
assertThat(error.getParameters().get(0).getKey(), is("id"));
assertThat(error.getParameters().get(0).getValue(), is(uuid));
}));
}
use of org.folio.rest.jaxrs.model.User in project raml-module-builder by folio-org.
the class PgUtilIT method put.
@Test
public void put(TestContext testContext) {
String uuid = randomUuid();
post(testContext, "Pippilotta", uuid, 201);
getUser(uuid).compose(user -> PgUtil.put("users", user.withUsername("Momo").withId(randomUuid()), uuid, okapiHeaders, vertx.getOrCreateContext(), Users.PutUsersByUserIdResponse.class)).onComplete(asyncAssertSuccess(testContext, 204, put -> assertGetById(testContext, uuid, "Momo")));
}
use of org.folio.rest.jaxrs.model.User in project raml-module-builder by folio-org.
the class PgUtilIT method putDuplicateUuid.
@Test
public void putDuplicateUuid(TestContext testContext) {
String uuid = randomUuid();
execute(testContext, "INSERT INTO " + schema + ".duplicateid VALUES " + "('" + uuid + "', '{}')," + "('" + uuid + "', '{}')");
PgUtil.put("duplicateid", new User(), uuid, okapiHeaders, vertx.getOrCreateContext(), Users.PutUsersByUserIdResponse.class, asyncAssertSuccess(testContext, 500, "Updated 2 records in duplicateid for id: " + uuid));
}
Aggregations