AbstractKogitoDMNService implements KogitoDMNService { @Override public FactModelTuple getFactModelTuple(final JSITDefinitions jsitDefinitions) { SortedMap<String, FactModelTree> visibleFacts = new TreeMap<>(); SortedMap<String, FactModelTree> hiddenFacts = new TreeMap<>(); ErrorHolder errorHolder = new ErrorHolder(); Map<String, ClientDMNType> dmnTypesMap = getDMNDataTypesMap(jsitDefinitions.getItemDefinition(), jsitDefinitions.getNamespace()); final List<JSITDRGElement> jsitdrgElements = jsitDefinitions.getDrgElement(); for (int i = 0; i < jsitdrgElements.size(); i++) { final JSITDRGElement jsitdrgElement = Js.uncheckedCast(jsitdrgElements.get(i)); if (isJSITInputData(jsitdrgElement)) { JSITInputData jsitInputData = Js.uncheckedCast(jsitdrgElement); final JSITInformationItem jsitInputDataVariable = jsitInputData.getVariable(); ClientDMNType type = getDMNTypeFromMaps(dmnTypesMap, getOtherAttributesMap(jsitInputDataVariable)); checkTypeSupport(type, errorHolder, jsitInputData.getName()); visibleFacts.put(jsitInputData.getName(), createTopLevelFactModelTree(jsitInputData.getName(), type, hiddenFacts, FactModelTree.Type.INPUT)); } else if (isJSITDecision(jsitdrgElement)) { JSITDecision jsitDecision = Js.uncheckedCast(jsitdrgElement); final JSITInformationItem jsitDecisionVariable = jsitDecision.getVariable(); ClientDMNType type = getDMNTypeFromMaps(dmnTypesMap, getOtherAttributesMap(jsitDecisionVariable)); checkTypeSupport(type, errorHolder, jsitdrgElement.getName()); visibleFacts.put(jsitDecisionVariable.getName(), createTopLevelFactModelTree(jsitDecisionVariable.getName(), type, hiddenFacts, FactModelTree.Type.DECISION)); } } FactModelTuple toReturn = new FactModelTuple(visibleFacts, hiddenFacts); errorHolder.getMultipleNestedCollection().forEach(toReturn::addMultipleNestedCollectionError); errorHolder.getMultipleNestedObject().forEach(toReturn::addMultipleNestedObjectError); return toReturn; }  @Override FactModelTuple getFactModelTuple(final JSITDefinitions jsitDefinitions); boolean isJSITInputData(JSITDRGElement jsitdrgElement); boolean isJSITDecision(JSITDRGElement jsitdrgElement); Map<QName, String> getOtherAttributesMap(JSITDMNElement jsitInputDataVariable); static final String URI_FEEL; static final String WRONG_DMN_MESSAGE; }
@Test public void getFactModelTupleEmptyElements() { attributesMapInput.put(TYPEREF_QNAME, "number"); FactModelTuple factModelTuple = abstractKogitoDMNServiceSpy.getFactModelTuple(jsiITDefinitionsMock); assertTrue(factModelTuple.getVisibleFacts().isEmpty()); assertTrue(factModelTuple.getHiddenFacts().isEmpty()); }
@Test public void getFactModelTupleSimpleInputData() { when(jsiITInputDataMock.getName()).thenReturn("inputDataName"); drgElements.add(jsiITInputDataMock); when(jsiITDefinitionsMock.getDrgElement()).thenReturn(drgElements); attributesMapInput.put(TYPEREF_QNAME, "number"); FactModelTuple factModelTuple = abstractKogitoDMNServiceSpy.getFactModelTuple(jsiITDefinitionsMock); assertTrue(factModelTuple.getVisibleFacts().size() == 1); FactModelTree inputDataNameFact = factModelTuple.getVisibleFacts().get("inputDataName"); assertNotNull(inputDataNameFact); assertTrue(inputDataNameFact.getSimpleProperties().size() == 1); assertEquals("number", inputDataNameFact.getSimpleProperties().get(VALUE).getTypeName()); assertEquals("number", inputDataNameFact.getSimpleProperties().get(VALUE).getPropertyTypeNameToVisualize()); assertFalse(inputDataNameFact.getSimpleProperties().get(VALUE).getBaseTypeName().isPresent()); }
@Test public void getFactModelTupleSimpleDecisionData() { when(jsiITInformationItemDecisionMock.getName()).thenReturn("inputDecisionName"); drgElements.add(jsiITDecisionMock); when(jsiITDefinitionsMock.getDrgElement()).thenReturn(drgElements); attributesMapDecision.put(TYPEREF_QNAME, "string"); FactModelTuple factModelTuple = abstractKogitoDMNServiceSpy.getFactModelTuple(jsiITDefinitionsMock); assertTrue(factModelTuple.getVisibleFacts().size() == 1); FactModelTree decisionDataNameFact = factModelTuple.getVisibleFacts().get("inputDecisionName"); assertNotNull(decisionDataNameFact); assertTrue(decisionDataNameFact.getSimpleProperties().size() == 1); assertEquals("string", decisionDataNameFact.getSimpleProperties().get(VALUE).getTypeName()); assertEquals("string", decisionDataNameFact.getSimpleProperties().get(VALUE).getPropertyTypeNameToVisualize()); assertFalse(decisionDataNameFact.getSimpleProperties().get(VALUE).getBaseTypeName().isPresent()); }
@Test public void getFactModelTupleSimpleInputAndDecisionData() { when(jsiITInputDataMock.getName()).thenReturn("inputDataName"); when(jsiITInformationItemDecisionMock.getName()).thenReturn("inputDecisionName"); drgElements.add(jsiITDecisionMock); drgElements.add(jsiITInputDataMock); when(jsiITDefinitionsMock.getDrgElement()).thenReturn(drgElements); attributesMapInput.put(TYPEREF_QNAME, "number"); attributesMapDecision.put(TYPEREF_QNAME, "string"); FactModelTuple factModelTuple = abstractKogitoDMNServiceSpy.getFactModelTuple(jsiITDefinitionsMock); assertTrue(factModelTuple.getVisibleFacts().size() == 2); FactModelTree inputDataNameFact = factModelTuple.getVisibleFacts().get("inputDataName"); assertNotNull(inputDataNameFact); assertTrue(inputDataNameFact.getSimpleProperties().size() == 1); assertEquals("number", inputDataNameFact.getSimpleProperties().get(VALUE).getTypeName()); assertEquals("number", inputDataNameFact.getSimpleProperties().get(VALUE).getPropertyTypeNameToVisualize()); assertFalse(inputDataNameFact.getSimpleProperties().get(VALUE).getBaseTypeName().isPresent()); FactModelTree decisionDataNameFact = factModelTuple.getVisibleFacts().get("inputDecisionName"); assertNotNull(decisionDataNameFact); assertTrue(decisionDataNameFact.getSimpleProperties().size() == 1); assertEquals("string", decisionDataNameFact.getSimpleProperties().get(VALUE).getTypeName()); assertEquals("string", decisionDataNameFact.getSimpleProperties().get(VALUE).getPropertyTypeNameToVisualize()); assertFalse(decisionDataNameFact.getSimpleProperties().get(VALUE).getBaseTypeName().isPresent()); }