use of org.folio.rest.jaxrs.model.Referencing in project raml-module-builder by folio-org.
the class PgUtilIT method putForeignKeyViolation422.
@Test
public void putForeignKeyViolation422(TestContext testContext) {
String user1 = randomUuid();
String user2 = randomUuid();
String refId = randomUuid();
post(testContext, "Folio", user1, 201);
insertReferencing(testContext, refId, user1);
PgUtil.put("referencing", new Referencing().withId(refId).withUserId(user2), refId, 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("Cannot set referencing.userid = " + user2 + " because it does not exist in users.id."));
assertThat(error.getParameters(), hasSize(1));
assertThat(error.getParameters().get(0).getKey(), is("referencing.userid"));
assertThat(error.getParameters().get(0).getValue(), is(user2));
}));
}
use of org.folio.rest.jaxrs.model.Referencing in project raml-module-builder by folio-org.
the class PgUtilIT method deleteByIdForeignKeyViolation422.
@Test
public void deleteByIdForeignKeyViolation422(TestContext testContext) {
String userId = randomUuid();
String refId = randomUuid();
post(testContext, "Folio", userId, 201);
insertReferencing(testContext, refId, userId);
PgUtil.deleteById("users", userId, 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("Cannot delete users.id = " + userId + " because id is still referenced from table referencing"));
assertThat(error.getParameters(), hasSize(1));
assertThat(error.getParameters().get(0).getKey(), is("users.id"));
assertThat(error.getParameters().get(0).getValue(), is(userId));
}));
}
use of org.folio.rest.jaxrs.model.Referencing in project raml-module-builder by folio-org.
the class PgUtilIT method insertReferencing.
private void insertReferencing(TestContext testContext, String id, String userId) {
Async async = testContext.async();
PgUtil.post("referencing", new Referencing().withId(id).withUserId(userId), okapiHeaders, vertx.getOrCreateContext(), ResponseImpl.class, asyncAssertSuccess(testContext, 201, post -> {
async.complete();
}));
async.awaitSuccess(10000);
}
use of org.folio.rest.jaxrs.model.Referencing in project raml-module-builder by folio-org.
the class PgUtilIT method putForeignKeyViolation400.
@Test
public void putForeignKeyViolation400(TestContext testContext) {
String user1 = randomUuid();
String user2 = randomUuid();
String refId = randomUuid();
post(testContext, "Folio", user1, 201);
insertReferencing(testContext, refId, user1);
PgUtil.put("referencing", new Referencing().withId(refId).withUserId(user2), refId, okapiHeaders, vertx.getOrCreateContext(), ResponseImpl.class, asyncAssertSuccess(testContext, 400, "referencing"));
}
Aggregations