Skip to content

Commit

Permalink
[#1107] Stabilize PolicyPersistenceActorTest.
Browse files Browse the repository at this point in the history
Signed-off-by: Yufei Cai <yufei.cai@bosch.io>
  • Loading branch information
yufei-cai committed Jul 13, 2021
1 parent a6acd81 commit 5a9d3d5
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -942,12 +942,18 @@ public void sendAnnouncementBeforeExpiry() {
final var captor = ArgumentCaptor.forClass(SubjectDeletionAnnouncement.class);
verify(policyAnnouncementPub, timeout(5000).times(2))
.publishWithAcks(captor.capture(), any(), any());
final SubjectDeletionAnnouncement announcement1 = captor.getAllValues().get(0);
final SubjectDeletionAnnouncement announcement2 = captor.getAllValues().get(1);
Assertions.assertThat(announcement1.getSubjectIds()).containsExactly(subject1.getId());
Assertions.assertThat(announcement1.getDeleteAt()).isAfterOrEqualTo(subjectExpiry1.getTimestamp());
Assertions.assertThat(announcement2.getSubjectIds()).containsExactly(subject2.getId());
Assertions.assertThat(announcement2.getDeleteAt()).isAfterOrEqualTo(subjectExpiry2.getTimestamp());
for (final var announcement : captor.getAllValues()) {
if (announcement.getSubjectIds().contains(subject1.getId())) {
Assertions.assertThat(announcement.getDeleteAt())
.isAfterOrEqualTo(subjectExpiry1.getTimestamp());
} else if (announcement.getSubjectIds().contains(subject2.getId())) {
Assertions.assertThat(announcement.getDeleteAt())
.isAfterOrEqualTo(subjectExpiry2.getTimestamp());
} else {
throw new AssertionError("Expect subject deletion announcement for subject1 " +
"or subject2, got: " + announcement);
}
}

// THEN: announcements are published no more than once while the actor is alive.
verifyNoMoreInteractions(policyAnnouncementPub);
Expand Down

0 comments on commit 5a9d3d5

Please sign in to comment.