Search in sources :

Example 6 with RESTApprovalEntity

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);
    }
}
Also used : RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with RESTApprovalEntity

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;
}
Also used : RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) ApprovalMethod(org.mifos.rest.approval.domain.ApprovalMethod) InvocationTargetException(java.lang.reflect.InvocationTargetException) DateTime(org.joda.time.DateTime) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with RESTApprovalEntity

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]);
}
Also used : RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) RESTCallInterruptException(org.mifos.rest.approval.service.RESTCallInterruptException) Test(org.junit.Test) Transactional(org.mifos.framework.hibernate.helper.Transactional)

Example 9 with RESTApprovalEntity

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());
}
Also used : RESTApprovalEntity(org.mifos.rest.approval.domain.RESTApprovalEntity) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

RESTApprovalEntity (org.mifos.rest.approval.domain.RESTApprovalEntity)9 Test (org.junit.Test)4 Transactional (org.springframework.transaction.annotation.Transactional)4 DateTime (org.joda.time.DateTime)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Ignore (org.junit.Ignore)1 PersonnelInformationDto (org.mifos.dto.screen.PersonnelInformationDto)1 Transactional (org.mifos.framework.hibernate.helper.Transactional)1 ApprovalMethod (org.mifos.rest.approval.domain.ApprovalMethod)1 RESTCallInterruptException (org.mifos.rest.approval.service.RESTCallInterruptException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1