use of io.vertx.pgclient.PgException in project raml-module-builder by folio-org.
the class PgUtilIT method responseUniqueViolationNoMatch422.
@Test
public void responseUniqueViolationNoMatch422(TestContext testContext) throws Exception {
Exception genericDatabaseException = new PgException("", null, "", "fooMessage");
PgExceptionFacade exception = new PgExceptionFacade(genericDatabaseException);
Method respond400 = ResponseImpl.class.getMethod("respond400WithTextPlain", Object.class);
Method respond500 = ResponseImpl.class.getMethod("respond500WithTextPlain", Object.class);
Method respond422 = PgUtil.respond422method(ResponseWith422.class);
Future<Response> future = PgUtil.responseUniqueViolation("mytable", "myid", exception, respond422, respond400, respond500);
assertTrue(future.succeeded());
assertThat(future.result().getStatus(), is(422));
Errors errors = (Errors) future.result().getEntity();
assertThat(errors.getErrors().get(0).getMessage(), containsString("fooMessage"));
}
use of io.vertx.pgclient.PgException in project raml-module-builder by folio-org.
the class PgExceptionUtilTest method assertString.
private void assertString(String sqlstate, String detail, String message, String expected) {
String actual = PgExceptionUtil.badRequestMessage(new PgException(message, null, sqlstate, detail));
assertThat(actual, is(expected));
}
use of io.vertx.pgclient.PgException in project raml-module-builder by folio-org.
the class PgUtilIT method responseForeignKeyViolationNoMatch400.
@Test
public void responseForeignKeyViolationNoMatch400(TestContext testContext) throws Exception {
Exception genericDatabaseException = new PgException("", null, "", "barMessage");
PgExceptionFacade exception = new PgExceptionFacade(genericDatabaseException);
Method respond400 = ResponseImpl.class.getMethod("respond400WithTextPlain", Object.class);
Method respond500 = ResponseImpl.class.getMethod("respond500WithTextPlain", Object.class);
Future<Response> future = PgUtil.responseForeignKeyViolation("mytable", "myid", exception, null, respond400, respond500);
assertTrue(future.succeeded());
assertThat(future.result().getStatus(), is(400));
assertThat(future.result().getEntity().toString(), containsString("barMessage"));
}
Aggregations