Ejemplo n.º 1
0
  @Test
  public void firstItemId_tableFirstItemRemoved_resultChanges() throws SQLException {
    Object first = container.firstItemId();

    assertTrue(container.removeItem(first));
    Assert.assertNotSame(first, container.firstItemId());
  }
Ejemplo n.º 2
0
 @Test
 public void firstItemId_table_returnsItemId0() throws SQLException {
   if (SQLTestsConstants.db == DB.ORACLE) {
     assertEquals(
         new RowId(new Object[] {0 + offset}).toString(), container.firstItemId().toString());
   } else {
     assertEquals(new RowId(new Object[] {0 + offset}), container.firstItemId());
   }
 }
Ejemplo n.º 3
0
  @Test
  public void removeItem_tableNoAddedItems_removesItemFromContainer() throws SQLException {
    int originalSize = container.size();
    Object id = container.firstItemId();

    assertTrue(container.removeItem(id));

    Assert.assertNotSame(id, container.firstItemId());
    assertEquals(originalSize - 1, container.size());
  }
Ejemplo n.º 4
0
  @Test
  public void firstItemId_tableNewlyAddedFirstItemRemoved_resultChanges() throws SQLException {
    SQLContainer garbageContainer = getGarbageContainer();

    Object first = garbageContainer.addItem();
    Object second = garbageContainer.addItem();

    Assert.assertSame(first, garbageContainer.firstItemId());
    assertTrue(garbageContainer.removeItem(first));
    Assert.assertSame(second, garbageContainer.firstItemId());
  }
Ejemplo n.º 5
0
  @Test
  public void addOrderBy_table_shouldReorderResults() throws SQLException {
    // Ville, Kalle, Pelle, Börje
    assertEquals("Ville", container.getContainerProperty(container.firstItemId(), NAME).getValue());
    assertEquals("Börje", container.getContainerProperty(container.lastItemId(), NAME).getValue());

    container.addOrderBy(new OrderBy(NAME, true));
    // Börje, Kalle, Pelle, Ville
    assertEquals("Börje", container.getContainerProperty(container.firstItemId(), NAME).getValue());
    assertEquals("Ville", container.getContainerProperty(container.lastItemId(), NAME).getValue());
  }
Ejemplo n.º 6
0
  @Test
  public void sort_table_sortsByName() throws SQLException {
    // Ville, Kalle, Pelle, Börje
    assertEquals("Ville", container.getContainerProperty(container.firstItemId(), NAME).getValue());
    assertEquals("Börje", container.getContainerProperty(container.lastItemId(), NAME).getValue());

    container.sort(new Object[] {NAME}, new boolean[] {true});

    // Börje, Kalle, Pelle, Ville
    assertEquals("Börje", container.getContainerProperty(container.firstItemId(), NAME).getValue());
    assertEquals("Ville", container.getContainerProperty(container.lastItemId(), NAME).getValue());
  }
Ejemplo n.º 7
0
  @Test
  public void isFirstId_tableFirstItemRemoved_returnsFalse() throws SQLException {
    Object first = container.firstItemId();

    assertTrue(container.removeItem(first));
    Assert.assertFalse(container.isFirstId(first));
  }
Ejemplo n.º 8
0
  @Test
  public void getItem_tableItemRemoved_returnsNull() throws SQLException {
    Object id = container.firstItemId();

    assertTrue(container.removeItem(id));
    Assert.assertNull(container.getItem(id));
  }
Ejemplo n.º 9
0
  @Test
  public void containsId_tableItemRemoved_returnsFalse() throws SQLException {
    Object id = container.firstItemId();

    assertTrue(container.containsId(id));
    assertTrue(container.removeItem(id));
    Assert.assertFalse(container.containsId(id));
  }
Ejemplo n.º 10
0
  @Test
  public void getItemIds_tableItemRemoved_shouldNotContainRemovedItem() throws SQLException {
    Object id = container.firstItemId();

    assertTrue(container.getItemIds().contains(id));
    assertTrue(container.removeItem(id));
    Assert.assertFalse(container.getItemIds().contains(id));
  }
Ejemplo n.º 11
0
  @Test
  public void firstItemId_tableEmptyResultSet_returnsFirstAddedItem() throws SQLException {
    SQLContainer garbageContainer = getGarbageContainer();

    Object id = garbageContainer.addItem();

    Assert.assertSame(id, garbageContainer.firstItemId());
  }
Ejemplo n.º 12
0
  @Test
  public void commit_removeModifiedItem_shouldSucceed() throws SQLException {
    int size = container.size();
    Object key = container.firstItemId();
    Item row = container.getItem(key);
    row.getItemProperty(NAME).setValue("Pekka");

    assertTrue(container.removeItem(key));
    container.commit();
    assertEquals(size - 1, container.size());
  }
Ejemplo n.º 13
0
  @Test
  public void isFirstId_tableAddedFirstItemRemoved_returnsFalse() throws SQLException {
    SQLContainer garbageContainer = getGarbageContainer();

    Object first = garbageContainer.addItem();
    garbageContainer.addItem();

    Assert.assertSame(first, garbageContainer.firstItemId());
    assertTrue(garbageContainer.removeItem(first));
    Assert.assertFalse(garbageContainer.isFirstId(first));
  }
Ejemplo n.º 14
0
  @Test
  public void sort_tableBufferedItems_sortsBufferedItemsLastInOrderAdded() throws SQLException {
    // Ville, Kalle, Pelle, Börje
    assertEquals("Ville", container.getContainerProperty(container.firstItemId(), NAME).getValue());
    assertEquals("Börje", container.getContainerProperty(container.lastItemId(), NAME).getValue());

    Object id1 = container.addItem();
    container.getContainerProperty(id1, NAME).setValue("Wilbert");
    Object id2 = container.addItem();
    container.getContainerProperty(id2, NAME).setValue("Albert");

    container.sort(new Object[] {NAME}, new boolean[] {true});

    // Börje, Kalle, Pelle, Ville, Wilbert, Albert
    assertEquals("Börje", container.getContainerProperty(container.firstItemId(), NAME).getValue());
    assertEquals(
        "Wilbert",
        container
            .getContainerProperty(container.getIdByIndex(container.size() - 2), NAME)
            .getValue());
    assertEquals("Albert", container.getContainerProperty(container.lastItemId(), NAME).getValue());
  }