use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.
the class CustomerBusinessServiceTest method testInvalidConnectionGetCustomer.
@Test
public void testInvalidConnectionGetCustomer() throws PersistenceException {
Integer customerId = new Integer(1);
try {
when(customerPersistence.getCustomer(customerId)).thenThrow(new PersistenceException("some exception"));
service.getCustomer(customerId);
junit.framework.Assert.fail("should fail because of invalid session");
} catch (ServiceException e) {
}
}
use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.
the class CenterBOTest method testInvalidConnectionInConstructor.
@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionInConstructor() throws PersistenceException {
try {
Short id = new Short("1");
OfficeBO office = mock(OfficeBO.class);
when(office.getOfficeId()).thenReturn(id);
when(customerPersistence.getCustomerCountForOffice(CustomerLevel.CENTER, id)).thenThrow(new PersistenceException("some exception"));
new CenterBO(mock(UserContext.class), "name", null, null, null, "externalId", null, office, mock(MeetingBO.class), mock(PersonnelBO.class), customerPersistence);
junit.framework.Assert.fail("should fail because of invalid session");
} catch (CustomerException e) {
}
}
use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.
the class CheckListBusinessServiceTest method testInvalidConnectionRetrieveAllAccountCheckLists.
@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionRetrieveAllAccountCheckLists() throws PersistenceException {
try {
when(checkListPersistence.retreiveAllAccountCheckLists()).thenThrow(new PersistenceException("some exception"));
service.retreiveAllAccountCheckLists();
junit.framework.Assert.fail("should fail because of invalid session");
} catch (ServiceException e) {
}
}
use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.
the class CheckListBusinessServiceTest method testInvalidConnectionRetrieveAllCustomerCheckLists.
@Test
@ExpectedException(value = CustomerException.class)
public void testInvalidConnectionRetrieveAllCustomerCheckLists() throws PersistenceException {
try {
when(checkListPersistence.retreiveAllCustomerCheckLists()).thenThrow(new PersistenceException("some exception"));
service.retreiveAllCustomerCheckLists();
junit.framework.Assert.fail("should fail because of invalid session");
} catch (ServiceException e) {
}
}
use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.
the class TestObjectFactory method generateOfficeGlobalNo.
private static String generateOfficeGlobalNo() throws OfficeException {
try {
/*
* TODO: Why not auto-increment? Fetching the max and adding one would seem to have a race condition.
*/
String officeGlobelNo = String.valueOf(new OfficePersistence().getMaxOfficeId().intValue() + 1);
if (officeGlobelNo.length() > 4) {
throw new OfficeException(OfficeConstants.MAXOFFICELIMITREACHED);
}
StringBuilder temp = new StringBuilder("");
for (int i = officeGlobelNo.length(); i < 4; i++) {
temp.append("0");
}
return officeGlobelNo = temp.append(officeGlobelNo).toString();
} catch (PersistenceException e) {
throw new OfficeException(e);
}
}
Aggregations