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);
}
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());
}
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);
}
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());
}
Aggregations