use of org.folio.rest.persist.PostgresClient.QueryHelper in project raml-module-builder by folio-org.
the class PostgresClientTest method testProcessQuery.
@Test
public void testProcessQuery() {
PostgresClient testClient = PostgresClient.testClient();
List<FacetField> facets = new ArrayList<FacetField>() {
{
add(new FacetField("jsonb->>'biz'"));
}
};
QueryHelper queryHelper = new QueryHelper("test_jsonb_pojo");
queryHelper.selectQuery = "SELECT id, foo, bar FROM test_jsonb_pojo LIMIT 30 OFFSET 1";
int total = 30;
PgConnection connection = new FakeSqlConnection(Future.succeededFuture(getMockTestJsonbPojoResultSet(total)), true);
testClient.processQuery(connection, queryHelper, total, "get", totaledResults -> testClient.processResults(totaledResults.set, totaledResults.estimatedTotal, DEFAULT_OFFSET, DEFAULT_LIMIT, TestJsonbPojo.class), reply -> {
List<TestJsonbPojo> results = reply.result().getResults();
assertTestJsonbPojoResults(results, total);
});
}
use of org.folio.rest.persist.PostgresClient.QueryHelper in project raml-module-builder by folio-org.
the class PostgresClientTest method testProcessQueryException.
@Test
public void testProcessQueryException() {
PostgresClient testClient = PostgresClient.testClient();
QueryHelper queryHelper = new QueryHelper("test_jsonb_pojo");
queryHelper.selectQuery = "SELECT foo";
PgConnection connection = null;
testClient.processQuery(connection, queryHelper, 30, "get", totaledResults -> testClient.processResults(totaledResults.set, totaledResults.estimatedTotal, DEFAULT_OFFSET, DEFAULT_LIMIT, TestJsonbPojo.class), reply -> {
assertThat(reply.failed(), is(true));
assertThat(reply.cause() instanceof NullPointerException, is(true));
});
}
use of org.folio.rest.persist.PostgresClient.QueryHelper in project raml-module-builder by folio-org.
the class PostgresClientTest method testProcessQueryFails.
@Test
public void testProcessQueryFails() {
PostgresClient testClient = PostgresClient.testClient();
QueryHelper queryHelper = new QueryHelper("test_jsonb_pojo");
queryHelper.selectQuery = "SELECT foo";
PgConnection connection = new FakeSqlConnection(Future.failedFuture("Bad query"), false);
testClient.processQuery(connection, queryHelper, 30, "get", totaledResults -> testClient.processResults(totaledResults.set, totaledResults.estimatedTotal, DEFAULT_OFFSET, DEFAULT_LIMIT, TestJsonbPojo.class), reply -> {
assertThat(reply.failed(), is(true));
assertThat(reply.cause().getMessage(), is("Bad query"));
});
}
Aggregations