DefaultSchemaMapper implements SchemaMapper, OperationExecutor { @Override public void create(JdbcIndex<?> index) { if (exists(index)) { LOG.debug("Skipping schema creation for {}. Schema exists.", index.getName()); return; } Table headTable = headTableEngine.create(index); Table histTable = historyTableEngine.create(index); index.setHeadTableName(headTable.getName()); index.setHistoryTableName(histTable.getName()); } DefaultSchemaMapper(TableEngine headTableEngine, TableEngine historyTableEngine); @Override boolean exists(JdbcIndex<?> index); @Override void create(JdbcIndex<?> index); @Override void drop(JdbcIndex<?> index); @Override void execute(Operation operation); @Override void execute(InsertOperation operation); @Override void execute(UpdateOperation operation); @Override void execute(DeleteOperation operation);  }
@Test public void create_setsTableNamesCorreclty() throws Exception { JdbcIndex<?> index = new JdbcIndex<>(); when(headTableEngine.create(index)).thenReturn(new Table("headTableName")); when(historyTableEngine.create(index)).thenReturn(new Table("historyTableName")); mapper.create(index); assertEquals("headTableName", index.getHeadTableName()); assertEquals("historyTableName", index.getHistoryTableName()); }