Skip to content

Commit e8e0f34

Browse files
committed
ObjectIndexTest: improve getAll() test coverage
Specifically, we test that lazy object resolution works in conjunction with a call to getAll(), to ensure that pending objects get resolved.
1 parent b31f17a commit e8e0f34

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/test/java/org/scijava/object/ObjectIndexTest.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import static org.junit.Assert.assertTrue;
3939

4040
import java.util.ArrayList;
41+
import java.util.Arrays;
42+
import java.util.Collection;
4143
import java.util.Iterator;
4244
import java.util.List;
4345

@@ -60,11 +62,25 @@ public void testGetAll() {
6062
objectIndex.add(o1);
6163
objectIndex.add(o2);
6264
objectIndex.add(o3);
65+
66+
final String o4 = "quick", o5 = "brown", o6 = "fox";
67+
objectIndex.addLater(new LazyObjects<String>() {
68+
69+
@Override
70+
public Collection<String> get() {
71+
return Arrays.asList(o4, o5, o6);
72+
}
73+
74+
});
75+
6376
final List<Object> all = objectIndex.getAll();
64-
assertEquals(3, all.size());
77+
assertEquals(6, all.size());
6578
assertSame(o1, all.get(0));
6679
assertSame(o2, all.get(1));
6780
assertSame(o3, all.get(2));
81+
assertSame(o4, all.get(3));
82+
assertSame(o5, all.get(4));
83+
assertSame(o6, all.get(5));
6884
}
6985

7086
@Test

0 commit comments

Comments
 (0)