Skip to content

Commit c528455

Browse files
committed
Adds a predicate to DataLoaderRegistry - added more tests
1 parent 9320fb4 commit c528455

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/test/java/org/dataloader/DataLoaderRegistryPredicateTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ public void test_the_registry_overall_predicate_firing_works() {
133133
DataLoader<Object, Object> dlB = newDataLoader(identityBatchLoader);
134134
DataLoader<Object, Object> dlC = newDataLoader(identityBatchLoader);
135135

136-
DispatchPredicate predicateOverAllOnThree = new CountingDispatchPredicate(3);
136+
DispatchPredicate predicateOnSix = new CountingDispatchPredicate(6);
137137

138138
DataLoaderRegistry registry = DataLoaderRegistry.newRegistry()
139139
.register("a", dlA, DISPATCH_NEVER)
140140
.register("b", dlB, DISPATCH_NEVER)
141141
.register("c", dlC, DISPATCH_NEVER)
142-
.dispatchPredicate(predicateOverAllOnThree)
142+
.dispatchPredicate(predicateOnSix)
143143
.build();
144144

145145

@@ -148,13 +148,18 @@ public void test_the_registry_overall_predicate_firing_works() {
148148
CompletableFuture<Object> cfC = dlC.load("C");
149149

150150
int count = registry.dispatchAllWithCount(); // first firing
151-
// none should fire
152151
assertThat(count, equalTo(0));
153152
assertThat(cfA.isDone(), equalTo(false));
154153
assertThat(cfB.isDone(), equalTo(false));
155154
assertThat(cfC.isDone(), equalTo(false));
156155

157-
count = registry.dispatchAllWithCount(); // second firing but the overall been asked 3 times already
156+
count = registry.dispatchAllWithCount(); // second firing but the overall been asked 6 times already
157+
assertThat(count, equalTo(0));
158+
assertThat(cfA.isDone(), equalTo(false));
159+
assertThat(cfB.isDone(), equalTo(false));
160+
assertThat(cfC.isDone(), equalTo(false));
161+
162+
count = registry.dispatchAllWithCount(); // third firing but the overall been asked 9 times already
158163
assertThat(count, equalTo(3));
159164
assertThat(cfA.isDone(), equalTo(true));
160165
assertThat(cfB.isDone(), equalTo(true));

0 commit comments

Comments
 (0)