Search in sources :

Example 6 with PgException

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();
    });
}
Also used : Async(io.vertx.ext.unit.Async) PgException(io.vertx.pgclient.PgException) Test(org.junit.Test)

Example 7 with PgException

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();
    });
}
Also used : Async(io.vertx.ext.unit.Async) PgException(io.vertx.pgclient.PgException) Test(org.junit.Test)

Example 8 with PgException

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();
    });
}
Also used : Async(io.vertx.ext.unit.Async) PgException(io.vertx.pgclient.PgException) Test(org.junit.Test)

Example 9 with PgException

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

Example 10 with PgException

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"));
}
Also used : PgException(io.vertx.pgclient.PgException) Test(org.junit.jupiter.api.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