use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource in project streamline by hortonworks.
the class TopologyTestRunResource method getTestRunCaseSource.
@GET
@Path("/topologies/{topologyId}/testcases/{testcaseId}/sources/{id}")
public Response getTestRunCaseSource(@PathParam("topologyId") Long topologyId, @PathParam("testcaseId") Long testcaseId, @PathParam("id") Long id, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
TopologyTestRunCaseSource testCaseSource = catalogService.getTopologyTestRunCaseSource(testcaseId, id);
if (testCaseSource == null) {
throw EntityNotFoundException.byId(Long.toString(id));
}
return WSUtils.respondEntity(testCaseSource, OK);
}
use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource in project streamline by hortonworks.
the class TopologyTestRunResource method addOrUpdateTestRunCaseSource.
@PUT
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sources/{id}")
public Response addOrUpdateTestRunCaseSource(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, @PathParam("id") Long id, TopologyTestRunCaseSource testRunCaseSource, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE);
testRunCaseSource.setId(id);
testRunCaseSource.setTestCaseId(testCaseId);
TopologySource topologySource = getAssociatedTopologySource(topologyId, testCaseId, testRunCaseSource.getSourceId());
testRunCaseSource.setVersionId(topologySource.getVersionId());
TopologyTestRunCaseSource updatedCase = catalogService.addOrUpdateTopologyTestRunCaseSource(testRunCaseSource.getId(), testRunCaseSource);
return WSUtils.respondEntity(updatedCase, OK);
}
use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource in project streamline by hortonworks.
the class TopologyTestRunResource method validateTestRunCaseSource.
@POST
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sources/{id}/validate")
@Timed
public Response validateTestRunCaseSource(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, @PathParam("id") Long id, @Context SecurityContext securityContext) throws IOException {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
TopologyTestRunCaseSource testCaseSource = catalogService.getTopologyTestRunCaseSource(testCaseId, id);
if (testCaseSource == null) {
throw EntityNotFoundException.byId(Long.toString(id));
}
try {
doValidationForTestRunCaseSource(topologyId, testCaseId, testCaseSource);
return WSUtils.respondEntity(Collections.singletonMap("status", "valid"), OK);
} catch (SchemaValidationFailedException e) {
throw handleSchemaValidationFailedException(topologyId, testCaseSource, e);
}
}
use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource in project streamline by hortonworks.
the class TopologyTestRunResource method getTestRunCaseSourceByTopologySource.
@GET
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sources/topologysource/{sourceId}")
public Response getTestRunCaseSourceByTopologySource(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, @PathParam("sourceId") Long sourceId, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
TopologyTestRunCaseSource testCaseSource = catalogService.getTopologyTestRunCaseSourceBySourceId(testCaseId, sourceId);
if (testCaseSource == null) {
throw EntityNotFoundException.byId("test case id: " + testCaseId + " , topology source id: " + sourceId);
}
return WSUtils.respondEntity(testCaseSource, OK);
}
use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource in project streamline by hortonworks.
the class TopologyTestRunResource method removeTestRunCase.
@DELETE
@Path("/topologies/{topologyId}/testcases/{testCaseId}")
public Response removeTestRunCase(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE);
Collection<TopologyTestRunCaseSource> sources = catalogService.listTopologyTestRunCaseSource(testCaseId);
if (sources != null) {
sources.forEach(s -> catalogService.removeTopologyTestRunCaseSource(s.getId()));
}
Collection<TopologyTestRunCaseSink> sinks = catalogService.listTopologyTestRunCaseSink(testCaseId);
if (sinks != null) {
sinks.forEach(s -> catalogService.removeTopologyTestRunCaseSink(s.getId()));
}
TopologyTestRunCase testRunCase = catalogService.removeTestRunCase(topologyId, testCaseId);
if (testRunCase != null) {
return WSUtils.respondEntity(testRunCase, OK);
}
throw EntityNotFoundException.byId(testCaseId.toString());
}
Aggregations