use of org.mifos.customers.center.business.CenterBO 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.center.business.CenterBO 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.center.business.CenterBO 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()));
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class TestObjectFactory method createCenter.
public static CenterBO createCenter(final String customerName, final MeetingBO meeting, final Short officeId, final Short personnelId, final List<FeeDto> fees) {
CenterBO center;
try {
center = new CenterBO(TestUtils.makeUserWithLocales(), customerName, null, null, fees, null, null, new OfficePersistence().getOffice(officeId), meeting, ApplicationContextProvider.getBean(LegacyPersonnelDao.class).getPersonnel(personnelId), new CustomerPersistence());
new CenterPersistence().saveCenter(center);
StaticHibernateUtil.flushSession();
} catch (Exception e) {
throw new RuntimeException(e);
}
return center;
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class IntegrationTestObjectMotherBuilderDsl method anExistingGroupUnderCenterInSameBranchAs.
public static GroupBO anExistingGroupUnderCenterInSameBranchAs(CenterBuilder centerBuilder) {
CenterBO centerAsParent = centerBuilder.build();
IntegrationTestObjectMother.createCenter(centerAsParent, centerAsParent.getCustomerMeetingValue());
GroupBO group = anActiveGroup().withParentCustomer(centerAsParent).formedBy(anExistingApplicationUser()).build();
IntegrationTestObjectMother.createGroup(group, group.getCustomerMeetingValue());
return group;
}
Aggregations