use of org.molgenis.data.MolgenisDataException in project molgenis by molgenis.
the class ScheduledJobRepositoryDecoratorTest method testDeleteFails.
@Test
public void testDeleteFails() {
doThrow(new MolgenisDataException("Failed")).when(delegateRepository).delete(scheduledJob);
when(scheduledJob.getId()).thenReturn("id");
try {
scheduledJobRepositoryDecorator.delete(scheduledJob);
Assert.fail("delete method should rethrow exception from delegate repository");
} catch (MolgenisDataException expected) {
}
verifyNoMoreInteractions(jobScheduler);
}
use of org.molgenis.data.MolgenisDataException in project molgenis by molgenis.
the class JobTest method testTransactionalJobFailure.
@Test
public void testTransactionalJobFailure() throws Exception {
when(transactionOperations.execute(actionCaptor.capture())).thenAnswer((call) -> actionCaptor.getValue().doInTransaction(transactionStatus));
MolgenisDataException mde = new MolgenisDataException();
when(callable.call()).thenThrow(mde);
try {
job.call();
fail("TransactionalJob call should throw exception if subclass execution fails.");
} catch (JobExecutionException ex) {
assertSame(ex.getCause(), mde);
}
verify(transactionOperations).execute(any());
verify(progress).start();
verify(callable).call();
verify(progress).failed(mde);
verifyNoMoreInteractions(callable, progress, transactionOperations);
}
use of org.molgenis.data.MolgenisDataException in project molgenis by molgenis.
the class EntityTypeMapper method toEntityType.
public EntityType toEntityType(EditorEntityType editorEntityType) {
if (editorEntityType.getLabelAttribute() == null || editorEntityType.getIdAttribute() == null) {
throw new MolgenisDataException("ID and Label attribute for EntityType [" + editorEntityType.getLabel() + "] can not be null");
}
EntityType entityType = entityTypeFactory.create();
entityType.setId(editorEntityType.getId());
entityType.setPackage(packageMapper.toPackageReference(editorEntityType.getPackage()));
entityType.setLabel(editorEntityType.getLabel());
if (editorEntityType.getLabelI18n() != null) {
getLanguageCodes().forEach(languageCode -> entityType.setLabel(languageCode, editorEntityType.getLabelI18n().get(languageCode)));
}
entityType.setDescription(editorEntityType.getDescription());
if (editorEntityType.getDescriptionI18n() != null) {
getLanguageCodes().forEach(languageCode -> entityType.setDescription(languageCode, editorEntityType.getDescriptionI18n().get(languageCode)));
}
entityType.setOwnAllAttributes(attributeMapper.toAttributes(editorEntityType.getAttributes(), editorEntityType));
entityType.setAbstract(editorEntityType.isAbstract());
entityType.setExtends(entityTypeParentMapper.toEntityTypeReference(editorEntityType.getEntityTypeParent()));
entityType.setTags(tagMapper.toTagReferences(editorEntityType.getTags()));
entityType.setBackend(editorEntityType.getBackend());
return entityType;
}
use of org.molgenis.data.MolgenisDataException in project molgenis by molgenis.
the class PostgreSqlExceptionTranslator method doTranslate.
private MolgenisDataException doTranslate(SQLException sqlException) {
if (sqlException instanceof BatchUpdateException) {
sqlException = sqlException.getNextException();
}
if (!(sqlException instanceof PSQLException)) {
throw new RuntimeException(format("Unexpected exception class [%s]", sqlException.getClass().getSimpleName()));
}
PSQLException pSqlException = (PSQLException) sqlException;
MolgenisDataException molgenisDataException = doTranslate(pSqlException);
if (molgenisDataException == null) {
molgenisDataException = new MolgenisDataException(sqlException);
}
return molgenisDataException;
}
use of org.molgenis.data.MolgenisDataException in project molgenis by molgenis.
the class PostgreSqlExceptionTranslator method doTranslate.
private MolgenisDataException doTranslate(DataAccessException dataAccessException) {
Throwable cause = dataAccessException.getCause();
if (!(cause instanceof PSQLException)) {
throw new RuntimeException(format("Unexpected exception class [%s]", cause.getClass().getSimpleName()));
}
PSQLException pSqlException = (PSQLException) cause;
MolgenisDataException molgenisDataException = doTranslate(pSqlException);
if (molgenisDataException == null) {
molgenisDataException = new MolgenisDataException(dataAccessException);
}
return molgenisDataException;
}
Aggregations