예제 #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());
  }
예제 #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());
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
  }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #11
0
 @Test
 public void Loe_Equal() throws Exception {
   testQuery(rating.loe("Good"), "rating:[* TO good]", 1);
 }
예제 #12
0
 @Test
 public void Loe() throws Exception {
   testQuery(rating.loe("Superb"), "rating:[* TO superb]", 1);
 }
예제 #13
0
 @Test
 public void Ends_With_Empty_String() throws Exception {
   testQuery(title.endsWith(""), "title:*", 1);
 }
예제 #14
0
 @Test
 public void Contains_Empty_String() throws Exception {
   testQuery(title.contains(""), "title:**", 1);
 }
예제 #15
0
 @Test
 public void Equals_Empty_String() throws Exception {
   testQuery(title.eq(""), "title:", 0);
 }
예제 #16
0
 @Test
 public void Goe_Equal() throws Exception {
   testQuery(rating.goe("Good"), "rating:[good TO *]", 1);
 }
예제 #17
0
 @Test
 public void Gt_Not_In_Range_Because_Equal() throws Exception {
   testQuery(rating.gt("Good"), "rating:{good TO *}", 0);
 }
예제 #18
0
 @Test
 public void Loe_Not_Found() throws Exception {
   testQuery(rating.loe("Bad"), "rating:[* TO bad]", 0);
 }
예제 #19
0
 @Test
 public void Gt() throws Exception {
   testQuery(rating.gt("Bad"), "rating:{bad TO *}", 1);
 }
예제 #20
0
 @Test
 public void Between_Is_Inclusive_From_Start() throws Exception {
   testQuery(title.between("Jurassic", "Kundun"), "title:[jurassic TO kundun]", 1);
 }
예제 #21
0
 @Test
 public void Goe() throws Exception {
   testQuery(rating.goe("Bad"), "rating:[bad TO *]", 1);
 }
예제 #22
0
 @Test
 public void Between_Is_Inclusive_To_End() throws Exception {
   testQuery(title.between("Indiana", "Jurassic"), "title:[indiana TO jurassic]", 1);
 }
예제 #23
0
 @Test
 public void Goe_Not_Found() throws Exception {
   testQuery(rating.goe("Hood"), "rating:[hood TO *]", 0);
 }
예제 #24
0
 @Test
 public void Between_Does_Not_Find_Results() throws Exception {
   testQuery(title.between("Indiana", "Jurassib"), "title:[indiana TO jurassib]", 0);
 }
예제 #25
0
 @Test
 public void Not_Equals_Empty_String() throws Exception {
   testQuery(title.ne(""), "-title: +*:*", 1);
 }
예제 #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);
 }
예제 #27
0
 @Test
 public void Like_Empty_String() throws Exception {
   testQuery(title.like(""), "title:", 0);
 }
예제 #28
0
 @Test
 public void Lt() throws Exception {
   testQuery(rating.lt("Superb"), "rating:{* TO superb}", 1);
 }
예제 #29
0
 @Test
 public void Between_Empty_Strings() throws Exception {
   testQuery(title.between("", ""), "title:[ TO ]", 0);
 }
예제 #30
0
 @Test
 public void Lt_Not_In_Range_Because_Equal() throws Exception {
   testQuery(rating.lt("Good"), "rating:{* TO good}", 0);
 }