ScenarioSimulationEditorPresenter { protected void cleanReadOnlyColumn(AbstractScesimModel abstractScesimModel) { ScesimModelDescriptor scesimModelDescriptor = abstractScesimModel.getScesimModelDescriptor(); for (int i = 0; i < abstractScesimModel.getUnmodifiableData().size(); i += 1) { AbstractScesimData abstractScesimData = abstractScesimModel.getDataByIndex(i); for (FactMapping factMapping : scesimModelDescriptor.getUnmodifiableFactMappings()) { if (isColumnReadOnly(factMapping)) { abstractScesimData.getFactMappingValue(factMapping.getFactIdentifier(), factMapping.getExpressionIdentifier()) .ifPresent(fmv -> fmv.setRawValue(null)); } } } } ScenarioSimulationEditorPresenter(); @Inject  ScenarioSimulationEditorPresenter(final AbstractScenarioSimulationProducer abstractScenarioSimulationProducer,
                                             final ScenarioSimulationResourceType type,
                                             final PlaceManager placeManager,
                                             final AbstractScenarioSimulationDocksHandler abstractScenarioSimulationDocksHandler,
                                             final TextFileExport textFileExport,
                                             final ConfirmPopupPresenter confirmPopupPresenter); void setWrapper(ScenarioSimulationEditorWrapper scenarioSimulationEditorWrapper); void setPath(ObservablePath path); ObservablePath getPath(); void setPackageName(String packageName); void onClose(); void showDocks(PlaceStatus status); void hideDocks(); void onUberfireDocksInteractionEvent(@Observes final UberfireDocksInteractionEvent uberfireDocksInteractionEvent); void expandToolsDock(); ScenarioSimulationView getView(); ScenarioSimulationModel getModel(); Command getPopulateTestToolsCommand(); void reloadTestTools(boolean disable); void onRunScenario(); void onRunScenario(List<Integer> indexOfScenarioToRun); void onUndo(); void onRedo(); void setUndoButtonEnabledStatus(boolean enabled); void setRedoButtonEnabledStatus(boolean enabled); void setItemMenuEnabled(boolean enabled); void addDownloadMenuItem(FileMenuBuilder fileMenuBuilder, Supplier<Path> pathSupplier); DataManagementStrategy getDataManagementStrategy(); void onImport(String fileContents, GridWidget gridWidget); EventBus getEventBus(); ScenarioSimulationContext getContext(); void sendNotification(String text, NotificationEvent.NotificationType type); void sendNotification(String text, NotificationEvent.NotificationType type, boolean autoHide); void makeMenuBar(FileMenuBuilder fileMenuBuilder); void addCommonActions(final FileMenuBuilder fileMenuBuilder, MenuItem versionMenuItem, MenuItem alertsButtonMenuItem); void loadContent(); boolean isDirty(); void onEditTabSelected(); void onBackgroundTabSelected(); void onOverviewSelected(); void onImportsTabSelected(); void validateSimulation(); void selectSimulationTab(); void selectBackgroundTab(); RemoteCallback<String> getExportCallBack(); ErrorCallback<Boolean> getValidationFailedCallback(); void populateRightDocks(String identifier); void getModelSuccessCallbackMethod(DataManagementStrategy dataManagementStrategy, ScenarioSimulationModel model); ScenarioSimulationResourceType getType(); void setTestTools(TestToolsView.Presenter presenter); void setCheatSheet(CheatSheetView.Presenter presenter); void setSettings(SettingsView.Presenter presenter); String getJsonModel(ScenarioSimulationModel model); static final String IDENTIFIER; }
@Test public void cleanReadOnlyColumn() { Simulation simulation = new Simulation(); ScesimModelDescriptor simulationDescriptor = simulation.getScesimModelDescriptor(); FactMapping test1 = simulationDescriptor .addFactMapping(FactIdentifier.create("test1", String.class.getCanonicalName()), ExpressionIdentifier.create("", FactMappingType.GIVEN)); FactMapping test2 = simulationDescriptor .addFactMapping(FactIdentifier.create("test2", String.class.getCanonicalName()), ExpressionIdentifier.create("", FactMappingType.GIVEN)); test1.addExpressionElement("test", String.class.getCanonicalName()); Scenario scenario = simulation.addData(); scenario.addMappingValue(test1.getFactIdentifier(), test1.getExpressionIdentifier(), LOWER_CASE_VALUE); scenario.addMappingValue(test2.getFactIdentifier(), test2.getExpressionIdentifier(), LOWER_CASE_VALUE); presenterSpy.cleanReadOnlyColumn(simulation); assertNotNull(scenario.getFactMappingValue(test1.getFactIdentifier(), test1.getExpressionIdentifier()).get().getRawValue()); assertNull(scenario.getFactMappingValue(test2.getFactIdentifier(), test2.getExpressionIdentifier()).get().getRawValue()); }