Search in sources :

Example 1 with TermElement

use of com.querydsl.lucene5.TermElement in project querydsl by querydsl.

the class TermElementTest method testEqualsAndHashCode.

@Test
public void testEqualsAndHashCode() {
    TermElement el1 = new TermElement("x"), el2 = new TermElement("x"), el3 = new TermElement("y");
    assertEquals(el1, el2);
    assertFalse(el1.equals(el3));
    assertEquals(el1.hashCode(), el2.hashCode());
}
Also used : TermElement(com.querydsl.lucene5.TermElement) Test(org.junit.Test)

Example 2 with TermElement

use of com.querydsl.lucene5.TermElement in project querydsl by querydsl.

the class TermElementTest method test.

@Test
public void test() {
    StringPath title = Expressions.stringPath("title");
    LuceneSerializer serializer = new LuceneSerializer(false, true);
    QueryMetadata metadata = new DefaultQueryMetadata();
    assertEquals("title:\"Hello World\"", serializer.toQuery(title.eq("Hello World"), metadata).toString());
    assertEquals("title:Hello World", serializer.toQuery(title.eq(new TermElement("Hello World")), metadata).toString());
}
Also used : QueryMetadata(com.querydsl.core.QueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) DefaultQueryMetadata(com.querydsl.core.DefaultQueryMetadata) TermElement(com.querydsl.lucene5.TermElement) StringPath(com.querydsl.core.types.dsl.StringPath) LuceneSerializer(com.querydsl.lucene5.LuceneSerializer) Test(org.junit.Test)

Aggregations

TermElement (com.querydsl.lucene5.TermElement)2 Test (org.junit.Test)2 DefaultQueryMetadata (com.querydsl.core.DefaultQueryMetadata)1 QueryMetadata (com.querydsl.core.QueryMetadata)1 StringPath (com.querydsl.core.types.dsl.StringPath)1 LuceneSerializer (com.querydsl.lucene5.LuceneSerializer)1