use of org.folio.cql2pgjson.CQL2PgJSON in project raml-module-builder by folio-org.
the class ConnIT method streamGetDoneHandlerWithThrowable.
@Test
void streamGetDoneHandlerWithThrowable(VertxTestContext vtc) throws CQL2PgJSONException {
CQLWrapper cqlWrapper = new CQLWrapper(new CQL2PgJSON("jsonb"), "key=b");
with(randomUuid(), "a", randomUuid(), "b", trans -> {
return trans.streamGet("t", Pojo.class, cqlWrapper, info -> info.result().handler(x -> {
throw new RuntimeException("foo");
}));
}).onComplete(failingThenComplete(vtc, t -> assertThat(t).hasMessage("foo")));
}
use of org.folio.cql2pgjson.CQL2PgJSON in project raml-module-builder by folio-org.
the class PostgresClientIT method getCQLWrapperJsonbField.
@Test
public void getCQLWrapperJsonbField(TestContext context) throws FieldException {
final String tableDefiniton = "id UUID PRIMARY KEY , jsonb JSONB NOT NULL, distinct_test_field TEXT";
List<FacetField> facets = null;
createTableWithPoLines(context, MOCK_POLINES_TABLE, tableDefiniton);
CQL2PgJSON cql2pgJson = new CQL2PgJSON(MOCK_POLINES_TABLE + ".jsonb");
{
CQLWrapper cqlWrapper = new CQLWrapper(cql2pgJson, "cql.allRecords=1");
Async async = context.async();
postgresClient.get(MOCK_POLINES_TABLE, Object.class, "jsonb", cqlWrapper, true, true, facets, null, handler -> {
context.assertTrue(handler.succeeded());
ResultInfo resultInfo = handler.result().getResultInfo();
context.assertEquals(6, resultInfo.getTotalRecords());
async.complete();
});
async.awaitSuccess();
}
String distinctOn = "jsonb->>'order_format'";
{
CQLWrapper cqlWrapper = new CQLWrapper(cql2pgJson, "cql.allRecords=1");
Async async = context.async();
postgresClient.get(MOCK_POLINES_TABLE, Object.class, "jsonb", cqlWrapper, true, true, facets, distinctOn, handler -> {
context.assertTrue(handler.succeeded());
ResultInfo resultInfo = handler.result().getResultInfo();
context.assertEquals(4, resultInfo.getTotalRecords());
async.complete();
});
async.awaitSuccess();
}
}
use of org.folio.cql2pgjson.CQL2PgJSON in project raml-module-builder by folio-org.
the class PostgresClientIT method streamGetWithSyntaxError.
@Test
public void streamGetWithSyntaxError(TestContext context) throws FieldException {
createTableWithPoLines(context);
CQLWrapper wrapper = new CQLWrapper(new CQL2PgJSON("jsonb"), "edition=");
postgresClient.streamGet(MOCK_POLINES_TABLE, Object.class, "jsonb", wrapper, false, null, context.asyncAssertFailure());
}
use of org.folio.cql2pgjson.CQL2PgJSON in project raml-module-builder by folio-org.
the class BooksDemoAPI method getRmbtestsTest.
@Validate
@Override
public void getRmbtestsTest(String query, RoutingContext routingContext, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
switch(query == null ? "null" : query) {
case "badclass=true":
PgUtil.streamGet(TABLE, /* can not be deserialized */
StringBuilder.class, null, 0, 10, new LinkedList<>(), "books", routingContext, okapiHeaders, vertxContext);
break;
case "nullpointer=true":
PgUtil.streamGet(TABLE, Book.class, null, 0, 10, null, "books", routingContext, /* okapiHeaders is null which results in exception */
null, vertxContext);
break;
case "slim=true":
PgUtil.streamGet(TABLE, SlimBook.class, null, 0, 10, new LinkedList<>(), "books", routingContext, okapiHeaders, vertxContext);
break;
case "wrapper=true":
try {
CQLWrapper wrapper = new CQLWrapper(new CQL2PgJSON("jsonb"), "cql.allRecords=true");
PgUtil.streamGet(TABLE, Book.class, wrapper, null, "books", routingContext, okapiHeaders, vertxContext);
} catch (FieldException e) {
GetRmbtestsTestResponse.respond500WithTextPlain(e.getMessage());
}
break;
default:
PgUtil.streamGet(TABLE, Book.class, query, 0, 10, new LinkedList<>(), "books", routingContext, okapiHeaders, vertxContext);
}
}
use of org.folio.cql2pgjson.CQL2PgJSON in project raml-module-builder by folio-org.
the class TestCLI method testCLIWithNoSchemaOrDBSchema.
@Test
public void testCLIWithNoSchemaOrDBSchema() throws FieldException, IOException, QueryValidationException, ParseException {
String cql = "holdingsRecords.permanentLocationId=\"fcd64ce1-6995-48f0-840e-89ffa2\"";
String[] args = new String[] { "-t", "instance", "-f", "jsonb", cql };
String fullFieldName = "instance.jsonb";
CQL2PgJSON cql2pgjson = new CQL2PgJSON(fullFieldName);
String output = CQL2PGCLIMain.parseCQL(cql2pgjson, "instance", cql);
String cli_output = CQL2PGCLIMain.handleOptions(args);
logger.info(output);
logger.info(cli_output);
assertNotNull(output);
assertEquals(output, cli_output);
}
Aggregations