ColumnStore implements ColumnIterable { public void addColumn(final Column column) { checkNonNullColumnObject(column); checkIndexStatus(column); lock(); try { final ColumnImpl columnImpl = (ColumnImpl) column; short id = idMap.getShort(columnImpl.getId()); if (id == NULL_SHORT) { if (!garbageQueue.isEmpty()) { id = garbageQueue.firstShort(); garbageQueue.remove(id); } else { id = intToShort(length); if (length >= MAX_SIZE) { throw new RuntimeException("Maximum number of columns reached at " + MAX_SIZE); } length++; } idMap.put(column.getId(), id); int intIndex = shortToInt(id); columnImpl.setStoreId(intIndex); columns[intIndex] = columnImpl; if (indexStore != null) { indexStore.addColumn(columnImpl); } updateConfiguration(column); } else { throw new IllegalArgumentException("The column already exist"); } } finally { unlock(); } } ColumnStore(Class<T> elementType, boolean indexed);  ColumnStore(GraphStore graphStore, Class<T> elementType, boolean indexed); void addColumn(final Column column); void removeColumn(final Column column); void removeColumn(final String key); int getColumnIndex(final String key); Column getColumnByIndex(final int index); Column getColumn(final String key); boolean hasColumn(String key); @Override Iterator<Column> iterator(); @Override ColumnImpl[] toArray(); @Override List<Column> toList(); @Override void doBreak(); Set<String> getColumnKeys(); void clear(); int size(); boolean deepEquals(ColumnStore<T> obj); int deepHashCode();  }
@Test public void testAddColumn() { ColumnStore<Node> store = new ColumnStore(Node.class, false); ColumnImpl col = new ColumnImpl("a", Integer.class, null, null, Origin.DATA, false, false); store.addColumn(col); Assert.assertTrue(store.hasColumn("a")); Assert.assertEquals(store.size(), 1); Assert.assertEquals(store.getColumn("a"), col); Assert.assertEquals(store.getColumn("A"), col); Assert.assertEquals(col.getIndex(), 0); Assert.assertEquals(store.getColumnByIndex(0), col); }
@Test(expectedExceptions = NullPointerException.class) public void testAddColumnNull() { ColumnStore<Node> store = new ColumnStore(Node.class, false); store.addColumn(null); }
@Test(expectedExceptions = ClassCastException.class) public void testAddColumnAnonymousClass() { ColumnStore<Node> store = new ColumnStore(Node.class, false); store.addColumn(new Column() { @Override public String getId() { throw new UnsupportedOperationException("Not supported yet."); } @Override public int getIndex() { throw new UnsupportedOperationException("Not supported yet."); } @Override public String getTitle() { throw new UnsupportedOperationException("Not supported yet."); } @Override public Class getTypeClass() { throw new UnsupportedOperationException("Not supported yet."); } @Override public Origin getOrigin() { throw new UnsupportedOperationException("Not supported yet."); } @Override public boolean isIndexed() { throw new UnsupportedOperationException("Not supported yet."); } @Override public boolean isArray() { throw new UnsupportedOperationException("Not supported yet."); } @Override public Object getDefaultValue() { throw new UnsupportedOperationException("Not supported yet."); } @Override public boolean isDynamic() { throw new UnsupportedOperationException("Not supported yet."); } @Override public boolean isNumber() { throw new UnsupportedOperationException("Not supported yet."); } @Override public boolean isProperty() { throw new UnsupportedOperationException("Not supported yet."); } @Override public Table getTable() { throw new UnsupportedOperationException("Not supported yet."); } @Override public boolean isReadOnly() { throw new UnsupportedOperationException("Not supported yet."); } @Override public ColumnObserver createColumnObserver(boolean withDiff) { throw new UnsupportedOperationException("Not supported yet."); } @Override public Estimator getEstimator() { throw new UnsupportedOperationException("Not supported yet."); } @Override public void setEstimator(Estimator estimator) { throw new UnsupportedOperationException("Not supported yet."); } }); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddColumnTwice() { ColumnStore<Node> store = new ColumnStore(Node.class, false); ColumnImpl col = new ColumnImpl("0", Integer.class, null, null, Origin.DATA, false, false); store.addColumn(col); store.addColumn(col); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddColumnDifferentCase() { ColumnStore<Node> store = new ColumnStore(Node.class, false); store.addColumn(new ColumnImpl("A", Integer.class, null, null, Origin.DATA, false, false)); store.addColumn(new ColumnImpl("a", Integer.class, null, null, Origin.DATA, false, false)); }
@Test public void testDefaultValue() { Integer defaultValue = 25; ColumnStore<Node> store = new ColumnStore(Node.class, false); ColumnImpl col = new ColumnImpl("0", Integer.class, null, defaultValue, Origin.DATA, false, false); store.addColumn(col); Assert.assertEquals(col.getDefaultValue(), defaultValue); }