@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "ISPN014802: 'from' must be an instance of java.lang.Comparable") public void testBetweenArgsAreComparable() { QueryFactory qf = getQueryFactory(); qf.from(getModelFactory().getTransactionImplClass()) .having("date").between(new Object(), new Object()) .build(); }
public void testSampleDomainQuery24() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getUserImplClass()) .not().having("id").between(1, 2).includeLower(false) .build(); List<User> list = q.list(); assertEquals(2, list.size()); assertTrue(Arrays.asList(1, 3).contains(list.get(0).getId())); assertTrue(Arrays.asList(1, 3).contains(list.get(1).getId())); }
public void testSampleDomainQuery25() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getUserImplClass()) .not().having("id").between(1, 2).includeUpper(false) .build(); List<User> list = q.list(); assertEquals(2, list.size()); assertTrue(Arrays.asList(2, 3).contains(list.get(0).getId())); assertTrue(Arrays.asList(2, 3).contains(list.get(1).getId())); }
}else{ if (this.startKey!=null && this.endKey!=null) context = (context == null ? qb : context.and()).having(getPrimaryFieldName()).between(this.startKey,this.endKey); else if (this.startKey!=null) context = (context == null ? qb : context.and()).having(getPrimaryFieldName()).between(this.startKey,null); else if (this.endKey!=null) (context == null ? qb : context.and()).having(getPrimaryFieldName()).between(null,this.endKey);
public void testDateFilteringWithGroupBy() throws Exception { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getTransactionImplClass()) .select("date") .having("date").between(makeDate("2013-02-15"), makeDate("2013-03-15")) .groupBy("date") .build(); List<Object[]> list = q.list(); assertEquals(1, list.size()); assertEquals(1, list.get(0).length); assertEquals(java.util.Date.class, list.get(0)[0].getClass()); assertEquals(makeDate("2013-02-27"), list.get(0)[0]); }
public void testSampleDomainQuery9() throws Exception { QueryFactory qf = getQueryFactory(); // all the transactions that happened in January 2013, projected by date field only Query q = qf.from(getModelFactory().getTransactionImplClass()) .select("date") .having("date").between(makeDate("2013-01-01"), makeDate("2013-01-31")) .build(); List<Object[]> list = q.list(); assertEquals(4, list.size()); assertEquals(1, list.get(0).length); assertEquals(1, list.get(1).length); assertEquals(1, list.get(2).length); assertEquals(1, list.get(3).length); for (int i = 0; i < 4; i++) { Date d = (Date) list.get(i)[0]; assertTrue(d.compareTo(makeDate("2013-01-31")) <= 0); assertTrue(d.compareTo(makeDate("2013-01-01")) >= 0); } }
public void testSampleDomainQuery23() { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getUserImplClass()) .not().having("id").between(1, 2) .build(); List<User> list = q.list(); assertEquals(1, list.size()); assertEquals(3, list.get(0).getId()); }
public void testDateGrouping1() throws Exception { QueryFactory qf = getQueryFactory(); Query q = qf.from(getModelFactory().getTransactionImplClass()) .select("date") .having("date").between(makeDate("2013-02-15"), makeDate("2013-03-15")) .groupBy("date") .build(); List<Object[]> list = q.list(); assertEquals(1, list.size()); assertEquals(1, list.get(0).length); assertEquals(makeDate("2013-02-27"), list.get(0)[0]); }
public void testSampleDomainQuery8() throws Exception { QueryFactory qf = getQueryFactory(); // all the transactions that happened in January 2013 Query q = qf.from(getModelFactory().getTransactionImplClass()) .having("date").between(makeDate("2013-01-01"), makeDate("2013-01-31")) .build(); List<Transaction> list = q.list(); assertEquals(4, list.size()); for (Transaction t : list) { assertTrue(t.getDate().compareTo(makeDate("2013-01-31")) <= 0); assertTrue(t.getDate().compareTo(makeDate("2013-01-01")) >= 0); } }
public void testBetween1() throws Exception { QueryFactory qf = getQueryFactory(); // all the transactions that happened in January 2013 Query q = qf.from(getModelFactory().getTransactionImplClass()) .having("date").between(makeDate("2013-01-01"), makeDate("2013-01-31")) .build(); List<Transaction> list = q.list(); assertEquals(4, list.size()); for (Transaction t : list) { assertTrue(t.getDate().compareTo(makeDate("2013-01-31")) <= 0); assertTrue(t.getDate().compareTo(makeDate("2013-01-01")) >= 0); } }
public void testBetween3() throws Exception { QueryFactory qf = getQueryFactory(); // all the transactions that happened in January 2013 Query q = qf.from(getModelFactory().getTransactionImplClass()) .having("date").between(makeDate("2013-01-01"), makeDate("2013-01-31")).includeLower(false) .build(); List<Transaction> list = q.list(); assertEquals(3, list.size()); for (Transaction t : list) { assertTrue(t.getDate().compareTo(makeDate("2013-01-31")) <= 0); assertTrue(t.getDate().compareTo(makeDate("2013-01-01")) > 0); } }
public void testBetween2() throws Exception { QueryFactory qf = getQueryFactory(); // all the transactions that happened in January 2013 Query q = qf.from(getModelFactory().getTransactionImplClass()) .having("date").between(makeDate("2013-01-01"), makeDate("2013-01-31")).includeUpper(false) .build(); List<Transaction> list = q.list(); assertEquals(3, list.size()); for (Transaction t : list) { assertTrue(t.getDate().compareTo(makeDate("2013-01-31")) < 0); assertTrue(t.getDate().compareTo(makeDate("2013-01-01")) >= 0); } }