@Test public void testSemanticParser() throws SelectorParseException { final ClassType student = provider.getClassType("Student"); final SemanticSelector selector; final ClassType section = provider.getClassType("Section"); final ClassType studentSectionAssociation = provider.getClassType("StudentSectionAssociation"); final Attribute name = provider.getAttributeType(student, "name"); final Attribute economicDisadvantaged = provider.getAttributeType(student, "economicDisadvantaged"); final ClassType studentSchoolAssociation = provider.getClassType("StudentSchoolAssociation"); final Attribute entryDate = provider.getAttributeType(studentSchoolAssociation, "entryDate"); selector = defaultSelectorSemanticModel.parse(generateSelectorObjectMap(), student); assertTrue("Should contain base type", selector.containsKey(student)); assertNotNull("Should have a list of attributes", selector.get(student)); assertEquals("Base type should have 1 selector", 1, selector.size()); final List<SelectorElement> studentList = selector.get(student); assertEquals(5, studentList.size()); assertTrue(!studentList.contains(null)); final Map<ModelElement, Object> selectorMap = mapify(studentList); assertTrue(selectorMap.containsKey(section)); assertTrue(selectorMap.containsKey(studentSectionAssociation)); assertTrue(selectorMap.containsKey(name)); assertTrue(selectorMap.containsKey(economicDisadvantaged)); assertTrue(selectorMap.containsKey(studentSchoolAssociation)); @SuppressWarnings("unchecked") final SemanticSelector sectionSelector = (SemanticSelector) selectorMap.get(section); final List<SelectorElement> sectionSelectorElements = (List<SelectorElement>) sectionSelector.get(section); assertEquals(1, sectionSelectorElements.size()); assertTrue(sectionSelectorElements.get(0) instanceof IncludeAllSelectorElement); assertEquals(true, selectorMap.get(studentSectionAssociation)); assertTrue(selectorMap.get(name) instanceof SemanticSelector); assertTrue(selectorMap.get(studentSchoolAssociation) instanceof SemanticSelector); final SemanticSelector studentSchoolSelector = (SemanticSelector) selectorMap.get(studentSchoolAssociation); final Map<ModelElement, Object> studentSchoolSelectorMap = mapify(studentSchoolSelector.get(studentSchoolAssociation)); assertEquals(true, studentSchoolSelectorMap.get(entryDate)); }
public SemanticSelector parse(final Map<String, Object> selectors, final ClassType type) throws SelectorParseException { if (type == null) { throw new IllegalArgumentException("type"); } if (selectors == null) { throw new IllegalArgumentException("selectors"); } final SemanticSelector selector = new SemanticSelector(); if (selectors.isEmpty()) { selector.addSelector(type, new EmptySelectorElement(type)); } for (final Map.Entry<String, Object> entry : selectors.entrySet()) { final String key = entry.getKey(); final Object value = entry.getValue(); addEntryToSelector(type, selector, key, value); } return selector; }
DefaultSelectorSemanticModel implements SelectorSemanticModel { public SemanticSelector parse(final Map<String, Object> selectors, final ClassType type) throws SelectorParseException { if (type == null) { throw new IllegalArgumentException("type"); } if (selectors == null) { throw new IllegalArgumentException("selectors"); } final SemanticSelector selector = new SemanticSelector(); if (selectors.isEmpty()) { selector.addSelector(type, new EmptySelectorElement(type)); } for (final Map.Entry<String, Object> entry : selectors.entrySet()) { final String key = entry.getKey(); final Object value = entry.getValue(); addEntryToSelector(type, selector, key, value); } return selector; } }
DefaultSelectorSemanticModel implements SelectorSemanticModel { public SemanticSelector parse(final Map<String, Object> selectors, final ClassType type) throws SelectorParseException { if (type == null) { throw new IllegalArgumentException("type"); } if (selectors == null) { throw new IllegalArgumentException("selectors"); } final SemanticSelector selector = new SemanticSelector(); if (selectors.isEmpty()) { selector.addSelector(type, new EmptySelectorElement(type)); } for (final Map.Entry<String, Object> entry : selectors.entrySet()) { final String key = entry.getKey(); final Object value = entry.getValue(); addEntryToSelector(type, selector, key, value); } return selector; }  }
DefaultSelectorSemanticModel implements SelectorSemanticModel { public SemanticSelector parse(final Map<String, Object> selectors, final ClassType type) throws SelectorParseException { if (type == null) { throw new IllegalArgumentException("type"); } if (selectors == null) { throw new IllegalArgumentException("selectors"); } final SemanticSelector selector = new SemanticSelector(); if (selectors.isEmpty()) { selector.addSelector(type, new EmptySelectorElement(type)); } for (final Map.Entry<String, Object> entry : selectors.entrySet()) { final String key = entry.getKey(); final Object value = entry.getValue(); addEntryToSelector(type, selector, key, value); } return selector; }  SemanticSelector parse(final Map<String, Object> selectors, final ClassType type); }
DefaultSelectorSemanticModel implements SelectorSemanticModel { public SemanticSelector parse(final Map<String, Object> selectors, final ClassType type) throws SelectorParseException { if (type == null) { throw new IllegalArgumentException("type"); } if (selectors == null) { throw new IllegalArgumentException("selectors"); } final SemanticSelector selector = new SemanticSelector(); if (selectors.isEmpty()) { selector.addSelector(type, new EmptySelectorElement(type)); } for (final Map.Entry<String, Object> entry : selectors.entrySet()) { final String key = entry.getKey(); final Object value = entry.getValue(); addEntryToSelector(type, selector, key, value); } return selector; }  SemanticSelector parse(final Map<String, Object> selectors, final ClassType type);  }