@Test public void executeIfSelectedColumn_WithoutInstanceAndProperty() { when(scenarioGridColumnMock1.isInstanceAssigned()).thenReturn(Boolean.FALSE); when(scenarioGridColumnMock1.isPropertyAssigned()).thenReturn(Boolean.FALSE); ((DuplicateInstanceCommand) commandSpy).executeIfSelectedColumn(scenarioSimulationContextLocal, scenarioGridColumnMock1); verify(scenarioGridModelMock, times(1)).getInstancesCount(eq(scenarioGridColumnMock1.getFactIdentifier().getClassName())); verify((DuplicateInstanceCommand) commandSpy, times(1)).insertNewColumn(eq(scenarioSimulationContextLocal), eq(scenarioGridColumnMock1), eq(COLUMN_NUMBER + 1), eq(Boolean.FALSE)); verify((DuplicateInstanceCommand) commandSpy, never()).setInstanceHeader(any(), any(), any(), any()); verify((DuplicateInstanceCommand) commandSpy, never()).setPropertyHeader(any(), any(), any(), any(), any()); verify(scenarioGridModelMock, never()).duplicateColumnValues(anyInt(), eq(0)); }
@Override protected void executeIfSelectedColumn(ScenarioSimulationContext context, ScenarioGridColumn selectedColumn) { final AbstractScesimGridModel<? extends AbstractScesimModel, ? extends AbstractScesimData> selectedScenarioGridModel = context.getAbstractScesimGridModelByGridWidget(gridWidget); int instancesCount = selectedScenarioGridModel.getInstancesCount(selectedColumn.getFactIdentifier().getClassName()); String alias = selectedColumn.getInformationHeaderMetaData().getTitle().split(COPY_LABEL)[0] + COPY_LABEL + instancesCount; int columnPosition = selectedScenarioGridModel.getInstanceLimits(selectedScenarioGridModel.getColumns().indexOf(selectedColumn)).getMaxRowIndex() + 1; AtomicInteger nextColumnPosition = new AtomicInteger(columnPosition); selectedScenarioGridModel.getInstanceScenarioGridColumns(selectedColumn).forEach( originalColumn -> { ScenarioGridColumn createdColumn = insertNewColumn(context, originalColumn, nextColumnPosition.getAndIncrement(), false); if (originalColumn.isInstanceAssigned()) { setInstanceHeader(context, createdColumn, alias, originalColumn.getFactIdentifier().getClassName()); if (originalColumn.isPropertyAssigned()) { int originalColumnIndex = selectedScenarioGridModel.getColumns().indexOf(originalColumn); final FactMapping originalFactMapping = selectedScenarioGridModel.getAbstractScesimModel().get().getScesimModelDescriptor().getFactMappingByIndex(originalColumnIndex); factMappingValueType = originalFactMapping.getFactMappingValueType(); List<String> propertyNameElements = new ArrayList<>(); propertyNameElements.add(alias); propertyNameElements.addAll(originalFactMapping.getExpressionElementsWithoutClass().stream().map(ExpressionElement::getStep).collect(Collectors.toList())); setPropertyHeader(context, createdColumn, propertyNameElements, originalFactMapping.getClassName(), originalColumn.getPropertyHeaderMetaData().getTitle()); int createdColumnIndex = selectedScenarioGridModel.getColumns().indexOf(createdColumn); selectedScenarioGridModel.duplicateColumnValues(originalColumnIndex, createdColumnIndex); } } }); }
DuplicateInstanceCommand extends AbstractSelectedColumnCommand { @Override protected void executeIfSelectedColumn(ScenarioSimulationContext context, ScenarioGridColumn selectedColumn) { final AbstractScesimGridModel<? extends AbstractScesimModel, ? extends AbstractScesimData> selectedScenarioGridModel = context.getAbstractScesimGridModelByGridWidget(gridWidget); int instancesCount = selectedScenarioGridModel.getInstancesCount(selectedColumn.getFactIdentifier().getClassName()); String alias = selectedColumn.getInformationHeaderMetaData().getTitle().split(COPY_LABEL)[0] + COPY_LABEL + instancesCount; int columnPosition = selectedScenarioGridModel.getInstanceLimits(selectedScenarioGridModel.getColumns().indexOf(selectedColumn)).getMaxRowIndex() + 1; AtomicInteger nextColumnPosition = new AtomicInteger(columnPosition); selectedScenarioGridModel.getInstanceScenarioGridColumns(selectedColumn).forEach( originalColumn -> { ScenarioGridColumn createdColumn = insertNewColumn(context, originalColumn, nextColumnPosition.getAndIncrement(), false); if (originalColumn.isInstanceAssigned()) { setInstanceHeader(context, createdColumn, alias, originalColumn.getFactIdentifier().getClassName()); if (originalColumn.isPropertyAssigned()) { int originalColumnIndex = selectedScenarioGridModel.getColumns().indexOf(originalColumn); final FactMapping originalFactMapping = selectedScenarioGridModel.getAbstractScesimModel().get().getScesimModelDescriptor().getFactMappingByIndex(originalColumnIndex); factMappingValueType = originalFactMapping.getFactMappingValueType(); List<String> propertyNameElements = new ArrayList<>(); propertyNameElements.add(alias); propertyNameElements.addAll(originalFactMapping.getExpressionElementsWithoutClass().stream().map(ExpressionElement::getStep).collect(Collectors.toList())); setPropertyHeader(context, createdColumn, propertyNameElements, originalFactMapping.getClassName(), originalColumn.getPropertyHeaderMetaData().getTitle()); int createdColumnIndex = selectedScenarioGridModel.getColumns().indexOf(createdColumn); selectedScenarioGridModel.duplicateColumnValues(originalColumnIndex, createdColumnIndex); } } }); } }
DuplicateInstanceCommand extends AbstractSelectedColumnCommand { @Override protected void executeIfSelectedColumn(ScenarioSimulationContext context, ScenarioGridColumn selectedColumn) { final AbstractScesimGridModel<? extends AbstractScesimModel, ? extends AbstractScesimData> selectedScenarioGridModel = context.getAbstractScesimGridModelByGridWidget(gridWidget); int instancesCount = selectedScenarioGridModel.getInstancesCount(selectedColumn.getFactIdentifier().getClassName()); String alias = selectedColumn.getInformationHeaderMetaData().getTitle().split(COPY_LABEL)[0] + COPY_LABEL + instancesCount; int columnPosition = selectedScenarioGridModel.getInstanceLimits(selectedScenarioGridModel.getColumns().indexOf(selectedColumn)).getMaxRowIndex() + 1; AtomicInteger nextColumnPosition = new AtomicInteger(columnPosition); selectedScenarioGridModel.getInstanceScenarioGridColumns(selectedColumn).forEach( originalColumn -> { ScenarioGridColumn createdColumn = insertNewColumn(context, originalColumn, nextColumnPosition.getAndIncrement(), false); if (originalColumn.isInstanceAssigned()) { setInstanceHeader(context, createdColumn, alias, originalColumn.getFactIdentifier().getClassName()); if (originalColumn.isPropertyAssigned()) { int originalColumnIndex = selectedScenarioGridModel.getColumns().indexOf(originalColumn); final FactMapping originalFactMapping = selectedScenarioGridModel.getAbstractScesimModel().get().getScesimModelDescriptor().getFactMappingByIndex(originalColumnIndex); factMappingValueType = originalFactMapping.getFactMappingValueType(); List<String> propertyNameElements = new ArrayList<>(); propertyNameElements.add(alias); propertyNameElements.addAll(originalFactMapping.getExpressionElementsWithoutClass().stream().map(ExpressionElement::getStep).collect(Collectors.toList())); setPropertyHeader(context, createdColumn, propertyNameElements, originalFactMapping.getClassName(), originalColumn.getPropertyHeaderMetaData().getTitle()); int createdColumnIndex = selectedScenarioGridModel.getColumns().indexOf(createdColumn); selectedScenarioGridModel.duplicateColumnValues(originalColumnIndex, createdColumnIndex); } } }); } DuplicateInstanceCommand(GridWidget gridWidget); private  DuplicateInstanceCommand(); }
DuplicateInstanceCommand extends AbstractSelectedColumnCommand { @Override protected void executeIfSelectedColumn(ScenarioSimulationContext context, ScenarioGridColumn selectedColumn) { final AbstractScesimGridModel<? extends AbstractScesimModel, ? extends AbstractScesimData> selectedScenarioGridModel = context.getAbstractScesimGridModelByGridWidget(gridWidget); int instancesCount = selectedScenarioGridModel.getInstancesCount(selectedColumn.getFactIdentifier().getClassName()); String alias = selectedColumn.getInformationHeaderMetaData().getTitle().split(COPY_LABEL)[0] + COPY_LABEL + instancesCount; int columnPosition = selectedScenarioGridModel.getInstanceLimits(selectedScenarioGridModel.getColumns().indexOf(selectedColumn)).getMaxRowIndex() + 1; AtomicInteger nextColumnPosition = new AtomicInteger(columnPosition); selectedScenarioGridModel.getInstanceScenarioGridColumns(selectedColumn).forEach( originalColumn -> { ScenarioGridColumn createdColumn = insertNewColumn(context, originalColumn, nextColumnPosition.getAndIncrement(), false); if (originalColumn.isInstanceAssigned()) { setInstanceHeader(context, createdColumn, alias, originalColumn.getFactIdentifier().getClassName()); if (originalColumn.isPropertyAssigned()) { int originalColumnIndex = selectedScenarioGridModel.getColumns().indexOf(originalColumn); final FactMapping originalFactMapping = selectedScenarioGridModel.getAbstractScesimModel().get().getScesimModelDescriptor().getFactMappingByIndex(originalColumnIndex); factMappingValueType = originalFactMapping.getFactMappingValueType(); List<String> propertyNameElements = new ArrayList<>(); propertyNameElements.add(alias); propertyNameElements.addAll(originalFactMapping.getExpressionElementsWithoutClass().stream().map(ExpressionElement::getStep).collect(Collectors.toList())); setPropertyHeader(context, createdColumn, propertyNameElements, originalFactMapping.getClassName(), originalColumn.getPropertyHeaderMetaData().getTitle()); int createdColumnIndex = selectedScenarioGridModel.getColumns().indexOf(createdColumn); selectedScenarioGridModel.duplicateColumnValues(originalColumnIndex, createdColumnIndex); } } }); } DuplicateInstanceCommand(GridWidget gridWidget); private  DuplicateInstanceCommand();  }
DuplicateInstanceCommand extends AbstractSelectedColumnCommand { @Override protected void executeIfSelectedColumn(ScenarioSimulationContext context, ScenarioGridColumn selectedColumn) { final AbstractScesimGridModel<? extends AbstractScesimModel, ? extends AbstractScesimData> selectedScenarioGridModel = context.getAbstractScesimGridModelByGridWidget(gridWidget); int instancesCount = selectedScenarioGridModel.getInstancesCount(selectedColumn.getFactIdentifier().getClassName()); String alias = selectedColumn.getInformationHeaderMetaData().getTitle().split(COPY_LABEL)[0] + COPY_LABEL + instancesCount; int columnPosition = selectedScenarioGridModel.getInstanceLimits(selectedScenarioGridModel.getColumns().indexOf(selectedColumn)).getMaxRowIndex() + 1; AtomicInteger nextColumnPosition = new AtomicInteger(columnPosition); selectedScenarioGridModel.getInstanceScenarioGridColumns(selectedColumn).forEach( originalColumn -> { ScenarioGridColumn createdColumn = insertNewColumn(context, originalColumn, nextColumnPosition.getAndIncrement(), false); if (originalColumn.isInstanceAssigned()) { setInstanceHeader(context, createdColumn, alias, originalColumn.getFactIdentifier().getClassName()); if (originalColumn.isPropertyAssigned()) { int originalColumnIndex = selectedScenarioGridModel.getColumns().indexOf(originalColumn); final FactMapping originalFactMapping = selectedScenarioGridModel.getAbstractScesimModel().get().getScesimModelDescriptor().getFactMappingByIndex(originalColumnIndex); factMappingValueType = originalFactMapping.getFactMappingValueType(); List<String> propertyNameElements = new ArrayList<>(); propertyNameElements.add(alias); propertyNameElements.addAll(originalFactMapping.getExpressionElementsWithoutClass().stream().map(ExpressionElement::getStep).collect(Collectors.toList())); setPropertyHeader(context, createdColumn, propertyNameElements, originalFactMapping.getClassName(), originalColumn.getPropertyHeaderMetaData().getTitle()); int createdColumnIndex = selectedScenarioGridModel.getColumns().indexOf(createdColumn); selectedScenarioGridModel.duplicateColumnValues(originalColumnIndex, createdColumnIndex); } } }); } DuplicateInstanceCommand(GridWidget gridWidget); private  DuplicateInstanceCommand();  static final String COPY_LABEL; }