SensitivityAnalysisResult { public Collection<SensitivityValue> getSensitivityValuesByVariable(SensitivityVariable variable) { return sensitivityValues.stream().filter(sensitivityValue -> sensitivityValue.getFactor().getVariable().equals(variable)) .collect(Collectors.toList()); } @JsonCreator  SensitivityAnalysisResult(@JsonProperty("ok") boolean ok,
                                     @JsonProperty("metrics") Map<String, String> metrics,
                                     @JsonProperty("logs") String logs,
                                     @JsonProperty("values") List<SensitivityValue> sensitivityValues,
                                     @JsonProperty("contingenciesValues") Map<String, List<SensitivityValue>> sensitivityValuesContingencies);  SensitivityAnalysisResult(boolean ok,
                                     Map<String, String> metrics,
                                     String logs,
                                     List<SensitivityValue> sensitivityValues); boolean isOk(); Map<String, String> getMetrics(); String getLogs(); Collection<SensitivityValue> getSensitivityValues(); Collection<SensitivityValue> getSensitivityValuesByFunction(SensitivityFunction function); Collection<SensitivityValue> getSensitivityValuesByVariable(SensitivityVariable variable); SensitivityValue getSensitivityValue(SensitivityFunction function, SensitivityVariable variable); SensitivityValue getSensitivityValue(SensitivityFactor factor); boolean contingenciesArePresent(); Map<String, List<SensitivityValue>> getSensitivityValuesContingencies(); Collection<SensitivityValue> getSensitivityValuesByFunction(SensitivityFunction function, String contingencyId); Collection<SensitivityValue> getSensitivityValuesByVariable(SensitivityVariable variable, String contingencyId); SensitivityValue getSensitivityValue(SensitivityFunction function, SensitivityVariable variable, String contingencyId); SensitivityValue getSensitivityValue(SensitivityFactor factor, String contingencyId); static SensitivityAnalysisResult empty();  }
@Test public void getSensitivityValuesByVariable() { List<SensitivityValue> values = new ArrayList<>(); values.add(new SensitivityValue(factorOk, Double.NaN, Double.NaN, Double.NaN)); values.add(new SensitivityValue(factorNok, Double.NaN, Double.NaN, Double.NaN)); SensitivityAnalysisResult results = new SensitivityAnalysisResult(true, Collections.emptyMap(), "", values, Collections.emptyMap()); assertEquals(2, results.getSensitivityValuesByVariable(factorOk.getVariable()).size()); assertEquals(2, results.getSensitivityValuesByVariable(factorNok.getVariable()).size()); }
@Test public void getSensitivityValuesByVariableContingency() { List<SensitivityValue> values = new ArrayList<>(); values.add(new SensitivityValue(factorOk, Double.NaN, Double.NaN, Double.NaN)); values.add(new SensitivityValue(factorNok, Double.NaN, Double.NaN, Double.NaN)); Map<String, List<SensitivityValue>> valuesContingency = Collections.singletonMap("Contingency", values); SensitivityAnalysisResult results = new SensitivityAnalysisResult(true, Collections.emptyMap(), "", values, valuesContingency); assertEquals(2, results.getSensitivityValuesByVariable(factorOk.getVariable(), "Contingency").size()); assertEquals(2, results.getSensitivityValuesByVariable(factorNok.getVariable(), "Contingency").size()); }