@Test(expectedExceptions = RuntimeException.class)
 public void translateForeignKeyViolationBadMessage() {
   ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
   when(serverErrorMessage.getSQLState()).thenReturn("23503");
   when(serverErrorMessage.getTable()).thenReturn("mytable");
   when(serverErrorMessage.getDetail()).thenReturn("xxxyyyyzzzz");
   //noinspection ThrowableResultOfMethodCallIgnored
   PostgreSqlExceptionTranslator.translateForeignKeyViolation(
       new PSQLException(serverErrorMessage));
 }
 @Test
 public void translateForeignKeyViolation() {
   ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
   when(serverErrorMessage.getSQLState()).thenReturn("23503");
   when(serverErrorMessage.getTable()).thenReturn("mytable");
   when(serverErrorMessage.getDetail()).thenReturn("... (mycolumn) ... (myvalue) ...");
   //noinspection ThrowableResultOfMethodCallIgnored
   MolgenisValidationException e =
       PostgreSqlExceptionTranslator.translateForeignKeyViolation(
           new PSQLException(serverErrorMessage));
   assertEquals(
       e.getMessage(),
       "Unknown xref value 'myvalue' for attribute 'mycolumn' of entity 'mytable'.");
 }
 @Test
 public void translateForeignKeyViolationStillReferenced() {
   ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
   when(serverErrorMessage.getSQLState()).thenReturn("23503");
   when(serverErrorMessage.getTable()).thenReturn("mytable");
   when(serverErrorMessage.getDetail())
       .thenReturn("Key (mycolumn)=(myvalue) is still referenced from table \"mytable\"");
   //noinspection ThrowableResultOfMethodCallIgnored
   MolgenisValidationException e =
       PostgreSqlExceptionTranslator.translateForeignKeyViolation(
           new PSQLException(serverErrorMessage));
   assertEquals(
       e.getMessage(),
       "Value 'myvalue' for attribute 'mycolumn' is referenced by entity 'mytable'.");
 }