public TopologyTestRunCase(TopologyTestRunCase other) { if (other != null) { setId(other.getId()); setName(other.getName()); setTopologyId(other.getTopologyId()); setVersionId(other.getVersionId()); setTimestamp(other.getTimestamp()); } }
public TopologyTestRunCase getTopologyTestRunCase(Long topologyId, Long testcaseId) { TopologyTestRunCase testCase = new TopologyTestRunCase(); testCase.setId(testcaseId); TopologyTestRunCase found = dao.get(new StorableKey(TopologyTestRunCase.NAMESPACE, testCase.getPrimaryKey())); if (found == null || !found.getTopologyId().equals(topologyId)) { return null; } return found; }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TopologyTestRunCase)) return false; TopologyTestRunCase that = (TopologyTestRunCase) o; if (getId() != null ? !getId().equals(that.getId()) : that.getId() != null) return false; if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false; if (getTopologyId() != null ? !getTopologyId().equals(that.getTopologyId()) : that.getTopologyId() != null) return false; if (getVersionId() != null ? !getVersionId().equals(that.getVersionId()) : that.getVersionId() != null) return false; return getTimestamp() != null ? getTimestamp().equals(that.getTimestamp()) : that.getTimestamp() == null; }
private TopologyTestRunCase addTopologyTestRunCase(Long topologyId, Long newVersionId, TopologyTestRunCase testRunCase) { // unlike topology related entities, just issues a new id testRunCase.setId(null); testRunCase.setTopologyId(topologyId); testRunCase.setVersionId(newVersionId); return addTopologyTestRunCase(testRunCase); }
public TopologyTestRunCase addTopologyTestRunCase(TopologyTestRunCase testCase) { if (testCase.getId() == null) { testCase.setId(dao.nextId(TopologyTestRunCase.NAMESPACE)); } testCase.setTimestamp(System.currentTimeMillis()); dao.add(testCase); return testCase; }
@POST @Path("/topologies/{topologyId}/versions/{versionId}/testcases") public Response addTestRunCase(@PathParam("topologyId") Long topologyId, @PathParam("versionId") Long versionId, TopologyTestRunCase testRunCase, @Context SecurityContext securityContext) { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE); testRunCase.setTopologyId(topologyId); testRunCase.setVersionId(versionId); TopologyTestRunCase addedCase = catalogService.addTopologyTestRunCase(testRunCase); return WSUtils.respondEntity(addedCase, CREATED); }
@PUT @Path("/topologies/{topologyId}/testcases/{testCaseId}") public Response addOrUpdateTestRunCase(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, TopologyTestRunCase testRunCase, @Context SecurityContext securityContext) { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE); testRunCase.setTopologyId(topologyId); testRunCase.setId(testCaseId); TopologyTestRunCase updatedCase = catalogService.addOrUpdateTopologyTestRunCase(topologyId, testRunCase); return WSUtils.respondEntity(updatedCase, OK); }
Collection<TopologyTestRunCaseSource> runCaseSources = listTopologyTestRunCaseSource(runCase.getId()); Collection<TopologyTestRunCaseSink> runCaseSinks = listTopologyTestRunCaseSink(runCase.getId()); TopologyTestRunCase newCase = addTopologyTestRunCase(topologyId, newVersionId, new TopologyTestRunCase(runCase)); addTopologyTestRunCaseSource(newCase.getId(), newVersionId, new TopologyTestRunCaseSource(runCaseSource)); addTopologyTestRunCaseSink(newCase.getId(), newVersionId, new TopologyTestRunCaseSink(runCaseSink));
public TopologyTestRunCase addOrUpdateTopologyTestRunCase(Long id, TopologyTestRunCase testCase) { testCase.setId(id); testCase.setTimestamp(System.currentTimeMillis()); dao.addOrUpdate(testCase); return testCase; }
private TopologySink getAssociatedTopologySink(Long topologyId, Long testCaseId, Long topologySinkId) { TopologyTestRunCase testCase = catalogService.getTopologyTestRunCase(topologyId, testCaseId); if (testCase == null) { throw EntityNotFoundException.byId("Topology test case with topology id " + topologyId + " and test case id " + testCaseId); } TopologySink topologySink = catalogService.getTopologySink(topologyId, topologySinkId, testCase.getVersionId()); if (topologySink == null) { throw EntityNotFoundException.byId("Topology sink with topology id " + topologyId + " and version id " + testCase.getVersionId()); } else if (!testCase.getVersionId().equals(topologySink.getVersionId())) { throw new IllegalStateException("Test case and topology sink point to the different version id: " + "version id of test case: " + testCase.getVersionId() + " / " + "version id of topology sink: " + topologySink.getVersionId()); } return topologySink; }
public TopologyTestRunCase removeTestRunCase(Long topologyId, Long testcaseId) { TopologyTestRunCase testcase = getTopologyTestRunCase(topologyId, testcaseId); if (testcase != null) { testcase = dao.remove(testcase.getStorableKey()); } return testcase; }
@Override public int hashCode() { int result = getId() != null ? getId().hashCode() : 0; result = 31 * result + (getName() != null ? getName().hashCode() : 0); result = 31 * result + (getTopologyId() != null ? getTopologyId().hashCode() : 0); result = 31 * result + (getVersionId() != null ? getVersionId().hashCode() : 0); result = 31 * result + (getTimestamp() != null ? getTimestamp().hashCode() : 0); return result; }
@POST @Path("/topologies/{topologyId}/testcases") public Response addTestRunCase(@PathParam("topologyId") Long topologyId, TopologyTestRunCase testRunCase, @Context SecurityContext securityContext) { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE); testRunCase.setTopologyId(topologyId); Long currentVersionId = catalogService.getCurrentVersionId(topologyId); testRunCase.setVersionId(currentVersionId); TopologyTestRunCase addedCase = catalogService.addTopologyTestRunCase(testRunCase); return WSUtils.respondEntity(addedCase, CREATED); }
private TopologySource getAssociatedTopologySource(Long topologyId, Long testCaseId, Long topologySourceId) { TopologyTestRunCase testCase = catalogService.getTopologyTestRunCase(topologyId, testCaseId); if (testCase == null) { throw EntityNotFoundException.byId("Topology test case with topology id " + topologyId + " and test case id " + testCaseId); } TopologySource topologySource = catalogService.getTopologySource(topologyId, topologySourceId, testCase.getVersionId()); if (topologySource == null) { throw EntityNotFoundException.byId("Topology source with topology id " + topologyId + " and version id " + testCase.getVersionId()); } else if (!testCase.getVersionId().equals(topologySource.getVersionId())) { throw new IllegalStateException("Test case and topology source point to the different version id: " + "version id of test case: " + testCase.getVersionId() + " / " + "version id of topology source: " + topologySource.getVersionId()); } return topologySource; }
private TopologyTestRunHistory initializeTopologyTestRunHistory(Topology topology, TopologyTestRunCase testRunCase, Map<String, List<Map<String, Object>>> expectedOutputRecords, String eventLogFilePath) throws JsonProcessingException { Long topologyVersionId = catalogService.getCurrentVersionId(topology.getId()); TopologyTestRunHistory history = new TopologyTestRunHistory(); history.setTopologyId(topology.getId()); history.setVersionId(topologyVersionId); history.setTestCaseId(testRunCase.getId()); if (expectedOutputRecords != null) { String expectedOutputRecordsJson = objectMapper.writeValueAsString(expectedOutputRecords); history.setExpectedOutputRecords(expectedOutputRecordsJson); } history.setFinished(false); history.setStartTime(System.currentTimeMillis()); history.setEventLogFilePath(eventLogFilePath); return history; }