AbstractDMODataManagementStrategy extends AbstractDataManagementStrategy { public FactModelTree getFactModelTree(String factName, Map<String, String> superTypeMap, ModelField[] modelFields) { Map<String, FactModelTree.PropertyTypeName> simpleProperties = new HashMap<>(); Map<String, List<String>> genericTypesMap = new HashMap<>(); String factPackageName = packageName; String fullFactClassName = getFQCNByFactName(factName); if (fullFactClassName != null && fullFactClassName.contains(".")) { factPackageName = fullFactClassName.substring(0, fullFactClassName.lastIndexOf('.')); } if (ScenarioSimulationSharedUtils.isEnumCanonicalName(superTypeMap.get(factName))) { simpleProperties.put(ConstantsHolder.VALUE, new FactModelTree.PropertyTypeName(fullFactClassName)); return getSimpleClassFactModelTree(factName, fullFactClassName); } for (ModelField modelField : modelFields) { if (!modelField.getName().equals("this")) { String className = defineClassNameField(modelField.getClassName(), superTypeMap); simpleProperties.put(modelField.getName(), new FactModelTree.PropertyTypeName(className)); if (ScenarioSimulationSharedUtils.isCollection(className)) { populateGenericTypeMap(genericTypesMap, factName, modelField.getName(), ScenarioSimulationSharedUtils.isList(className)); } } } return new FactModelTree(factName, factPackageName, simpleProperties, genericTypesMap); }  @Override void populateTestTools(final TestToolsView.Presenter testToolsPresenter,
                                  final ScenarioSimulationContext context,
                                  final GridWidget gridWidget); FactModelTree getFactModelTree(String factName, Map<String, String> superTypeMap, ModelField[] modelFields); void populateGenericTypeMap(Map<String, List<String>> toPopulate, String factName, String propertyName, boolean isList); void aggregatorCallbackMethod(final TestToolsView.Presenter testToolsPresenter,
                                         final int expectedElements,
                                         final SortedMap<String, FactModelTree> factTypeFieldsMap,
                                         final ScenarioSimulationContext context,
                                         final FactModelTree result,
                                         final List<String> simpleJavaTypes,
                                         final GridWidget gridWidget); void populateFactModelTree(FactModelTree toPopulate, final SortedMap<String, FactModelTree> factTypeFieldsMap);  }
@Test public void getFactModelTree() { Map<String, FactModelTree.PropertyTypeName> simpleProperties = getSimplePropertiesInner(); final ModelField[] modelFields = getModelFieldsInner(simpleProperties); final FactModelTree retrieved = abstractDMODataManagementStrategySpy.getFactModelTree(FACT_NAME, Collections.emptyMap(), modelFields); assertNotNull(retrieved); assertEquals(FACT_NAME, retrieved.getFactName()); assertEquals(FULL_PACKAGE, retrieved.getFullPackage()); assertFalse(retrieved.getSimpleProperties().isEmpty()); retrieved.getSimpleProperties().entrySet().forEach( entry -> { assertFalse(entry.getValue().getBaseTypeName().isPresent()); assertEquals(entry.getValue().getTypeName(), entry.getValue().getPropertyTypeNameToVisualize()); } ); }
@Test public void getFactModelTreeEnumClass() { final ModelField[] modelFields = {}; Map<String, String> superTypesMap = new HashMap<>(); superTypesMap.put(FACT_NAME, Enum.class.getCanonicalName()); final FactModelTree retrieved = abstractDMODataManagementStrategySpy.getFactModelTree(FACT_NAME, superTypesMap, modelFields); assertNotNull(retrieved); assertEquals(FACT_NAME, retrieved.getFactName()); assertEquals(FULL_PACKAGE, retrieved.getFullPackage()); assertTrue(retrieved.getSimpleProperties().containsKey(TestProperties.LOWER_CASE_VALUE)); assertEquals(FULL_CLASS_NAME, retrieved.getSimpleProperties().get(TestProperties.LOWER_CASE_VALUE).getTypeName()); assertEquals(FULL_CLASS_NAME, retrieved.getSimpleProperties().get(TestProperties.LOWER_CASE_VALUE).getPropertyTypeNameToVisualize()); assertFalse(retrieved.getSimpleProperties().get(TestProperties.LOWER_CASE_VALUE).getBaseTypeName().isPresent()); assertEquals(FULL_CLASS_NAME, retrieved.getSimpleProperties().get(TestProperties.LOWER_CASE_VALUE).getPropertyTypeNameToVisualize()); }