public void addExpressionElement(String stepName, String className) { this.className = className; expressionElements.add(new ExpressionElement(stepName)); }
@Override public int hashCode() { return Objects.hash(getStep()); } }
public void addExpressionElement(String stepName, String className) { this.className = className; expressionElements.add(new ExpressionElement(stepName)); }
@Override public int hashCode() { return Objects.hash(getStep()); } }
@Override public Function<String, String> from1_2to1_3() { return rawXml -> { ScenarioSimulationXMLPersistence xmlPersistence = ScenarioSimulationXMLPersistence.getInstance(); ScenarioSimulationModel model = xmlPersistence.unmarshal(rawXml, false); for (FactMapping factMapping : model.getSimulation().getSimulationDescriptor().getUnmodifiableFactMappings()) { factMapping.getExpressionElements().add(0, new ExpressionElement(factMapping.getFactIdentifier().getName())); } return xmlPersistence.marshal(model).replaceAll("<ScenarioSimulationModel version=\"1.2\">", "<ScenarioSimulationModel version=\"1.3\">"); }; } }
@Test public void isPropertyAssigned() { factMappingDescription.getExpressionElements().clear(); assertTrue(scenarioGrid.isPropertyAssigned(false, factMappingDescription)); assertTrue(scenarioGrid.isPropertyAssigned(true, factMappingDescription)); factMappingDescription.getExpressionElements().add(new ExpressionElement("test")); assertTrue(scenarioGrid.isPropertyAssigned(false, factMappingDescription)); assertTrue(scenarioGrid.isPropertyAssigned(true, factMappingDescription)); factMappingGiven.getExpressionElements().clear(); assertFalse(scenarioGrid.isPropertyAssigned(false, factMappingGiven)); assertFalse(scenarioGrid.isPropertyAssigned(true, factMappingGiven)); factMappingGiven.getExpressionElements().add(new ExpressionElement("test")); assertFalse(scenarioGrid.isPropertyAssigned(false, factMappingGiven)); assertTrue(scenarioGrid.isPropertyAssigned(true, factMappingGiven)); factMappingInteger.getExpressionElements().clear(); assertFalse(scenarioGrid.isPropertyAssigned(false, factMappingInteger)); assertTrue(scenarioGrid.isPropertyAssigned(true, factMappingInteger)); }
private FactMapping(FactMapping original) { original.expressionElements.forEach(expressionElement -> this.addExpressionElement(expressionElement.getStep(), original.className)); this.expressionIdentifier = original.expressionIdentifier; this.factIdentifier = original.factIdentifier; this.className = original.className; this.factAlias = original.factAlias; this.expressionAlias = original.expressionAlias; }
private FactMapping(FactMapping original) { original.expressionElements.forEach(expressionElement -> this.addExpressionElement(expressionElement.getStep(), original.className)); this.expressionIdentifier = original.expressionIdentifier; this.factIdentifier = original.factIdentifier; this.className = original.className; this.factAlias = original.factAlias; this.expressionAlias = original.expressionAlias; }
@SuppressWarnings("unchecked") protected ResultWrapper getSingleFactValueResult(FactMapping factMapping, FactMappingValue expectedResult, DMNDecisionResult decisionResult, ExpressionEvaluator expressionEvaluator) { Object resultRaw = decisionResult.getResult(); if (!SUCCEEDED.equals(decisionResult.getEvaluationStatus())) { return createErrorResult(); } for (ExpressionElement expressionElement : factMapping.getExpressionElementsWithoutClass()) { if (!(resultRaw instanceof Map)) { throw new ScenarioException("Wrong resultRaw structure because it is not a complex type as expected"); } Map<String, Object> result = (Map<String, Object>) resultRaw; resultRaw = result.get(expressionElement.getStep()); } Class<?> resultClass = resultRaw != null ? resultRaw.getClass() : null; try { return expressionEvaluator.evaluate(expectedResult.getRawValue(), resultRaw, resultClass) ? createResult(resultRaw) : createErrorResult(); } catch (Exception e) { expectedResult.setError(true); throw new ScenarioException(e.getMessage(), e); } }