@Test public void rootMustBeTheFirstNodeSet() throws Exception { boolean caughtEx = false; try { ColumnCategoriesModel model = new ColumnCategoriesModel(); model.addCategory(new Node("1"), "1a"); } catch (Exception e) { caughtEx = true; } assertTrue(caughtEx); }
@Test public void shouldCreateModelCorrectly() throws Exception { assertEquals(6, model.getRootCategory().getNumberOfChildren()); assertEquals( "[{ROOT,Root,[17,18,19,a,b,c]}, " + "{COLUMN,17,[]}, {COLUMN,18,[]}, {COLUMN,19,[]}, " + "{CATEGORY,a,[0,2,3,4,5,6]}, {COLUMN,0,[]}, {COLUMN,2,[]}, {COLUMN,3,[]}, {COLUMN,4,[]}, {COLUMN,5,[]}, {COLUMN,6,[]}, " + "{CATEGORY,b,[b1,b2]}, {CATEGORY,b1,[7,8]}, {COLUMN,7,[]}, {COLUMN,8,[]}, " + "{CATEGORY,b2,[9,10,11]}, {COLUMN,9,[]}, {COLUMN,10,[]}, {COLUMN,11,[]}, " + "{CATEGORY,c,[12,13,14,15,16]}, {COLUMN,12,[]}, {COLUMN,13,[]}, {COLUMN,14,[]}, {COLUMN,15,[]}, {COLUMN,16,[]}]", model.toString()); }
@Test public void rootCanOnlyBeSetOnce() throws Exception { boolean caughtEx = false; try { ColumnCategoriesModel model = new ColumnCategoriesModel(); model.addRootCategory("Root"); model.addRootCategory("Root"); } catch (Exception e) { caughtEx = true; assertEquals("Root has been set already. Clear using (clear()) to reset.", e.getMessage()); } assertTrue(caughtEx); model.clear(); model.addRootCategory("Root"); }
@Test public void removeColumnIndexesFromModel() throws Exception { assertEquals(6, model.getRootCategory().getNumberOfChildren()); model.removeColumnIndex(17); assertEquals(5, model.getRootCategory().getNumberOfChildren()); }