@Test public void recursivelyFindIsPropertyType() { Map<String, FactModelTree.PropertyTypeName> bookSimpleProperties = new HashMap<>(); bookSimpleProperties.put("name", new FactModelTree.PropertyTypeName("String")); Map<String, String> bookExpandableProperties = new HashMap<>(); bookExpandableProperties.put("author", "Author"); Map<String, FactModelTree.PropertyTypeName> authorSimpleProperties = new HashMap<>(); authorSimpleProperties.put("books", new FactModelTree.PropertyTypeName("List")); Map<String, String> authorExpandableProperties = new HashMap<>(); FactModelTree bookFactModelTreeMock = getMockedFactModelTree(bookSimpleProperties, bookExpandableProperties); FactModelTree authorFactModelTreeMock = getMockedFactModelTree(authorSimpleProperties, authorExpandableProperties); when(dataObjectFieldsMapMock.get("Author")).thenReturn(authorFactModelTreeMock); when(dataObjectFieldsMapMock.get("Book")).thenReturn(bookFactModelTreeMock); assertFalse(((SetHeaderCellValueCommand) commandSpy).recursivelyFindIsPropertyType(scenarioSimulationContextLocal, bookFactModelTreeMock, Collections.singletonList("not-existing"))); assertTrue(((SetHeaderCellValueCommand) commandSpy).recursivelyFindIsPropertyType(scenarioSimulationContextLocal, bookFactModelTreeMock, Collections.singletonList("name"))); assertFalse(((SetHeaderCellValueCommand) commandSpy).recursivelyFindIsPropertyType(scenarioSimulationContextLocal, bookFactModelTreeMock, Arrays.asList("author", "not-existing"))); assertTrue(((SetHeaderCellValueCommand) commandSpy).recursivelyFindIsPropertyType(scenarioSimulationContextLocal, bookFactModelTreeMock, Arrays.asList("author", "books"))); }
protected boolean recursivelyFindIsPropertyType(ScenarioSimulationContext context, FactModelTree factModelTree, List<String> propertyNameElements) { boolean toReturn = propertyNameElements.size() == 1 && (factModelTree.getSimpleProperties().containsKey(propertyNameElements.get(0)) || factModelTree.getExpandableProperties().containsKey(propertyNameElements.get(0))); if (!toReturn && propertyNameElements.size() > 1) { String propertyParent = propertyNameElements.get(0); if (factModelTree.getExpandableProperties().containsKey(propertyParent)) { List<String> nestedPropertyNameElements = propertyNameElements.subList(1, propertyNameElements.size()); String className = factModelTree.getExpandableProperties().get(propertyParent); final FactModelTree nestedFactModelTree = context.getDataObjectFieldsMap().get(className); toReturn = recursivelyFindIsPropertyType(context, nestedFactModelTree, nestedPropertyNameElements); } } return toReturn; }
SetHeaderCellValueCommand extends AbstractScenarioGridCommand { protected boolean recursivelyFindIsPropertyType(ScenarioSimulationContext context, FactModelTree factModelTree, List<String> propertyNameElements) { boolean toReturn = propertyNameElements.size() == 1 && (factModelTree.getSimpleProperties().containsKey(propertyNameElements.get(0)) || factModelTree.getExpandableProperties().containsKey(propertyNameElements.get(0))); if (!toReturn && propertyNameElements.size() > 1) { String propertyParent = propertyNameElements.get(0); if (factModelTree.getExpandableProperties().containsKey(propertyParent)) { List<String> nestedPropertyNameElements = propertyNameElements.subList(1, propertyNameElements.size()); String className = factModelTree.getExpandableProperties().get(propertyParent); final FactModelTree nestedFactModelTree = context.getDataObjectFieldsMap().get(className); toReturn = recursivelyFindIsPropertyType(context, nestedFactModelTree, nestedPropertyNameElements); } } return toReturn; } }
SetHeaderCellValueCommand extends AbstractScenarioGridCommand { protected boolean recursivelyFindIsPropertyType(ScenarioSimulationContext context, FactModelTree factModelTree, List<String> propertyNameElements) { boolean toReturn = propertyNameElements.size() == 1 && (factModelTree.getSimpleProperties().containsKey(propertyNameElements.get(0)) || factModelTree.getExpandableProperties().containsKey(propertyNameElements.get(0))); if (!toReturn && propertyNameElements.size() > 1) { String propertyParent = propertyNameElements.get(0); if (factModelTree.getExpandableProperties().containsKey(propertyParent)) { List<String> nestedPropertyNameElements = propertyNameElements.subList(1, propertyNameElements.size()); String className = factModelTree.getExpandableProperties().get(propertyParent); final FactModelTree nestedFactModelTree = context.getDataObjectFieldsMap().get(className); toReturn = recursivelyFindIsPropertyType(context, nestedFactModelTree, nestedPropertyNameElements); } } return toReturn; } SetHeaderCellValueCommand(GridWidget gridWidget, boolean isInstanceHeader, boolean isPropertyHeader); private  SetHeaderCellValueCommand(); }
SetHeaderCellValueCommand extends AbstractScenarioGridCommand { protected boolean recursivelyFindIsPropertyType(ScenarioSimulationContext context, FactModelTree factModelTree, List<String> propertyNameElements) { boolean toReturn = propertyNameElements.size() == 1 && (factModelTree.getSimpleProperties().containsKey(propertyNameElements.get(0)) || factModelTree.getExpandableProperties().containsKey(propertyNameElements.get(0))); if (!toReturn && propertyNameElements.size() > 1) { String propertyParent = propertyNameElements.get(0); if (factModelTree.getExpandableProperties().containsKey(propertyParent)) { List<String> nestedPropertyNameElements = propertyNameElements.subList(1, propertyNameElements.size()); String className = factModelTree.getExpandableProperties().get(propertyParent); final FactModelTree nestedFactModelTree = context.getDataObjectFieldsMap().get(className); toReturn = recursivelyFindIsPropertyType(context, nestedFactModelTree, nestedPropertyNameElements); } } return toReturn; } SetHeaderCellValueCommand(GridWidget gridWidget, boolean isInstanceHeader, boolean isPropertyHeader); private  SetHeaderCellValueCommand();  }
SetHeaderCellValueCommand extends AbstractScenarioGridCommand { protected boolean recursivelyFindIsPropertyType(ScenarioSimulationContext context, FactModelTree factModelTree, List<String> propertyNameElements) { boolean toReturn = propertyNameElements.size() == 1 && (factModelTree.getSimpleProperties().containsKey(propertyNameElements.get(0)) || factModelTree.getExpandableProperties().containsKey(propertyNameElements.get(0))); if (!toReturn && propertyNameElements.size() > 1) { String propertyParent = propertyNameElements.get(0); if (factModelTree.getExpandableProperties().containsKey(propertyParent)) { List<String> nestedPropertyNameElements = propertyNameElements.subList(1, propertyNameElements.size()); String className = factModelTree.getExpandableProperties().get(propertyParent); final FactModelTree nestedFactModelTree = context.getDataObjectFieldsMap().get(className); toReturn = recursivelyFindIsPropertyType(context, nestedFactModelTree, nestedPropertyNameElements); } } return toReturn; } SetHeaderCellValueCommand(GridWidget gridWidget, boolean isInstanceHeader, boolean isPropertyHeader); private  SetHeaderCellValueCommand();   }