@Test public void testRollback() throws Exception { testedTable.put("abc1", "1"); testedTable.remove("abc1"); testedTable.put("abc1", "2"); Assert.assertEquals(testedTable.rollback(), 1); Assert.assertNull(testedTable.get("abc1")); }
@Test public void testSize() throws Exception { int sizeBefore = testedTable.size(); testedTable.put("abcdef1", "1"); testedTable.put("abcdef2", "2"); testedTable.put("abcdef1", "3"); Assert.assertEquals(testedTable.size(), sizeBefore + 2); }
@Override public boolean execute(String[] args) { Table table = manager.getCurrentTable(); String oldValue = table.remove(args[1]); if (oldValue == null) { manager.printMessage("not found"); } else { manager.printMessage("removed"); } return true; }
@Test public void testComplex() throws Exception { testedTable.put("testkey", "testvalue"); Assert.assertEquals(testedTable.get("testkey"), "testvalue"); testedTable.put("testkey", "testvalue2"); Assert.assertEquals(testedTable.remove("testkey"), "testvalue2"); Assert.assertNull(testedTable.get("abcd")); Assert.assertNull(testedTable.remove("abcd")); }
@Test public void testCommit() throws Exception { testedTable.put("abcd1", "1"); testedTable.put("abcd2", "2"); Assert.assertEquals(testedTable.commit(), 2); Assert.assertEquals(testedTable.get("abcd1"), "1"); testedTable.remove("abcd1"); testedTable.remove("abcd2"); Assert.assertEquals(testedTable.commit(), 2); Assert.assertNull(testedTable.get("abcd2")); }
@Test(expected = IllegalArgumentException.class) public void testRemoveNull() throws Exception { testedTable.remove(null); }
@Test(expected = IllegalArgumentException.class) public void testGetNl() throws Exception { testedTable.get(""); }
@Test public void testGetName() throws Exception { Assert.assertEquals(testedTable.getName(), TABLE_NAME); }