use of org.postgresql.util.ServerErrorMessage in project molgenis by molgenis.
the class PostgreSqlExceptionTranslatorTest method translateDependentObjectsStillExistOneDependentTableSingleDependency.
@Test
public void translateDependentObjectsStillExistOneDependentTableSingleDependency() {
ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
when(serverErrorMessage.getSQLState()).thenReturn("2BP01");
when(serverErrorMessage.getDetail()).thenReturn("constraint my_foreign_key_constraint on table \"myTable\" depends on table \"myDependentTable\"");
// noinspection ThrowableResultOfMethodCallIgnored
MolgenisValidationException e = postgreSqlExceptionTranslator.translateDependentObjectsStillExist(new PSQLException(serverErrorMessage));
assertEquals(e.getMessage(), "Cannot delete entity 'myRefEntity' because entity 'myEntity' depends on it.");
}
Aggregations