org.postgresql.util.ServerErrorMessage Java Examples
The following examples show how to use
org.postgresql.util.ServerErrorMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 6 votes |
@Test void translateForeignKeyViolationStillReferenced() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("23503"); when(serverErrorMessage.getTable()).thenReturn("myTable"); when(serverErrorMessage.getMessage()) .thenReturn( "update or delete on table \"myDependentTable\" violates foreign key constraint \"myTable_myAttr_fkey\" on table \"myTable\""); when(serverErrorMessage.getDetail()) .thenReturn("Key (myColumn)=(myValue) is still referenced from table \"myTable\""); //noinspection ThrowableResultOfMethodCallIgnored Exception e = postgreSqlExceptionTranslator.translateForeignKeyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("entityTypeId:myEntity attributeName:myAttr value:myValue", e.getMessage()); assertTrue(e instanceof ValueReferencedException); }
Example #2
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 6 votes |
@Test void translateUniqueKeyViolationCompositeKey() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("23505"); when(serverErrorMessage.getTable()).thenReturn("myTable"); when(serverErrorMessage.getDetail()) .thenReturn("Key (myIdColumn, myColumn)=(myIdValue, myValue) already exists."); //noinspection ThrowableResultOfMethodCallIgnored Exception e = postgreSqlExceptionTranslator.translateUniqueKeyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals( "entityTypeId:myEntity attributeName:myAttr entityId:myIdValue value:myValue", e.getMessage()); assertTrue(e instanceof ListValueAlreadyExistsException); }
Example #3
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateUniqueKeyViolationKeyIsDuplicatedDoubleQuotes() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("23505"); when(serverErrorMessage.getTable()).thenReturn("myTable"); when(serverErrorMessage.getDetail()).thenReturn("Key (\"myColumn\")=(myValue) is duplicated."); //noinspection ThrowableResultOfMethodCallIgnored Exception e = postgreSqlExceptionTranslator.translateUniqueKeyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("entityTypeId:myEntity attributeName:myAttr value:myValue", e.getMessage()); assertTrue(e instanceof DuplicateValueException); }
Example #4
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateForeignKeyViolationBadMessage() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("23503"); when(serverErrorMessage.getTable()).thenReturn("mytable"); when(serverErrorMessage.getDetail()).thenReturn("xxxyyyyzzzz"); //noinspection ThrowableResultOfMethodCallIgnored assertThrows( RuntimeException.class, () -> postgreSqlExceptionTranslator.translateForeignKeyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage))); }
Example #5
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateForeignKeyViolationCannotResolveAttribute() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("23503"); when(serverErrorMessage.getTable()).thenReturn("myTable"); when(serverErrorMessage.getDetail()).thenReturn("... (myUnknownColumn) ... (myValue) ..."); //noinspection ThrowableResultOfMethodCallIgnored Exception e = postgreSqlExceptionTranslator.translateForeignKeyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("entityTypeId:myEntity attributeName:null value:myValue", e.getMessage()); assertTrue(e instanceof UnknownValueReferenceException); }
Example #6
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateForeignKeyViolationCannotResolveEntityType() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("23503"); when(serverErrorMessage.getTable()).thenReturn("myUnknownTable"); when(serverErrorMessage.getDetail()).thenReturn("... (myColumn) ... (myValue) ..."); //noinspection ThrowableResultOfMethodCallIgnored Exception e = postgreSqlExceptionTranslator.translateForeignKeyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("entityTypeId:null attributeName:null value:myValue", e.getMessage()); assertTrue(e instanceof UnknownValueReferenceException); }
Example #7
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateUniqueKeyViolation() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("23505"); when(serverErrorMessage.getTable()).thenReturn("myTable"); when(serverErrorMessage.getDetail()).thenReturn("Key (myColumn)=(myValue) already exists."); //noinspection ThrowableResultOfMethodCallIgnored Exception e = postgreSqlExceptionTranslator.translateUniqueKeyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("entityTypeId:myEntity attributeName:myAttr value:myValue", e.getMessage()); assertTrue(e instanceof ValueAlreadyExistsException); }
Example #8
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateUniqueKeyViolationDoubleQuotes() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("23505"); when(serverErrorMessage.getTable()).thenReturn("myTable"); when(serverErrorMessage.getDetail()).thenReturn("Key (\"myColumn\")=(myValue) already exists."); //noinspection ThrowableResultOfMethodCallIgnored Exception e = postgreSqlExceptionTranslator.translateUniqueKeyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("entityTypeId:myEntity attributeName:myAttr value:myValue", e.getMessage()); assertTrue(e instanceof ValueAlreadyExistsException); }
Example #9
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateUniqueKeyViolationKeyIsDuplicated() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("23505"); when(serverErrorMessage.getTable()).thenReturn("myTable"); when(serverErrorMessage.getDetail()).thenReturn("Key (myColumn)=(myValue) is duplicated."); //noinspection ThrowableResultOfMethodCallIgnored Exception e = postgreSqlExceptionTranslator.translateUniqueKeyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("entityTypeId:myEntity attributeName:myAttr value:myValue", e.getMessage()); assertTrue(e instanceof DuplicateValueException); }
Example #10
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateForeignKeyViolationNotPresent() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("23503"); when(serverErrorMessage.getTable()).thenReturn("myTable"); when(serverErrorMessage.getDetail()) .thenReturn("Key (myColumn)=(myValue) is not present in table \"myTable\""); //noinspection ThrowableResultOfMethodCallIgnored Exception e = postgreSqlExceptionTranslator.translateForeignKeyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("entityTypeId:myEntity attributeName:myAttr value:myValue", e.getMessage()); assertTrue(e instanceof UnknownValueReferenceException); }
Example #11
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateUniqueKeyViolationBadMessage() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("23505"); when(serverErrorMessage.getTable()).thenReturn("mytable"); when(serverErrorMessage.getDetail()).thenReturn("xxxyyyyzzz"); //noinspection ThrowableResultOfMethodCallIgnored assertThrows( RuntimeException.class, () -> postgreSqlExceptionTranslator.translateUniqueKeyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage))); }
Example #12
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateInvalidIntegerExceptionInteger() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getMessage()).thenReturn("invalid input syntax for integer: \"str1\""); //noinspection ThrowableResultOfMethodCallIgnored InvalidValueTypeException e = PostgreSqlExceptionTranslator.translateInvalidIntegerException( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("value:str1 type:INT or LONG", e.getMessage()); }
Example #13
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateInvalidIntegerExceptionBoolean() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getMessage()) .thenReturn("invalid input syntax for type boolean: \"str1\""); //noinspection ThrowableResultOfMethodCallIgnored InvalidValueTypeException e = PostgreSqlExceptionTranslator.translateInvalidIntegerException( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("value:str1 type:BOOL", e.getMessage()); }
Example #14
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateInvalidIntegerExceptionDouble() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getMessage()) .thenReturn("invalid input syntax for type double precision: \"str1\""); //noinspection ThrowableResultOfMethodCallIgnored InvalidValueTypeException e = PostgreSqlExceptionTranslator.translateInvalidIntegerException( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("value:str1 type:DECIMAL", e.getMessage()); }
Example #15
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateInvalidIntegerExceptionDate() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getMessage()) .thenReturn("invalid input syntax for type date: \"str1\""); //noinspection ThrowableResultOfMethodCallIgnored InvalidValueTypeException e = PostgreSqlExceptionTranslator.translateInvalidIntegerException( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("value:str1 type:DATE", e.getMessage()); }
Example #16
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateInvalidIntegerExceptionDateTime() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getMessage()) .thenReturn("invalid input syntax for type timestamp with time zone: \"str1\""); //noinspection ThrowableResultOfMethodCallIgnored InvalidValueTypeException e = PostgreSqlExceptionTranslator.translateInvalidIntegerException( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("value:str1 type:DATE_TIME", e.getMessage()); }
Example #17
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateCheckConstraintViolation() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getTable()).thenReturn("myTable"); when(serverErrorMessage.getConstraint()).thenReturn("myTable_myColumn_chk"); //noinspection ThrowableResultOfMethodCallIgnored UnknownEnumValueException e = postgreSqlExceptionTranslator.translateCheckConstraintViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("entityTypeId:myEntity attributeName:myAttr", e.getMessage()); }
Example #18
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateUndefinedColumnException() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getSQLState()).thenReturn("42703"); when(serverErrorMessage.getMessage()) .thenReturn("Undefined column: 7 ERROR: column \"test\" does not exist"); //noinspection ThrowableResultOfMethodCallIgnored Exception e = PostgreSqlExceptionTranslator.translateUndefinedColumnException( new PSQLException(serverErrorMessage)); assertEquals("Undefined column: 7 ERROR: column \"test\" does not exist", e.getMessage()); }
Example #19
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateReadonlyViolationNoDoubleQuotes() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getMessage()) .thenReturn( "Updating read-only column myColumn of table myTable with id [abc] is not allowed"); //noinspection ThrowableResultOfMethodCallIgnored ReadonlyValueException e = postgreSqlExceptionTranslator.translateReadonlyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("entityTypeId:myEntity attributeName:myAttr entityId:abc", e.getMessage()); }
Example #20
Source File: PostgreSQLComBindExecutorTest.java From shardingsphere with Apache License 2.0 | 5 votes |
@Test @SneakyThrows public void assertExecuteHasError() { PostgreSQLComBindExecutor postgreSQLComBindExecutor = new PostgreSQLComBindExecutor(mock(PostgreSQLComBindPacket.class), null); FieldSetter.setField(postgreSQLComBindExecutor, PostgreSQLComBindExecutor.class.getDeclaredField("databaseCommunicationEngine"), databaseCommunicationEngine); ErrorResponse errorResponse = new ErrorResponse(new PSQLException(mock(ServerErrorMessage.class))); when(databaseCommunicationEngine.execute()).thenReturn(errorResponse); Assert.assertThat(((LinkedList) postgreSQLComBindExecutor.execute()).get(1), Matchers.instanceOf(PostgreSQLErrorResponsePacket.class)); Assert.assertThat(postgreSQLComBindExecutor.isErrorResponse(), Matchers.is(true)); }
Example #21
Source File: PostgreSqlExceptionTranslator.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
/** Package private for testability */ EntityTypeReferencedException translateDependentObjectsStillExist( Throwable sourceThrowable, PSQLException pSqlException) { ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage(); String detail = serverErrorMessage.getDetail(); Matcher matcher = Pattern.compile( "constraint (.+) on table \"?([^\"]+)\"? depends on table \"?([^\"]+)\"?\n?") .matcher(detail); Map<String, Set<String>> entityTypeDependencyMap = new LinkedHashMap<>(); while (matcher.find()) { String tableName = matcher.group(2); String dependentTableName = matcher.group(3); String entityTypeName = tryGetEntityTypeName(tableName).orElse(null); String dependentEntityTypeName = tryGetEntityTypeName(dependentTableName).orElse(null); Set<String> dependentTableNames = entityTypeDependencyMap.computeIfAbsent( dependentEntityTypeName, k -> new LinkedHashSet<>()); dependentTableNames.add(entityTypeName); } if (entityTypeDependencyMap.isEmpty()) // no matches { LOG.error(ERROR_TRANSLATING_POSTGRES_EXC_MSG, pSqlException); throw new RuntimeException(ERROR_TRANSLATING_EXCEPTION_MSG, pSqlException); } return new EntityTypeReferencedException(entityTypeDependencyMap, sourceThrowable); }
Example #22
Source File: PostgreSqlExceptionTranslator.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
/** Package private for testability */ static InvalidValueTypeException translateInvalidIntegerException( Throwable sourceThrowable, PSQLException pSqlException) { ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage(); String message = serverErrorMessage.getMessage(); Matcher matcher = Pattern.compile("invalid input syntax for \\b(?:type )?\\b(.+?): \"(.*?)\"") .matcher(message); boolean matches = matcher.matches(); if (!matches) { throw new RuntimeException(ERROR_TRANSLATING_EXCEPTION_MSG, pSqlException); } String postgreSqlType = matcher.group(1); // convert PostgreSQL data type to attribute type: String type; switch (postgreSqlType) { case "boolean": type = BOOL.toString(); break; case "date": type = DATE.toString(); break; case "timestamp with time zone": type = DATE_TIME.toString(); break; case "double precision": type = DECIMAL.toString(); break; case "integer": type = INT.toString() + " or " + LONG.toString(); break; default: type = postgreSqlType; break; } String value = matcher.group(2); return new InvalidValueTypeException(value, type, sourceThrowable); }
Example #23
Source File: PostgreSqlExceptionTranslator.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
private String getRefTableFromForeignKeyPsqlException(PSQLException pSqlException) { ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage(); Matcher messageMatcher = Pattern.compile( "update or delete on table \"(.*)\" violates foreign key constraint \"(.*)\" on table \"(.*)\"") .matcher(serverErrorMessage.getMessage()); if (!messageMatcher.matches()) { LOG.error(ERROR_TRANSLATING_POSTGRES_EXC_MSG, pSqlException); throw new RuntimeException(ERROR_TRANSLATING_EXCEPTION_MSG, pSqlException); } return messageMatcher.group(1); }
Example #24
Source File: PostgreSqlExceptionTranslator.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
/** Package private for testability */ UnknownEnumValueException translateCheckConstraintViolation( Throwable sourceThrowable, PSQLException pSqlException) { ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage(); String tableName = serverErrorMessage.getTable(); String constraintName = serverErrorMessage.getConstraint(); // constraint name: <tableName>_<columnName>_chk String columnName = constraintName.substring(tableName.length() + 1, constraintName.length() - 4); String entityTypeId = tryGetEntityTypeName(tableName).orElse(null); String attributeName = tryGetAttributeName(tableName, columnName).orElse(null); return new UnknownEnumValueException(entityTypeId, attributeName, sourceThrowable); }
Example #25
Source File: PostgreSqlExceptionTranslator.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
/** Package private for testability */ static MolgenisValidationException translateUndefinedColumnException( PSQLException pSqlException) { ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage(); String message = serverErrorMessage.getMessage(); // FIXME exposes internal message ConstraintViolation constraintViolation = new ConstraintViolation(message); return new MolgenisValidationException(singleton(constraintViolation)); }
Example #26
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateValueTooLongViolation() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getMessage()) .thenReturn("ERROR: value too long for type character varying(255)"); //noinspection ThrowableResultOfMethodCallIgnored ValueLengthExceededException e = postgreSqlExceptionTranslator.translateValueTooLongViolation(mock(Throwable.class)); assertNull(e.getMessage()); }
Example #27
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateReadonlyViolation() { ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class); when(serverErrorMessage.getMessage()) .thenReturn( "Updating read-only column \"myColumn\" of table \"myTable\" with id [abc] is not allowed"); //noinspection ThrowableResultOfMethodCallIgnored ReadonlyValueException e = postgreSqlExceptionTranslator.translateReadonlyViolation( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("entityTypeId:myEntity attributeName:myAttr entityId:abc", e.getMessage()); }
Example #28
Source File: PostgreSQLComQueryExecutorTest.java From shardingsphere with Apache License 2.0 | 5 votes |
@Test @SneakyThrows public void assertExecuteReturnErrorResponsePacket() { PostgreSQLComQueryExecutor postgreSQLComQueryExecutor = new PostgreSQLComQueryExecutor(mock(PostgreSQLComQueryPacket.class), null); FieldSetter.setField(postgreSQLComQueryExecutor, PostgreSQLComQueryExecutor.class.getDeclaredField("textProtocolBackendHandler"), textProtocolBackendHandler); ErrorResponse errorResponse = new ErrorResponse(new PSQLException(mock(ServerErrorMessage.class))); when(textProtocolBackendHandler.execute()).thenReturn(errorResponse); Assert.assertThat(postgreSQLComQueryExecutor.execute().iterator().next(), Matchers.instanceOf(PostgreSQLErrorResponsePacket.class)); Assert.assertThat(postgreSQLComQueryExecutor.isErrorResponse(), Matchers.is(true)); }
Example #29
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test 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 EntityTypeReferencedException e = postgreSqlExceptionTranslator.translateDependentObjectsStillExist( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("dependencies:myRefEntity=myEntity", e.getMessage()); }
Example #30
Source File: PostgreSqlExceptionTranslatorTest.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Test void translateDependentObjectsStillExistOneDependentTableMultipleDependencies() { 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\"\nconstraint myOther_foreign_key_constraint on table \"myTable\" depends on table \"myDependentTable\""); //noinspection ThrowableResultOfMethodCallIgnored EntityTypeReferencedException e = postgreSqlExceptionTranslator.translateDependentObjectsStillExist( mock(Throwable.class), new PSQLException(serverErrorMessage)); assertEquals("dependencies:myRefEntity=myEntity", e.getMessage()); }