use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink in project streamline by hortonworks.
the class StreamCatalogService method getTopologyTestRunCaseSinkBySinkId.
public TopologyTestRunCaseSink getTopologyTestRunCaseSinkBySinkId(Long testCaseId, Long sinkId) {
TopologyTestRunCaseSink testCaseSink = new TopologyTestRunCaseSink();
testCaseSink.setId(testCaseId);
Collection<TopologyTestRunCaseSink> sinks = dao.find(TopologyTestRunCaseSink.NAMESPACE, Lists.newArrayList(new QueryParam("testCaseId", testCaseId.toString()), new QueryParam("sinkId", sinkId.toString())));
if (sinks == null || sinks.isEmpty()) {
return null;
} else if (sinks.size() > 1) {
LOG.warn("More than one test run case sink entity for same test case and sink. test case id: " + testCaseId + " , sink id: " + sinkId);
LOG.warn("Returning first one...");
}
return sinks.iterator().next();
}
use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink in project streamline by hortonworks.
the class TopologyTestRunResource method addTestRunCaseSink.
@POST
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sinks")
public Response addTestRunCaseSink(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, TopologyTestRunCaseSink testRunCaseSink, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE);
TopologySink topologySink = getAssociatedTopologySink(topologyId, testCaseId, testRunCaseSink.getSinkId());
testRunCaseSink.setVersionId(topologySink.getVersionId());
TopologyTestRunCaseSink addedCaseSink = catalogService.addTopologyTestRunCaseSink(testRunCaseSink);
return WSUtils.respondEntity(addedCaseSink, CREATED);
}
use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink in project streamline by hortonworks.
the class TopologyTestRunResource method getTestRunCaseSinkByTopologySink.
@GET
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sinks/topologysink/{sinkId}")
public Response getTestRunCaseSinkByTopologySink(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, @PathParam("sinkId") Long sinkId, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
TopologyTestRunCaseSink testCaseSink = catalogService.getTopologyTestRunCaseSinkBySinkId(testCaseId, sinkId);
if (testCaseSink == null) {
throw EntityNotFoundException.byId("test case id: " + testCaseId + " , topology source id: " + sinkId);
}
return WSUtils.respondEntity(testCaseSink, OK);
}
use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink in project streamline by hortonworks.
the class TopologyTestRunResource method addOrUpdateTestRunCaseSink.
@PUT
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sinks/{id}")
public Response addOrUpdateTestRunCaseSink(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, @PathParam("id") Long id, TopologyTestRunCaseSink testRunCaseSink, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE);
testRunCaseSink.setId(id);
testRunCaseSink.setTestCaseId(testCaseId);
TopologySink topologySink = getAssociatedTopologySink(topologyId, testCaseId, testRunCaseSink.getSinkId());
testRunCaseSink.setVersionId(topologySink.getVersionId());
TopologyTestRunCaseSink updatedCase = catalogService.addOrUpdateTopologyTestRunCaseSink(testRunCaseSink.getId(), testRunCaseSink);
return WSUtils.respondEntity(updatedCase, OK);
}
Aggregations