MetadataChangesOnActionsGenerator { public StepDiff computeCreatedColumns(final RowMetadata metadata, List<RunnableAction> currentActions, List<RunnableAction> newActions) { RowMetadata workingMetadata = compileActionsOnMetadata(currentActions, metadata); return computeCreatedColumns(newActions, workingMetadata); }  StepDiff computeCreatedColumns(final RowMetadata metadata, List<RunnableAction> currentActions,
            List<RunnableAction> newActions);  }
@Test public void getActionCreatedColumns_firstActionCreatedColumnDoesNotCount() throws Exception { RowMetadata rowMetadata = new RowMetadata(); rowMetadata.addColumn(createColumnNamed("do")); rowMetadata.addColumn(createColumnNamed("ré")); rowMetadata.addColumn(createColumnNamed("mi")); doAnswer(answer(newArrayList("foo", "bar"), emptyList(), firstActionStuffInActionContext)) .when(firstRowAction) .compile(any(ActionContext.class) ); doAnswer(answer(newArrayList("beer"), newArrayList("do", "ré"), secondActionStuffInActionContext)) .when(secondRowAction) .compile(any(ActionContext.class) ); StepDiff diff = onActionsGenerator.computeCreatedColumns(rowMetadata, newArrayList(firstAction), newArrayList(secondAction)); assertEquals(newArrayList("0005"), diff.getCreatedColumns()); }
@Test public void getActionCreatedColumns_should_return_created_columns_for_multiple_diffs() throws Exception { RowMetadata workingMetadata = new RowMetadata(); workingMetadata.addColumn(createColumnNamed("do")); workingMetadata.addColumn(createColumnNamed("ré")); workingMetadata.addColumn(createColumnNamed("mi")); doAnswer(answer(newArrayList("foo", "bar"), emptyList(), null)) .when(firstRowAction) .compile(any(ActionContext.class) ); doAnswer(answer(emptyList(), newArrayList("do", "ré"), null)) .when(secondRowAction) .compile(any(ActionContext.class) ); StepDiff stepDiff = onActionsGenerator.computeCreatedColumns(newArrayList(firstAction, secondAction), workingMetadata); assertEquals(newArrayList("0003", "0004"), stepDiff.getCreatedColumns()); }
@Test public void getActionCreatedColumns_should_cleanup_transformation_context() throws Exception { RowMetadata workingMetadata = new RowMetadata(); workingMetadata.addColumn(createColumnNamed("do")); doAnswer(answer(emptyList(), emptyList(), firstActionStuffInActionContext)) .when(firstRowAction) .compile(any(ActionContext.class) ); doAnswer(answer(emptyList(), emptyList(), secondActionStuffInActionContext)) .when(secondRowAction) .compile(any(ActionContext.class) ); onActionsGenerator.computeCreatedColumns(newArrayList(firstAction, secondAction), workingMetadata); verify(firstActionStuffInActionContext).destroy(); verify(secondActionStuffInActionContext).destroy(); }