Search in sources :

Example 11 with AddressDto

use of org.mifos.dto.domain.AddressDto 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 12 with AddressDto

use of org.mifos.dto.domain.AddressDto in project head by mifos.

the class CenterUpdateUsingCustomerServiceIntegrationTest method canUpdateCenterWithDifferentLoanOfficer.

@Test
public void canUpdateCenterWithDifferentLoanOfficer() throws Exception {
    // setup
    String externalId = center.getExternalId();
    String mfiJoiningDate = new SimpleDateFormat("dd/MM/yyyy").format(center.getMfiJoiningDate());
    AddressDto address = null;
    if (center.getAddress() != null) {
        address = Address.toDto(center.getAddress());
    }
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    List<CustomerPositionDto> customerPositions = new ArrayList<CustomerPositionDto>();
    UserContext userContext = TestUtils.makeUser();
    otherLoanOfficer.setPreferredLocale(userContext.getLocaleId());
    IntegrationTestObjectMother.createPersonnel(otherLoanOfficer);
    String updatedDisplayName = "Center " + RandomStringUtils.randomAlphanumeric(5);
    CenterUpdate centerUpdate = new CenterUpdate(center.getCustomerId(), updatedDisplayName, center.getVersionNo(), otherLoanOfficer.getPersonnelId(), externalId, mfiJoiningDate, address, customFields, customerPositions);
    // exercise test
    customerService.updateCenter(userContext, centerUpdate);
    // verification
    center = customerDao.findCenterBySystemId(center.getGlobalCustNum());
    assertThat(center.getPersonnel().getDisplayName(), is(otherLoanOfficer.getDisplayName()));
}
Also used : CenterUpdate(org.mifos.dto.domain.CenterUpdate) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto) AddressDto(org.mifos.dto.domain.AddressDto) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 13 with AddressDto

use of org.mifos.dto.domain.AddressDto in project head by mifos.

the class CenterUpdateUsingCustomerServiceIntegrationTest method canUpdateCenterWithNoLoanOfficerWhenCenterIsInactive.

@Test
public void canUpdateCenterWithNoLoanOfficerWhenCenterIsInactive() throws Exception {
    // setup
    CustomerStatusFlag centerStatusFlag = null;
    CustomerNoteEntity customerNote = null;
    customerService.updateCenterStatus(center, CustomerStatus.CENTER_INACTIVE, centerStatusFlag, customerNote);
    StaticHibernateUtil.flushAndClearSession();
    Short loanOfficerId = null;
    String externalId = center.getExternalId();
    String mfiJoiningDate = new SimpleDateFormat("dd/MM/yyyy").format(center.getMfiJoiningDate());
    AddressDto address = null;
    if (center.getAddress() != null) {
        address = Address.toDto(center.getAddress());
    }
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    List<CustomerPositionDto> customerPositions = new ArrayList<CustomerPositionDto>();
    String updatedDisplayName = "Center " + RandomStringUtils.randomAlphanumeric(5);
    CenterUpdate centerUpdate = new CenterUpdate(center.getCustomerId(), updatedDisplayName, center.getVersionNo(), loanOfficerId, externalId, mfiJoiningDate, address, customFields, customerPositions);
    UserContext userContext = TestUtils.makeUser();
    // exercise test
    customerService.updateCenter(userContext, centerUpdate);
    // verification
    center = customerDao.findCenterBySystemId(center.getGlobalCustNum());
    assertThat(center.getPersonnel(), is(nullValue()));
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) CenterUpdate(org.mifos.dto.domain.CenterUpdate) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 14 with AddressDto

use of org.mifos.dto.domain.AddressDto in project head by mifos.

the class CenterUpdateUsingCustomerServiceIntegrationTest method canUpdateCenterWithExternalId.

@Test
public void canUpdateCenterWithExternalId() throws Exception {
    // setup
    Short loanOfficerId = center.getPersonnel().getPersonnelId();
    String newExternalId = "ext123";
    LocalDate dateInPast = new LocalDate(center.getMfiJoiningDate()).minusWeeks(4);
    String mfiJoiningDate = new SimpleDateFormat("dd/MM/yyyy").format(dateInPast.toDateMidnight().toDate());
    AddressDto newAddress = null;
    if (center.getAddress() != null) {
        newAddress = Address.toDto(center.getAddress());
    }
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    List<CustomerPositionDto> customerPositions = new ArrayList<CustomerPositionDto>();
    String updatedDisplayName = "Center " + RandomStringUtils.randomAlphanumeric(5);
    CenterUpdate centerUpdate = new CenterUpdate(center.getCustomerId(), updatedDisplayName, center.getVersionNo(), loanOfficerId, newExternalId, mfiJoiningDate, newAddress, customFields, customerPositions);
    UserContext userContext = TestUtils.makeUser();
    // exercise test
    customerService.updateCenter(userContext, centerUpdate);
    // verification
    center = customerDao.findCenterBySystemId(center.getGlobalCustNum());
    assertThat(center.getExternalId(), is(newExternalId));
}
Also used : CenterUpdate(org.mifos.dto.domain.CenterUpdate) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto) AddressDto(org.mifos.dto.domain.AddressDto) LocalDate(org.joda.time.LocalDate) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 15 with AddressDto

use of org.mifos.dto.domain.AddressDto in project head by mifos.

the class CenterUpdateBuilder method build.

public CenterUpdate build() {
    int versionNum = 1;
    int customerId = -1;
    Short loanOfficerId = -1;
    String externalId = null;
    String updatedDisplayName = "Center " + RandomStringUtils.random(5);
    String mfiJoiningDate = new SimpleDateFormat("dd/MM/yyyy").format(new Date());
    AddressDto address = null;
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    List<CustomerPositionDto> customerPositions = new ArrayList<CustomerPositionDto>();
    return new CenterUpdate(customerId, updatedDisplayName, versionNum, loanOfficerId, externalId, mfiJoiningDate, address, customFields, customerPositions);
}
Also used : CenterUpdate(org.mifos.dto.domain.CenterUpdate) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto) AddressDto(org.mifos.dto.domain.AddressDto) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

AddressDto (org.mifos.dto.domain.AddressDto)37 ArrayList (java.util.ArrayList)24 DateTime (org.joda.time.DateTime)16 Address (org.mifos.framework.business.util.Address)16 UserContext (org.mifos.security.util.UserContext)16 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)14 OfficeBO (org.mifos.customers.office.business.OfficeBO)13 MeetingBO (org.mifos.application.meeting.business.MeetingBO)12 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)12 CustomerDetailsDto (org.mifos.dto.domain.CustomerDetailsDto)11 MeetingDto (org.mifos.dto.domain.MeetingDto)10 MifosUser (org.mifos.security.MifosUser)10 BusinessRuleException (org.mifos.service.BusinessRuleException)9 LocalDate (org.joda.time.LocalDate)8 Test (org.junit.Test)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)8 CustomerPositionDto (org.mifos.dto.domain.CustomerPositionDto)8 CenterUpdate (org.mifos.dto.domain.CenterUpdate)7 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)7 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)7