DMNTypeServiceImpl extends AbstractKieContainerService implements DMNTypeService { protected FactModelTree createTopLevelFactModelTree(String factName, DMNType type, SortedMap<String, FactModelTree> hiddenFacts, FactModelTree.Type fmType) throws WrongDMNTypeException { return isToBeManagedAsCollection(type) ? createFactModelTreeForCollection(new HashMap<>(), factName, type, hiddenFacts, fmType, new ArrayList<>()) : createFactModelTreeForNoCollection(new HashMap<>(), factName, factName, type.getName(), type, hiddenFacts, fmType, new ArrayList<>()); }  @Override FactModelTuple retrieveFactModelTuple(Path path, String dmnPath); @Override void initializeNameAndNamespace(Settings settings, Path path, String dmnPath); DMNModel getDMNModel(Path path, String dmnPath); DMNRuntime getDMNRuntime(Path path);  }
@Test public void createTopLevelFactModelTreeSimpleNoCollection() throws WrongDMNTypeException { DMNType simpleString = getSimpleNoCollection(); FactModelTree retrieved = dmnTypeServiceImpl.createTopLevelFactModelTree("testPath", simpleString, new TreeMap<>(), FactModelTree.Type.INPUT); assertNotNull(retrieved); assertEquals("testPath", retrieved.getFactName()); assertEquals(1, retrieved.getSimpleProperties().size()); assertTrue(retrieved.getSimpleProperties().containsKey(VALUE)); assertEquals(simpleString.getName(), retrieved.getSimpleProperties().get(VALUE).getTypeName()); assertFalse(retrieved.getSimpleProperties().get(VALUE).getBaseTypeName().isPresent()); assertEquals(simpleString.getName(), retrieved.getSimpleProperties().get(VALUE).getPropertyTypeNameToVisualize()); assertTrue(retrieved.getExpandableProperties().isEmpty()); assertTrue(retrieved.getGenericTypesMap().isEmpty()); }
@Test public void createTopLevelFactModelTreeSimpleCollection() throws WrongDMNTypeException { DMNType simpleCollectionString = getSimpleCollection(); TreeMap<String, FactModelTree> hiddenFactSimpleCollection = new TreeMap<>(); FactModelTree retrieved = dmnTypeServiceImpl.createTopLevelFactModelTree("testPath", simpleCollectionString, hiddenFactSimpleCollection, FactModelTree.Type.INPUT); assertNotNull(retrieved); assertEquals("testPath", retrieved.getFactName()); assertEquals(1, retrieved.getSimpleProperties().size()); assertTrue(retrieved.getSimpleProperties().containsKey(VALUE)); assertEquals("java.util.List", retrieved.getSimpleProperties().get(VALUE).getTypeName()); assertFalse(retrieved.getSimpleProperties().get(VALUE).getBaseTypeName().isPresent()); assertEquals("java.util.List", retrieved.getSimpleProperties().get(VALUE).getPropertyTypeNameToVisualize()); assertTrue(retrieved.getExpandableProperties().isEmpty()); assertEquals(1, retrieved.getGenericTypesMap().size()); assertTrue(retrieved.getGenericTypesMap().containsKey(VALUE)); assertNotNull(retrieved.getGenericTypesMap().get(VALUE)); assertEquals(1, retrieved.getGenericTypesMap().get(VALUE).size()); assertEquals(simpleCollectionString.getName(), retrieved.getGenericTypesMap().get(VALUE).get(0)); }
@Test public void createTopLevelFactModelTreeCompositeNoCollectionBaseType() throws WrongDMNTypeException { DMNType composite = getSingleCompositeWithBaseTypeField(); FactModelTree retrieved = dmnTypeServiceImpl.createTopLevelFactModelTree("testPath", composite, new TreeMap<>(), FactModelTree.Type.INPUT); assertNotNull(retrieved); assertEquals("testPath", retrieved.getFactName()); assertEquals(2, retrieved.getSimpleProperties().size()); assertTrue(retrieved.getSimpleProperties().containsKey("name")); assertEquals(SIMPLE_TYPE_NAME, retrieved.getSimpleProperties().get("name").getTypeName()); assertFalse(retrieved.getSimpleProperties().get("name").getBaseTypeName().isPresent()); assertEquals(SIMPLE_TYPE_NAME, retrieved.getSimpleProperties().get("name").getPropertyTypeNameToVisualize()); assertTrue(retrieved.getSimpleProperties().containsKey("gender")); assertEquals("simpleType", retrieved.getSimpleProperties().get("gender").getTypeName()); assertEquals(SIMPLE_TYPE_NAME, retrieved.getSimpleProperties().get("gender").getBaseTypeName().get()); assertEquals(SIMPLE_TYPE_NAME, retrieved.getSimpleProperties().get("gender").getPropertyTypeNameToVisualize()); assertTrue(retrieved.getExpandableProperties().isEmpty()); assertTrue(retrieved.getGenericTypesMap().isEmpty()); }
@Test public void createTopLevelFactModelTreeCompositeNoCollection() throws WrongDMNTypeException { DMNType compositePerson = getSingleCompositeWithSimpleCollection(); FactModelTree retrieved = dmnTypeServiceImpl.createTopLevelFactModelTree("testPath", compositePerson, new TreeMap<>(), FactModelTree.Type.INPUT); assertNotNull(retrieved); assertEquals("testPath", retrieved.getFactName()); assertEquals(2, retrieved.getSimpleProperties().size()); assertTrue(retrieved.getSimpleProperties().containsKey("friends")); assertEquals("java.util.List", retrieved.getSimpleProperties().get("friends").getTypeName()); assertFalse(retrieved.getSimpleProperties().get("friends").getBaseTypeName().isPresent()); assertEquals("java.util.List", retrieved.getSimpleProperties().get("friends").getPropertyTypeNameToVisualize()); assertTrue(retrieved.getSimpleProperties().containsKey("name")); assertEquals(SIMPLE_TYPE_NAME, retrieved.getSimpleProperties().get("name").getTypeName()); assertFalse(retrieved.getSimpleProperties().get("name").getBaseTypeName().isPresent()); assertEquals(SIMPLE_TYPE_NAME, retrieved.getSimpleProperties().get("name").getPropertyTypeNameToVisualize()); assertEquals(1, retrieved.getGenericTypesMap().size()); assertTrue(retrieved.getGenericTypesMap().containsKey("friends")); assertEquals(compositePerson.getFields().get("friends").getName(), retrieved.getGenericTypesMap().get("friends").get(0)); assertEquals(2, retrieved.getExpandableProperties().size()); assertTrue(retrieved.getExpandableProperties().containsKey(EXPANDABLE_PROPERTY_PHONENUMBERS)); assertEquals("tPhoneNumber", retrieved.getExpandableProperties().get(EXPANDABLE_PROPERTY_PHONENUMBERS)); assertTrue(retrieved.getExpandableProperties().containsKey(EXPANDABLE_PROPERTY_DETAILS)); assertEquals("tDetails", retrieved.getExpandableProperties().get(EXPANDABLE_PROPERTY_DETAILS)); }
@Test public void createTopLevelFactModelTreeCompositeCollection() throws WrongDMNTypeException { DMNType compositePerson = getCompositeCollection(); TreeMap<String, FactModelTree> hiddenFactSimpleCollection = new TreeMap<>(); FactModelTree retrieved = dmnTypeServiceImpl.createTopLevelFactModelTree("testPath", compositePerson, hiddenFactSimpleCollection, FactModelTree.Type.INPUT); assertNotNull(retrieved); assertEquals("testPath", retrieved.getFactName()); assertEquals(1, retrieved.getSimpleProperties().size()); assertTrue(retrieved.getSimpleProperties().containsKey(VALUE)); assertEquals("java.util.List", retrieved.getSimpleProperties().get(VALUE).getTypeName()); assertFalse(retrieved.getSimpleProperties().get(VALUE).getBaseTypeName().isPresent()); assertEquals("java.util.List", retrieved.getSimpleProperties().get(VALUE).getPropertyTypeNameToVisualize()); assertTrue(retrieved.getExpandableProperties().isEmpty()); assertEquals(1, retrieved.getGenericTypesMap().size()); assertTrue(retrieved.getGenericTypesMap().containsKey(VALUE)); assertNotNull(retrieved.getGenericTypesMap().get(VALUE)); assertEquals(1, retrieved.getGenericTypesMap().get(VALUE).size()); assertEquals(compositePerson.getName(), retrieved.getGenericTypesMap().get(VALUE).get(0)); }
@Test public void createTopLevelFactModelTreeRecursiveTypes() throws WrongDMNTypeException { SortedMap<String, FactModelTree> hiddenFacts = new TreeMap<>(); FactModelTree person = dmnTypeServiceImpl.createTopLevelFactModelTree("person", getRecursivePersonComposite(false), hiddenFacts, FactModelTree.Type.DECISION); assertNotNull(person); assertTrue(person.getExpandableProperties().containsKey("parent")); assertEquals("tPerson", person.getExpandableProperties().get("parent")); assertTrue(hiddenFacts.containsKey("tPerson")); hiddenFacts = new TreeMap<>(); FactModelTree personCollection = dmnTypeServiceImpl.createTopLevelFactModelTree("person", getRecursivePersonComposite(true), hiddenFacts, FactModelTree.Type.DECISION); assertNotNull(personCollection); assertTrue(personCollection.getGenericTypesMap().containsKey(VALUE)); assertEquals("tPerson", personCollection.getGenericTypeInfo(VALUE).get(0)); assertTrue(hiddenFacts.containsKey("tPerson")); assertTrue(hiddenFacts.containsKey("tPersonList")); }