private void removeAllTopologyTestSources(TopologySource topologySource) { QueryParam sourceIdQuery = new QueryParam("sourceId", String.valueOf(topologySource.getId())); Collection<TopologyTestRunCaseSource> sources = listTopologyTestRunCaseSource(Collections.singletonList(sourceIdQuery)); if (sources != null) { sources.forEach(s -> removeTopologyTestRunCaseSource(s.getId())); } }
public TopologyTestRunCaseSource addTopologyTestRunCaseSource(TopologyTestRunCaseSource testCaseSource) { if (testCaseSource.getId() == null) { testCaseSource.setId(dao.nextId(TopologyTestRunCaseSource.NAMESPACE)); } testCaseSource.setTimestamp(System.currentTimeMillis()); dao.add(testCaseSource); return testCaseSource; }
@Override public int hashCode() { int result = getId() != null ? getId().hashCode() : 0; result = 31 * result + (getTestCaseId() != null ? getTestCaseId().hashCode() : 0); result = 31 * result + (getSourceId() != null ? getSourceId().hashCode() : 0); result = 31 * result + (getVersionId() != null ? getVersionId().hashCode() : 0); result = 31 * result + (getRecords() != null ? getRecords().hashCode() : 0); result = 31 * result + (getOccurrence() != null ? getOccurrence().hashCode() : 0); result = 31 * result + (getSleepMsPerIteration() != null ? getSleepMsPerIteration().hashCode() : 0); result = 31 * result + (getTimestamp() != null ? getTimestamp().hashCode() : 0); return result; }
@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()); }
@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); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TopologyTestRunCaseSource)) return false; TopologyTestRunCaseSource that = (TopologyTestRunCaseSource) o; if (getId() != null ? !getId().equals(that.getId()) : that.getId() != null) return false; if (getTestCaseId() != null ? !getTestCaseId().equals(that.getTestCaseId()) : that.getTestCaseId() != null) return false; if (getSourceId() != null ? !getSourceId().equals(that.getSourceId()) : that.getSourceId() != null) return false; if (getVersionId() != null ? !getVersionId().equals(that.getVersionId()) : that.getVersionId() != null) return false; if (getRecords() != null ? !getRecords().equals(that.getRecords()) : that.getRecords() != null) return false; if (getOccurrence() != null ? !getOccurrence().equals(that.getOccurrence()) : that.getOccurrence() != null) return false; if (getSleepMsPerIteration() != null ? !getSleepMsPerIteration().equals(that.getSleepMsPerIteration()) : that.getSleepMsPerIteration() != null) return false; return getTimestamp() != null ? getTimestamp().equals(that.getTimestamp()) : that.getTimestamp() == null; }
private RuntimeException handleSchemaValidationFailedException(Long topologyId, TopologyTestRunCaseSource source, SchemaValidationFailedException e) { TopologySource topologySource; if (source.getVersionId() != null) { topologySource = catalogService.getTopologySource(topologyId, source.getSourceId(), source.getVersionId()); } else { topologySource = catalogService.getTopologySource(topologyId, source.getSourceId()); } if (topologySource != null) { throw BadRequestException.message("Schema validation failed in test case source name: " + topologySource.getName() + " - " + e.getMessage()); } else { throw BadRequestException.message("Schema validation failed in test case source ID: " + source.getId() + " - " + e.getMessage()); } }
public TopologyTestRunCaseSource(TopologyTestRunCaseSource other) { if (other != null) { setId(other.getId()); setTestCaseId(other.getTestCaseId()); setSourceId(other.getSourceId()); setVersionId(other.getVersionId()); setRecords(other.getRecords()); setOccurrence(other.getOccurrence()); setSleepMsPerIteration(other.getSleepMsPerIteration()); setTimestamp(other.getTimestamp()); } }
removeTopologyTestRunCaseSource(runCaseSource.getId());