Search in sources :

Example 1 with TopologyTestRunCaseSource

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);
}
Also used : TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 2 with TopologyTestRunCaseSource

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);
}
Also used : TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Example 3 with TopologyTestRunCaseSource

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);
    }
}
Also used : TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) SchemaValidationFailedException(com.hortonworks.streamline.common.exception.SchemaValidationFailedException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed)

Example 4 with TopologyTestRunCaseSource

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);
}
Also used : TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 5 with TopologyTestRunCaseSource

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());
}
Also used : TopologyTestRunCaseSink(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Aggregations

TopologyTestRunCaseSource (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)15 Path (javax.ws.rs.Path)7 TopologyTestRunCase (com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)5 QueryParam (com.hortonworks.registries.common.QueryParam)4 WSUtils.buildEdgesFromQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam)4 WSUtils.buildEdgesToQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)4 WSUtils.currentVersionQueryParam (com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam)4 WSUtils.versionIdQueryParam (com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam)4 TopologySource (com.hortonworks.streamline.streams.catalog.TopologySource)4 TopologyTestRunCaseSink (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink)4 TopologyTestRunHistory (com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory)3 POST (javax.ws.rs.POST)3 Timed (com.codahale.metrics.annotation.Timed)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 SchemaValidationFailedException (com.hortonworks.streamline.common.exception.SchemaValidationFailedException)2 BaseTopologyRule (com.hortonworks.streamline.streams.catalog.BaseTopologyRule)2 Topology (com.hortonworks.streamline.streams.catalog.Topology)2 TopologyBranchRule (com.hortonworks.streamline.streams.catalog.TopologyBranchRule)2 TopologyEdge (com.hortonworks.streamline.streams.catalog.TopologyEdge)2 TopologyProcessor (com.hortonworks.streamline.streams.catalog.TopologyProcessor)2