use of org.mifos.customers.group.business.GroupBO in project head by mifos.
the class CustomerStatusUpdateTest method throwsCheckedExceptionWhenValidationFailsForTransitioningToActive.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenValidationFailsForTransitioningToActive() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.GROUP_ACTIVE).build();
CenterBO existingCenter = new CenterBuilder().build();
GroupBO existingGroup = new GroupBuilder().active().withParentCustomer(existingCenter).withVersion(customerStatusUpdate.getVersionNum()).build();
existingGroup.setLoanOfficer(null);
// stubbing
when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(existingGroup);
// exercise test
customerService.updateCustomerStatus(userContext, customerStatusUpdate);
}
use of org.mifos.customers.group.business.GroupBO in project head by mifos.
the class CustomerStatusUpdateTest method updatesPendingChildrenToPartialWhenTransitioningGroupFromPendingToCancelled.
@Test
public void updatesPendingChildrenToPartialWhenTransitioningGroupFromPendingToCancelled() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.GROUP_CANCELLED).build();
PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
CenterBO existingCenter = new CenterBuilder().withLoanOfficer(loanOfficer).active().build();
GroupBO existingGroup = new GroupBuilder().pendingApproval().withParentCustomer(existingCenter).withVersion(customerStatusUpdate.getVersionNum()).build();
ClientBO existingClient = new ClientBuilder().withParentCustomer(existingGroup).pendingApproval().buildForUnitTests();
existingGroup.addChild(existingClient);
// stubbing
when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(existingGroup);
// exercise test
customerService.updateCustomerStatus(userContext, customerStatusUpdate);
// verification
assertThat(existingGroup.getStatus(), is(CustomerStatus.GROUP_CANCELLED));
assertThat(existingClient.getUserContext(), is(userContext));
assertThat(existingClient.getStatus(), is(CustomerStatus.CLIENT_PARTIAL));
}
use of org.mifos.customers.group.business.GroupBO in project head by mifos.
the class GroupTransferToCenterTest method transferingGroupToCenterInSameBranchIncrementsMaxChildCountOfNewParentAndDoesNotDecrementsMaxChildCountOfOldParent.
@Test
public void transferingGroupToCenterInSameBranchIncrementsMaxChildCountOfNewParentAndDoesNotDecrementsMaxChildCountOfOldParent() throws Exception {
CenterBO fromCenter = new CenterBuilder().withName("fromCenter").build();
GroupBO groupForTransfer = new GroupBuilder().withParentCustomer(fromCenter).active().build();
fromCenter.addChild(groupForTransfer);
CenterBO centerWithNoChildren = new CenterBuilder().withName("receivingCenter").build();
// pre-verification
assertThat(centerWithNoChildren.getMaxChildCount(), is(0));
assertThat(centerWithNoChildren.getChildren().size(), is(0));
assertThat(groupForTransfer.getParentCustomer().getMaxChildCount(), is(1));
// exercise test
groupForTransfer.transferTo(centerWithNoChildren);
// verification
assertThat(centerWithNoChildren.getMaxChildCount(), is(1));
assertThat(fromCenter.getMaxChildCount(), is(1));
}
use of org.mifos.customers.group.business.GroupBO in project head by mifos.
the class CustomerPersistenceIntegrationTest method testGetAllBasicGroupInfo.
@Test
public void testGetAllBasicGroupInfo() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
center = createCenter("new_center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
GroupBO newGroup = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup", CustomerStatus.GROUP_HOLD, center);
GroupBO newGroup2 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup2", CustomerStatus.GROUP_CANCELLED, center);
GroupBO newGroup3 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup3", CustomerStatus.GROUP_CLOSED, center);
GroupBO newGroup4 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup4", CustomerStatus.GROUP_PARTIAL, center);
GroupBO newGroup5 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup5", CustomerStatus.GROUP_PENDING, center);
List<BasicGroupInfo> groupInfos = customerPersistence.getAllBasicGroupInfo();
Assert.assertEquals(2, groupInfos.size());
Assert.assertEquals(group.getDisplayName(), groupInfos.get(0).getGroupName());
Assert.assertEquals(group.getSearchId(), groupInfos.get(0).getSearchId());
Assert.assertEquals(group.getOffice().getOfficeId(), groupInfos.get(0).getBranchId());
Assert.assertEquals(group.getCustomerId(), groupInfos.get(0).getGroupId());
Assert.assertEquals(newGroup.getDisplayName(), groupInfos.get(1).getGroupName());
Assert.assertEquals(newGroup.getSearchId(), groupInfos.get(1).getSearchId());
Assert.assertEquals(newGroup.getOffice().getOfficeId(), groupInfos.get(1).getBranchId());
Assert.assertEquals(newGroup.getCustomerId(), groupInfos.get(1).getGroupId());
// TestObjectFactory.cleanUp(newGroup);
// TestObjectFactory.cleanUp(newGroup2);
// TestObjectFactory.cleanUp(newGroup3);
// TestObjectFactory.cleanUp(newGroup4);
// TestObjectFactory.cleanUp(newGroup5);
}
use of org.mifos.customers.group.business.GroupBO in project head by mifos.
the class CustomerPersistenceIntegrationTest method testRetrieveAllSavingsAccountUnderCustomer.
@Test
public void testRetrieveAllSavingsAccountUnderCustomer() throws Exception {
center = createCenter("new_center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
CenterBO center1 = createCenter("new_center1");
GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group1);
account = getSavingsAccount(center, "Savings Prd1", "Abc1");
AccountBO account1 = getSavingsAccount(client, "Savings Prd2", "Abc2");
AccountBO account2 = getSavingsAccount(client2, "Savings Prd3", "Abc3");
AccountBO account3 = getSavingsAccount(client3, "Savings Prd4", "Abc4");
AccountBO account4 = getSavingsAccount(group1, "Savings Prd5", "Abc5");
AccountBO account5 = getSavingsAccount(group, "Savings Prd6", "Abc6");
AccountBO account6 = getSavingsAccount(center1, "Savings Prd7", "Abc7");
List<AccountBO> savingsForCenter = customerPersistence.retrieveAccountsUnderCustomer(center.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
Assert.assertEquals(4, savingsForCenter.size());
List<AccountBO> savingsForGroup = customerPersistence.retrieveAccountsUnderCustomer(group.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
Assert.assertEquals(3, savingsForGroup.size());
List<AccountBO> savingsForClient = customerPersistence.retrieveAccountsUnderCustomer(client.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
Assert.assertEquals(1, savingsForClient.size());
}
Aggregations