@Test(expectedExceptions = ParsingException.class, expectedExceptionsMessageRegExp = "ISPN028522: .*property is analyzed.*") public void testExactMatchOnAnalyzedFieldNotAllowed() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " where longDescription = 'Birthday present'"); q.list(); }
@Test(expectedExceptions = ParsingException.class, expectedExceptionsMessageRegExp = "ISPN028526: Invalid query.*") public void testFullTextRegexpFuzzyNotAllowed() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " t where t.longDescription : /[R|r]ent/~2"); q.list(); }
@Test(enabled = false) public void testParamWithSpacePadding() { //todo [anistor] need special tree nodes for all literal types (and for params) to be able to distinguish them better; QueryRendererDelegate.predicateXXX should receive such a tree node instead of a string Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " where id = : idParam"); List<Transaction> list = q.list(); assertEquals(1, list.size()); }
public void testFullTextTermOccur() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " t where not (t.longDescription : (+'failed') or t.longDescription : 'blocked')"); List<Transaction> list = q.list(); assertEquals(56, list.size()); }
public void testFullTextFuzzy() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " t where t.longDescription : 'retn'~"); List<Transaction> list = q.list(); assertEquals(1, list.size()); }
public void testExactMatch() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " where description = 'Birthday present'"); List<Transaction> list = q.list(); assertEquals(1, list.size()); }
public void testFullTextTerm() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " where longDescription:'rent'"); List<Transaction> list = q.list(); assertEquals(1, list.size()); }
public void testFullTextTermRightOperandAnalyzed() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " where longDescription:'RENT'"); List<Transaction> list = q.list(); assertEquals(1, list.size()); }
public void testFullTextTermBoost() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " where longDescription:('rent'^8 'shoes')"); List<Transaction> list = q.list(); assertEquals(51, list.size()); }
public void testFullTextTermDoesntOccur() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " t where t.longDescription : (-'really')"); List<Transaction> list = q.list(); assertEquals(6, list.size()); }
public void testFullTextRange() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " t where t.amount : [23 to 45]"); List<Transaction> list = q.list(); assertEquals(2, list.size()); }
public void testFullTextWithAggregation() { Query q = createQueryFromString("select t.accountId, max(t.amount), max(t.description) from " + getModelFactory().getTransactionTypeName() + " t where t.longDescription : (+'beer' && -'food') group by t.accountId"); List<Object[]> list = q.list(); assertEquals(1, list.size()); assertEquals(2, list.get(0)[0]); assertEquals(149.0, list.get(0)[1]); assertEquals("Expensive shoes 9", list.get(0)[2]); }
public void testFullTextTermBoostAndSorting() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " where longDescription:('rent'^8 'shoes') order by amount"); List<Transaction> list = q.list(); assertEquals(51, list.size()); }
public void testFullTextRangeWildcard() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " t where t.longDescription : [* to *]"); List<Transaction> list = q.list(); assertEquals(54, list.size()); }
public void testFullTextPrefix() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " t where t.longDescription : 'ren*'"); List<Transaction> list = q.list(); assertEquals(1, list.size()); }
public void testFullTextWildcard() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " t where t.longDescription : 're?t'"); List<Transaction> list = q.list(); assertEquals(1, list.size()); }
public void testFullTextFuzzySpecifiedEdits() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " t where t.longDescription : 'ajnuary'~1"); List<Transaction> list = q.list(); assertEquals(1, list.size()); q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " t where t.longDescription : 'ajunary'~1"); list = q.list(); assertEquals(0, list.size()); }
public void testFullTextTerm() { QueryFactory qf = getQueryFactory(); Query q = qf.create("from " + getModelFactory().getTransactionTypeName() + " where longDescription:'rent'"); List<Transaction> list = q.list(); assertEquals(1, list.size()); }
public void testFullTextPhrase() { QueryFactory qf = getQueryFactory(); Query q = qf.create("from " + getModelFactory().getTransactionTypeName() + " where longDescription:'expensive shoes'"); List<Transaction> list = q.list(); assertEquals(50, list.size()); }
public void testParam() { Query q = createQueryFromString("from " + getModelFactory().getTransactionTypeName() + " where id = :idParam"); q.setParameter("idParam", 1); List<Transaction> list = q.list(); assertEquals(1, list.size()); assertEquals(1, list.get(0).getId()); q.setParameter("idParam", 2); list = q.list(); assertEquals(1, list.size()); assertEquals(2, list.get(0).getId()); }