use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.
the class NeverEndingProcessor method process.
@Override
public EventResult<IdmIdentityDto> process(EntityEvent<IdmIdentityDto> event) {
// TODO Auto-generated method stub
int counter = 0;
while (wait && counter < 50) {
// max wait is 15s
try {
counter++;
Thread.sleep(300L);
} catch (Exception ex) {
throw new CoreException(ex);
}
}
return null;
}
use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.
the class AbstractSchedulableStatefulExecutorIntegrationTest method testNotContinueWithoutRequiresNew.
@Test
public void testNotContinueWithoutRequiresNew() throws Exception {
List<IdmIdentityDto> identities = createTestIdentities(3);
//
TestIdentityIntegrationExecutor executor = new TestIdentityIntegrationExecutor();
executor.dtos = identities;
executor.continueOnException = false;
executor.requireNewTransaction = false;
String changeLastName = "last-name-update";
executor.changeLastName = changeLastName;
executor.exceptionOnItem = 2;
//
try {
getTransactionTemplate().execute(new TransactionCallback<Object>() {
public Object doInTransaction(TransactionStatus transactionStatus) {
longRunningTaskManager.execute(executor);
// lookout: long running task never fails on exception => processed with exception. Rollback has to be controlled manually.
throw new CoreException("fail");
}
});
} catch (Exception ex) {
// nothing
}
//
IdmLongRunningTaskDto taskDto = longRunningTaskService.get(executor.getLongRunningTaskId(), getContext());
Assert.assertEquals(3, taskDto.getCount().intValue());
Assert.assertEquals(1, taskDto.getSuccessItemCount().intValue());
Assert.assertEquals(1, taskDto.getFailedItemCount().intValue());
// nothing committed
for (IdmIdentityDto i : identities) {
IdmIdentityDto identity = identityService.get(i);
//
Assert.assertNotEquals(changeLastName, identity.getLastName());
}
}
use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.
the class AbstractSchedulableStatefulExecutorIntegrationTest method testTransaction.
@Test
public void testTransaction() throws Exception {
List<IdmIdentityDto> identities = createTestIdentities(3);
String lastName = getHelper().createName();
try {
getTransactionTemplate().execute(new TransactionCallback<Object>() {
public Object doInTransaction(TransactionStatus transactionStatus) {
IdmIdentityDto identity = identities.get(0);
identity.setLastName(lastName);
identityService.save(identity);
throw new CoreException("fail");
}
});
} catch (Exception ex) {
// nothing
} finally {
Assert.assertNotEquals(lastName, identityService.get(identities.get(0)).getLastName());
}
}
use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.
the class AbstractSchedulableStatefulExecutorIntegrationTest method testContinueWithoutRequiresNew.
@Test
public void testContinueWithoutRequiresNew() throws Exception {
List<IdmIdentityDto> identities = createTestIdentities(3);
//
TestIdentityIntegrationExecutor executor = new TestIdentityIntegrationExecutor();
executor.dtos = identities;
executor.continueOnException = true;
executor.requireNewTransaction = false;
String changeLastName = "last-name-update";
executor.changeLastName = changeLastName;
executor.exceptionOnItem = 2;
//
try {
getTransactionTemplate().execute(new TransactionCallback<Object>() {
public Object doInTransaction(TransactionStatus transactionStatus) {
longRunningTaskManager.execute(executor);
// lookout: long running task never fails on exception => processed with exception. Rollback has to be controlled manually.
throw new CoreException("fail");
}
});
} catch (Exception ex) {
// nothing
}
//
Assert.assertNotNull(executor);
Assert.assertNotNull(executor.getLongRunningTaskId());
IdmLongRunningTaskDto taskDto = longRunningTaskManager.getLongRunningTask(executor);
Assert.assertEquals(3, taskDto.getCount().intValue());
Assert.assertEquals(2, taskDto.getSuccessItemCount().intValue());
Assert.assertEquals(1, taskDto.getFailedItemCount().intValue());
// nothing committed
for (IdmIdentityDto i : identities) {
IdmIdentityDto identity = identityService.get(i);
//
Assert.assertNotEquals(changeLastName, identity.getLastName());
}
}
Aggregations