Search in sources :

Example 1 with ParseFieldsResult

use of org.folio.services.util.parser.ParseFieldsResult in project mod-source-record-storage by folio-org.

the class SearchExpressionParserUnitTest method shouldParseFieldsSearchExpression_forDateRangeOperand_NotEqualsOperator.

@Test
public void shouldParseFieldsSearchExpression_forDateRangeOperand_NotEqualsOperator() {
    // given
    String fieldsSearchExpression = "005.date not= '201701025'";
    // when
    ParseFieldsResult result = parseFieldsSearchExpression(fieldsSearchExpression);
    // then
    assertTrue(result.isEnabled());
    assertEquals(singletonList("201701025"), result.getBindingParams());
    assertEquals(new HashSet<>(singletonList("005")), result.getFieldsToJoin());
    assertEquals("to_date(substring(\"i005\".\"value\", 1, 8), 'yyyymmdd') <> ?", result.getWhereExpression());
}
Also used : ParseFieldsResult(org.folio.services.util.parser.ParseFieldsResult) Test(org.junit.Test)

Example 2 with ParseFieldsResult

use of org.folio.services.util.parser.ParseFieldsResult in project mod-source-record-storage by folio-org.

the class SearchExpressionParserUnitTest method shouldParseFieldsSearchExpression_for_PositionOperand_NotEqualsOperator.

@Test
public void shouldParseFieldsSearchExpression_for_PositionOperand_NotEqualsOperator() {
    // given
    String fieldsSearchExpression = "005.00_04 not= '2014'";
    // when
    ParseFieldsResult result = parseFieldsSearchExpression(fieldsSearchExpression);
    // then
    assertTrue(result.isEnabled());
    assertEquals(singletonList("2014"), result.getBindingParams());
    assertEquals(new HashSet<>(singletonList("005")), result.getFieldsToJoin());
    assertEquals("substring(\"i005\".\"value\", 1, 4) <> ?", result.getWhereExpression());
}
Also used : ParseFieldsResult(org.folio.services.util.parser.ParseFieldsResult) Test(org.junit.Test)

Example 3 with ParseFieldsResult

use of org.folio.services.util.parser.ParseFieldsResult in project mod-source-record-storage by folio-org.

the class SearchExpressionParserUnitTest method shouldParseFieldsSearchExpression_for_SubFieldOperand_NotEqualsOperator.

@Test
public void shouldParseFieldsSearchExpression_for_SubFieldOperand_NotEqualsOperator() {
    // given
    String fieldsSearchExpression = "035.a not= '(OCoLC)'";
    // when
    ParseFieldsResult result = parseFieldsSearchExpression(fieldsSearchExpression);
    // then
    assertTrue(result.isEnabled());
    assertEquals(singletonList("(OCoLC)"), result.getBindingParams());
    assertEquals(new HashSet<>(singletonList("035")), result.getFieldsToJoin());
    assertEquals("(\"i035\".\"subfield_no\" = 'a' and \"i035\".\"value\" <> ?)", result.getWhereExpression());
}
Also used : ParseFieldsResult(org.folio.services.util.parser.ParseFieldsResult) Test(org.junit.Test)

Example 4 with ParseFieldsResult

use of org.folio.services.util.parser.ParseFieldsResult in project mod-source-record-storage by folio-org.

the class SearchExpressionParserUnitTest method shouldParseFieldsSearchExpression_for_ValueOperand_LeftAnchoredEqualsOperator.

@Test
public void shouldParseFieldsSearchExpression_for_ValueOperand_LeftAnchoredEqualsOperator() {
    // given
    String fieldsSearchExpression = "005.value ^= '20141107'";
    // when
    ParseFieldsResult result = parseFieldsSearchExpression(fieldsSearchExpression);
    // then
    assertTrue(result.isEnabled());
    assertEquals(singletonList("20141107%"), result.getBindingParams());
    assertEquals(new HashSet<>(singletonList("005")), result.getFieldsToJoin());
    assertEquals("\"i005\".\"value\" like ?", result.getWhereExpression());
}
Also used : ParseFieldsResult(org.folio.services.util.parser.ParseFieldsResult) Test(org.junit.Test)

Example 5 with ParseFieldsResult

use of org.folio.services.util.parser.ParseFieldsResult in project mod-source-record-storage by folio-org.

the class SearchExpressionParserUnitTest method shouldParseFieldsSearchExpression_forDateRangeOperand_EqualsOperator.

@Test
public void shouldParseFieldsSearchExpression_forDateRangeOperand_EqualsOperator() {
    // given
    String fieldsSearchExpression = "005.date = '201701025'";
    // when
    ParseFieldsResult result = parseFieldsSearchExpression(fieldsSearchExpression);
    // then
    assertTrue(result.isEnabled());
    assertEquals(singletonList("201701025"), result.getBindingParams());
    assertEquals(new HashSet<>(singletonList("005")), result.getFieldsToJoin());
    assertEquals("to_date(substring(\"i005\".\"value\", 1, 8), 'yyyymmdd') = ?", result.getWhereExpression());
}
Also used : ParseFieldsResult(org.folio.services.util.parser.ParseFieldsResult) Test(org.junit.Test)

Aggregations

ParseFieldsResult (org.folio.services.util.parser.ParseFieldsResult)26 Test (org.junit.Test)24 Lists (com.google.common.collect.Lists)1 ReactiveClassicGenericQueryExecutor (io.github.jklingsporn.vertx.jooq.classic.reactivepg.ReactiveClassicGenericQueryExecutor)1 QueryResult (io.github.jklingsporn.vertx.jooq.shared.internal.QueryResult)1 Flowable (io.reactivex.Flowable)1 Future (io.vertx.core.Future)1 Promise (io.vertx.core.Promise)1 PgPool (io.vertx.reactivex.pgclient.PgPool)1 Row (io.vertx.sqlclient.Row)1 String.format (java.lang.String.format)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 ZoneOffset (java.time.ZoneOffset)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1