use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientIntegrationTest method testFailureCreatePendingClientWithParentGroupInLowerStatus.
@Test
public void testFailureCreatePendingClientWithParentGroupInLowerStatus() throws Exception {
try {
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_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(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
createParentObjects(CustomerStatus.GROUP_PARTIAL);
client = new ClientBO(TestUtils.makeUserWithLocales(), clientNameDetailDto.getDisplayName(), CustomerStatus.CLIENT_PENDING, null, null, null, null, null, null, personnel, group.getOffice(), group, null, null, null, null, YesNoFlag.YES.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto);
Assert.fail();
} catch (CustomerException e) {
Assert.assertNull(client);
Assert.assertEquals(ClientConstants.INVALID_CLIENT_STATUS_EXCEPTION, e.getKey());
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientIntegrationTest method testFailureCreateActiveClientWithoutLO.
@Test
public void testFailureCreateActiveClientWithoutLO() throws Exception {
List<FeeDto> fees = getFees();
try {
meeting = getMeeting();
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "", "last", "");
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(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("3")), null, null, null, null, fees, null, personnel, officeBo, meeting, null, null, null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
Assert.fail();
} catch (CustomerException e) {
Assert.assertNull(client);
Assert.assertEquals(CustomerConstants.INVALID_LOAN_OFFICER, e.getKey());
}
removeFees(fees);
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientIntegrationTest method testSuccessfulValidateBeforeAddingClientToGroup_Amount.
@Test
public void testSuccessfulValidateBeforeAddingClientToGroup_Amount() throws Exception {
String oldMeetingPlace = "Tunis";
MeetingBO weeklyMeeting = new MeetingBO(WeekDay.FRIDAY, Short.valueOf("1"), new java.util.Date(), MeetingType.CUSTOMER_MEETING, oldMeetingPlace);
client = TestObjectFactory.createClient("clientname", weeklyMeeting, CustomerStatus.CLIENT_CANCELLED);
group1 = TestObjectFactory.createGroupUnderBranch("Group2", CustomerStatus.GROUP_PENDING, new Short("3"), getMeeting(), new Short("1"));
try {
client.validateBeforeAddingClientToGroup(group1);
Assert.fail();
} catch (CustomerException expected) {
Assert.assertEquals(CustomerConstants.CLIENT_IS_CLOSED_OR_CANCELLED_EXCEPTION, expected.getKey());
Assert.assertNotSame(CustomerConstants.CLIENT_HAVE_OPEN_LOAN_ACCOUNT_EXCEPTION, expected.getKey());
Assert.assertTrue(true);
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupValidationTest method givenAnActiveSavingsAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation.
@Test
public void givenAnActiveSavingsAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation() {
// setup
CenterBO center = new CenterBuilder().build();
GroupBO group = new GroupBuilder().withParentCustomer(center).build();
ClientBO client = new ClientBuilder().withParentCustomer(group).active().buildForUnitTests();
group.addChild(client);
SavingsBO savings = new SavingsAccountBuilder().active().withCustomer(group).build();
client.addAccount(savings);
// exercise test
try {
group.validateNoActiveAccountsExist();
fail("should fail validation");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_CHILDREN_HAS_ACTIVE_ACCOUNT));
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupValidationTest method givenAnActiveLoanAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation.
@Test
public void givenAnActiveLoanAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation() {
// setup
CenterBO center = new CenterBuilder().build();
GroupBO group = new GroupBuilder().withParentCustomer(center).build();
ClientBO client = new ClientBuilder().withParentCustomer(group).active().buildForUnitTests();
group.addChild(client);
LoanBO loan = new LoanAccountBuilder().activeInGoodStanding().build();
client.addAccount(loan);
// exercise test
try {
group.validateNoActiveAccountsExist();
fail("should fail validation");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_CHILDREN_HAS_ACTIVE_ACCOUNT));
}
}
Aggregations