@Test public void testGetRecursiveAndFieldCollectionsDMNTypes() { final JSITItemDefinition tPeople = mock(JSITItemDefinition.class); final JSITItemDefinition tAddress = mock(JSITItemDefinition.class); final JSITItemDefinition tCountry = mock(JSITItemDefinition.class); final String tPeopleType = "tPeopleType"; final String tAddressType = "tAddressType"; final String tCountryType = "tCountryType"; final String addressFieldName = "address"; final String countryFieldName = "president"; final String peopleFieldName = "people"; final String regionsName = "regions"; final String nameLabel = "name"; when(tPeople.getName()).thenReturn(tPeopleType); when(tAddress.getName()).thenReturn(tAddressType); when(tCountry.getName()).thenReturn(tCountryType); final JSITItemDefinition address = mock(JSITItemDefinition.class); when(address.getTypeRef()).thenReturn(tAddressType); when(address.getName()).thenReturn(addressFieldName); final List<JSITItemDefinition> tPeopleFields = Arrays.asList(address); final JSITItemDefinition country = mock(JSITItemDefinition.class); when(country.getName()).thenReturn(countryFieldName); when(country.getTypeRef()).thenReturn(tCountryType); final List<JSITItemDefinition> tAddressFields = Arrays.asList(country); final JSITItemDefinition people = mock(JSITItemDefinition.class); when(people.getTypeRef()).thenReturn(tPeopleType); when(people.getName()).thenReturn(peopleFieldName); when(people.getIsCollection()).thenReturn(true); final JSITItemDefinition regions = mock(JSITItemDefinition.class); when(regions.getTypeRef()).thenReturn(BuiltInType.STRING.getName()); when(regions.getName()).thenReturn(regionsName); when(regions.getIsCollection()).thenReturn(true); final JSITItemDefinition nameField = mock(JSITItemDefinition.class); when(nameField.getTypeRef()).thenReturn(BuiltInType.STRING.getName()); when(nameField.getName()).thenReturn(nameLabel); final List<JSITItemDefinition> tCountryFields = Arrays.asList(people, regions, nameField); when(tPeople.getItemComponent()).thenReturn(tPeopleFields); when(tAddress.getItemComponent()).thenReturn(tAddressFields); when(tCountry.getItemComponent()).thenReturn(tCountryFields); final List<JSITItemDefinition> definitions = Arrays.asList(tPeople, tAddress, tCountry); final Map<String, ClientDMNType> dmnTypesMap = abstractKogitoDMNServiceSpy.getDMNDataTypesMap(definitions, "namespace"); assertTrue(dmnTypesMap.containsKey(tPeopleType)); assertTrue(dmnTypesMap.containsKey(tAddressType)); assertTrue(dmnTypesMap.containsKey(tCountryType)); final ClientDMNType dmnPeopleType = dmnTypesMap.get(tPeopleType); final ClientDMNType dmnAddressType = dmnTypesMap.get(tAddressType); final ClientDMNType dmnCountryType = dmnTypesMap.get(tCountryType); final ClientDMNType stringType = dmnTypesMap.get(BuiltInType.STRING.getName()); assertEquals(1, dmnPeopleType.getFields().size()); assertTrue(dmnPeopleType.getFields().containsKey(addressFieldName)); assertEquals(dmnAddressType, dmnPeopleType.getFields().get(addressFieldName)); assertNull(dmnPeopleType.getFeelType()); assertFalse(dmnPeopleType.isCollection()); assertTrue(dmnPeopleType.isComposite()); assertEquals(1, dmnAddressType.getFields().size()); assertTrue(dmnAddressType.getFields().containsKey(countryFieldName)); assertEquals(dmnCountryType, dmnAddressType.getFields().get(countryFieldName)); assertNull(dmnAddressType.getFeelType()); assertFalse(dmnAddressType.isCollection()); assertTrue(dmnAddressType.isComposite()); assertEquals(3, dmnCountryType.getFields().size()); assertTrue(dmnCountryType.getFields().containsKey(peopleFieldName)); assertNotEquals(dmnPeopleType, dmnCountryType.getFields().get(peopleFieldName)); assertTrue(dmnCountryType.getFields().get(peopleFieldName).isCollection()); assertTrue(dmnCountryType.getFields().get(peopleFieldName).isComposite()); assertEquals(tPeopleType, dmnCountryType.getFields().get(peopleFieldName).getName()); assertTrue(dmnCountryType.getFields().containsKey(regionsName)); assertNull(dmnCountryType.getFeelType()); assertNotEquals(stringType, dmnCountryType.getFields().get(regionsName)); assertTrue(dmnCountryType.getFields().get(regionsName).isCollection()); assertFalse(dmnCountryType.getFields().get(regionsName).isComposite()); assertEquals(BuiltInType.STRING.getName(), dmnCountryType.getFields().get(regionsName).getName()); assertTrue(dmnCountryType.getFields().containsKey(nameLabel)); assertEquals(stringType, dmnCountryType.getFields().get(nameLabel)); assertEquals(BuiltInType.STRING, stringType.getFeelType()); assertFalse(stringType.isCollection()); assertFalse(stringType.isComposite()); assertTrue(dmnTypesMap.size() == 17); for (BuiltInType builtInType : BuiltInType.values()) { Arrays.stream(builtInType.getNames()).forEach(name -> assertNotNull(dmnTypesMap.get(name))); } }
protected Map<String, ClientDMNType> getDMNDataTypesMap(final List<JSITItemDefinition> jsitItemDefinitions, final String nameSpace) { Map<String, ClientDMNType> dmnDataTypesMap = new HashMap<>(); for (BuiltInType type : BuiltInType.values()) { for (String name : type.getNames()) { ClientDMNType feelPrimitiveType; if (type == BuiltInType.CONTEXT) { feelPrimitiveType = new ClientDMNType(URI_FEEL, name, null, false, true, Collections.emptyMap(), type); } else { feelPrimitiveType = new ClientDMNType(URI_FEEL, name, null, false, type); } dmnDataTypesMap.put(name, feelPrimitiveType); } } final Map<String, JSITItemDefinition> itemDefinitionMap = indexDefinitionsByName(jsitItemDefinitions); for (int i = 0; i < jsitItemDefinitions.size(); i++) { final JSITItemDefinition jsitItemDefinition = Js.uncheckedCast(jsitItemDefinitions.get(i)); getOrCreateDMNType(itemDefinitionMap, jsitItemDefinition.getName(), nameSpace, dmnDataTypesMap); } return Collections.unmodifiableMap(dmnDataTypesMap); }
AbstractKogitoDMNService implements KogitoDMNService { protected Map<String, ClientDMNType> getDMNDataTypesMap(final List<JSITItemDefinition> jsitItemDefinitions, final String nameSpace) { Map<String, ClientDMNType> dmnDataTypesMap = new HashMap<>(); for (BuiltInType type : BuiltInType.values()) { for (String name : type.getNames()) { ClientDMNType feelPrimitiveType; if (type == BuiltInType.CONTEXT) { feelPrimitiveType = new ClientDMNType(URI_FEEL, name, null, false, true, Collections.emptyMap(), type); } else { feelPrimitiveType = new ClientDMNType(URI_FEEL, name, null, false, type); } dmnDataTypesMap.put(name, feelPrimitiveType); } } final Map<String, JSITItemDefinition> itemDefinitionMap = indexDefinitionsByName(jsitItemDefinitions); for (int i = 0; i < jsitItemDefinitions.size(); i++) { final JSITItemDefinition jsitItemDefinition = Js.uncheckedCast(jsitItemDefinitions.get(i)); getOrCreateDMNType(itemDefinitionMap, jsitItemDefinition.getName(), nameSpace, dmnDataTypesMap); } return Collections.unmodifiableMap(dmnDataTypesMap); } }
AbstractKogitoDMNService implements KogitoDMNService { protected Map<String, ClientDMNType> getDMNDataTypesMap(final List<JSITItemDefinition> jsitItemDefinitions, final String nameSpace) { Map<String, ClientDMNType> dmnDataTypesMap = new HashMap<>(); for (BuiltInType type : BuiltInType.values()) { for (String name : type.getNames()) { ClientDMNType feelPrimitiveType; if (type == BuiltInType.CONTEXT) { feelPrimitiveType = new ClientDMNType(URI_FEEL, name, null, false, true, Collections.emptyMap(), type); } else { feelPrimitiveType = new ClientDMNType(URI_FEEL, name, null, false, type); } dmnDataTypesMap.put(name, feelPrimitiveType); } } final Map<String, JSITItemDefinition> itemDefinitionMap = indexDefinitionsByName(jsitItemDefinitions); for (int i = 0; i < jsitItemDefinitions.size(); i++) { final JSITItemDefinition jsitItemDefinition = Js.uncheckedCast(jsitItemDefinitions.get(i)); getOrCreateDMNType(itemDefinitionMap, jsitItemDefinition.getName(), nameSpace, dmnDataTypesMap); } return Collections.unmodifiableMap(dmnDataTypesMap); }  }
AbstractKogitoDMNService implements KogitoDMNService { protected Map<String, ClientDMNType> getDMNDataTypesMap(final List<JSITItemDefinition> jsitItemDefinitions, final String nameSpace) { Map<String, ClientDMNType> dmnDataTypesMap = new HashMap<>(); for (BuiltInType type : BuiltInType.values()) { for (String name : type.getNames()) { ClientDMNType feelPrimitiveType; if (type == BuiltInType.CONTEXT) { feelPrimitiveType = new ClientDMNType(URI_FEEL, name, null, false, true, Collections.emptyMap(), type); } else { feelPrimitiveType = new ClientDMNType(URI_FEEL, name, null, false, type); } dmnDataTypesMap.put(name, feelPrimitiveType); } } final Map<String, JSITItemDefinition> itemDefinitionMap = indexDefinitionsByName(jsitItemDefinitions); for (int i = 0; i < jsitItemDefinitions.size(); i++) { final JSITItemDefinition jsitItemDefinition = Js.uncheckedCast(jsitItemDefinitions.get(i)); getOrCreateDMNType(itemDefinitionMap, jsitItemDefinition.getName(), nameSpace, dmnDataTypesMap); } return Collections.unmodifiableMap(dmnDataTypesMap); }  @Override FactModelTuple getFactModelTuple(final JSITDefinitions jsitDefinitions); boolean isJSITInputData(JSITDRGElement jsitdrgElement); boolean isJSITDecision(JSITDRGElement jsitdrgElement); Map<QName, String> getOtherAttributesMap(JSITDMNElement jsitInputDataVariable); }
AbstractKogitoDMNService implements KogitoDMNService { protected Map<String, ClientDMNType> getDMNDataTypesMap(final List<JSITItemDefinition> jsitItemDefinitions, final String nameSpace) { Map<String, ClientDMNType> dmnDataTypesMap = new HashMap<>(); for (BuiltInType type : BuiltInType.values()) { for (String name : type.getNames()) { ClientDMNType feelPrimitiveType; if (type == BuiltInType.CONTEXT) { feelPrimitiveType = new ClientDMNType(URI_FEEL, name, null, false, true, Collections.emptyMap(), type); } else { feelPrimitiveType = new ClientDMNType(URI_FEEL, name, null, false, type); } dmnDataTypesMap.put(name, feelPrimitiveType); } } final Map<String, JSITItemDefinition> itemDefinitionMap = indexDefinitionsByName(jsitItemDefinitions); for (int i = 0; i < jsitItemDefinitions.size(); i++) { final JSITItemDefinition jsitItemDefinition = Js.uncheckedCast(jsitItemDefinitions.get(i)); getOrCreateDMNType(itemDefinitionMap, jsitItemDefinition.getName(), nameSpace, dmnDataTypesMap); } return Collections.unmodifiableMap(dmnDataTypesMap); }  @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; }