use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class CenterServiceFacadeWebTierIntegrationTest method shouldCreateCenterWithExpectedSearchId.
@Test
public void shouldCreateCenterWithExpectedSearchId() {
MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
MeetingDto meetingDto = meeting.toDto();
String displayName = "testCenter";
String externalId = null;
AddressDto addressDto = new AddressDto("here", "", "", "", "", "", "", "");
PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
Short loanOfficerId = user.getPersonnelId();
List<CreateAccountFeeDto> feesToApply = new ArrayList<CreateAccountFeeDto>();
CustomerStatus.GROUP_ACTIVE.getValue();
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
// setup
createOfficeHierarchyUnderHeadOffice(headOffice);
Short officeId = branch1.getOfficeId();
DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
new DateTime().minusWeeks(1);
CenterCreationDetail centerCreationDetail = new CenterCreationDetail(mfiJoiningDate.toLocalDate(), displayName, externalId, addressDto, loanOfficerId, officeId, feesToApply);
// exercise test
CustomerDetailsDto newlyCreatedCenterDetails = centerServiceFacade.createNewCenter(centerCreationDetail, meetingDto);
// verification
CenterBO center = customerDao.findCenterBySystemId(newlyCreatedCenterDetails.getGlobalCustNum());
Assert.assertThat(center.getSearchId(), is("1." + center.getCustomerId()));
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class ImportedFilesDaoHibernateIntegrationTest method testSaveConstraintVoilation.
/**
* ignoring as can't get first
*/
@Test(expected = MifosRuntimeException.class)
public void testSaveConstraintVoilation() throws Exception {
Short personnelId = new Short("1");
PersonnelBO personnelBO = TestObjectFactory.getPersonnel(personnelId);
Timestamp timeStamp = new Timestamp(123134554L);
String fileName = "testFile.xls";
ImportedFilesEntity expected = new ImportedFilesEntity(fileName, timeStamp, personnelBO, null, false, false);
StaticHibernateUtil.startTransaction();
importedFilesDao.saveImportedFile(expected);
StaticHibernateUtil.flushSession();
ImportedFilesEntity shouldViolateConstraint = new ImportedFilesEntity(fileName, timeStamp, personnelBO, null, false, false);
importedFilesDao.saveImportedFile(shouldViolateConstraint);
StaticHibernateUtil.flushSession();
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class ImportedFilesDaoHibernateIntegrationTest method testSaveAndFind.
@Test
public void testSaveAndFind() throws Exception {
Short personnelId = new Short("1");
PersonnelBO personnelBO = TestObjectFactory.getPersonnel(personnelId);
Timestamp timeStamp = new Timestamp(123134554L);
String fileName = "testFile.xls";
ImportedFilesEntity expected = new ImportedFilesEntity(fileName, timeStamp, personnelBO, null, false, false);
StaticHibernateUtil.startTransaction();
importedFilesDao.saveImportedFile(expected);
StaticHibernateUtil.flushSession();
ImportedFilesEntity actual = importedFilesDao.findImportedFileByName(fileName);
Assert.assertEquals(fileName, actual.getFileName());
Assert.assertEquals(personnelId, actual.getSubmittedBy().getPersonnelId());
Assert.assertEquals(timeStamp, actual.getSubmittedOn());
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class CenterBOIntegrationTest method testSearchIdOnlyUniquePerOffice.
@Test
public void testSearchIdOnlyUniquePerOffice() throws Exception {
Date startDate = new Date();
StaticHibernateUtil.startTransaction();
// In real life, would be another branch rather than an area
OfficeBO branch1 = new OfficePersistence().getOffice(TestObjectFactory.SAMPLE_AREA_OFFICE);
MeetingBO meeting = new MeetingBO(WeekDay.THURSDAY, (short) 1, startDate, MeetingType.CUSTOMER_MEETING, "Delhi");
PersonnelBO systemUser = legacyPersonnelDao.getPersonnel(PersonnelConstants.SYSTEM_USER);
center = new CenterBO(TestUtils.makeUser(), "Center", null, null, null, null, startDate, branch1, meeting, systemUser, new CustomerPersistence());
StaticHibernateUtil.getSessionTL().save(center);
CenterBO center2 = new CenterBO(TestUtils.makeUser(), "center2", null, null, null, null, startDate, new OfficePersistence().getOffice(TestObjectFactory.SAMPLE_BRANCH_OFFICE), meeting, systemUser, new CustomerPersistence());
CenterBO sameBranch = new CenterBO(TestUtils.makeUser(), "sameBranch", null, null, null, null, startDate, branch1, meeting, systemUser, new CustomerPersistence());
StaticHibernateUtil.getSessionTL().save(center);
StaticHibernateUtil.flushSession();
Assert.assertEquals("1.1", center.getSearchId());
Assert.assertEquals("1.1", center2.getSearchId());
Assert.assertEquals("1.2", sameBranch.getSearchId());
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class ClientCustActionStrutsTest method createClientForAuditLog.
private void createClientForAuditLog() throws Exception {
OfficeBO office = new OfficePersistence().getOffice(TestObjectFactory.HEAD_OFFICE);
PersonnelBO personnel = legacyPersonnelDao.getPersonnel(PersonnelConstants.TEST_USER);
meeting = getMeeting();
Integer salutation = 47;
Integer ethnicity = 218;
Integer citizenship = 130;
Integer handicapped = 138;
Integer businessActivities = 225;
Integer educationLevel = 226;
Short numChildren = Short.valueOf("1");
Short gender = Short.valueOf("49");
Short povertyStatus = Short.valueOf("41");
StaticHibernateUtil.startTransaction();
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), salutation, "Client", "", "1", "");
clientNameDetailDto.setNames(ClientRules.getNameSequence());
ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
spouseNameDetailView.setNames(ClientRules.getNameSequence());
ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(ethnicity, citizenship, handicapped, businessActivities, ClientPersonalDetailDto.MARRIED, educationLevel, numChildren, gender, povertyStatus);
client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("1")), null, null, new Address(), getCustomFields(), null, null, personnel, office, meeting, personnel, new java.util.Date(), null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
legacyClientDao.saveClient(client);
StaticHibernateUtil.flushAndClearSession();
client = TestObjectFactory.getClient(new Integer(client.getCustomerId()).intValue());
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
}
Aggregations