Search in sources :

Example 66 with PersonnelBO

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()));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) AddressDto(org.mifos.dto.domain.AddressDto) DateTime(org.joda.time.DateTime) MeetingDto(org.mifos.dto.domain.MeetingDto) CenterCreationDetail(org.mifos.dto.domain.CenterCreationDetail) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) OfficeBO(org.mifos.customers.office.business.OfficeBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) Test(org.junit.Test)

Example 67 with PersonnelBO

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();
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Timestamp(java.sql.Timestamp) ImportedFilesEntity(org.mifos.application.importexport.business.ImportedFilesEntity) Test(org.junit.Test)

Example 68 with PersonnelBO

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());
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Timestamp(java.sql.Timestamp) ImportedFilesEntity(org.mifos.application.importexport.business.ImportedFilesEntity) Test(org.junit.Test)

Example 69 with PersonnelBO

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());
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Date(java.util.Date) Test(org.junit.Test)

Example 70 with PersonnelBO

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);
}
Also used : Address(org.mifos.framework.business.util.Address) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ClientBO(org.mifos.customers.client.business.ClientBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Date(java.util.Date)

Aggregations

PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)239 Test (org.junit.Test)91 UserContext (org.mifos.security.util.UserContext)65 ArrayList (java.util.ArrayList)62 Money (org.mifos.framework.util.helpers.Money)46 MifosRuntimeException (org.mifos.core.MifosRuntimeException)44 OfficeBO (org.mifos.customers.office.business.OfficeBO)44 MifosUser (org.mifos.security.MifosUser)44 PersistenceException (org.mifos.framework.exceptions.PersistenceException)41 Date (java.util.Date)39 LocalDate (org.joda.time.LocalDate)37 AccountException (org.mifos.accounts.exceptions.AccountException)37 DateTime (org.joda.time.DateTime)36 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)34 BusinessRuleException (org.mifos.service.BusinessRuleException)33 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)31 MeetingBO (org.mifos.application.meeting.business.MeetingBO)30 CustomerBO (org.mifos.customers.business.CustomerBO)27 ServiceException (org.mifos.framework.exceptions.ServiceException)27 LoanBO (org.mifos.accounts.loan.business.LoanBO)25