Search in sources :

Example 6 with GroupUpdate

use of org.mifos.dto.domain.GroupUpdate in project head by mifos.

the class GroupUpdateTest method userContextIsSetBeforeBeginningAuditLogging.

@Test
public void userContextIsSetBeforeBeginningAuditLogging() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    GroupUpdate groupUpdate = new GroupUpdateBuilder().build();
    // stubbing
    when(customerDao.findGroupBySystemId(groupUpdate.getGlobalCustNum())).thenReturn(mockedGroup);
    // exercise test
    customerService.updateGroup(userContext, groupUpdate);
    // verification
    InOrder inOrder = inOrder(hibernateTransactionHelper, mockedGroup);
    inOrder.verify(mockedGroup).setUserContext(userContext);
    inOrder.verify(hibernateTransactionHelper).beginAuditLoggingFor(mockedGroup);
}
Also used : GroupUpdateBuilder(org.mifos.domain.builders.GroupUpdateBuilder) InOrder(org.mockito.InOrder) UserContext(org.mifos.security.util.UserContext) GroupUpdate(org.mifos.dto.domain.GroupUpdate) Test(org.junit.Test)

Example 7 with GroupUpdate

use of org.mifos.dto.domain.GroupUpdate in project head by mifos.

the class GroupUpdateTest method validatesNameOfGroupIsNotTakenWhenNameIsUpdatedToDifferentValue.

@Test
public void validatesNameOfGroupIsNotTakenWhenNameIsUpdatedToDifferentValue() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    GroupUpdate groupUpdate = new GroupUpdateBuilder().build();
    // stubbing
    when(customerDao.findGroupBySystemId(groupUpdate.getGlobalCustNum())).thenReturn(mockedGroup);
    when(mockedGroup.isNameDifferent(groupUpdate.getDisplayName())).thenReturn(true);
    when(mockedGroup.getOffice()).thenReturn(new OfficeBuilder().build());
    // exercise test
    customerService.updateGroup(userContext, groupUpdate);
    // verification
    verify(mockedGroup).setDisplayName(groupUpdate.getDisplayName());
    verify(customerDao).validateGroupNameIsNotTakenForOffice(anyString(), anyShort());
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) GroupUpdateBuilder(org.mifos.domain.builders.GroupUpdateBuilder) UserContext(org.mifos.security.util.UserContext) GroupUpdate(org.mifos.dto.domain.GroupUpdate) Test(org.junit.Test)

Example 8 with GroupUpdate

use of org.mifos.dto.domain.GroupUpdate in project head by mifos.

the class GroupUpdateTest method throwsCheckedExceptionWhenVersionOfGroupForUpdateIsDifferentToPersistedGroupVersion.

@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenVersionOfGroupForUpdateIsDifferentToPersistedGroupVersion() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    GroupUpdate groupUpdate = new GroupUpdateBuilder().build();
    // stubbing
    when(customerDao.findGroupBySystemId(groupUpdate.getGlobalCustNum())).thenReturn(mockedGroup);
    doThrow(new CustomerException(Constants.ERROR_VERSION_MISMATCH)).when(mockedGroup).validateVersion(groupUpdate.getVersionNo());
    // exercise test
    customerService.updateGroup(userContext, groupUpdate);
}
Also used : GroupUpdateBuilder(org.mifos.domain.builders.GroupUpdateBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) GroupUpdate(org.mifos.dto.domain.GroupUpdate) Test(org.junit.Test)

Example 9 with GroupUpdate

use of org.mifos.dto.domain.GroupUpdate in project head by mifos.

the class GroupUpdateTest method addressAndExternalIdAreUpdated.

@Test
public void addressAndExternalIdAreUpdated() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    GroupUpdate groupUpdate = new GroupUpdateBuilder().build();
    // stubbing
    when(customerDao.findGroupBySystemId(groupUpdate.getGlobalCustNum())).thenReturn(mockedGroup);
    // exercise test
    customerService.updateGroup(userContext, groupUpdate);
    // verification
    verify(mockedGroup).setExternalId(groupUpdate.getExternalId());
    verify(mockedGroup).updateAddress((Address) anyObject());
}
Also used : GroupUpdateBuilder(org.mifos.domain.builders.GroupUpdateBuilder) UserContext(org.mifos.security.util.UserContext) GroupUpdate(org.mifos.dto.domain.GroupUpdate) Test(org.junit.Test)

Aggregations

GroupUpdate (org.mifos.dto.domain.GroupUpdate)9 Test (org.junit.Test)8 GroupUpdateBuilder (org.mifos.domain.builders.GroupUpdateBuilder)8 UserContext (org.mifos.security.util.UserContext)8 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)4 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)3 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)3 CustomerException (org.mifos.customers.exceptions.CustomerException)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 GroupBO (org.mifos.customers.group.business.GroupBO)1 GroupCustActionForm (org.mifos.customers.group.struts.actionforms.GroupCustActionForm)1 AddressDto (org.mifos.dto.domain.AddressDto)1 ApplicationException (org.mifos.framework.exceptions.ApplicationException)1 CloseSession (org.mifos.framework.util.helpers.CloseSession)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1 InOrder (org.mockito.InOrder)1