Search in sources :

Example 6 with GroupUpdateBuilder

use of org.mifos.domain.builders.GroupUpdateBuilder 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 7 with GroupUpdateBuilder

use of org.mifos.domain.builders.GroupUpdateBuilder 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 8 with GroupUpdateBuilder

use of org.mifos.domain.builders.GroupUpdateBuilder 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

Test (org.junit.Test)8 GroupUpdateBuilder (org.mifos.domain.builders.GroupUpdateBuilder)8 GroupUpdate (org.mifos.dto.domain.GroupUpdate)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 InOrder (org.mockito.InOrder)1