use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.
the class StandardApprovalService method updateMethodContent.
@Transactional
@Override
public void updateMethodContent(Long id, ApprovalMethod approvalMethod) throws Exception {
RESTApprovalEntity entity = approvalDao.getDetails(id);
if (entity.getState().equals(ApprovalState.WAITING)) {
entity.setApprovalMethod(approvalMethod);
approvalDao.update(entity);
}
}
use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.
the class StandardApprovalService method approve.
@Transactional
@Override
public Object approve(Long id) throws Exception {
RESTApprovalEntity entity = approvalDao.getDetails(id);
ApprovalMethod am = entity.getApprovalMethod();
Object result = null;
try {
result = excuteMethod(am);
entity.setState(ApprovalState.APPROVED);
} catch (Exception e) {
skipCreate = false;
result = "Error : " + interceptError(e);
}
entity.setApprovedBy(getCurrentUserId());
entity.setApprovedOn(new DateTime());
approvalDao.update(entity);
return result;
}
use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.
the class AspectJApprovalInterceptorTest method testRESTCallExecution.
@Test
@Transactional
public void testRESTCallExecution() throws Exception {
Assert.assertEquals(0, approvalService.getAllWaiting().size());
try {
stubRestController.createCall("HELLO");
Assert.fail("should throw interrupt exception");
} catch (RESTCallInterruptException e) {
}
Assert.assertEquals(1, approvalService.getAllWaiting().size());
RESTApprovalEntity entity = approvalService.getAllWaiting().get(0);
Assert.assertEquals("arg", entity.getApprovalMethod().getArgsHolder().getNames()[0]);
}
use of org.mifos.rest.approval.domain.RESTApprovalEntity in project head by mifos.
the class ApprovalServiceTest method testApproveFailure.
@Test
@Ignore
public void testApproveFailure() throws Exception {
createFailureApprovalMethod();
RESTApprovalEntity rae = approvalService.getAllWaiting().get(0);
assertNotNull(rae);
assertEquals(ApprovalState.WAITING, rae.getState());
Object result = approvalService.approve(rae.getId());
assertEquals("Error : check parameters", result);
assertEquals(ApprovalState.WAITING, rae.getState());
}
Aggregations