@Test public void testDeleteBatch() { List<Person> persons = new ArrayList<>(); for (int i = 0; i < 100; i++) { Person person = randomPerson(); persons.add(person); } data.insert(persons); assertEquals(100, data.count(Person.class).get().value().intValue()); data.delete(persons); assertEquals(0, data.count(Person.class).get().value().intValue()); }
@Test public void testQuerySelectCountWhere() { for (int i = 0; i < 10; i++) { Person person = randomPerson(); if (i == 0) { person.setName("countme"); } data.insert(person); } assertEquals( 1, data.count(Person.class).where(Person.NAME.eq("countme")).get().value().intValue()); }
@Test public void testQuerySelectCount() { data.insert(randomPersons(10)); try (Result<Tuple> result = data.select(Count.count(Person.class).as("bb")).get()) { assertTrue(result.first().get("bb").equals(10)); } try (Result<Tuple> result = data.select(Count.count(Person.class)).get()) { assertTrue(result.first().get(0).equals(10)); } assertEquals(10, data.count(Person.class).get().value().intValue()); data.count(Person.class) .get() .consume( new Consumer<Integer>() { @Override public void accept(Integer integer) { assertTrue(integer == 10); } }); }