Search in sources :

Example 46 with QueryResult

use of org.mifos.framework.hibernate.helper.QueryResult in project head by mifos.

the class CustomerPersistenceIntegrationTest method testSearchWithOfficeId.

@Test
public void testSearchWithOfficeId() throws Exception {
    createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
    StaticHibernateUtil.flushSession();
    QueryResult queryResult = new CustomerPersistence().search("C", Short.valueOf("3"), Short.valueOf("1"), Short.valueOf("1"), filters);
    Assert.assertNotNull(queryResult);
    Assert.assertEquals(2, queryResult.getSize());
    Assert.assertEquals(2, queryResult.get(0, 10).size());
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) Test(org.junit.Test)

Example 47 with QueryResult

use of org.mifos.framework.hibernate.helper.QueryResult in project head by mifos.

the class CustomerPersistenceIntegrationTest method testSearchWithGlobalNo.

@Test
public void testSearchWithGlobalNo() throws Exception {
    createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
    StaticHibernateUtil.flushSession();
    QueryResult queryResult = new CustomerPersistence().search(group.getGlobalCustNum(), Short.valueOf("3"), Short.valueOf("1"), Short.valueOf("1"), filters);
    Assert.assertNotNull(queryResult);
    Assert.assertEquals(1, queryResult.getSize());
    Assert.assertEquals(1, queryResult.get(0, 10).size());
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) Test(org.junit.Test)

Example 48 with QueryResult

use of org.mifos.framework.hibernate.helper.QueryResult in project head by mifos.

the class CustomerPersistenceIntegrationTest method testSearchWithAccountGlobalNo.

@Test
public void testSearchWithAccountGlobalNo() throws Exception {
    getCustomer();
    StaticHibernateUtil.flushSession();
    QueryResult queryResult = new CustomerPersistence().search(groupAccount.getGlobalAccountNum(), Short.valueOf("3"), Short.valueOf("1"), Short.valueOf("1"), filters);
    Assert.assertNotNull(queryResult);
    Assert.assertEquals(1, queryResult.getSize());
    Assert.assertEquals(1, queryResult.get(0, 10).size());
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) Test(org.junit.Test)

Example 49 with QueryResult

use of org.mifos.framework.hibernate.helper.QueryResult in project head by mifos.

the class CustomerPersistenceIntegrationTest method testSearchForActiveInBadStandingLoanAccount.

@SuppressWarnings("unchecked")
@Test
public void testSearchForActiveInBadStandingLoanAccount() throws Exception {
    groupAccount = getLoanAccount();
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    groupAccount.changeStatus(AccountState.LOAN_ACTIVE_IN_BAD_STANDING, null, "Changing to badStanding", loggedInUser);
    TestObjectFactory.updateObject(groupAccount);
    groupAccount = TestObjectFactory.getObject(LoanBO.class, groupAccount.getAccountId());
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    QueryResult queryResult = new CustomerPersistence().search(group.getGlobalCustNum(), Short.valueOf("3"), Short.valueOf("1"), Short.valueOf("1"), filters);
    Assert.assertNotNull(queryResult);
    Assert.assertEquals(1, queryResult.getSize());
    List results = queryResult.get(0, 10);
    Assert.assertEquals(1, results.size());
    CustomerSearchDto customerSearchDto = (CustomerSearchDto) results.get(0);
    Assert.assertEquals(1, customerSearchDto.getLoanGlobalAccountNum().size());
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) CustomerSearchDto(org.mifos.customers.business.CustomerSearchDto) List(java.util.List) Test(org.junit.Test)

Example 50 with QueryResult

use of org.mifos.framework.hibernate.helper.QueryResult in project head by mifos.

the class CustomerPersistenceIntegrationTest method testSearchGropAndClientForLoNoResults.

@Test
public void testSearchGropAndClientForLoNoResults() throws Exception {
    meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting, Short.valueOf("3"), Short.valueOf("3"));
    group = TestObjectFactory.createGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, "1234", true, new java.util.Date(), null, null, null, Short.valueOf("3"), center);
    StaticHibernateUtil.flushSession();
    QueryResult queryResult = new CustomerPersistence().searchGroupClient("C", Short.valueOf("3"), false);
    Assert.assertNotNull(queryResult);
    Assert.assertEquals(0, queryResult.getSize());
    Assert.assertEquals(0, queryResult.get(0, 10).size());
}
Also used : QueryResult(org.mifos.framework.hibernate.helper.QueryResult) Date(java.sql.Date) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Aggregations

QueryResult (org.mifos.framework.hibernate.helper.QueryResult)53 Test (org.junit.Test)30 HibernateSearchException (org.mifos.framework.exceptions.HibernateSearchException)16 PersistenceException (org.mifos.framework.exceptions.PersistenceException)14 ArrayList (java.util.ArrayList)13 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)10 QueryInputs (org.mifos.framework.hibernate.helper.QueryInputs)10 Param (org.mifos.customers.util.helpers.Param)9 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 UserContext (org.mifos.security.util.UserContext)7 MifosUser (org.mifos.security.MifosUser)5 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)4 List (java.util.List)3 Query (org.hibernate.Query)3 Session (org.hibernate.Session)3 AccountSearchResultsDto (org.mifos.accounts.util.helpers.AccountSearchResultsDto)3 CustomerSearchDto (org.mifos.customers.business.CustomerSearchDto)3 CustomerException (org.mifos.customers.exceptions.CustomerException)3 CustomerSearchResultDto (org.mifos.dto.domain.CustomerSearchResultDto)3 Date (java.sql.Date)2