Search in sources :

Example 11 with PgException

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"));
}
Also used : Response(javax.ws.rs.core.Response) PostUsersResponse(org.folio.rest.jaxrs.model.Users.PostUsersResponse) Errors(org.folio.rest.jaxrs.model.Errors) Method(java.lang.reflect.Method) PgException(io.vertx.pgclient.PgException) ExpectedException(org.junit.rules.ExpectedException) PgException(io.vertx.pgclient.PgException) Test(org.junit.Test)

Example 12 with PgException

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));
}
Also used : PgException(io.vertx.pgclient.PgException)

Example 13 with PgException

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"));
}
Also used : Response(javax.ws.rs.core.Response) PostUsersResponse(org.folio.rest.jaxrs.model.Users.PostUsersResponse) Method(java.lang.reflect.Method) PgException(io.vertx.pgclient.PgException) ExpectedException(org.junit.rules.ExpectedException) PgException(io.vertx.pgclient.PgException) Test(org.junit.Test)

Aggregations

PgException (io.vertx.pgclient.PgException)13 Test (org.junit.Test)10 Async (io.vertx.ext.unit.Async)5 Method (java.lang.reflect.Method)4 Response (javax.ws.rs.core.Response)4 PostUsersResponse (org.folio.rest.jaxrs.model.Users.PostUsersResponse)4 ExpectedException (org.junit.rules.ExpectedException)4 Errors (org.folio.rest.jaxrs.model.Errors)3 Test (org.junit.jupiter.api.Test)2