コード例 #1
0
ファイル: FunctionalTest.java プロジェクト: cinar/requery
 @Test
 public void testQuerySelectWhereIn() {
   final String name = "Hello!";
   Person person = randomPerson();
   person.setName(name);
   data.insert(person);
   Group group = new Group();
   group.setName("Hello!");
   data.insert(group);
   person.getGroups().add(group);
   data.update(person);
   Return<Result<Tuple>> groupNames = data.select(Group.NAME).where(Group.NAME.equal(name));
   Person p = data.select(Person.class).where(Person.NAME.in(groupNames)).get().first();
   assertEquals(p.getName(), name);
   p = data.select(Person.class).where(Person.NAME.notIn(groupNames)).get().firstOrNull();
   assertNull(p);
   p =
       data.select(Person.class)
           .where(Person.NAME.in(Arrays.asList("Hello!", "Other")))
           .get()
           .first();
   assertEquals(p.getName(), name);
   p =
       data.select(Person.class)
           .where(Person.NAME.in(Collections.singleton("Hello!")))
           .get()
           .first();
   assertEquals(p.getName(), name);
   assertTrue(
       data.select(Person.class)
           .where(Person.NAME.notIn(Collections.singleton("Hello!")))
           .get()
           .toList()
           .isEmpty());
 }