private File getEventLogFile(Long topologyId, Long historyId) { TopologyTestRunHistory history = catalogService.getTopologyTestRunHistory(historyId); if (history == null) { throw EntityNotFoundException.byId(String.valueOf(historyId)); } if (!history.getTopologyId().equals(topologyId)) { throw BadRequestException.message("Test history " + historyId + " is not belong to topology " + topologyId); } String eventLogFilePath = history.getEventLogFilePath(); File eventLogFile = new File(eventLogFilePath); if (!eventLogFile.exists() || eventLogFile.isDirectory() || !eventLogFile.canRead()) { throw BadRequestException.message("Event log file of history " + historyId + " does not exist or is not readable."); } return eventLogFile; }
@GET @Path("/topologies/{topologyId}/testhistories/{historyId}") @Timed public Response getHistoryOfTestRunTopology (@Context UriInfo urlInfo, @PathParam("topologyId") Long topologyId, @PathParam("historyId") Long historyId, @QueryParam("simplify") Boolean simplify, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); TopologyTestRunHistory history = catalogService.getTopologyTestRunHistory(historyId); if (history == null) { throw EntityNotFoundException.byId(String.valueOf(historyId)); } if (!history.getTopologyId().equals(topologyId)) { throw BadRequestException.message("Test history " + historyId + " is not belong to topology " + topologyId); } if (BooleanUtils.isTrue(simplify)) { return WSUtils.respondEntity(new SimplifiedTopologyTestRunHistory(history), OK); } else { return WSUtils.respondEntity(history, OK); } }
@Override public int hashCode() { int result = getId() != null ? getId().hashCode() : 0; result = 31 * result + (getTopologyId() != null ? getTopologyId().hashCode() : 0); result = 31 * result + (getVersionId() != null ? getVersionId().hashCode() : 0); result = 31 * result + (getTestCaseId() != null ? getTestCaseId().hashCode() : 0); result = 31 * result + (getFinished() != null ? getFinished().hashCode() : 0); result = 31 * result + (getSuccess() != null ? getSuccess().hashCode() : 0); result = 31 * result + (getExpectedOutputRecords() != null ? getExpectedOutputRecords().hashCode() : 0); result = 31 * result + (getActualOutputRecords() != null ? getActualOutputRecords().hashCode() : 0); result = 31 * result + (getMatched() != null ? getMatched().hashCode() : 0); result = 31 * result + (getEventLogFilePath() != null ? getEventLogFilePath().hashCode() : 0); result = 31 * result + (getStartTime() != null ? getStartTime().hashCode() : 0); result = 31 * result + (getFinishTime() != null ? getFinishTime().hashCode() : 0); result = 31 * result + (getTimestamp() != null ? getTimestamp().hashCode() : 0); return result; }
SimplifiedTopologyTestRunHistory(TopologyTestRunHistory history) { id = history.getId(); topologyId = history.getTopologyId(); versionId = history.getVersionId(); finished = history.getFinished(); success = history.getSuccess(); matched = history.getMatched(); startTime = history.getStartTime(); finishTime = history.getFinishTime(); timestamp = history.getTimestamp(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof TopologyTestRunHistory)) return false; TopologyTestRunHistory that = (TopologyTestRunHistory) o; if (getId() != null ? !getId().equals(that.getId()) : that.getId() != 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; if (getTestCaseId() != null ? !getTestCaseId().equals(that.getTestCaseId()) : that.getTestCaseId() != null) return false; if (getFinished() != null ? !getFinished().equals(that.getFinished()) : that.getFinished() != null) return false; if (getSuccess() != null ? !getSuccess().equals(that.getSuccess()) : that.getSuccess() != null) return false; if (getExpectedOutputRecords() != null ? !getExpectedOutputRecords().equals(that.getExpectedOutputRecords()) : that.getExpectedOutputRecords() != null) return false; if (getActualOutputRecords() != null ? !getActualOutputRecords().equals(that.getActualOutputRecords()) : that.getActualOutputRecords() != null) return false; if (getMatched() != null ? !getMatched().equals(that.getMatched()) : that.getMatched() != null) return false; if (getEventLogFilePath() != null ? !getEventLogFilePath().equals(that.getEventLogFilePath()) : that.getEventLogFilePath() != null) return false; if (getStartTime() != null ? !getStartTime().equals(that.getStartTime()) : that.getStartTime() != null) return false; if (getFinishTime() != null ? !getFinishTime().equals(that.getFinishTime()) : that.getFinishTime() != null) return false; return getTimestamp() != null ? getTimestamp().equals(that.getTimestamp()) : that.getTimestamp() == null; }