KogitoScenarioSimulationBuilder { protected void addFactMapping(final FactMappingExtractor factMappingExtractor, final FactModelTree factModelTree, final List<String> previousSteps, final Map<String, FactModelTree> hiddenValues) { internalAddToScenario(factMappingExtractor, factModelTree, previousSteps, hiddenValues, new HashSet<>()); }  void populateScenarioSimulationModel(final ScenarioSimulationModel content, final ScenarioSimulationModel.Type type, final String value, RemoteCallback<String> callback);  }
@Test public void addToScenarioRecursive() { FactMapping factMappingMock = mock(FactMapping.class); KogitoScenarioSimulationBuilder.FactMappingExtractor factMappingExtractorMock = mock(KogitoScenarioSimulationBuilder.FactMappingExtractor.class); when(factMappingExtractorMock.getFactMapping(any(), anyString(), any(), anyString())).thenReturn(factMappingMock); Map<String, FactModelTree> hiddenFacts = new HashMap<>(); FactModelTree factModelTree = new FactModelTree("myFact", "", new HashMap<>(), Collections.emptyMap()); factModelTree.addExpandableProperty("recursiveProperty", "recursive"); String propertyType = String.class.getCanonicalName(); String propertyName = "simpleProperty"; factModelTree.addSimpleProperty(propertyName, new FactModelTree.PropertyTypeName(propertyType)); hiddenFacts.put("recursive", factModelTree); kogitoScenarioSimulationBuilderSpy.addFactMapping(factMappingExtractorMock, factModelTree, new ArrayList<>(), hiddenFacts); verify(factMappingExtractorMock, times(1)) .getFactMapping( eq(factModelTree), eq(propertyName), eq(Arrays.asList("myFact", "recursiveProperty")), eq(propertyType)); verify(factMappingExtractorMock, times(2)) .getFactMapping( any(), any(), any(), any()); }
@Test public void addToScenarioMultipleNested() { FactMapping factMappingMock = mock(FactMapping.class); KogitoScenarioSimulationBuilder.FactMappingExtractor factMappingExtractorMock = mock(KogitoScenarioSimulationBuilder.FactMappingExtractor.class); when(factMappingExtractorMock.getFactMapping(any(), anyString(), any(), anyString())).thenReturn(factMappingMock); Map<String, FactModelTree> hiddenFacts = new HashMap<>(); FactModelTree factModelTree = new FactModelTree("myFact", "", new HashMap<>(), Collections.emptyMap()); factModelTree.addExpandableProperty("nestedProperty", "tNested"); factModelTree.addExpandableProperty("nestedProperty2", "tNested2"); FactModelTree nested1 = new FactModelTree("tNested1", "", new HashMap<>(), Collections.emptyMap()); FactModelTree nested2 = new FactModelTree("tNested2", "", new HashMap<>(), Collections.emptyMap()); String propertyType = String.class.getCanonicalName(); String propertyName = "stingProperty"; nested1.addSimpleProperty(propertyName, new FactModelTree.PropertyTypeName(propertyType)); String propertyType2 = Boolean.class.getCanonicalName(); String propertyName2 = "booleanProperty"; nested2.addSimpleProperty(propertyName2, new FactModelTree.PropertyTypeName(propertyType2)); hiddenFacts.put("tNested", nested1); hiddenFacts.put("tNested2", nested2); kogitoScenarioSimulationBuilderSpy.addFactMapping(factMappingExtractorMock, factModelTree, new ArrayList<>(), hiddenFacts); verify(factMappingExtractorMock, times(1)) .getFactMapping( eq(nested1), eq(propertyName), eq(Arrays.asList("myFact", "nestedProperty")), eq(propertyType)); verify(factMappingExtractorMock, times(1)) .getFactMapping( eq(nested2), eq(propertyName2), eq(Arrays.asList("myFact", "nestedProperty2")), eq(propertyType2)); verify(factMappingExtractorMock, times(2)) .getFactMapping( any(), any(), any(), any()); }