Example #1
0
 @Test
 public void Nothing_Found_With_Not_Equals_Or_Equals() throws Exception {
   testQuery(
       title.ne("jurassic park").or(rating.eq("lousy")),
       "(-title:\"jurassic park\" +*:*) rating:lousy",
       0);
 }
  @Test
  public void Serialization() throws IOException, ClassNotFoundException {
    StringPath expr = Expressions.stringPath("str");
    metadata.addJoin(JoinType.DEFAULT, expr);
    metadata.addFlag(new QueryFlag(Position.AFTER_FILTERS, ""));
    metadata.addGroupBy(expr);
    metadata.addHaving(expr.isEmpty());
    //        metadata.getJoins().get(0).addFlag(new JoinFlag(""));
    metadata.addJoinCondition(expr.isEmpty());
    metadata.addOrderBy(expr.asc());
    metadata.setProjection(expr);
    metadata.addWhere(expr.isEmpty());

    QueryMetadata metadata2 = Serialization.serialize(metadata);

    assertEquals(metadata.getFlags(), metadata2.getFlags());
    assertEquals(metadata.getGroupBy().get(0), metadata2.getGroupBy().get(0));
    assertEquals(metadata.getGroupBy(), metadata2.getGroupBy());
    assertEquals(metadata.getHaving(), metadata2.getHaving());
    assertEquals(metadata.getJoins(), metadata2.getJoins());
    assertEquals(metadata.getModifiers(), metadata2.getModifiers());
    assertEquals(metadata.getOrderBy(), metadata2.getOrderBy());
    assertEquals(metadata.getParams(), metadata2.getParams());
    assertEquals(metadata.getProjection(), metadata2.getProjection());
    assertEquals(metadata.getWhere(), metadata2.getWhere());
  }
Example #3
0
 @Test
 public void Various1() {
   StringPath str = Expressions.stringPath("str");
   assertEquals(
       Arrays.asList("a", "ab"),
       from(str, "a", "ab", "cd", "de").where(str.startsWith("a")).select(str).fetch());
 }
Example #4
0
 @Test
 public void Eq_or_Eq_and_Eq_Does_Not_Find_Results() throws Exception {
   testQuery(
       title.eq("jeeves").or(rating.eq("superb")).and(author.eq("michael crichton")),
       "+(title:jeeves rating:superb) +author:\"michael crichton\"",
       0);
 }
Example #5
0
 @Test(expected = UnsupportedOperationException.class)
 public void Title_Equals_Ignore_Case_Negation_Or_Rating_Equals_Ignore_Case() throws Exception {
   testQuery(
       title.equalsIgnoreCase("House").not().or(rating.equalsIgnoreCase("Good")),
       "-title:house rating:good",
       1);
 }
Example #6
0
 @Test
 @Ignore
 public void Eq_and_Eq_and_eq() throws Exception {
   testQuery(
       title.eq("Jurassic Park").and(year.eq(1990)).and(author.eq("Michael Crichton")),
       "+(+title:\"jurassic park\" +year:" + YEAR_PREFIX_CODED + ") +author:\"michael crichton\"",
       1);
 }
Example #7
0
  @Test
  public void QueryElement() throws Exception {
    Query query1 = serializer.toQuery(author.like("Michael"), metadata);
    Query query2 = serializer.toQuery(text.like("Text"), metadata);

    BooleanExpression query = Expressions.anyOf(new QueryElement(query1), new QueryElement(query2));
    testQuery(query, "author:michael text:text", 1);
  }
Example #8
0
 @Test(expected = UnsupportedOperationException.class)
 public void Equals_Ignore_Case_And_Or() throws Exception {
   testQuery(
       title
           .equalsIgnoreCase("Jurassic Park")
           .and(rating.equalsIgnoreCase("Bad"))
           .or(author.equalsIgnoreCase("Michael Crichton")),
       "(+title:\"jurassic park\" +rating:bad) author:\"michael crichton\"",
       1);
 }
Example #9
0
 @Test(expected = UnsupportedOperationException.class)
 public void Title_Equals_Ignore_Case_Or_Year_Equals() throws Exception {
   testQuery(
       title.equalsIgnoreCase("House").or(year.eq(1990)),
       "title:house year:" + YEAR_PREFIX_CODED,
       1);
 }
Example #10
0
 @Test
 @Ignore
 public void Eq_and_eq() throws Exception {
   testQuery(
       title.eq("Jurassic Park").and(year.eq(1990)),
       "+title:\"jurassic park\" +year:" + YEAR_PREFIX_CODED,
       1);
 }
Example #11
0
 @Test
 public void Loe_Equal() throws Exception {
   testQuery(rating.loe("Good"), "rating:[* TO good]", 1);
 }
Example #12
0
 @Test
 public void Loe() throws Exception {
   testQuery(rating.loe("Superb"), "rating:[* TO superb]", 1);
 }
Example #13
0
 @Test
 public void Ends_With_Empty_String() throws Exception {
   testQuery(title.endsWith(""), "title:*", 1);
 }
Example #14
0
 @Test
 public void Contains_Empty_String() throws Exception {
   testQuery(title.contains(""), "title:**", 1);
 }
Example #15
0
 @Test
 public void Equals_Empty_String() throws Exception {
   testQuery(title.eq(""), "title:", 0);
 }
Example #16
0
 @Test
 public void Goe_Equal() throws Exception {
   testQuery(rating.goe("Good"), "rating:[good TO *]", 1);
 }
Example #17
0
 @Test
 public void Gt_Not_In_Range_Because_Equal() throws Exception {
   testQuery(rating.gt("Good"), "rating:{good TO *}", 0);
 }
Example #18
0
 @Test
 public void Loe_Not_Found() throws Exception {
   testQuery(rating.loe("Bad"), "rating:[* TO bad]", 0);
 }
Example #19
0
 @Test
 public void Gt() throws Exception {
   testQuery(rating.gt("Bad"), "rating:{bad TO *}", 1);
 }
Example #20
0
 @Test
 public void Between_Is_Inclusive_From_Start() throws Exception {
   testQuery(title.between("Jurassic", "Kundun"), "title:[jurassic TO kundun]", 1);
 }
Example #21
0
 @Test
 public void Goe() throws Exception {
   testQuery(rating.goe("Bad"), "rating:[bad TO *]", 1);
 }
Example #22
0
 @Test
 public void Between_Is_Inclusive_To_End() throws Exception {
   testQuery(title.between("Indiana", "Jurassic"), "title:[indiana TO jurassic]", 1);
 }
Example #23
0
 @Test
 public void Goe_Not_Found() throws Exception {
   testQuery(rating.goe("Hood"), "rating:[hood TO *]", 0);
 }
Example #24
0
 @Test
 public void Between_Does_Not_Find_Results() throws Exception {
   testQuery(title.between("Indiana", "Jurassib"), "title:[indiana TO jurassib]", 0);
 }
Example #25
0
 @Test
 public void Not_Equals_Empty_String() throws Exception {
   testQuery(title.ne(""), "-title: +*:*", 1);
 }
Example #26
0
 @Test
 public void In() throws Exception {
   testQuery(title.in(Arrays.asList("jurassic", "park")), "title:jurassic title:park", 1);
   testQuery(title.in("jurassic", "park"), "title:jurassic title:park", 1);
   testQuery(title.eq("jurassic").or(title.eq("park")), "title:jurassic title:park", 1);
 }
Example #27
0
 @Test
 public void Like_Empty_String() throws Exception {
   testQuery(title.like(""), "title:", 0);
 }
Example #28
0
 @Test
 public void Lt() throws Exception {
   testQuery(rating.lt("Superb"), "rating:{* TO superb}", 1);
 }
Example #29
0
 @Test
 public void Between_Empty_Strings() throws Exception {
   testQuery(title.between("", ""), "title:[ TO ]", 0);
 }
Example #30
0
 @Test
 public void Lt_Not_In_Range_Because_Equal() throws Exception {
   testQuery(rating.lt("Good"), "rating:{* TO good}", 0);
 }