@Test
 public void nextItemId_tableCurrentItem1337_returnsItem1338() throws SQLException {
   DataGenerator.addFiveThousandPeople(connectionPool);
   SQLContainer container =
       new SQLContainer(new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen));
   Object itemId = container.getIdByIndex(1337);
   if (SQLTestsConstants.db == DB.ORACLE) {
     assertEquals(
         new RowId(new Object[] {1338 + offset}).toString(),
         container.nextItemId(itemId).toString());
   } else {
     assertEquals(new RowId(new Object[] {1338 + offset}), container.nextItemId(itemId));
   }
 }
  @Test
  public void nextItemId_tableAddedItemRemoved_skipsRemovedItem() throws SQLException {
    Object first = container.lastItemId();
    Object second = container.addItem();
    Object third = container.addItem();

    assertTrue(container.removeItem(second));
    assertEquals(third, container.nextItemId(first));
  }
  @Test
  public void nextItemId_tableItemRemoved_skipsRemovedItem() throws SQLException {
    Object first = container.getIdByIndex(0);
    Object second = container.getIdByIndex(1);
    Object third = container.getIdByIndex(2);

    assertTrue(container.removeItem(second));
    assertEquals(third, container.nextItemId(first));
  }
  @Test
  public void addFilter_tableBufferedItems_alsoFiltersBufferedItems() throws SQLException {
    // Ville, Kalle, Pelle, Börje
    assertEquals(4, container.size());
    assertEquals("Börje", container.getContainerProperty(container.lastItemId(), NAME).getValue());

    Object id1 = container.addItem();
    container.getContainerProperty(id1, NAME).setValue("Palle");
    Object id2 = container.addItem();
    container.getContainerProperty(id2, NAME).setValue("Bengt");

    container.addContainerFilter(new Like(NAME, "%lle"));

    // Ville, Kalle, Pelle, Palle
    assertEquals(4, container.size());
    assertEquals(
        "Ville", container.getContainerProperty(container.getIdByIndex(0), NAME).getValue());
    assertEquals(
        "Kalle", container.getContainerProperty(container.getIdByIndex(1), NAME).getValue());
    assertEquals(
        "Pelle", container.getContainerProperty(container.getIdByIndex(2), NAME).getValue());
    assertEquals(
        "Palle", container.getContainerProperty(container.getIdByIndex(3), NAME).getValue());

    try {
      container.getIdByIndex(4);
      Assert.fail(
          "SQLContainer.getIdByIndex() returned a value for an index beyond the end of the container");
    } catch (IndexOutOfBoundsException e) {
      // should throw exception - item is filtered out
    }
    Assert.assertNull(container.nextItemId(container.getIdByIndex(3)));

    Assert.assertFalse(container.containsId(id2));
    Assert.assertFalse(container.getItemIds().contains(id2));

    Assert.assertNull(container.getItem(id2));
    assertEquals(-1, container.indexOfId(id2));

    Assert.assertNotSame(id2, container.lastItemId());
    Assert.assertSame(id1, container.lastItemId());
  }
 @Test
 public void nextItemId_tableNewlyAddedItem_returnsNewlyAdded() throws SQLException {
   Object lastId = container.lastItemId();
   Object id = container.addItem();
   assertEquals(id, container.nextItemId(lastId));
 }