public void removeFactMappingValueByIdentifiers(FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier) { getFactMappingValue(factIdentifier, expressionIdentifier).ifPresent(factMappingValues::remove); }
public void removeFactMappingValueByIdentifiers(FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier) { getFactMappingValue(factIdentifier, expressionIdentifier).ifPresent(factMappingValues::remove); }
public FactMappingValue addMappingValue(FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier, Object value) { String factName = factIdentifier.getName(); if (getFactMappingValue(factIdentifier, expressionIdentifier).isPresent()) { throw new IllegalArgumentException( new StringBuilder().append("A fact value for expression '").append(expressionIdentifier.getName()) .append("' and fact '").append(factName).append("' already exist").toString()); } FactMappingValue factMappingValue = new FactMappingValue(factIdentifier, expressionIdentifier, value); factMappingValues.add(factMappingValue); return factMappingValue; }
public FactMappingValue addMappingValue(FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier, Object value) { String factName = factIdentifier.getName(); if (getFactMappingValue(factIdentifier, expressionIdentifier).isPresent()) { throw new IllegalArgumentException( new StringBuilder().append("A fact value for expression '").append(expressionIdentifier.getName()) .append("' and fact '").append(factName).append("' already exist").toString()); } FactMappingValue factMappingValue = new FactMappingValue(factIdentifier, expressionIdentifier, value); factMappingValues.add(factMappingValue); return factMappingValue; }
public Optional<FactMappingValue> getFactMappingValueByIndex(int index) { FactMapping factMappingByIndex; try { factMappingByIndex = simulationDescriptor.getFactMappingByIndex(index); } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException( new StringBuilder().append("Impossible to retrieve FactMapping at index ").append(index).toString(), e); } return getFactMappingValue(factMappingByIndex.getFactIdentifier(), factMappingByIndex.getExpressionIdentifier()); }
public FactMappingValue addOrUpdateMappingValue(FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier, Object value) { return getFactMappingValue(factIdentifier, expressionIdentifier).map(e -> { e.setRawValue(value); return e; }).orElseGet(() -> addMappingValue(factIdentifier, expressionIdentifier, value)); }
public FactMappingValue addOrUpdateMappingValue(FactIdentifier factIdentifier, ExpressionIdentifier expressionIdentifier, Object value) { return getFactMappingValue(factIdentifier, expressionIdentifier).map(e -> { e.setRawValue(value); return e; }).orElseGet(() -> addMappingValue(factIdentifier, expressionIdentifier, value)); }
public Optional<FactMappingValue> getFactMappingValueByIndex(int index) { FactMapping factMappingByIndex; try { factMappingByIndex = simulationDescriptor.getFactMappingByIndex(index); } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException( new StringBuilder().append("Impossible to retrieve FactMapping at index ").append(index).toString(), e); } return getFactMappingValue(factMappingByIndex.getFactIdentifier(), factMappingByIndex.getExpressionIdentifier()); }
@Test public void refreshErrorsRow() { FactMappingValue factMappingValue = mock(FactMappingValue.class); when(factMappingValue.isError()).thenReturn(true); when(scenarioMock.getFactMappingValue(any(), any())).thenReturn(Optional.empty()); scenarioGridModel.refreshErrorsRow(0); verify(gridCellMock, times(6)).setErrorMode(false); when(scenarioMock.getFactMappingValue(any(), any())).thenReturn(Optional.of(factMappingValue)); scenarioGridModel.refreshErrorsRow(0); verify(gridCellMock, times(6)).setErrorMode(true); } }
@Test public void removeFactMappingValue() { scenario.addMappingValue(factIdentifier, expressionIdentifier, "test value"); Optional<FactMappingValue> retrieved = scenario.getFactMappingValue(factIdentifier, expressionIdentifier); assertTrue(retrieved.isPresent()); scenario.removeFactMappingValue(retrieved.get()); retrieved = scenario.getFactMappingValue(factIdentifier, expressionIdentifier); assertFalse(retrieved.isPresent()); }
@Test public void removeFactMappingValueByIdentifiersTest() { scenario.addMappingValue(factIdentifier, expressionIdentifier, "test value"); Optional<FactMappingValue> retrieved = scenario.getFactMappingValue(factIdentifier, expressionIdentifier); assertTrue(retrieved.isPresent()); scenario.removeFactMappingValueByIdentifiers(factIdentifier, expressionIdentifier); retrieved = scenario.getFactMappingValue(factIdentifier, expressionIdentifier); assertFalse(retrieved.isPresent()); }
protected void refreshErrorsRow(int rowIndex) { SimulationDescriptor simulationDescriptor = simulation.getSimulationDescriptor(); Scenario scenarioByIndex = simulation.getScenarioByIndex(rowIndex); IntStream.range(0, getColumnCount()).forEach(columnIndex -> { ScenarioGridCell cell = (ScenarioGridCell) getCell(rowIndex, columnIndex); if (cell == null) { return; } final FactMapping factMappingByIndex = simulationDescriptor.getFactMappingByIndex(columnIndex); Optional<FactMappingValue> factMappingValue = scenarioByIndex.getFactMappingValue(factMappingByIndex.getFactIdentifier(), factMappingByIndex.getExpressionIdentifier()); if (factMappingValue.isPresent()) { cell.setErrorMode(factMappingValue.get().isError()); } else { cell.setErrorMode(false); } }); }
@Test public void removeFactMappingValue() { scenario.addMappingValue(factIdentifier, expressionIdentifier, "test value"); Optional<FactMappingValue> retrieved = scenario.getFactMappingValue(factIdentifier, expressionIdentifier); assertTrue(retrieved.isPresent()); scenario.removeFactMappingValue(retrieved.get()); retrieved = scenario.getFactMappingValue(factIdentifier, expressionIdentifier); assertFalse(retrieved.isPresent()); }
@Test public void removeFactMappingValueByIdentifiersTest() { scenario.addMappingValue(factIdentifier, expressionIdentifier, "test value"); Optional<FactMappingValue> retrieved = scenario.getFactMappingValue(factIdentifier, expressionIdentifier); assertTrue(retrieved.isPresent()); scenario.removeFactMappingValueByIdentifiers(factIdentifier, expressionIdentifier); retrieved = scenario.getFactMappingValue(factIdentifier, expressionIdentifier); assertFalse(retrieved.isPresent()); }
when(simulationMock.cloneScenario(ROW_COUNT, ROW_COUNT + 1)).thenReturn(scenarioMock); when(scenarioMock.getFactMappingValue(any(), any())).thenReturn(Optional.of(factMappingValueMock)); when(factMappingValueMock.isError()).thenReturn(true);