}
private void disablePreviousSnapshot(DbSession session, AnalysisReportDto report) {
- SnapshotDto referenceSnapshot = dao.getByKey(session, report.getSnapshotId());
+ SnapshotDto referenceSnapshot;
+
+ try {
+ referenceSnapshot = dao.getByKey(session, report.getSnapshotId());
+ } catch (Exception exception) {
+ throw new IllegalStateException(String.format("Unexpected error while trying to retrieve snapshot of analysis %s", report), exception);
+ }
List<SnapshotDto> snapshots = dao.findSnapshotAndChildrenOfProjectScope(session, referenceSnapshot);
for (SnapshotDto snapshot : snapshots) {
db.assertDbUnit(getClass(), "snapshots-result.xml", "snapshots");
}
+
+ @Test(expected = IllegalStateException.class)
+ public void throw_IllegalStateException_when_not_finding_snapshot() {
+ db.prepareDbUnit(getClass(), "empty.xml");
+
+ sut.execute(session, AnalysisReportDto.newForTests(1L).setSnapshotId(1L));
+ }
}
return Objects.toStringHelper(this)
.add("id", getId())
.add("projectKey", getProjectKey())
+ .add("snapshotId", getSnapshotId())
.add("status", getStatus())
.add("createdAt", getCreatedAt())
.add("startedAt", getStartedAt())