private Map<String, List<Map<String, Object>>> readExpectedRecordsFromTestCaseSinks(List<StreamlineSink> sinks, List<TopologyTestRunCaseSink> testRunCaseSinks) { Map<String, String> sinkIdToName = sinks.stream() .collect(toMap(s -> s.getId(), s -> s.getName())); return testRunCaseSinks.stream() .filter(Objects::nonNull) .collect(toMap(s -> sinkIdToName.get(String.valueOf(s.getSinkId())), s -> { try { String records = s.getRecords(); if (StringUtils.isEmpty(records)) { return new ArrayList<Map<String, Object>>(); } else { return objectMapper.readValue(records, new TypeReference<List<Map<String, Object>>>() { }); } } catch (IOException e) { throw new RuntimeException(e); } })); }
@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); }
@Override public int hashCode() { int result = getId() != null ? getId().hashCode() : 0; result = 31 * result + (getTestCaseId() != null ? getTestCaseId().hashCode() : 0); result = 31 * result + (getSinkId() != null ? getSinkId().hashCode() : 0); result = 31 * result + (getVersionId() != null ? getVersionId().hashCode() : 0); result = 31 * result + (getRecords() != null ? getRecords().hashCode() : 0); result = 31 * result + (getTimestamp() != null ? getTimestamp().hashCode() : 0); return result; }
@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); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TopologyTestRunCaseSink)) return false; TopologyTestRunCaseSink that = (TopologyTestRunCaseSink) 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 (getSinkId() != null ? !getSinkId().equals(that.getSinkId()) : that.getSinkId() != 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; return getTimestamp() != null ? getTimestamp().equals(that.getTimestamp()) : that.getTimestamp() == null; }
public TopologyTestRunCaseSink(TopologyTestRunCaseSink other) { if (other != null) { setId(other.getId()); setTestCaseId(other.getTestCaseId()); setSinkId(other.getSinkId()); setVersionId(other.getVersionId()); setRecords(other.getRecords()); setTimestamp(other.getTimestamp()); } }