DocumentRepositoryImpl extends AbstractCRUDRepository<Document> implements DocumentRepository { @Override public Document create(Document entity) { if (exists(entity.getId())) { throw new DuplicateItemException(entity.getClass().getSimpleName() + " ID already exists: " + entity.getId().toString()); } Table table = entity.getTable(); PreparedStatement createStmt = PreparedStatementFactory.getPreparedStatement(String.format(CREATE_CQL, table.toDbTable(), Columns.ID), getSession()); try { BoundStatement bs = new BoundStatement(createStmt); bindCreate(bs, entity); BatchStatement batch = new BatchStatement(BatchStatement.Type.LOGGED); batch.add(bs); List<BoundStatement> indexStatements = IndexMaintainerHelper.generateDocumentCreateIndexEntriesStatements(getSession(), entity, bucketLocator); for (BoundStatement boundIndexStatement : indexStatements) { batch.add(boundIndexStatement); } getSession().execute(batch); return entity; } catch (IndexParseException e) { throw new RuntimeException(e); } } DocumentRepositoryImpl(Session session); @Override Document create(Document entity); @Override Document read(Identifier identifier); @Override QueryResponseWrapper readAll(String database, String tableString, int limit, long offset); @Override Document update(Document entity); @Override void delete(Document entity); @Override void delete(Identifier id); @Override boolean exists(Identifier identifier);  }
@Test public void testDoCreate() { System.out.println("doCreate"); Document entity = Fixtures.createTestDocument(); DocumentRepository instance = new DocumentRepositoryImpl(f.getSession()); Document result = instance.create(entity); assertNotNull(result); assertEquals(entity.getDatabaseName(), result.getDatabaseName()); assertEquals(entity.getTableName(), result.getTableName()); assertEquals(entity.getObject(), result.getObject()); assertNotNull(result.getUuid()); f.deleteDocument(result); }