TableImpl implements Table { @Override public Column addColumn(String id, Class type) { return addColumn(id, null, type, Origin.DATA, null, true); } TableImpl(Class<T> elementType, boolean indexed);  TableImpl(GraphStore graphStore, Class<T> elementType, boolean indexed); @Override Column addColumn(String id, Class type); @Override Column addColumn(String id, Class type, Origin origin); @Override Column addColumn(String id, String title, Class type, Object defaultValue); @Override Column addColumn(String id, String title, Class type, Origin origin, Object defaultValue, boolean indexed); @Override int countColumns(); @Override Iterator<Column> iterator(); @Override void doBreak(); @Override Column[] toArray(); @Override List<Column> toList(); @Override Column getColumn(int index); @Override Column getColumn(String id); @Override boolean hasColumn(String id); @Override void removeColumn(Column column); @Override void removeColumn(String id); @Override TableObserver createTableObserver(boolean withDiff); @Override Class getElementClass(); @Override Graph getGraph(); void destroyTableObserver(TableObserver observer); boolean deepEquals(TableImpl<T> obj); int deepHashCode();  }
@Test public void testAddColumnWithOrigin() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); Column col = table.addColumn("Id", Integer.class, Origin.PROPERTY); Assert.assertEquals(col.getOrigin(), Origin.PROPERTY); Assert.assertTrue(col.isProperty()); }
@Test public void testAddColumnWithTitleAndDefaultValue() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); Column col = table.addColumn("Id", "Foo", Integer.class, 42); Assert.assertEquals(col.getTitle(), "Foo"); Assert.assertEquals(col.getDefaultValue(), 42); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testUnknownType() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); table.addColumn("Id", Node.class); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testDefaultValueWrongType() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); Float defaultValue = 25f; table.addColumn("Id", null, Integer.class, Origin.DATA, defaultValue, false); }
@Test(expectedExceptions = NullPointerException.class) public void testOriginCantBeNull() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); table.addColumn("Id", null, Integer.class, null, 0, false); }
@Test(expectedExceptions = NullPointerException.class) public void testOriginCantBeNull2() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); table.addColumn("Id", Integer.class, null); }
@Test(expectedExceptions = NullPointerException.class) public void testTypeClassCantBeNull() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); table.addColumn("Id", null, null, Origin.DATA, 0, false); }
@Test(expectedExceptions = NullPointerException.class) public void testTypeClassCantBeNull2() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); table.addColumn("Id", null); }
@Test public void testIsIndexed() { TableImpl<Node> table = new TableImpl<Node>(Node.class, true); Column col1 = table.addColumn("Id", null, Integer.class, Origin.DATA, null, false); Column col2 = table.addColumn("1", null, Integer.class, Origin.DATA, null, true); Assert.assertFalse(col1.isIndexed()); Assert.assertTrue(col2.isIndexed()); }
@Test public void testTitleBackFill() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); Column col = table.addColumn("Id", Integer.class); Assert.assertEquals(col.getTitle(), "Id"); }
@Test public void testIdLowercase() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); Column col = table.addColumn("A", Integer.class); Assert.assertEquals(col.getId(), "a"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNonStandardType() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); table.addColumn("Id", Color.class); }
@Test public void testStandardizePrimitiveType() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); Column col = table.addColumn("Id", int.class); Assert.assertEquals(col.getTypeClass(), Integer.class); }
@Test public void testStandardizeArrayType() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); Column col = table.addColumn("test_col", Integer[].class); Assert.assertEquals(col.getTypeClass(), int[].class); }
@Test public void testStandardizeArrayDefaultValue() { TableImpl<Node> table = new TableImpl<Node>(Node.class, false); Integer[] t = new Integer[] { 1, 2 }; Column col = table.addColumn("test_col", null, Integer[].class, Origin.DATA, t, false); Object d = col.getDefaultValue(); Assert.assertEquals(d.getClass(), int[].class); Assert.assertEquals(d, new int[] { 1, 2 }); }