use of edu.uci.ics.texera.web.response.planstore.QueryPlanListBean in project textdb by TextDB.
the class PlanStoreResource method getAllQueryPlans.
@GET
public QueryPlanListBean getAllQueryPlans() {
ArrayList<QueryPlanBean> queryPlans = new ArrayList<>();
try {
// Getting an iterator for the plan store
DataReader reader = planStore.getPlanIterator();
reader.open();
// Iterating through the stored plans, and mapping them to a QueryPlanRequest object
Tuple tuple;
while ((tuple = reader.getNextTuple()) != null) {
String name = tuple.getField(PlanStoreConstants.NAME).getValue().toString();
String description = tuple.getField(PlanStoreConstants.DESCRIPTION).getValue().toString();
String logicalPlanJson = tuple.getField(PlanStoreConstants.LOGICAL_PLAN_JSON).getValue().toString();
queryPlans.add(new QueryPlanBean(name, description, mapper.readValue(logicalPlanJson, LogicalPlan.class)));
}
} catch (TexeraException e) {
throw new TexeraWebException(e.getMessage());
} catch (IOException e) {
throw new TexeraWebException("fail to parse json:\n" + e.getMessage());
}
return new QueryPlanListBean(queryPlans);
}
use of edu.uci.ics.texera.web.response.planstore.QueryPlanListBean in project textdb by TextDB.
the class PlanStoreResourceTest method checkAddMultiplePlans.
@Test
public void checkAddMultiplePlans() throws IOException {
Response response = client.target(String.format(planStoreEndpoint, RULE.getLocalPort())).request().post(Entity.entity(queryPlan2, MediaType.APPLICATION_JSON));
assertThat(response.getStatus()).isEqualTo(200);
response = client.target(String.format(planStoreEndpoint, RULE.getLocalPort())).request().post(Entity.entity(queryPlan1, MediaType.APPLICATION_JSON));
assertThat(response.getStatus()).isEqualTo(200);
response = client.target(String.format(planStoreEndpoint, RULE.getLocalPort())).request().get();
ObjectMapper mapper = new ObjectMapper();
QueryPlanListBean queryPlanResponse = mapper.readValue(response.readEntity(String.class), QueryPlanListBean.class);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(queryPlanResponse.getQueryPlanList().size() == 2);
}
Aggregations