Skip to content

Commit 631759b

Browse files
committed
test added
1 parent 0ae45ef commit 631759b

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingEventSourceTest.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,30 @@ void supportsDynamicPollingDelay() {
143143
when(supplier.fetchResources(any()))
144144
.thenReturn(Set.of(SampleExternalResource.testResource1()));
145145
when(supplier.fetchDelay(any(),any()))
146-
.thenReturn(Optional.of(Duration.ofMillis(PERIOD*2)))
147-
.thenReturn(Optional.of(Duration.ofMillis(PERIOD)));
146+
.thenReturn(Optional.of(Duration.ofMillis(PERIOD)))
147+
.thenReturn(Optional.of(Duration.ofMillis(PERIOD*2)));
148148

149149
source.onResourceCreated(testCustomResource);
150150

151-
await().pollDelay(Duration.ofMillis(PERIOD)).untilAsserted(() -> {
152-
// todo
151+
await().pollDelay(Duration.ofMillis(PERIOD)).atMost(Duration.ofMillis((long) (1.5 * PERIOD)))
152+
.pollInterval(Duration.ofMillis(20))
153+
.untilAsserted(() -> {
154+
verify(supplier,times(1)).fetchResources(any());
153155
});
156+
157+
// verifying that it is not called as with normal interval
158+
await().pollDelay(Duration.ofMillis(PERIOD)).atMost(Duration.ofMillis((long) (1.5*PERIOD)))
159+
.pollInterval(Duration.ofMillis(20))
160+
.untilAsserted(() -> {
161+
verify(supplier,times(1)).fetchResources(any());
162+
});
163+
164+
await().pollDelay(Duration.ofMillis(PERIOD)).atMost(Duration.ofMillis(2 * PERIOD))
165+
.pollInterval(Duration.ofMillis(20))
166+
.untilAsserted(() -> {
167+
verify(supplier,times(2)).fetchResources(any());
168+
});
169+
154170
}
155171

156172
}

0 commit comments

Comments
 (0)