@Test public void removeValidKeyTest() { Assert.assertNull(dataTable.remove("chair")); Storeable firstValue = new StoreableDataValue(types); firstValue.setColumnAt(0, 2); firstValue.setColumnAt(1, "black"); dataTable.put("cats", firstValue); Assert.assertEquals(dataTable.remove("cats"), firstValue); }
@Test public void rollbackTest() throws Exception { dataTable.put( "7", tableProvider.deserialize(dataTable, "<row><col>5</col><col>text</col></row>")); dataTable.remove("7"); Assert.assertEquals(dataTable.rollback(), 0); dataTable.put( "8", tableProvider.deserialize(dataTable, "<row><col>45</col><col>text</col></row>")); dataTable.remove("7"); Assert.assertEquals(dataTable.rollback(), 1); }
@Test public void commitTest() throws Exception { dataTable.put( "1", tableProvider.deserialize(dataTable, "<row><col>98</col><col>bear</col></row>")); dataTable.put( "3", tableProvider.deserialize(dataTable, "<row><col>5</col><col>pig</col></row>")); dataTable.remove("3"); Assert.assertEquals(dataTable.commit(), 1); }
@Test public void sizeTest() throws Exception { Assert.assertEquals(dataTable.size(), 0); dataTable.put( "moo", tableProvider.deserialize(dataTable, "<row><col>5</col><col>text</col></row>")); dataTable.remove("moo"); dataTable.remove("foo"); dataTable.put( "newValue", tableProvider.deserialize(dataTable, "<row><col>78</col><col>car</col></row>")); Assert.assertEquals(dataTable.size(), 1); }
@Test(expected = IllegalArgumentException.class) public void removeNullKeyShouldFail() { dataTable.remove(null); }