use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class CenterStatusChangeIntegrationTest method shouldValidateStatusWithActiveGroups.
@Test
public void shouldValidateStatusWithActiveGroups() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().withName("Center-IntegrationTest").with(existingMeeting).with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
GroupBO existingActiveGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingActiveGroup, existingMeeting);
ClientBO existingCancelledClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_CANCELLED).withParentCustomer(existingActiveGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingCancelledClient, existingMeeting);
existingCenter = this.customerDao.findCenterBySystemId(existingCenter.getGlobalCustNum());
existingCenter.setUserContext(TestUtils.makeUserWithLocales());
existingActiveGroup = this.customerDao.findGroupBySystemId(existingActiveGroup.getGlobalCustNum());
existingCancelledClient = this.customerDao.findClientBySystemId(existingCancelledClient.getGlobalCustNum());
CustomerStatusFlag customerStatusFlag = null;
CustomerNoteEntity customerNote = new CustomerNoteEntity("go inactive", new Date(), existingCenter.getPersonnel(), existingCenter);
// exercise test
try {
customerService.updateCenterStatus(existingCenter, CustomerStatus.CENTER_INACTIVE, customerStatusFlag, customerNote);
fail("should fail validation");
} catch (CustomerException expected) {
// verification
assertThat(expected.getKey(), is(CustomerConstants.ERROR_STATE_CHANGE_EXCEPTION));
assertThat(existingCenter.getStatus(), is(CustomerStatus.CENTER_ACTIVE));
}
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class ClientStatusChangeIntegrationTest method givenClientHasActiveAccountsShouldNotPassValidationWhenTryingToTranistionClientToClosed.
@Test
public void givenClientHasActiveAccountsShouldNotPassValidationWhenTryingToTranistionClientToClosed() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
GroupBO existingActiveGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingActiveGroup, existingMeeting);
ClientBO existingActiveClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_ACTIVE).withParentCustomer(existingActiveGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingActiveClient, existingMeeting);
StaticHibernateUtil.flushAndClearSession();
DateTime startDate = new DateTime().minusDays(14);
LoanOfferingBO clientLoanProduct = new LoanProductBuilder().appliesToClientsOnly().withGlobalProductNumber("XXX-00002").active().withMeeting(existingMeeting).withName("Loan-client").withShortName("dsvd").withStartDate(startDate).withDefaultInterest(1.2).buildForIntegrationTests();
IntegrationTestObjectMother.createProduct(clientLoanProduct);
LoanBO clientLoan = new LoanAccountBuilder().withLoanProduct(clientLoanProduct).withCustomer(existingActiveClient).withOriginalLoanAmount(600.0).build();
IntegrationTestObjectMother.saveLoanAccount(clientLoan);
existingActiveGroup = this.customerDao.findGroupBySystemId(existingActiveGroup.getGlobalCustNum());
existingActiveClient = this.customerDao.findClientBySystemId(existingActiveClient.getGlobalCustNum());
existingActiveClient.setUserContext(TestUtils.makeUser());
CustomerStatusFlag customerStatusFlag = null;
CustomerNoteEntity customerNote = new CustomerNoteEntity("go active", new Date(), existingActiveClient.getPersonnel(), existingActiveClient);
// exercise test
try {
customerService.updateClientStatus(existingActiveClient, existingActiveClient.getStatus(), CustomerStatus.CLIENT_CLOSED, customerStatusFlag, customerNote);
fail("should fail validation");
} catch (CustomerException expected) {
assertThat(expected.getKey(), is(CustomerConstants.CUSTOMER_HAS_ACTIVE_ACCOUNTS_EXCEPTION));
assertThat(existingActiveClient.getStatus(), is(CustomerStatus.CLIENT_ACTIVE));
}
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class ClientStatusChangeIntegrationTest method givenGroupIsInPartialStateShouldNotPassValidationWhenTryingToTranistionClientToActive.
@Test
public void givenGroupIsInPartialStateShouldNotPassValidationWhenTryingToTranistionClientToActive() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
GroupBO existingCancelledGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_PARTIAL).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingCancelledGroup, existingMeeting);
ClientBO existingPartialClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_PARTIAL).withParentCustomer(existingCancelledGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingPartialClient, existingMeeting);
existingCancelledGroup = this.customerDao.findGroupBySystemId(existingCancelledGroup.getGlobalCustNum());
existingPartialClient = this.customerDao.findClientBySystemId(existingPartialClient.getGlobalCustNum());
existingPartialClient.setUserContext(TestUtils.makeUser());
CustomerStatusFlag customerStatusFlag = null;
CustomerNoteEntity customerNote = new CustomerNoteEntity("go active", new Date(), existingPartialClient.getPersonnel(), existingPartialClient);
// exercise test
try {
customerService.updateClientStatus(existingPartialClient, existingPartialClient.getStatus(), CustomerStatus.CLIENT_ACTIVE, customerStatusFlag, customerNote);
fail("should fail validation");
} catch (CustomerException expected) {
assertThat(expected.getKey(), is(ClientConstants.INVALID_CLIENT_STATUS_EXCEPTION));
assertThat(existingPartialClient.getStatus(), is(CustomerStatus.CLIENT_PARTIAL));
}
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class GroupStatusChangeIntegrationTest method auditLogingTracksStatusChangeOfGroupFromActiveToCancelled.
@Test
public void auditLogingTracksStatusChangeOfGroupFromActiveToCancelled() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().withName("Center-IntegrationTest").with(existingMeeting).with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
GroupBO existingActiveGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingActiveGroup, existingMeeting);
ClientBO existingCancelledClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_CANCELLED).withParentCustomer(existingActiveGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingCancelledClient, existingMeeting);
existingActiveGroup = this.customerDao.findGroupBySystemId(existingActiveGroup.getGlobalCustNum());
existingActiveGroup.setUserContext(TestUtils.makeUserWithLocales());
CustomerStatusFlag customerStatusFlag = CustomerStatusFlag.GROUP_CANCEL_BLACKLISTED;
CustomerNoteEntity customerNote = new CustomerNoteEntity("Made Inactive", new java.util.Date(), existingActiveGroup.getPersonnel(), existingActiveGroup);
// exercise test
customerService.updateGroupStatus(existingActiveGroup, existingActiveGroup.getStatus(), CustomerStatus.GROUP_CANCELLED, customerStatusFlag, customerNote);
StaticHibernateUtil.getInterceptor().afterTransactionCompletion(new AuditTransactionForTests());
// verification
List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.GROUP, existingActiveGroup.getCustomerId());
assertThat(auditLogList.size(), is(1));
assertThat(auditLogList.get(0).getEntityTypeAsEnum(), is(EntityType.GROUP));
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class GroupTransferServiceIntegrationTest method transferingGroupToCenterWithDifferentMeetingDayOfWeekCausesFutureSchedulesToBeRegeneratedForGroupsChildren.
@Ignore
@Test
public void transferingGroupToCenterWithDifferentMeetingDayOfWeekCausesFutureSchedulesToBeRegeneratedForGroupsChildren() throws Exception {
// setup
OfficeBO branchOffice = anExistingBranchOffice(new OfficeBuilder().withGlobalOfficeNum("xxxx-003").withName("builder-branch-office1").withShortName("bf1").withSearchId("1.1.1.1."));
OfficeBO branchOffice2 = new OfficeBuilder().withParentOffice(branchOffice.getParentOffice()).branchOffice().withGlobalOfficeNum("xxxx-004").withName("builder-branch-office2").withShortName("bf1").withSearchId("1.1.1.2.").build();
IntegrationTestObjectMother.createOffice(branchOffice2);
DateTime todaySixWeeksAgo = new DateMidnight().toDateTime().minusWeeks(6);
MeetingBO weeklyMeeting = aWeeklyMeeting().withLocation("weeklyMeeting-sixWeeksAgo").startingFrom(todaySixWeeksAgo.toDate()).build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
CenterBuilder centerWithWeeklyMeeting = anActiveCenter().withName("center-with-no-children").with(weeklyMeeting).with(branchOffice).withActivationDate(todaySixWeeksAgo).withLoanOfficer(anExistingLoanOfficer());
CenterBO centerWithNoChildren = anExistingActiveCenter(centerWithWeeklyMeeting);
DateTime tomorrowTwoWeeksAgo = new DateMidnight().toDateTime().minusWeeks(2).plusDays(1);
MeetingBO differentWeeklyMeeting = aWeeklyMeeting().withLocation("weeklyMeeting-tomorrow-twoWeeksAgo").withStartDate(tomorrowTwoWeeksAgo.minusWeeks(1)).build();
IntegrationTestObjectMother.saveMeeting(differentWeeklyMeeting);
CenterBuilder centerInDifferentBranchWithDifferentMeeting = centerWithWeeklyMeeting.withName("center-with-group").with(branchOffice2).with(differentWeeklyMeeting).withActivationDate(tomorrowTwoWeeksAgo);
GroupBO groupForTransfer = anExistingGroupUnderCenterInDifferentBranchAs(centerInDifferentBranchWithDifferentMeeting);
ClientBO child1 = new ClientBuilder().active().withName("client1").withParentCustomer(groupForTransfer).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(child1, child1.getCustomerMeetingValue());
// pre-verification
ClientBO client = customerDao.findClientBySystemId(child1.getGlobalCustNum());
TestUtils.assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(client, WeekDay.getJodaWeekDay(tomorrowTwoWeeksAgo.getDayOfWeek()));
// exercise test
groupForTransfer = customerDao.findGroupBySystemId(groupForTransfer.getGlobalCustNum());
groupForTransfer.setUserContext(TestUtils.makeUser());
customerService.transferGroupTo(groupForTransfer, centerWithNoChildren);
// verification
client = customerDao.findClientBySystemId(child1.getGlobalCustNum());
TestUtils.assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(client, WeekDay.getJodaWeekDay(tomorrowTwoWeeksAgo.getDayOfWeek()));
// TO-FIX TestUtils.assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(client, WeekDay.getJodaWeekDay(todaySixWeeksAgo.getDayOfWeek()));
}
Aggregations