Skip to content

Commit 75d1220

Browse files
QueryTest: test setParameters for int[] and long[].
- Split testScalarIn test.
1 parent 293c075 commit 75d1220

File tree

1 file changed

+27
-3
lines changed
  • tests/objectbox-java-test/src/test/java/io/objectbox/query

1 file changed

+27
-3
lines changed

tests/objectbox-java-test/src/test/java/io/objectbox/query/QueryTest.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,37 @@ public void testScalarBetween() {
152152
}
153153

154154
@Test
155-
public void testScalarIn() {
155+
public void testIntIn() {
156156
putTestEntitiesScalars();
157157

158158
int[] valuesInt = {1, 1, 2, 3, 2003, 2007, 2002, -1};
159-
Query<TestEntity> query = box.query().in(simpleInt, valuesInt).build();
159+
Query<TestEntity> query = box.query().in(simpleInt, valuesInt).parameterAlias("int").build();
160160
assertEquals(3, query.count());
161161

162+
int[] valuesInt2 = {2003};
163+
query.setParameters(simpleInt, valuesInt2);
164+
assertEquals(1, query.count());
165+
166+
int[] valuesInt3 = {2003, 2007};
167+
query.setParameters("int", valuesInt3);
168+
assertEquals(2, query.count());
169+
}
170+
171+
@Test
172+
public void testLongIn() {
173+
putTestEntitiesScalars();
174+
162175
long[] valuesLong = {1, 1, 2, 3, 3003, 3007, 3002, -1};
163-
query = box.query().in(simpleLong, valuesLong).build();
176+
Query<TestEntity> query = box.query().in(simpleLong, valuesLong).parameterAlias("long").build();
164177
assertEquals(3, query.count());
178+
179+
long[] valuesLong2 = {3003};
180+
query.setParameters(simpleLong, valuesLong2);
181+
assertEquals(1, query.count());
182+
183+
long[] valuesLong3 = {3003, 3007};
184+
query.setParameters("long", valuesLong3);
185+
assertEquals(2, query.count());
165186
}
166187

167188
@Test
@@ -573,6 +594,9 @@ public boolean keep(TestEntity entity) {
573594
};
574595
}
575596

597+
/**
598+
* Puts 10 TestEntity starting at nr 2000 using {@link AbstractObjectBoxTest#createTestEntity(String, int)}.
599+
*/
576600
private List<TestEntity> putTestEntitiesScalars() {
577601
return putTestEntities(10, null, 2000);
578602
}

0 commit comments

Comments
 (0)