use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupValidationTest method givenCenterHasMeetingWithDifferentPeriodicityGroupTransferToCenterShouldFailValidation.
@Test
public void givenCenterHasMeetingWithDifferentPeriodicityGroupTransferToCenterShouldFailValidation() {
// setup
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).build();
CenterBO toCenter = new CenterBuilder().withName("receivingCenter").with(weeklyMeeting).build();
MeetingBO monthlyMeeting = new MeetingBuilder().customerMeeting().monthly().every(1).onDayOfMonth(1).build();
CenterBO oldCenter = new CenterBuilder().withName("oldCenter").with(monthlyMeeting).build();
GroupBO group = new GroupBuilder().withParentCustomer(oldCenter).build();
// exercise test
try {
group.validateReceivingCenter(toCenter);
fail("should fail validation");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_MEETING_FREQUENCY_MISMATCH));
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupValidationTest method loanOfficerMustBeAssigned.
@Test
public void loanOfficerMustBeAssigned() {
OfficeBO office = new OfficeBuilder().build();
group = new GroupBuilder().withName("group-On-branch").withOffice(office).withLoanOfficer(null).buildAsTopOfHierarchy();
try {
group.validate();
fail("should throw customer exception as loan officer must exist when creating group under a branch.");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_SELECT_LOAN_OFFICER));
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupValidationTest method givenCenterIsSameAsGroupsParentGroupTransferToCenterShouldFailValidation.
@Test
public void givenCenterIsSameAsGroupsParentGroupTransferToCenterShouldFailValidation() {
// setup
CenterBO center = new CenterBuilder().build();
GroupBO group = new GroupBuilder().withParentCustomer(center).build();
// exercise test
try {
group.validateReceivingCenter(center);
fail("should fail validation");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_SAME_CENTER_TRANSFER));
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupValidationTest method givenGroupIsTrainedButTrainedDateIsNotSetThenShouldThrowCustomerException.
@Test
public void givenGroupIsTrainedButTrainedDateIsNotSetThenShouldThrowCustomerException() {
PersonnelBO formedBy = new PersonnelBuilder().build();
group = new GroupBuilder().withName("group-On-center").withParentCustomer(center).formedBy(formedBy).isTrained().trainedOn(null).build();
try {
group.validate();
fail("should throw customer exception as trained date must be provided if in trained state when creating group.");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.INVALID_TRAINED_OR_TRAINEDDATE));
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustomerStatusUpdateTest method throwsCheckedExceptionWhenUserDoesNotHavePermissionToUpdateCustomerStatus.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenUserDoesNotHavePermissionToUpdateCustomerStatus() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().build();
CenterBO existingCenter = new CenterBuilder().withVersion(customerStatusUpdate.getVersionNum()).build();
// stubbing
when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(existingCenter);
doThrow(new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED)).when(customerDao).checkPermissionForStatusChange(anyShort(), eq(userContext), anyShort(), anyShort(), anyShort());
// exercise test
customerService.updateCustomerStatus(userContext, customerStatusUpdate);
// verification
verify(customerDao).checkPermissionForStatusChange(customerStatusUpdate.getNewStatus().getValue(), userContext, customerStatusUpdate.getCustomerStatusFlag().getValue(), existingCenter.getOffice().getOfficeId(), existingCenter.getPersonnel().getPersonnelId());
}
Aggregations