use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.
the class ExecutionEngineImplTest method testErrorCreatingService.
@Test
public void testErrorCreatingService() {
ExecutionEngineImpl engine = new ExecutionEngineImpl();
engine.setModelClient(modelClient);
engine.setServiceFactory(new ExecutionServiceFactory() {
@Override
public ExecutionService createService(Order order, CatalogService catalogService) throws ServiceNotFoundException {
throw new RuntimeException("Unexpected error");
}
});
Order order = executeOrder(engine, createOrder("ErrorCreatingService"));
Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
}
use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.
the class ExecutionEngineImplTest method testClearSomeRollback.
@Test
public void testClearSomeRollback() {
final EmptyTask rollback1 = new EmptyTask("Rollback 1");
final EmptyTask rollback2 = new EmptyTask("Rollback 2");
ExecutionService rollbackService = new EmptyService() {
@Override
public void execute() throws Exception {
addRollback(rollback1);
clearRollback();
addRollback(rollback2);
throw new Exception("Trigger rollback");
}
};
Order order = executeOrder(rollbackService, "ClearSomeRollback");
Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
Assert.assertEquals(false, rollback1.wasRun);
Assert.assertEquals(true, rollback2.wasRun);
}
use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.
the class ExecutionEngineImplTest method testRollback.
@Test
public void testRollback() {
final EmptyTask firstRollbackTask = new EmptyTask("First Rollback");
final EmptyTask secondRollbackTask = new EmptyTask("Second Rollback");
ExecutionService rollbackService = new EmptyService() {
@Param
protected boolean rollback;
@Override
public void execute() throws Exception {
addRollback(firstRollbackTask);
addRollback(secondRollbackTask);
if (rollback) {
throw new Exception("Trigger rollback");
}
}
};
Order noRollbackOrder = executeOrder(rollbackService, "NoRollback", "rollback=false");
Assert.assertEquals(OrderStatus.SUCCESS.name(), noRollbackOrder.getOrderStatus());
Assert.assertFalse(firstRollbackTask.wasRun);
Assert.assertFalse(secondRollbackTask.wasRun);
Order rollbackOrder = executeOrder(rollbackService, "Rollback", "rollback=true");
Assert.assertEquals(OrderStatus.ERROR.name(), rollbackOrder.getOrderStatus());
Assert.assertTrue(firstRollbackTask.wasRun);
Assert.assertTrue(secondRollbackTask.wasRun);
}
use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.
the class ExecutionEngineImplTest method testClearRollback.
@Test
public void testClearRollback() {
final EmptyTask rollback1 = new EmptyTask("Rollback 1");
final EmptyTask rollback2 = new EmptyTask("Rollback 2");
ExecutionService rollbackService = new EmptyService() {
@Override
public void execute() throws Exception {
addRollback(rollback1);
addRollback(rollback2);
clearRollback();
throw new Exception("Trigger rollback");
}
};
Order order = executeOrder(rollbackService, "ClearRollback");
Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
Assert.assertEquals(false, rollback1.wasRun);
Assert.assertEquals(false, rollback2.wasRun);
}
use of com.emc.sa.engine.service.ExecutionService in project coprhd-controller by CoprHD.
the class ExecutionEngineImplTest method testRemoveRollbackByType.
@Test
public void testRemoveRollbackByType() {
final FailureTask rollback1 = new FailureTask("Rollback 1", "Fail 1");
final EmptyTask rollback2 = new EmptyTask("Rollback 2");
ExecutionService rollbackService = new EmptyService() {
@Override
public void execute() throws Exception {
addRollback(rollback1);
addRollback(rollback2);
removeRollback(FailureTask.class);
throw new Exception("Trigger rollback");
}
};
Order order = executeOrder(rollbackService, "RemoveRollbackByType");
Assert.assertEquals(OrderStatus.ERROR.name(), order.getOrderStatus());
Assert.assertEquals(false, rollback1.wasRun);
Assert.assertEquals(true, rollback2.wasRun);
}
Aggregations