Skip to content

Commit 3ca864a

Browse files
Add test for getAll after get and remove bug.
#626
1 parent aa40195 commit 3ca864a

File tree

1 file changed

+20
-0
lines changed
  • tests/objectbox-java-test/src/test/java/io/objectbox

1 file changed

+20
-0
lines changed

tests/objectbox-java-test/src/test/java/io/objectbox/BoxTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,26 @@ public void testRemoveMany() {
136136
assertEquals(0, box.count());
137137
}
138138

139+
// https://github.com/objectbox/objectbox-java/issues/626
140+
@Test
141+
public void testGetAllAfterGetAndRemove() {
142+
assertEquals(0, box.count());
143+
assertEquals(0, box.getAll().size());
144+
145+
List<TestEntity> entities = putTestEntities(10);
146+
147+
// explicitly get an entity (any will do)
148+
TestEntity entity = box.get(entities.get(1).getId());
149+
assertNotNull(entity);
150+
151+
box.removeAll();
152+
153+
assertEquals(0, box.count());
154+
List<TestEntity> all = box.getAll();
155+
// note only 1 entity is returned by getAll, it is the one we explicitly get (last) above
156+
assertEquals(0, all.size());
157+
}
158+
139159
@Test
140160
public void testPanicModeRemoveAllObjects() {
141161
assertEquals(0, box.panicModeRemoveAll());

0 commit comments

Comments
 (0)