use of io.vertx.pgclient.PgException in project raml-module-builder by folio-org.
the class ValidationHelperTest method fkTest.
@Test
public void fkTest(TestContext context) {
Async async = context.async();
Throwable t = new PgException("insert or update on table \"item\" violates foreign key constraint \"item_permanentloantypeid_fkey\"", null, "23503", "Key (permanentloantypeid)=(2b94c631-fca9-4892-a730-03ee529ffe27) is not present in table \"loan_type\".");
ValidationHelper.handleError(t, r -> {
context.assertEquals(422, r.result().getStatus());
async.complete();
});
}
use of io.vertx.pgclient.PgException in project raml-module-builder by folio-org.
the class ValidationHelperTest method authTest.
@Test
public void authTest(TestContext context) {
Async async = context.async();
Throwable t = new PgException("password authentication failed for user \"harvard9_mod_configuration\"", null, "28P01", null);
ValidationHelper.handleError(t, r -> {
context.assertEquals(401, r.result().getStatus());
async.complete();
});
}
use of io.vertx.pgclient.PgException in project raml-module-builder by folio-org.
the class ValidationHelperTest method dupTest.
@Test
public void dupTest(TestContext context) {
Async async = context.async();
Throwable t = new PgException("duplicate key value violates unique constraint \"123456\"", null, "23505", "Key (_id)=(55835c7c-2885-44f4-96ac-f03525b8e608) already exists.");
ValidationHelper.handleError(t, r -> {
context.assertEquals(422, r.result().getStatus());
async.complete();
});
}
use of io.vertx.pgclient.PgException in project raml-module-builder by folio-org.
the class PgExceptionFacadeTest method isInvalidTextRepresentation.
@Test
void isInvalidTextRepresentation() {
PgExceptionFacade f = new PgExceptionFacade(new PgException(null, null, "22P02", null));
assertThat(f.isInvalidTextRepresentation(), is(true));
PgExceptionFacade f2 = new PgExceptionFacade(new PgException(null, null, "22P03", null));
assertThat(f2.isInvalidTextRepresentation(), is(false));
}
use of io.vertx.pgclient.PgException in project raml-module-builder by folio-org.
the class PgExceptionFacadeTest method getter.
@Test
void getter() {
PgExceptionFacade f = new PgExceptionFacade(new PgException("msg", "FINAL WARNING", "22P02", "very bad"));
assertThat(f.getMessage(), is("msg"));
assertThat(f.getSeverity(), is("FINAL WARNING"));
assertThat(f.getSqlState(), is("22P02"));
assertThat(f.getDetail(), is("very bad"));
Map<Character, String> fields = f.getFields();
assertThat(fields.get('M'), is("msg"));
assertThat(fields.get('S'), is("FINAL WARNING"));
assertThat(fields.get('C'), is("22P02"));
assertThat(fields.get('D'), is("very bad"));
}
Aggregations