@Test public void selectSnapshotBefore() { ComponentDto project = db.components().insertPrivateProject(); SnapshotDto analysis1 = newAnalysis(project).setCreatedAt(50L).setPeriodDate(20L); SnapshotDto analysis2 = newAnalysis(project).setCreatedAt(20L).setPeriodDate(10L); SnapshotDto analysis3 = newAnalysis(project).setCreatedAt(10L).setPeriodDate(null); db.components().insertSnapshots(analysis1, analysis2, analysis3); assertThat(underTest.selectSnapshotBefore(project.uuid(), 50L, dbSession)) .extracting(ViewsSnapshotDto::getUuid, ViewsSnapshotDto::getCreatedAt, ViewsSnapshotDto::getLeakDate) .containsExactlyInAnyOrder(analysis2.getUuid(), analysis2.getCreatedAt(), analysis2.getPeriodDate()); assertThat(underTest.selectSnapshotBefore(project.uuid(), 20L, dbSession)) .extracting(ViewsSnapshotDto::getUuid, ViewsSnapshotDto::getLeakDate) .containsExactlyInAnyOrder(analysis3.getUuid(), null); assertThat(underTest.selectSnapshotBefore(project.uuid(), 5L, dbSession)).isNull(); }