Search in sources :

Example 16 with CustomerNoteEntity

use of org.mifos.customers.business.CustomerNoteEntity in project head by mifos.

the class ClientStatusChangeIntegrationTest method givenGroupIsInCancelledStateShouldNotPassValidationWhenTryingToTranistionClientToActive.

@Test
public void givenGroupIsInCancelledStateShouldNotPassValidationWhenTryingToTranistionClientToActive() 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_CANCELLED).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.ERRORS_GROUP_CANCELLED));
        assertThat(existingPartialClient.getStatus(), is(CustomerStatus.CLIENT_PARTIAL));
    }
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerException(org.mifos.customers.exceptions.CustomerException) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) Date(java.util.Date) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 17 with CustomerNoteEntity

use of org.mifos.customers.business.CustomerNoteEntity in project head by mifos.

the class TestObjectFactory method getCustomerNote.

public static CustomerNoteEntity getCustomerNote(final String comment, final CustomerBO customer) {
    java.sql.Date commentDate = new java.sql.Date(System.currentTimeMillis());
    CustomerNoteEntity notes = new CustomerNoteEntity(comment, commentDate, customer.getPersonnel(), customer);
    return notes;
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Aggregations

CustomerNoteEntity (org.mifos.customers.business.CustomerNoteEntity)17 Test (org.junit.Test)12 CustomerStatusFlag (org.mifos.customers.util.helpers.CustomerStatusFlag)12 ClientBO (org.mifos.customers.client.business.ClientBO)10 Date (java.util.Date)9 CenterBO (org.mifos.customers.center.business.CenterBO)9 GroupBO (org.mifos.customers.group.business.GroupBO)9 CenterBuilder (org.mifos.domain.builders.CenterBuilder)8 ClientBuilder (org.mifos.domain.builders.ClientBuilder)8 GroupBuilder (org.mifos.domain.builders.GroupBuilder)8 CustomerException (org.mifos.customers.exceptions.CustomerException)6 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)3 UserContext (org.mifos.security.util.UserContext)3 LocalDate (org.joda.time.LocalDate)2 CustomerBO (org.mifos.customers.business.CustomerBO)2 CustomerService (org.mifos.customers.business.service.CustomerService)2 AuditLog (org.mifos.framework.components.audit.business.AuditLog)2 AuditTransactionForTests (org.mifos.framework.hibernate.helper.AuditTransactionForTests)2 DateTimeService (org.mifos.framework.util.DateTimeService)2 MifosUser (org.mifos.security.MifosUser)2