target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test(expected = SelectorParseException.class) public void testInvalidSelectors() throws SelectorParseException { final ClassType student = provider.getClassType("Student"); final SemanticSelector selector = defaultSelectorSemanticModel.parse(generateFaultySelectorObjectMap(), student); }
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); }
@Test public void testDefaultXSD() { final Map<String, Object> studentAttrs = new HashMap<String, Object>(); studentAttrs.put("$", true); final ClassType student = provider.getClassType("Student"); final SemanticSelector semanticSelector = defaultSelectorSemanticModel.parse(studentAttrs, student); final List<SelectorElement> elementList = semanticSelector.get(student); assertEquals(1, elementList.size()); assertTrue(elementList.get(0) instanceof IncludeXSDSelectorElement); }
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); }
@Test public void testDefault() { final Map<String, Object> studentAttrs = new HashMap<String, Object>(); studentAttrs.put(".", true); final ClassType student = provider.getClassType("Student"); final SemanticSelector semanticSelector = defaultSelectorSemanticModel.parse(studentAttrs, student); final List<SelectorElement> elementList = semanticSelector.get(student); assertEquals(1, elementList.size()); assertTrue(elementList.get(0) instanceof IncludeDefaultSelectorElement); final Map<String, Object> embedded = new HashMap<String, Object>(); final Map<String, Object> sectionAttrs = new HashMap<String, Object>(); sectionAttrs.put(".", true); embedded.put("sections", sectionAttrs); final SemanticSelector embeddedSelector = defaultSelectorSemanticModel.parse(embedded, student); assertEquals(1, embeddedSelector.get(student).size()); final SelectorElement embeddedElement = embeddedSelector.get(student).get(0); assertTrue(embeddedElement instanceof ComplexSelectorElement); assertEquals(1, ((ComplexSelectorElement) embeddedElement).getSelector().size()); }
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); }
@Test public void testEmptySelectors() { final Map<String, Object> studentAttrs = new HashMap<String, Object>(); final ClassType student = provider.getClassType("Student"); final SemanticSelector semanticSelector = defaultSelectorSemanticModel.parse(studentAttrs, student); assertEquals(1, semanticSelector.get(student).size()); assertTrue(semanticSelector.get(student).get(0) instanceof EmptySelectorElement); final Map<String, Object> embeddedEmpty = new HashMap<String, Object>(); embeddedEmpty.put("sections", new HashMap<String, Object>()); final SemanticSelector emptySelector = defaultSelectorSemanticModel.parse(embeddedEmpty, student); assertEquals(1, semanticSelector.get(student).size()); final ClassType section = provider.getClassType("Section"); assertEquals(section, emptySelector.get(student).get(0).getLHS()); }
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); }
@Test public void testAddSelector() { final Type testType = mock(Type.class); final SelectorElement se = mock(SelectorElement.class); selector.addSelector(testType, se); assertNotNull(selector.get(testType)); assertEquals(1, selector.get(testType).size()); selector.addSelector(testType, mock(BooleanSelectorElement.class)); assertEquals(2, selector.get(testType).size()); }
public void addSelector(final Type type, final SelectorElement se) { if (this.containsKey(type)) { this.get(type).add(se); } else { this.put(type, new ArrayList<SelectorElement>(Arrays.asList(se))); } }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { public void addSelector(final Type type, final SelectorElement se) { if (this.containsKey(type)) { this.get(type).add(se); } else { this.put(type, new ArrayList<SelectorElement>(Arrays.asList(se))); } } }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { public void addSelector(final Type type, final SelectorElement se) { if (this.containsKey(type)) { this.get(type).add(se); } else { this.put(type, new ArrayList<SelectorElement>(Arrays.asList(se))); } } }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { public void addSelector(final Type type, final SelectorElement se) { if (this.containsKey(type)) { this.get(type).add(se); } else { this.put(type, new ArrayList<SelectorElement>(Arrays.asList(se))); } } void addSelector(final Type type, final SelectorElement se); @Override SelectorQueryPlan accept(SelectorQueryVisitor selectorQueryVisitor); @Override String toString(); }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { public void addSelector(final Type type, final SelectorElement se) { if (this.containsKey(type)) { this.get(type).add(se); } else { this.put(type, new ArrayList<SelectorElement>(Arrays.asList(se))); } } void addSelector(final Type type, final SelectorElement se); @Override SelectorQueryPlan accept(SelectorQueryVisitor selectorQueryVisitor); @Override String toString(); }
@Test public void testToString() { assertTrue(selector.toString().isEmpty()); }
@Override public String toString() { final StringBuilder builder = new StringBuilder(); for (final Map.Entry<Type, List<SelectorElement>> item : this.entrySet()) { final List<SelectorElement> elements = item.getValue(); builder.append("["); builder.append(StringUtils.join(elements, ',')); builder.append("]"); } return builder.toString(); }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { @Override public String toString() { final StringBuilder builder = new StringBuilder(); for (final Map.Entry<Type, List<SelectorElement>> item : this.entrySet()) { final List<SelectorElement> elements = item.getValue(); builder.append("["); builder.append(StringUtils.join(elements, ',')); builder.append("]"); } return builder.toString(); } }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { @Override public String toString() { final StringBuilder builder = new StringBuilder(); for (final Map.Entry<Type, List<SelectorElement>> item : this.entrySet()) { final List<SelectorElement> elements = item.getValue(); builder.append("["); builder.append(StringUtils.join(elements, ',')); builder.append("]"); } return builder.toString(); } }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { @Override public String toString() { final StringBuilder builder = new StringBuilder(); for (final Map.Entry<Type, List<SelectorElement>> item : this.entrySet()) { final List<SelectorElement> elements = item.getValue(); builder.append("["); builder.append(StringUtils.join(elements, ',')); builder.append("]"); } return builder.toString(); } void addSelector(final Type type, final SelectorElement se); @Override SelectorQueryPlan accept(SelectorQueryVisitor selectorQueryVisitor); @Override String toString(); }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { @Override public String toString() { final StringBuilder builder = new StringBuilder(); for (final Map.Entry<Type, List<SelectorElement>> item : this.entrySet()) { final List<SelectorElement> elements = item.getValue(); builder.append("["); builder.append(StringUtils.join(elements, ',')); builder.append("]"); } return builder.toString(); } void addSelector(final Type type, final SelectorElement se); @Override SelectorQueryPlan accept(SelectorQueryVisitor selectorQueryVisitor); @Override String toString(); }
@Test public void testVisitor() { final SelectorQueryVisitor visitor = mock(SelectorQueryVisitor.class); selector.accept(visitor); verify(visitor).visit(selector); }
@Override public SelectorQueryPlan accept(SelectorQueryVisitor selectorQueryVisitor) { return selectorQueryVisitor.visit(this); }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { @Override public SelectorQueryPlan accept(SelectorQueryVisitor selectorQueryVisitor) { return selectorQueryVisitor.visit(this); } }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { @Override public SelectorQueryPlan accept(SelectorQueryVisitor selectorQueryVisitor) { return selectorQueryVisitor.visit(this); } }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { @Override public SelectorQueryPlan accept(SelectorQueryVisitor selectorQueryVisitor) { return selectorQueryVisitor.visit(this); } void addSelector(final Type type, final SelectorElement se); @Override SelectorQueryPlan accept(SelectorQueryVisitor selectorQueryVisitor); @Override String toString(); }
SemanticSelector extends HashMap<Type, List<SelectorElement>> implements SelectorQueryVisitable { @Override public SelectorQueryPlan accept(SelectorQueryVisitor selectorQueryVisitor) { return selectorQueryVisitor.visit(this); } void addSelector(final Type type, final SelectorElement se); @Override SelectorQueryPlan accept(SelectorQueryVisitor selectorQueryVisitor); @Override String toString(); }
@Test public void testSuccessfulLoadOfData() { final ClassType studentType = provider.getClassType("Student"); final ClassType studentSectionAssociationType = provider.getClassType("StudentSectionAssociation"); final ClassType sectionType = provider.getClassType("Section"); SemanticSelector sectionSelector = defaultSelectorRepository.getSelector("Section"); assertNotNull("Should not be null", sectionSelector); List<SelectorElement> elements = sectionSelector.get(sectionType); SelectorElement element = elements.get(0); assertTrue("Should be true", element instanceof BooleanSelectorElement); assertEquals("Should match", "sequenceOfCourse", element.getElementName()); SemanticSelector studentSelector = defaultSelectorRepository.getSelector("Student"); assertNotNull("Should not be null", studentSelector); elements = studentSelector.get(studentType); for (SelectorElement e : elements) { if (e instanceof IncludeXSDSelectorElement) { assertEquals("Should match", studentType, e.getLHS()); } else if (e instanceof BooleanSelectorElement) { assertEquals("Should match", studentSectionAssociationType, e.getLHS()); } else { fail("unknown type"); } } SemanticSelector studentSectionAssociationSelector = defaultSelectorRepository.getSelector("StudentSectionAssociation"); assertNotNull("Should not be null", studentSectionAssociationSelector); elements = studentSectionAssociationSelector.get(studentSectionAssociationType); element = elements.get(0); assertTrue("Should be true", element instanceof IncludeXSDSelectorElement); }
@Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } @Override SemanticSelector getSelector(String type); }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } @Override SemanticSelector getSelector(String type); static final String DEFAULT_SELECTOR_TYPE_KEY; static final String DEFAULT_SELECTOR_VALUE_KEY; static final String DEFAULT_SELECTOR_RESOURCE_FILENAME; static final Map<String, Object> FALLBACK_SELECTOR; }
@Test public void testCourseTranscriptMapping() { NeutralRecord transcript = createCourseTranscriptNeutralRecord(false); ReportStats reportStats = new SimpleReportStats(); List<? extends Entity> result = transformer.transform(transcript, new DummyMessageReport(), reportStats); Assert.assertNotNull(result); Assert.assertEquals(1, result.size()); Assert.assertFalse( transcript.getAttributes().containsKey( "GradeType")); Assert.assertEquals("courseAttemptResult", result.get(0).getBody().get("courseAttemptResult")); Assert.assertEquals("C", result.get(0).getBody().get("finalLetterGradeEarned")); Assert.assertEquals("Final", result.get(0).getBody().get("gradeType")); Assert.assertEquals("courseTranscript", result.get(0).getType()); NeutralRecord transcript1 = createCourseTranscriptNeutralRecord( true ); ReportStats reportStats1 = new SimpleReportStats(); result = transformer.transform(transcript1, new DummyMessageReport(), reportStats1); Assert.assertNotNull(result); Assert.assertEquals(1, result.size()); Assert.assertTrue( transcript1.getAttributes().containsKey( "GradeType")); Assert.assertEquals("courseAttemptResult", result.get(0).getBody().get("courseAttemptResult")); Assert.assertEquals("C", result.get(0).getBody().get("finalLetterGradeEarned")); Assert.assertEquals("GradeType", result.get(0).getBody().get("gradeType")); Assert.assertEquals("courseTranscript", result.get(0).getType()); }
@Override public List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats) { JavaResult result = new JavaResult(); Smooks smooks = smooksConfigs.get(item.getRecordType()); if (smooks == null) { String type = item.getRecordType().replaceAll("_transformed", ""); Map<String, Object> body = item.getAttributes(); SimpleEntity entity = new SimpleEntity(); entity.setType(type); entity.setBody(body); entity.setStagedEntityId(item.getRecordId()); entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } String externalId = (String) item.getLocalId(); if (externalId != null) { entity.getMetaData().put("externalId", externalId); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); return Arrays.asList(entity); } List<SimpleEntity> sliEntities; try { StringSource source = new StringSource(MAPPER.writeValueAsString(item)); smooks.filterSource(source, result); sliEntities = getEntityListResult(result); for (SimpleEntity entity : sliEntities) { entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); } } catch (java.io.IOException e) { sliEntities = Collections.emptyList(); } return sliEntities; }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats) { JavaResult result = new JavaResult(); Smooks smooks = smooksConfigs.get(item.getRecordType()); if (smooks == null) { String type = item.getRecordType().replaceAll("_transformed", ""); Map<String, Object> body = item.getAttributes(); SimpleEntity entity = new SimpleEntity(); entity.setType(type); entity.setBody(body); entity.setStagedEntityId(item.getRecordId()); entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } String externalId = (String) item.getLocalId(); if (externalId != null) { entity.getMetaData().put("externalId", externalId); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); return Arrays.asList(entity); } List<SimpleEntity> sliEntities; try { StringSource source = new StringSource(MAPPER.writeValueAsString(item)); smooks.filterSource(source, result); sliEntities = getEntityListResult(result); for (SimpleEntity entity : sliEntities) { entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); } } catch (java.io.IOException e) { sliEntities = Collections.emptyList(); } return sliEntities; } }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats) { JavaResult result = new JavaResult(); Smooks smooks = smooksConfigs.get(item.getRecordType()); if (smooks == null) { String type = item.getRecordType().replaceAll("_transformed", ""); Map<String, Object> body = item.getAttributes(); SimpleEntity entity = new SimpleEntity(); entity.setType(type); entity.setBody(body); entity.setStagedEntityId(item.getRecordId()); entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } String externalId = (String) item.getLocalId(); if (externalId != null) { entity.getMetaData().put("externalId", externalId); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); return Arrays.asList(entity); } List<SimpleEntity> sliEntities; try { StringSource source = new StringSource(MAPPER.writeValueAsString(item)); smooks.filterSource(source, result); sliEntities = getEntityListResult(result); for (SimpleEntity entity : sliEntities) { entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); } } catch (java.io.IOException e) { sliEntities = Collections.emptyList(); } return sliEntities; } }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats) { JavaResult result = new JavaResult(); Smooks smooks = smooksConfigs.get(item.getRecordType()); if (smooks == null) { String type = item.getRecordType().replaceAll("_transformed", ""); Map<String, Object> body = item.getAttributes(); SimpleEntity entity = new SimpleEntity(); entity.setType(type); entity.setBody(body); entity.setStagedEntityId(item.getRecordId()); entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } String externalId = (String) item.getLocalId(); if (externalId != null) { entity.getMetaData().put("externalId", externalId); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); return Arrays.asList(entity); } List<SimpleEntity> sliEntities; try { StringSource source = new StringSource(MAPPER.writeValueAsString(item)); smooks.filterSource(source, result); sliEntities = getEntityListResult(result); for (SimpleEntity entity : sliEntities) { entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); } } catch (java.io.IOException e) { sliEntities = Collections.emptyList(); } return sliEntities; } @Override List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats); Map<String, Smooks> getSmooksConfigs(); void setSmooksConfigs(Map<String, Smooks> smooksConfigs); @Override List<List<SimpleEntity>> handle(List<NeutralRecord> items, AbstractMessageReport report, ReportStats reportStats); @Override String getStageName(); }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats) { JavaResult result = new JavaResult(); Smooks smooks = smooksConfigs.get(item.getRecordType()); if (smooks == null) { String type = item.getRecordType().replaceAll("_transformed", ""); Map<String, Object> body = item.getAttributes(); SimpleEntity entity = new SimpleEntity(); entity.setType(type); entity.setBody(body); entity.setStagedEntityId(item.getRecordId()); entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } String externalId = (String) item.getLocalId(); if (externalId != null) { entity.getMetaData().put("externalId", externalId); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); return Arrays.asList(entity); } List<SimpleEntity> sliEntities; try { StringSource source = new StringSource(MAPPER.writeValueAsString(item)); smooks.filterSource(source, result); sliEntities = getEntityListResult(result); for (SimpleEntity entity : sliEntities) { entity.setSourceFile(item.getSourceFile()); entity.setVisitBeforeLineNumber(item.getVisitBeforeLineNumber()); entity.setVisitBeforeColumnNumber(item.getVisitBeforeColumnNumber()); entity.setVisitAfterLineNumber(item.getVisitAfterLineNumber()); entity.setVisitAfterColumnNumber(item.getVisitAfterColumnNumber()); if (entity.getMetaData() == null) { entity.setMetaData(new HashMap<String, Object>()); } entity.setAction( item.getActionVerb()); entity.setActionAttributes(item.getActionAttributes()); } } catch (java.io.IOException e) { sliEntities = Collections.emptyList(); } return sliEntities; } @Override List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats); Map<String, Smooks> getSmooksConfigs(); void setSmooksConfigs(Map<String, Smooks> smooksConfigs); @Override List<List<SimpleEntity>> handle(List<NeutralRecord> items, AbstractMessageReport report, ReportStats reportStats); @Override String getStageName(); }
@Test public void assertGracefulHandlingOfInvalidTypeDefaultSelector() { assertNull("Should be null", defaultSelectorRepository.getSelector("type1")); }
@Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } @Override SemanticSelector getSelector(String type); }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } @Override SemanticSelector getSelector(String type); static final String DEFAULT_SELECTOR_TYPE_KEY; static final String DEFAULT_SELECTOR_VALUE_KEY; static final String DEFAULT_SELECTOR_RESOURCE_FILENAME; static final Map<String, Object> FALLBACK_SELECTOR; }
@Test public void assertGracefulHandlingOfMissingDefaultSelector() { final ClassType schoolType = provider.getClassType("School"); SemanticSelector schoolSelector = defaultSelectorRepository.getSelector("School"); assertNotNull("Should not be null", schoolSelector); List<SelectorElement> elements = schoolSelector.get(schoolType); assertEquals("Should match", 1, elements.size()); SelectorElement element = elements.get(0); assertTrue("Should be true", element instanceof IncludeXSDSelectorElement); }
@Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } @Override SemanticSelector getSelector(String type); }
DefaultSelectorStore implements SelectorRepository { @Override public SemanticSelector getSelector(String type) { return defaultSelectors.containsKey(type) ? defaultSelectors.get(type) : getFallBackSelector(type); } @Override SemanticSelector getSelector(String type); static final String DEFAULT_SELECTOR_TYPE_KEY; static final String DEFAULT_SELECTOR_VALUE_KEY; static final String DEFAULT_SELECTOR_RESOURCE_FILENAME; static final Map<String, Object> FALLBACK_SELECTOR; }
@Test public void testCreateEntities() { final EntityDefinition mockEntityDefinition = mock(EntityDefinition.class); when(mockEntityDefinition.getType()).thenReturn("TEST"); when(resourceHelper.getEntityDefinition(anyString())).thenReturn(mockEntityDefinition); @SuppressWarnings("unchecked") final SelectorQuery mockPlan = mock(SelectorQuery.class); when(selectorQueryEngine.assembleQueryPlan(any(SemanticSelector.class))).thenReturn(mockPlan); final ApiQuery apiQuery = mock(ApiQuery.class); when(apiQuery.getSelector()).thenReturn(new HashMap<String, Object>()); @SuppressWarnings("unchecked") final List<EntityBody> mockEntityList = mock(List.class); when(selectorDocument.aggregate(mockPlan, apiQuery)).thenReturn(mockEntityList); final List<EntityBody> entityList = logicalEntity.getEntities(apiQuery, "TEST"); assertEquals(mockEntityList, entityList); }
@Override public List<EntityBody> getEntities(final ApiQuery apiQuery, final String resourceName) { if (apiQuery == null) { throw new IllegalArgumentException("apiQuery"); } if (apiQuery.getSelector() == null) { throw new UnsupportedSelectorException("No selector to parse"); } final EntityDefinition typeDef = resourceHelper.getEntityDefinition(resourceName); final ClassType entityType = provider.getClassType(StringUtils.capitalize(typeDef.getType())); if (UNSUPPORTED_RESOURCE_LIST.contains(resourceName)) { throw new UnsupportedSelectorException("Selector is not supported yet for this resource"); } final SemanticSelector semanticSelector = selectorSemanticModel.parse(apiQuery.getSelector(), entityType); final SelectorQuery selectorQuery = selectorQueryEngine.assembleQueryPlan(semanticSelector); return selectorDocument.aggregate(selectorQuery, apiQuery); }
DefaultLogicalEntity implements LogicalEntity { @Override public List<EntityBody> getEntities(final ApiQuery apiQuery, final String resourceName) { if (apiQuery == null) { throw new IllegalArgumentException("apiQuery"); } if (apiQuery.getSelector() == null) { throw new UnsupportedSelectorException("No selector to parse"); } final EntityDefinition typeDef = resourceHelper.getEntityDefinition(resourceName); final ClassType entityType = provider.getClassType(StringUtils.capitalize(typeDef.getType())); if (UNSUPPORTED_RESOURCE_LIST.contains(resourceName)) { throw new UnsupportedSelectorException("Selector is not supported yet for this resource"); } final SemanticSelector semanticSelector = selectorSemanticModel.parse(apiQuery.getSelector(), entityType); final SelectorQuery selectorQuery = selectorQueryEngine.assembleQueryPlan(semanticSelector); return selectorDocument.aggregate(selectorQuery, apiQuery); } }
DefaultLogicalEntity implements LogicalEntity { @Override public List<EntityBody> getEntities(final ApiQuery apiQuery, final String resourceName) { if (apiQuery == null) { throw new IllegalArgumentException("apiQuery"); } if (apiQuery.getSelector() == null) { throw new UnsupportedSelectorException("No selector to parse"); } final EntityDefinition typeDef = resourceHelper.getEntityDefinition(resourceName); final ClassType entityType = provider.getClassType(StringUtils.capitalize(typeDef.getType())); if (UNSUPPORTED_RESOURCE_LIST.contains(resourceName)) { throw new UnsupportedSelectorException("Selector is not supported yet for this resource"); } final SemanticSelector semanticSelector = selectorSemanticModel.parse(apiQuery.getSelector(), entityType); final SelectorQuery selectorQuery = selectorQueryEngine.assembleQueryPlan(semanticSelector); return selectorDocument.aggregate(selectorQuery, apiQuery); } }
DefaultLogicalEntity implements LogicalEntity { @Override public List<EntityBody> getEntities(final ApiQuery apiQuery, final String resourceName) { if (apiQuery == null) { throw new IllegalArgumentException("apiQuery"); } if (apiQuery.getSelector() == null) { throw new UnsupportedSelectorException("No selector to parse"); } final EntityDefinition typeDef = resourceHelper.getEntityDefinition(resourceName); final ClassType entityType = provider.getClassType(StringUtils.capitalize(typeDef.getType())); if (UNSUPPORTED_RESOURCE_LIST.contains(resourceName)) { throw new UnsupportedSelectorException("Selector is not supported yet for this resource"); } final SemanticSelector semanticSelector = selectorSemanticModel.parse(apiQuery.getSelector(), entityType); final SelectorQuery selectorQuery = selectorQueryEngine.assembleQueryPlan(semanticSelector); return selectorDocument.aggregate(selectorQuery, apiQuery); } @Override List<EntityBody> getEntities(final ApiQuery apiQuery, final String resourceName); }
DefaultLogicalEntity implements LogicalEntity { @Override public List<EntityBody> getEntities(final ApiQuery apiQuery, final String resourceName) { if (apiQuery == null) { throw new IllegalArgumentException("apiQuery"); } if (apiQuery.getSelector() == null) { throw new UnsupportedSelectorException("No selector to parse"); } final EntityDefinition typeDef = resourceHelper.getEntityDefinition(resourceName); final ClassType entityType = provider.getClassType(StringUtils.capitalize(typeDef.getType())); if (UNSUPPORTED_RESOURCE_LIST.contains(resourceName)) { throw new UnsupportedSelectorException("Selector is not supported yet for this resource"); } final SemanticSelector semanticSelector = selectorSemanticModel.parse(apiQuery.getSelector(), entityType); final SelectorQuery selectorQuery = selectorQueryEngine.assembleQueryPlan(semanticSelector); return selectorDocument.aggregate(selectorQuery, apiQuery); } @Override List<EntityBody> getEntities(final ApiQuery apiQuery, final String resourceName); }
@Test public void testTranslate() throws Exception { List<Entity> learningObjectiveList = new ArrayList<Entity>(); Entity loEntity = mock(Entity.class); Map<String, Object> body = new HashMap<String, Object>(); body.put("parentLearningObjective", "456"); when(loEntity.getEntityId()).thenReturn("123"); when(loEntity.getBody()).thenReturn(body); learningObjectiveList.add(loEntity); when(repository.findAll(anyString(), any(NeutralQuery.class))).thenReturn(learningObjectiveList); String newPath = translator.getTranslator("parentLearningObjective").translate("v1/learningObjectives/123/parentLearningObjectives"); assertTrue("Should match new uri", "learningObjectives/456".equals(newPath)); }
public void translate(ContainerRequest request) { String uri = request.getPath(); List<PathSegment> segments = request.getPathSegments(); String version = PathConstants.V1; if (!segments.isEmpty()) { version = segments.get(0).getPath(); } for (Map.Entry<String, URITranslation> entry : uriTranslationMap.entrySet()) { String key = entry.getKey(); if (uri.contains(key)) { String newPath = uriTranslationMap.get(key).translate(request.getPath()); if (!newPath.equals(uri)) { request.setUris(request.getBaseUri(), request.getBaseUriBuilder().path(version).path(newPath).build()); } } } }
URITranslator { public void translate(ContainerRequest request) { String uri = request.getPath(); List<PathSegment> segments = request.getPathSegments(); String version = PathConstants.V1; if (!segments.isEmpty()) { version = segments.get(0).getPath(); } for (Map.Entry<String, URITranslation> entry : uriTranslationMap.entrySet()) { String key = entry.getKey(); if (uri.contains(key)) { String newPath = uriTranslationMap.get(key).translate(request.getPath()); if (!newPath.equals(uri)) { request.setUris(request.getBaseUri(), request.getBaseUriBuilder().path(version).path(newPath).build()); } } } } }
URITranslator { public void translate(ContainerRequest request) { String uri = request.getPath(); List<PathSegment> segments = request.getPathSegments(); String version = PathConstants.V1; if (!segments.isEmpty()) { version = segments.get(0).getPath(); } for (Map.Entry<String, URITranslation> entry : uriTranslationMap.entrySet()) { String key = entry.getKey(); if (uri.contains(key)) { String newPath = uriTranslationMap.get(key).translate(request.getPath()); if (!newPath.equals(uri)) { request.setUris(request.getBaseUri(), request.getBaseUriBuilder().path(version).path(newPath).build()); } } } } URITranslator(); }
URITranslator { public void translate(ContainerRequest request) { String uri = request.getPath(); List<PathSegment> segments = request.getPathSegments(); String version = PathConstants.V1; if (!segments.isEmpty()) { version = segments.get(0).getPath(); } for (Map.Entry<String, URITranslation> entry : uriTranslationMap.entrySet()) { String key = entry.getKey(); if (uri.contains(key)) { String newPath = uriTranslationMap.get(key).translate(request.getPath()); if (!newPath.equals(uri)) { request.setUris(request.getBaseUri(), request.getBaseUriBuilder().path(version).path(newPath).build()); } } } } URITranslator(); void setRepository(PagingRepositoryDelegate<Entity> repository); void translate(ContainerRequest request); URITranslation getTranslator(String uri); }
URITranslator { public void translate(ContainerRequest request) { String uri = request.getPath(); List<PathSegment> segments = request.getPathSegments(); String version = PathConstants.V1; if (!segments.isEmpty()) { version = segments.get(0).getPath(); } for (Map.Entry<String, URITranslation> entry : uriTranslationMap.entrySet()) { String key = entry.getKey(); if (uri.contains(key)) { String newPath = uriTranslationMap.get(key).translate(request.getPath()); if (!newPath.equals(uri)) { request.setUris(request.getBaseUri(), request.getBaseUriBuilder().path(version).path(newPath).build()); } } } } URITranslator(); void setRepository(PagingRepositoryDelegate<Entity> repository); void translate(ContainerRequest request); URITranslation getTranslator(String uri); }
@Test public void testGetId() { EntityBody entityBody = new EntityBody(createTestMap()); List<String> list1 = entityBody.getValues("key1"); assertNotNull("List should not be null", list1); assertEquals("List should have 1 value", list1.size(), 1); assertEquals("List value should be original id", list1.get(0), "stringValue1"); List<String> list2 = entityBody.getValues("key2"); assertNotNull("List should not be null", list2); assertEquals("List should have 1 value", list2.size(), 1); assertEquals("List value should be original id", list2.get(0), "stringValue2"); List<String> list3 = entityBody.getValues("key3"); assertNotNull("List should not be null", list3); assertEquals("List should have 2 values", list3.size(), 2); assertEquals("List value 1 should be original id", list3.get(0), "stringInList1"); assertEquals("List value 2 should be original id", list3.get(1), "stringInList2"); List<String> list4 = entityBody.getValues("key4"); assertNotNull("List should not be null", list4); assertEquals("List should have 0 values", list4.size(), 0); }
public List<String> getValues(String key) { List<String> valueList = new ArrayList<String>(); Object value = this.get(key); if (value instanceof String) { valueList.add((String) value); } else if (value instanceof List<?>) { for (Object subValues : (List<?>) value) { valueList.add(subValues.toString()); } } return valueList; }
EntityBody extends HashMap<String, Object> { public List<String> getValues(String key) { List<String> valueList = new ArrayList<String>(); Object value = this.get(key); if (value instanceof String) { valueList.add((String) value); } else if (value instanceof List<?>) { for (Object subValues : (List<?>) value) { valueList.add(subValues.toString()); } } return valueList; } }
EntityBody extends HashMap<String, Object> { public List<String> getValues(String key) { List<String> valueList = new ArrayList<String>(); Object value = this.get(key); if (value instanceof String) { valueList.add((String) value); } else if (value instanceof List<?>) { for (Object subValues : (List<?>) value) { valueList.add(subValues.toString()); } } return valueList; } EntityBody(); EntityBody(Map<? extends String, ? extends Object> m); }
EntityBody extends HashMap<String, Object> { public List<String> getValues(String key) { List<String> valueList = new ArrayList<String>(); Object value = this.get(key); if (value instanceof String) { valueList.add((String) value); } else if (value instanceof List<?>) { for (Object subValues : (List<?>) value) { valueList.add(subValues.toString()); } } return valueList; } EntityBody(); EntityBody(Map<? extends String, ? extends Object> m); List<String> getValues(String key); }
EntityBody extends HashMap<String, Object> { public List<String> getValues(String key) { List<String> valueList = new ArrayList<String>(); Object value = this.get(key); if (value instanceof String) { valueList.add((String) value); } else if (value instanceof List<?>) { for (Object subValues : (List<?>) value) { valueList.add(subValues.toString()); } } return valueList; } EntityBody(); EntityBody(Map<? extends String, ? extends Object> m); List<String> getValues(String key); }
@Test public void testEntityResponse() { Map<String, String> map = new HashMap<String, String>(); map.put("testkey", "testvalue"); EntityResponse response = new EntityResponse("testcollection", map); assertNotNull("Should not be null", response.getEntity()); Map<String, String> testMap = (Map<String, String>) response.getEntity(); assertEquals("Should match", "testvalue", testMap.get("testkey")); }
public EntityResponse(String entityCollectionName, Object object) { super(); setEntityCollectionName(entityCollectionName); put(this.entityCollectionName, object); }
EntityResponse extends HashMap<String, Object> { public EntityResponse(String entityCollectionName, Object object) { super(); setEntityCollectionName(entityCollectionName); put(this.entityCollectionName, object); } }
EntityResponse extends HashMap<String, Object> { public EntityResponse(String entityCollectionName, Object object) { super(); setEntityCollectionName(entityCollectionName); put(this.entityCollectionName, object); } EntityResponse(String entityCollectionName, Object object); }
EntityResponse extends HashMap<String, Object> { public EntityResponse(String entityCollectionName, Object object) { super(); setEntityCollectionName(entityCollectionName); put(this.entityCollectionName, object); } EntityResponse(String entityCollectionName, Object object); Object getEntity(); final void setEntityCollectionName(String entityCollectionName); String getEntityCollectionName(); }
EntityResponse extends HashMap<String, Object> { public EntityResponse(String entityCollectionName, Object object) { super(); setEntityCollectionName(entityCollectionName); put(this.entityCollectionName, object); } EntityResponse(String entityCollectionName, Object object); Object getEntity(); final void setEntityCollectionName(String entityCollectionName); String getEntityCollectionName(); }
@Test public void testEntityResponseNullCollectionName() { EntityResponse response = new EntityResponse(null, new HashMap<String, String>()); assertNotNull("Should not be null", response.getEntity()); }
public Object getEntity() { return this.get(entityCollectionName); }
EntityResponse extends HashMap<String, Object> { public Object getEntity() { return this.get(entityCollectionName); } }
EntityResponse extends HashMap<String, Object> { public Object getEntity() { return this.get(entityCollectionName); } EntityResponse(String entityCollectionName, Object object); }
EntityResponse extends HashMap<String, Object> { public Object getEntity() { return this.get(entityCollectionName); } EntityResponse(String entityCollectionName, Object object); Object getEntity(); final void setEntityCollectionName(String entityCollectionName); String getEntityCollectionName(); }
EntityResponse extends HashMap<String, Object> { public Object getEntity() { return this.get(entityCollectionName); } EntityResponse(String entityCollectionName, Object object); Object getEntity(); final void setEntityCollectionName(String entityCollectionName); String getEntityCollectionName(); }
@Test public void testConvertTenantIdToDbName() { Assert.assertEquals("7be07aaf460d593a323d0db33da05b64bfdcb3a5", TenantIdToDbName.convertTenantIdToDbName("ABCDE")); Assert.assertEquals("782a35eb5b9cd3e771047a60381e1274d76bc069", TenantIdToDbName.convertTenantIdToDbName("ABC.DE")); Assert.assertEquals("1072a2a56f16654387d030014968a48f04ca7488", TenantIdToDbName.convertTenantIdToDbName(" ABC DE ")); Assert.assertEquals("f89b39e01f5b1bb76655211472cd71274766070e", TenantIdToDbName.convertTenantIdToDbName("$ABCDE")); Assert.assertEquals("8e1cea182e0e0499fe1e0fe28e02d9ffb47ba098", TenantIdToDbName.convertTenantIdToDbName("ABC/DE")); }
public static String convertTenantIdToDbName(String tenantId) { if (tenantId != null) { return TENANT_ID_CACHE.getUnchecked(tenantId); } else { return tenantId; } }
TenantIdToDbName { public static String convertTenantIdToDbName(String tenantId) { if (tenantId != null) { return TENANT_ID_CACHE.getUnchecked(tenantId); } else { return tenantId; } } }
TenantIdToDbName { public static String convertTenantIdToDbName(String tenantId) { if (tenantId != null) { return TENANT_ID_CACHE.getUnchecked(tenantId); } else { return tenantId; } } }
TenantIdToDbName { public static String convertTenantIdToDbName(String tenantId) { if (tenantId != null) { return TENANT_ID_CACHE.getUnchecked(tenantId); } else { return tenantId; } } static String convertTenantIdToDbName(String tenantId); }
TenantIdToDbName { public static String convertTenantIdToDbName(String tenantId) { if (tenantId != null) { return TENANT_ID_CACHE.getUnchecked(tenantId); } else { return tenantId; } } static String convertTenantIdToDbName(String tenantId); }
@Test public void testIsFieldExpired() { Map<String, Object> body = generateEntityBody(); Assert.assertTrue(dateHelper.isFieldExpired(body, "endDate", false)); body.put("exitWithdrawDate", "2070-10-25"); Assert.assertFalse(dateHelper.isFieldExpired(body, "exitWithdrawDate", false)); }
public boolean isFieldExpired(Map<String, Object> body) { for (String key : Arrays.asList("endDate", "exitWithdrawDate")) { if (body.containsKey(key)) { return isFieldExpired(body, key, false); } } return false; }
DateHelper { public boolean isFieldExpired(Map<String, Object> body) { for (String key : Arrays.asList("endDate", "exitWithdrawDate")) { if (body.containsKey(key)) { return isFieldExpired(body, key, false); } } return false; } }
DateHelper { public boolean isFieldExpired(Map<String, Object> body) { for (String key : Arrays.asList("endDate", "exitWithdrawDate")) { if (body.containsKey(key)) { return isFieldExpired(body, key, false); } } return false; } }
DateHelper { public boolean isFieldExpired(Map<String, Object> body) { for (String key : Arrays.asList("endDate", "exitWithdrawDate")) { if (body.containsKey(key)) { return isFieldExpired(body, key, false); } } return false; } String getFilterDate(boolean useGracePeriod); DateTime getNowMinusGracePeriod(); boolean isFieldExpired(Map<String, Object> body); boolean isFieldExpired(Map<String, Object> body, String fieldName); boolean isFieldExpired(Map<String, Object> body, String fieldName, boolean useGracePeriod); DateTime getDate(Map<String, Object> body, String fieldName); boolean isLhsBeforeRhs(DateTime lhs, DateTime rhs); static DateTimeFormatter getDateTimeFormat(); static Criteria getExpiredCriteria(); static Criteria getExpiredCriteria(String endDateField); }
DateHelper { public boolean isFieldExpired(Map<String, Object> body) { for (String key : Arrays.asList("endDate", "exitWithdrawDate")) { if (body.containsKey(key)) { return isFieldExpired(body, key, false); } } return false; } String getFilterDate(boolean useGracePeriod); DateTime getNowMinusGracePeriod(); boolean isFieldExpired(Map<String, Object> body); boolean isFieldExpired(Map<String, Object> body, String fieldName); boolean isFieldExpired(Map<String, Object> body, String fieldName, boolean useGracePeriod); DateTime getDate(Map<String, Object> body, String fieldName); boolean isLhsBeforeRhs(DateTime lhs, DateTime rhs); static DateTimeFormatter getDateTimeFormat(); static Criteria getExpiredCriteria(); static Criteria getExpiredCriteria(String endDateField); }
@Test public void testGetDate() { Map<String, Object> body = generateEntityBody(); DateTime result = dateHelper.getDate(body, "endDate"); Assert.assertEquals(2010, result.getYear()); Assert.assertEquals(07, result.getMonthOfYear()); Assert.assertEquals(10, result.getDayOfMonth()); result = dateHelper.getDate(body, "expirationDate"); Assert.assertNull(result); }
public DateTime getDate(Map<String, Object> body, String fieldName) { DateTime date = null; if (body.get(fieldName) != null) { date = DateTime.parse((String) body.get(fieldName), FMT); } return date; }
DateHelper { public DateTime getDate(Map<String, Object> body, String fieldName) { DateTime date = null; if (body.get(fieldName) != null) { date = DateTime.parse((String) body.get(fieldName), FMT); } return date; } }
DateHelper { public DateTime getDate(Map<String, Object> body, String fieldName) { DateTime date = null; if (body.get(fieldName) != null) { date = DateTime.parse((String) body.get(fieldName), FMT); } return date; } }
DateHelper { public DateTime getDate(Map<String, Object> body, String fieldName) { DateTime date = null; if (body.get(fieldName) != null) { date = DateTime.parse((String) body.get(fieldName), FMT); } return date; } String getFilterDate(boolean useGracePeriod); DateTime getNowMinusGracePeriod(); boolean isFieldExpired(Map<String, Object> body); boolean isFieldExpired(Map<String, Object> body, String fieldName); boolean isFieldExpired(Map<String, Object> body, String fieldName, boolean useGracePeriod); DateTime getDate(Map<String, Object> body, String fieldName); boolean isLhsBeforeRhs(DateTime lhs, DateTime rhs); static DateTimeFormatter getDateTimeFormat(); static Criteria getExpiredCriteria(); static Criteria getExpiredCriteria(String endDateField); }
DateHelper { public DateTime getDate(Map<String, Object> body, String fieldName) { DateTime date = null; if (body.get(fieldName) != null) { date = DateTime.parse((String) body.get(fieldName), FMT); } return date; } String getFilterDate(boolean useGracePeriod); DateTime getNowMinusGracePeriod(); boolean isFieldExpired(Map<String, Object> body); boolean isFieldExpired(Map<String, Object> body, String fieldName); boolean isFieldExpired(Map<String, Object> body, String fieldName, boolean useGracePeriod); DateTime getDate(Map<String, Object> body, String fieldName); boolean isLhsBeforeRhs(DateTime lhs, DateTime rhs); static DateTimeFormatter getDateTimeFormat(); static Criteria getExpiredCriteria(); static Criteria getExpiredCriteria(String endDateField); }
@SuppressWarnings("deprecation") @Test public void testCreateAssessmentEntity() { EntityConfigFactory entityConfigurations = new EntityConfigFactory(); MongoEntityRepository mockedEntityRepository = mock(MongoEntityRepository.class); NeutralRecord assessmentRC = createAssessmentNeutralRecord(true); entityConfigurations.setResourceLoader(new DefaultResourceLoader()); entityConfigurations.setSearchPath("classpath:smooksEdFi2SLI/"); transformer.setEntityRepository(mockedEntityRepository); transformer.setEntityConfigurations(entityConfigurations); DeterministicIdResolver mockDidResolver = Mockito.mock(DeterministicIdResolver.class); transformer.setDIdResolver(mockDidResolver); List<Entity> le = new ArrayList<Entity>(); le.add(createAssessmentEntity(true)); when( mockedEntityRepository.findByQuery(eq("assessment"), Mockito.any(Query.class), eq(0), eq(0))).thenReturn(le); AbstractMessageReport errorReport = new DummyMessageReport(); ReportStats reportStats = new SimpleReportStats(); List<SimpleEntity> res = transformer.handle(assessmentRC, errorReport, reportStats); verify(mockedEntityRepository).findByQuery(eq("assessment"), Mockito.any(Query.class), eq(0), eq(0)); Assert.assertNotNull(res); Assert.assertEquals(ASSESSMENT_TITLE, res.get(0).getBody().get("assessmentTitle")); Assert.assertEquals(TENANT_ID, res.get(0).getMetaData().get(TENANT_ID_FIELD)); Assert.assertEquals(STUDENT_ID, res.get(0).getMetaData().get(EXTERNAL_ID_FIELD)); }
@Override public List<List<SimpleEntity>> handle(List<NeutralRecord> items, AbstractMessageReport report, ReportStats reportStats) { return null; }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<List<SimpleEntity>> handle(List<NeutralRecord> items, AbstractMessageReport report, ReportStats reportStats) { return null; } }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<List<SimpleEntity>> handle(List<NeutralRecord> items, AbstractMessageReport report, ReportStats reportStats) { return null; } }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<List<SimpleEntity>> handle(List<NeutralRecord> items, AbstractMessageReport report, ReportStats reportStats) { return null; } @Override List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats); Map<String, Smooks> getSmooksConfigs(); void setSmooksConfigs(Map<String, Smooks> smooksConfigs); @Override List<List<SimpleEntity>> handle(List<NeutralRecord> items, AbstractMessageReport report, ReportStats reportStats); @Override String getStageName(); }
SmooksEdFi2SLITransformer extends EdFi2SLITransformer { @Override public List<List<SimpleEntity>> handle(List<NeutralRecord> items, AbstractMessageReport report, ReportStats reportStats) { return null; } @Override List<SimpleEntity> transform(NeutralRecord item, AbstractMessageReport report, ReportStats reportStats); Map<String, Smooks> getSmooksConfigs(); void setSmooksConfigs(Map<String, Smooks> smooksConfigs); @Override List<List<SimpleEntity>> handle(List<NeutralRecord> items, AbstractMessageReport report, ReportStats reportStats); @Override String getStageName(); }
@Test public void testStripFields() { Map<String, Object> body = new HashMap<String, Object>(); body.put("f1", "v1"); EntityManipulator.removeFields(body, "f1"); assertTrue(body.get("f1") == null); }
public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList); static void removeFields(final Map<String, Object> toRemoveFrom, final String toRemove); }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList); static void removeFields(final Map<String, Object> toRemoveFrom, final String toRemove); }
@Test public void testWrongExclude() { Map<String, Object> body = new HashMap<String, Object>(); body.put("f1", "v1"); EntityManipulator.removeFields(body, "foobar"); assertTrue(body.get("f1") != null); }
public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList); static void removeFields(final Map<String, Object> toRemoveFrom, final String toRemove); }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList); static void removeFields(final Map<String, Object> toRemoveFrom, final String toRemove); }
@Test public void testMultipleExclude() { Map<String, Object> body = new HashMap<String, Object>(); body.put("f1", "v1"); body.put("f2", "v2"); body.put("f3", "v3"); List<String> toStrip = Arrays.asList("f1", "f2"); EntityManipulator.removeFields(body, toStrip); assertTrue(body.get("f1") == null); assertTrue(body.get("f2") == null); assertTrue(body.get("f3") != null); }
public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList); static void removeFields(final Map<String, Object> toRemoveFrom, final String toRemove); }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList); static void removeFields(final Map<String, Object> toRemoveFrom, final String toRemove); }
@Test public void testStripMap() { Map<String, Object> body = new HashMap<String, Object>(); Map<String, Object> embeddedMap = new HashMap<String, Object>(); embeddedMap.put("ef1", "ev1"); embeddedMap.put("ef2", "ev2"); body.put("f1", embeddedMap); EntityManipulator.removeFields(body, "f1.ef1"); @SuppressWarnings("unchecked") Map<String, Object> f1 = (Map<String, Object>) body.get("f1"); assertTrue(f1 != null); assertEquals("ev2", f1.get("ef2")); assertTrue(f1.get("ef1") == null); }
public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList); static void removeFields(final Map<String, Object> toRemoveFrom, final String toRemove); }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList); static void removeFields(final Map<String, Object> toRemoveFrom, final String toRemove); }
@SuppressWarnings("unchecked") @Test public void testStripList() { Map<String, Object> body = new HashMap<String, Object>(); List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); Map<String, Object> em1 = new HashMap<String, Object>(); em1.put("ek1", "ev1"); em1.put("ek2", "ev2"); Map<String, Object> em2 = new HashMap<String, Object>(); em2.put("ek1", "ev1"); em2.put("ek2", "ev2"); mapList.add(em1); mapList.add(em2); body.put("k1", mapList); EntityManipulator.removeFields(body, "k1.ek1"); assertTrue(body.get("k1") instanceof List); List<Map<String, Object>> mapListRemoved = (List<Map<String, Object>>) body.get("k1"); assertEquals(2, mapListRemoved.size()); assertEquals("ev2", mapListRemoved.get(0).get("ek2")); assertEquals(null, mapListRemoved.get(0).get("ek1")); assertEquals("ev2", mapListRemoved.get(1).get("ek2")); assertEquals(null, mapListRemoved.get(1).get("ek1")); body = new HashMap<String, Object>(); List<String> values = Arrays.asList("ev1", "ev2"); body.put("k1", values); body.put("k2", "v2"); EntityManipulator.removeFields(body, "k1"); assertEquals("v2", body.get("k2")); assertFalse(body.containsKey("k1")); body = new HashMap<String, Object>(); List<Object> el1 = new ArrayList<Object>(); List<Object> el2 = new ArrayList<Object>(); em2 = new HashMap<String, Object>(); em2.put("eek1", "eev1"); em2.put("eek2", "eev2"); el2.add(em2); em1 = new HashMap<String, Object>(); em1.put("ek1", el2); el1.add(em1); body.put("k1", el1); EntityManipulator.removeFields(body, "k1.ek1.eek1"); List<Object> k1List = (List<Object>) body.get("k1"); Map<String, Object> ek1Map = (Map<String, Object>) k1List.get(0); List<Object> ek1List = (List<Object>) ek1Map.get("ek1"); Map<String, Object> removedMap = (Map<String, Object>) ek1List.get(0); assertTrue(removedMap.containsKey("eek2")); assertEquals("eev2", removedMap.get("eek2")); assertEquals(null, removedMap.get("eek1")); }
public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList); static void removeFields(final Map<String, Object> toRemoveFrom, final String toRemove); }
EntityManipulator { public static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList) { if (toRemoveList == null || toRemoveList.isEmpty()) { return; } if (toRemoveFrom == null) { return; } for (final String toStrip : toRemoveList) { removeField(toRemoveFrom, toStrip); } } private EntityManipulator(); static void removeFields(final Map<String, Object> toRemoveFrom, final List<String> toRemoveList); static void removeFields(final Map<String, Object> toRemoveFrom, final String toRemove); }
@Test public void testDeterministicUUID() { String resultUuid = "someId"; Mockito.when(mockShardType1UUIDGeneratorStrategy.generateId()).thenReturn(resultUuid); String uuid = deterministicUUIDGeneratorStrategy.generateId(); assertNotNull(uuid); assertEquals(resultUuid, uuid); }
@Override public String generateId() { return uuidStrategy.generateId(); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); static final String DIGEST_ALGORITHM; }
@Test public void shouldHaveSuffix() { String expectedSuffix = "_id"; Map<String, String> hashMap = new HashMap<String, String>(); hashMap.put("key1", "value1"); NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); naturalKeyDescriptor.setNaturalKeys(hashMap); naturalKeyDescriptor.setEntityType("testEntityType"); naturalKeyDescriptor.setTenantId("testTenantId"); String deterministicId = deterministicUUIDGeneratorStrategy.generateId(naturalKeyDescriptor); boolean hasSuffix = deterministicId.endsWith(expectedSuffix); Assert.assertTrue("Incorrect suffix: " + deterministicId, hasSuffix); }
@Override public String generateId() { return uuidStrategy.generateId(); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); static final String DIGEST_ALGORITHM; }
@Test public void testDeterministicUUIDMapOfStringString() { Map<String, String> hashMap = new HashMap<String, String>(); hashMap.put("key1", "value1"); hashMap.put("key2", "value2"); hashMap.put("key3", "value3"); NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); naturalKeyDescriptor.setNaturalKeys(hashMap); naturalKeyDescriptor.setEntityType("testEntityType"); naturalKeyDescriptor.setTenantId("testTenantId"); String deterministicId = deterministicUUIDGeneratorStrategy.generateId(naturalKeyDescriptor); assertEquals("deterministicId should be of length 43", 43, deterministicId.length()); assertEquals("deterministicId should be a specific value", "a9e40c18e0638c2ef986deca9dec43ccc26349f4_id", deterministicId); }
@Override public String generateId() { return uuidStrategy.generateId(); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); static final String DIGEST_ALGORITHM; }
@Test public void testNullNaturalKeyDescriptor() { String resultUuid = "someId"; Mockito.when(mockShardType1UUIDGeneratorStrategy.generateId()).thenReturn(resultUuid); String uuid = deterministicUUIDGeneratorStrategy.generateId(null); assertNotNull(uuid); assertEquals(resultUuid, uuid); }
@Override public String generateId() { return uuidStrategy.generateId(); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); static final String DIGEST_ALGORITHM; }
@Test public void testGenerateUuid() { byte[] testBytes = "abcdefghij1234567890".getBytes(); UUID uuid = DeterministicUUIDGeneratorStrategy.generateUuid(testBytes); assertNotNull("uuid must not be null", uuid); assertEquals("61626364-6566-6768-696a-313233343536", uuid.toString()); }
protected static UUID generateUuid(byte[] data) { ByteBuffer byteBuffer = ByteBuffer.wrap(data); long msb = byteBuffer.getLong(0); long lsb = byteBuffer.getLong(8); UUID uuid = new UUID(msb, lsb); return uuid; }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { protected static UUID generateUuid(byte[] data) { ByteBuffer byteBuffer = ByteBuffer.wrap(data); long msb = byteBuffer.getLong(0); long lsb = byteBuffer.getLong(8); UUID uuid = new UUID(msb, lsb); return uuid; } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { protected static UUID generateUuid(byte[] data) { ByteBuffer byteBuffer = ByteBuffer.wrap(data); long msb = byteBuffer.getLong(0); long lsb = byteBuffer.getLong(8); UUID uuid = new UUID(msb, lsb); return uuid; } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { protected static UUID generateUuid(byte[] data) { ByteBuffer byteBuffer = ByteBuffer.wrap(data); long msb = byteBuffer.getLong(0); long lsb = byteBuffer.getLong(8); UUID uuid = new UUID(msb, lsb); return uuid; } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { protected static UUID generateUuid(byte[] data) { ByteBuffer byteBuffer = ByteBuffer.wrap(data); long msb = byteBuffer.getLong(0); long lsb = byteBuffer.getLong(8); UUID uuid = new UUID(msb, lsb); return uuid; } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); static final String DIGEST_ALGORITHM; }
@Test public void testCreateStudentEntity() { MongoEntityRepository entityRepository = mock(MongoEntityRepository.class); NeutralQuery query = new NeutralQuery(); query.addCriteria(new NeutralCriteria(METADATA_BLOCK + "." + REGION_ID_FIELD, NeutralCriteria.OPERATOR_EQUAL, REGION_ID, false)); query.addCriteria(new NeutralCriteria(METADATA_BLOCK + "." + EXTERNAL_ID_FIELD, NeutralCriteria.OPERATOR_EQUAL, STUDENT_ID, false)); SimpleEntity studentEntity = createStudentEntity(true); List<Entity> le = new ArrayList<Entity>(); le.add(studentEntity); when(entityRepository.findAll(eq("student"), any(NeutralQuery.class))).thenReturn(le); when(entityRepository.updateWithRetries(studentEntity.getType(), studentEntity, totalRetries)).thenReturn(true); entityPersistHandler.setEntityRepository(entityRepository); AbstractMessageReport errorReport = new DummyMessageReport(); ReportStats reportStats = new SimpleReportStats(); entityPersistHandler.handle(studentEntity, errorReport, reportStats); verify(entityRepository).updateWithRetries(studentEntity.getType(), studentEntity, totalRetries); le.clear(); SimpleEntity studentEntity2 = createStudentEntity(false); le.add(studentEntity2); entityPersistHandler.handle(studentEntity2, errorReport, reportStats); verify(entityRepository).createWithRetries(studentEntity.getType(), null, studentEntity.getBody(), studentEntity.getMetaData(), "student", totalRetries); Assert.assertFalse("Error report should not contain errors", reportStats.hasErrors()); }
public void setEntityRepository(Repository<Entity> entityRepository) { this.entityRepository = entityRepository; }
EntityPersistHandler extends AbstractIngestionHandler<SimpleEntity, Entity> implements InitializingBean { public void setEntityRepository(Repository<Entity> entityRepository) { this.entityRepository = entityRepository; } }
EntityPersistHandler extends AbstractIngestionHandler<SimpleEntity, Entity> implements InitializingBean { public void setEntityRepository(Repository<Entity> entityRepository) { this.entityRepository = entityRepository; } }
EntityPersistHandler extends AbstractIngestionHandler<SimpleEntity, Entity> implements InitializingBean { public void setEntityRepository(Repository<Entity> entityRepository) { this.entityRepository = entityRepository; } @Override void afterPropertiesSet(); void setEntityRepository(Repository<Entity> entityRepository); EntityConfigFactory getEntityConfigurations(); void setEntityConfigurations(EntityConfigFactory entityConfigurations); @Override String getStageName(); }
EntityPersistHandler extends AbstractIngestionHandler<SimpleEntity, Entity> implements InitializingBean { public void setEntityRepository(Repository<Entity> entityRepository) { this.entityRepository = entityRepository; } @Override void afterPropertiesSet(); void setEntityRepository(Repository<Entity> entityRepository); EntityConfigFactory getEntityConfigurations(); void setEntityConfigurations(EntityConfigFactory entityConfigurations); @Override String getStageName(); static final Logger LOG; }
@Test public void testDeterministicUUIDMapOfStringString2() { Map<String, String> hashMap = new HashMap<String, String>(); hashMap.put("key1", "value1"); hashMap.put("key2", "value2"); hashMap.put("key3", "value3"); NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); naturalKeyDescriptor.setNaturalKeys(hashMap); naturalKeyDescriptor.setEntityType("entity||"); naturalKeyDescriptor.setTenantId("Type"); String deterministicId = deterministicUUIDGeneratorStrategy.generateId(naturalKeyDescriptor); NaturalKeyDescriptor naturalKeyDescriptor2 = new NaturalKeyDescriptor(); naturalKeyDescriptor2.setNaturalKeys(hashMap); naturalKeyDescriptor2.setEntityType("entity"); naturalKeyDescriptor2.setTenantId("||Type"); String deterministicId2 = deterministicUUIDGeneratorStrategy.generateId(naturalKeyDescriptor2); Assert.assertFalse("Ids should not be the same: ", deterministicId.equals(deterministicId2)); }
@Override public String generateId() { return uuidStrategy.generateId(); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); static final String DIGEST_ALGORITHM; }
@Test public void testWithBothDelimiters() { Map<String, String> hashMap = new HashMap<String, String>(); hashMap.put("key1", "value1"); NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); naturalKeyDescriptor.setNaturalKeys(hashMap); naturalKeyDescriptor.setEntityType("entity|~"); naturalKeyDescriptor.setTenantId("Type"); String deterministicId = deterministicUUIDGeneratorStrategy.generateId(naturalKeyDescriptor); NaturalKeyDescriptor naturalKeyDescriptor2 = new NaturalKeyDescriptor(); naturalKeyDescriptor2.setNaturalKeys(hashMap); naturalKeyDescriptor2.setEntityType("entity"); naturalKeyDescriptor2.setTenantId("|~Type"); String deterministicId2 = deterministicUUIDGeneratorStrategy.generateId(naturalKeyDescriptor2); Assert.assertFalse("Ids should not be the same: ", deterministicId.equals(deterministicId2)); }
@Override public String generateId() { return uuidStrategy.generateId(); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); static final String DIGEST_ALGORITHM; }
@Test public void testWithSecondDelimiter() { Map<String, String> hashMap = new HashMap<String, String>(); hashMap.put("key1", "value1"); NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); naturalKeyDescriptor.setNaturalKeys(hashMap); naturalKeyDescriptor.setEntityType("entity~"); naturalKeyDescriptor.setTenantId("Type"); String deterministicId = deterministicUUIDGeneratorStrategy.generateId(naturalKeyDescriptor); NaturalKeyDescriptor naturalKeyDescriptor2 = new NaturalKeyDescriptor(); naturalKeyDescriptor2.setNaturalKeys(hashMap); naturalKeyDescriptor2.setEntityType("entity"); naturalKeyDescriptor2.setTenantId("~Type"); String deterministicId2 = deterministicUUIDGeneratorStrategy.generateId(naturalKeyDescriptor2); Assert.assertFalse("Ids should not be the same: ", deterministicId.equals(deterministicId2)); }
@Override public String generateId() { return uuidStrategy.generateId(); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); }
DeterministicUUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { return uuidStrategy.generateId(); } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); static final String DIGEST_ALGORITHM; }
@Test public void testShardType1UUIDGenerator() { ShardType1UUIDGeneratorStrategy uuidGen = new ShardType1UUIDGeneratorStrategy(); String uuid = uuidGen.generateId(); assertNotNull(uuid); assertEquals('1', uuid.charAt(22)); assertEquals(43, uuid.length()); }
@Override public String generateId() { StringBuilder builder = new StringBuilder(); char c1 = (char) (r.nextInt(26) + 'a'); char c2 = (char) (r.nextInt(26) + 'a'); builder.append(new DateTime().getYear()); builder.append(c1); builder.append(c2); builder.append("-"); builder.append(generator.generate().toString()); String uuid = builder.toString(); return uuid; }
ShardType1UUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { StringBuilder builder = new StringBuilder(); char c1 = (char) (r.nextInt(26) + 'a'); char c2 = (char) (r.nextInt(26) + 'a'); builder.append(new DateTime().getYear()); builder.append(c1); builder.append(c2); builder.append("-"); builder.append(generator.generate().toString()); String uuid = builder.toString(); return uuid; } }
ShardType1UUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { StringBuilder builder = new StringBuilder(); char c1 = (char) (r.nextInt(26) + 'a'); char c2 = (char) (r.nextInt(26) + 'a'); builder.append(new DateTime().getYear()); builder.append(c1); builder.append(c2); builder.append("-"); builder.append(generator.generate().toString()); String uuid = builder.toString(); return uuid; } }
ShardType1UUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { StringBuilder builder = new StringBuilder(); char c1 = (char) (r.nextInt(26) + 'a'); char c2 = (char) (r.nextInt(26) + 'a'); builder.append(new DateTime().getYear()); builder.append(c1); builder.append(c2); builder.append("-"); builder.append(generator.generate().toString()); String uuid = builder.toString(); return uuid; } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); }
ShardType1UUIDGeneratorStrategy implements UUIDGeneratorStrategy { @Override public String generateId() { StringBuilder builder = new StringBuilder(); char c1 = (char) (r.nextInt(26) + 'a'); char c2 = (char) (r.nextInt(26) + 'a'); builder.append(new DateTime().getYear()); builder.append(c1); builder.append(c2); builder.append("-"); builder.append(generator.generate().toString()); String uuid = builder.toString(); return uuid; } @Override String generateId(); @Override String generateId(NaturalKeyDescriptor naturalKeyDescriptor); }
@Test public void testGetUser() { User slcoperator = ldapService.getUser("LocalNew", "slcoperator"); assertNotNull(slcoperator); assertTrue(slcoperator.getGroups().contains("SLC Operator")); assertTrue(slcoperator.getEmail().equals("[email protected]")); assertTrue(slcoperator.getUid().equals("slcoperator")); assertNotNull(slcoperator.getHomeDir()); assertNotNull(slcoperator.getGivenName()); assertNotNull(slcoperator.getSn()); assertNotNull(slcoperator.getFullName()); assertNull(slcoperator.getTenant()); assertNull(slcoperator.getEdorg()); assertNotNull(slcoperator.getCreateTime()); assertNotNull(slcoperator.getModifyTime()); }
@SuppressWarnings("rawtypes") @Override public User getUser(String realm, String uid) { AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)).and(new EqualsFilter(userSearchAttribute, uid)); DistinguishedName dn = new DistinguishedName("ou=" + realm); User user; try { List userList = ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper()); if (userList == null || userList.size() == 0) { throw new EmptyResultDataAccessException(1); } else if (userList.size() > 1) { throw new IncorrectResultSizeDataAccessException("User must be unique", 1); } user = (User) userList.get(0); user.setUid(uid); user.setGroups(getGroupNames(getUserGroups(realm, uid))); } catch (EmptyResultDataAccessException e) { return null; } return user; }
LdapServiceImpl implements LdapService { @SuppressWarnings("rawtypes") @Override public User getUser(String realm, String uid) { AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)).and(new EqualsFilter(userSearchAttribute, uid)); DistinguishedName dn = new DistinguishedName("ou=" + realm); User user; try { List userList = ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper()); if (userList == null || userList.size() == 0) { throw new EmptyResultDataAccessException(1); } else if (userList.size() > 1) { throw new IncorrectResultSizeDataAccessException("User must be unique", 1); } user = (User) userList.get(0); user.setUid(uid); user.setGroups(getGroupNames(getUserGroups(realm, uid))); } catch (EmptyResultDataAccessException e) { return null; } return user; } }
LdapServiceImpl implements LdapService { @SuppressWarnings("rawtypes") @Override public User getUser(String realm, String uid) { AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)).and(new EqualsFilter(userSearchAttribute, uid)); DistinguishedName dn = new DistinguishedName("ou=" + realm); User user; try { List userList = ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper()); if (userList == null || userList.size() == 0) { throw new EmptyResultDataAccessException(1); } else if (userList.size() > 1) { throw new IncorrectResultSizeDataAccessException("User must be unique", 1); } user = (User) userList.get(0); user.setUid(uid); user.setGroups(getGroupNames(getUserGroups(realm, uid))); } catch (EmptyResultDataAccessException e) { return null; } return user; } }
LdapServiceImpl implements LdapService { @SuppressWarnings("rawtypes") @Override public User getUser(String realm, String uid) { AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)).and(new EqualsFilter(userSearchAttribute, uid)); DistinguishedName dn = new DistinguishedName("ou=" + realm); User user; try { List userList = ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper()); if (userList == null || userList.size() == 0) { throw new EmptyResultDataAccessException(1); } else if (userList.size() > 1) { throw new IncorrectResultSizeDataAccessException("User must be unique", 1); } user = (User) userList.get(0); user.setUid(uid); user.setGroups(getGroupNames(getUserGroups(realm, uid))); } catch (EmptyResultDataAccessException e) { return null; } return user; } @SuppressWarnings("rawtypes") @Override User getUser(String realm, String uid); @SuppressWarnings("unchecked") @Override Collection<Group> getUserGroups(String realm, String uid); @Override void removeUser(String realm, String uid); @Override String createUser(String realm, User user); @Override boolean updateUser(String realm, User user); @Override Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant); @Override Collection<User> findUsersByAttributes(String realm, Collection<String> attributes); @Override Group getGroup(String realm, String groupName); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant, Collection<String> edorgs); @Override boolean addUserToGroup(String realm, Group group, User user); @Override boolean removeUserFromGroup(String realm, Group group, User user); @Override boolean updateGroup(String realm, Group group); @Override void setLdapTemplate(LdapTemplate ldapTemplate); }
LdapServiceImpl implements LdapService { @SuppressWarnings("rawtypes") @Override public User getUser(String realm, String uid) { AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)).and(new EqualsFilter(userSearchAttribute, uid)); DistinguishedName dn = new DistinguishedName("ou=" + realm); User user; try { List userList = ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper()); if (userList == null || userList.size() == 0) { throw new EmptyResultDataAccessException(1); } else if (userList.size() > 1) { throw new IncorrectResultSizeDataAccessException("User must be unique", 1); } user = (User) userList.get(0); user.setUid(uid); user.setGroups(getGroupNames(getUserGroups(realm, uid))); } catch (EmptyResultDataAccessException e) { return null; } return user; } @SuppressWarnings("rawtypes") @Override User getUser(String realm, String uid); @SuppressWarnings("unchecked") @Override Collection<Group> getUserGroups(String realm, String uid); @Override void removeUser(String realm, String uid); @Override String createUser(String realm, User user); @Override boolean updateUser(String realm, User user); @Override Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant); @Override Collection<User> findUsersByAttributes(String realm, Collection<String> attributes); @Override Group getGroup(String realm, String groupName); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant, Collection<String> edorgs); @Override boolean addUserToGroup(String realm, Group group, User user); @Override boolean removeUserFromGroup(String realm, Group group, User user); @Override boolean updateGroup(String realm, Group group); @Override void setLdapTemplate(LdapTemplate ldapTemplate); static final String OBJECTCLASS; }
@Test public void testGetGroup() { Group slcoperatorGroup = ldapService.getGroup("LocalNew", "SLC Operator"); assertNotNull(slcoperatorGroup); assertEquals("SLC Operator", slcoperatorGroup.getGroupName()); assertTrue(slcoperatorGroup.getMemberUids().contains("slcoperator")); }
@Override public Group getGroup(String realm, String groupName) { DistinguishedName dn = new DistinguishedName("ou=" + realm); AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, groupObjectClass)).and(new EqualsFilter("cn", groupName)); try { return (Group) ldapTemplate.searchForObject(dn, filter.toString(), new GroupContextMapper()); } catch (EmptyResultDataAccessException e) { return null; } }
LdapServiceImpl implements LdapService { @Override public Group getGroup(String realm, String groupName) { DistinguishedName dn = new DistinguishedName("ou=" + realm); AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, groupObjectClass)).and(new EqualsFilter("cn", groupName)); try { return (Group) ldapTemplate.searchForObject(dn, filter.toString(), new GroupContextMapper()); } catch (EmptyResultDataAccessException e) { return null; } } }
LdapServiceImpl implements LdapService { @Override public Group getGroup(String realm, String groupName) { DistinguishedName dn = new DistinguishedName("ou=" + realm); AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, groupObjectClass)).and(new EqualsFilter("cn", groupName)); try { return (Group) ldapTemplate.searchForObject(dn, filter.toString(), new GroupContextMapper()); } catch (EmptyResultDataAccessException e) { return null; } } }
LdapServiceImpl implements LdapService { @Override public Group getGroup(String realm, String groupName) { DistinguishedName dn = new DistinguishedName("ou=" + realm); AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, groupObjectClass)).and(new EqualsFilter("cn", groupName)); try { return (Group) ldapTemplate.searchForObject(dn, filter.toString(), new GroupContextMapper()); } catch (EmptyResultDataAccessException e) { return null; } } @SuppressWarnings("rawtypes") @Override User getUser(String realm, String uid); @SuppressWarnings("unchecked") @Override Collection<Group> getUserGroups(String realm, String uid); @Override void removeUser(String realm, String uid); @Override String createUser(String realm, User user); @Override boolean updateUser(String realm, User user); @Override Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant); @Override Collection<User> findUsersByAttributes(String realm, Collection<String> attributes); @Override Group getGroup(String realm, String groupName); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant, Collection<String> edorgs); @Override boolean addUserToGroup(String realm, Group group, User user); @Override boolean removeUserFromGroup(String realm, Group group, User user); @Override boolean updateGroup(String realm, Group group); @Override void setLdapTemplate(LdapTemplate ldapTemplate); }
LdapServiceImpl implements LdapService { @Override public Group getGroup(String realm, String groupName) { DistinguishedName dn = new DistinguishedName("ou=" + realm); AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, groupObjectClass)).and(new EqualsFilter("cn", groupName)); try { return (Group) ldapTemplate.searchForObject(dn, filter.toString(), new GroupContextMapper()); } catch (EmptyResultDataAccessException e) { return null; } } @SuppressWarnings("rawtypes") @Override User getUser(String realm, String uid); @SuppressWarnings("unchecked") @Override Collection<Group> getUserGroups(String realm, String uid); @Override void removeUser(String realm, String uid); @Override String createUser(String realm, User user); @Override boolean updateUser(String realm, User user); @Override Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant); @Override Collection<User> findUsersByAttributes(String realm, Collection<String> attributes); @Override Group getGroup(String realm, String groupName); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant, Collection<String> edorgs); @Override boolean addUserToGroup(String realm, Group group, User user); @Override boolean removeUserFromGroup(String realm, Group group, User user); @Override boolean updateGroup(String realm, Group group); @Override void setLdapTemplate(LdapTemplate ldapTemplate); static final String OBJECTCLASS; }
@Test public void testGetUserGroups() { Collection<Group> groups = ldapService.getUserGroups("LocalNew", "slcoperator"); assertNotNull(groups); Collection<String> groupNames = new ArrayList<String>(); for (Group group : groups) { groupNames.add(group.getGroupName()); } assertTrue(groupNames.contains("SLC Operator")); }
@SuppressWarnings("unchecked") @Override public Collection<Group> getUserGroups(String realm, String uid) { DistinguishedName dn = new DistinguishedName("ou=" + realm); AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, groupObjectClass)).and(new EqualsFilter(groupSearchAttribute, uid)); List<Group> groups = ldapTemplate.search(dn, filter.toString(), new GroupContextMapper()); return groups; }
LdapServiceImpl implements LdapService { @SuppressWarnings("unchecked") @Override public Collection<Group> getUserGroups(String realm, String uid) { DistinguishedName dn = new DistinguishedName("ou=" + realm); AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, groupObjectClass)).and(new EqualsFilter(groupSearchAttribute, uid)); List<Group> groups = ldapTemplate.search(dn, filter.toString(), new GroupContextMapper()); return groups; } }
LdapServiceImpl implements LdapService { @SuppressWarnings("unchecked") @Override public Collection<Group> getUserGroups(String realm, String uid) { DistinguishedName dn = new DistinguishedName("ou=" + realm); AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, groupObjectClass)).and(new EqualsFilter(groupSearchAttribute, uid)); List<Group> groups = ldapTemplate.search(dn, filter.toString(), new GroupContextMapper()); return groups; } }
LdapServiceImpl implements LdapService { @SuppressWarnings("unchecked") @Override public Collection<Group> getUserGroups(String realm, String uid) { DistinguishedName dn = new DistinguishedName("ou=" + realm); AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, groupObjectClass)).and(new EqualsFilter(groupSearchAttribute, uid)); List<Group> groups = ldapTemplate.search(dn, filter.toString(), new GroupContextMapper()); return groups; } @SuppressWarnings("rawtypes") @Override User getUser(String realm, String uid); @SuppressWarnings("unchecked") @Override Collection<Group> getUserGroups(String realm, String uid); @Override void removeUser(String realm, String uid); @Override String createUser(String realm, User user); @Override boolean updateUser(String realm, User user); @Override Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant); @Override Collection<User> findUsersByAttributes(String realm, Collection<String> attributes); @Override Group getGroup(String realm, String groupName); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant, Collection<String> edorgs); @Override boolean addUserToGroup(String realm, Group group, User user); @Override boolean removeUserFromGroup(String realm, Group group, User user); @Override boolean updateGroup(String realm, Group group); @Override void setLdapTemplate(LdapTemplate ldapTemplate); }
LdapServiceImpl implements LdapService { @SuppressWarnings("unchecked") @Override public Collection<Group> getUserGroups(String realm, String uid) { DistinguishedName dn = new DistinguishedName("ou=" + realm); AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, groupObjectClass)).and(new EqualsFilter(groupSearchAttribute, uid)); List<Group> groups = ldapTemplate.search(dn, filter.toString(), new GroupContextMapper()); return groups; } @SuppressWarnings("rawtypes") @Override User getUser(String realm, String uid); @SuppressWarnings("unchecked") @Override Collection<Group> getUserGroups(String realm, String uid); @Override void removeUser(String realm, String uid); @Override String createUser(String realm, User user); @Override boolean updateUser(String realm, User user); @Override Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant); @Override Collection<User> findUsersByAttributes(String realm, Collection<String> attributes); @Override Group getGroup(String realm, String groupName); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant, Collection<String> edorgs); @Override boolean addUserToGroup(String realm, Group group, User user); @Override boolean removeUserFromGroup(String realm, Group group, User user); @Override boolean updateGroup(String realm, Group group); @Override void setLdapTemplate(LdapTemplate ldapTemplate); static final String OBJECTCLASS; }
@Test public void testFindUserByGroups() { String[] groups = new String[] { "SEA Administrator" }; Collection<User> users = ldapService.findUsersByGroups("LocalNew", Arrays.asList(groups)); assertNotNull(users); }
@Override public Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs) { Collection<String> allowed = allowedGroupNames; Collection<String> disallowed = disallowedGroupNames; if (allowed == null) { allowed = new LinkedList<String>(); } if (disallowed == null) { disallowed = new LinkedList<String>(); } Set<String> allowedUsers = new HashSet<String>(); Map<String, List<String>> uidToGroupsMap = new HashMap<String, List<String>>(); for (String groupName : allowed) { Group group = getGroup(realm, groupName); if (group != null) { List<String> memberUids = group.getMemberUids(); if (memberUids != null && memberUids.size() > 0) { for (String memberUid : memberUids) { if (uidToGroupsMap.containsKey(memberUid)) { uidToGroupsMap.get(memberUid).add(groupName); } else { List<String> uidGroupNames = new ArrayList<String>(); uidGroupNames.add(groupName); uidToGroupsMap.put(memberUid, uidGroupNames); } allowedUsers.add(memberUid); } } } } for (String groupName : disallowed) { Group group = getGroup(realm, groupName); if (group != null) { allowedUsers.removeAll(group.getMemberUids()); } } AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)); OrFilter orFilter = new OrFilter(); for (String uid : allowedUsers) { orFilter.or(new EqualsFilter(userSearchAttribute, uid)); } filter.and(orFilter); DistinguishedName dn = new DistinguishedName("ou=" + realm); @SuppressWarnings("unchecked") Collection<User> users = (ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper())); for (User user : users) { user.setGroups(uidToGroupsMap.get(user.getUid())); } if (tenant != null) { users = filterByTenant(users, tenant); } if (edorgs != null) { users = filterByEdorgs(users, edorgs); } return users; }
LdapServiceImpl implements LdapService { @Override public Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs) { Collection<String> allowed = allowedGroupNames; Collection<String> disallowed = disallowedGroupNames; if (allowed == null) { allowed = new LinkedList<String>(); } if (disallowed == null) { disallowed = new LinkedList<String>(); } Set<String> allowedUsers = new HashSet<String>(); Map<String, List<String>> uidToGroupsMap = new HashMap<String, List<String>>(); for (String groupName : allowed) { Group group = getGroup(realm, groupName); if (group != null) { List<String> memberUids = group.getMemberUids(); if (memberUids != null && memberUids.size() > 0) { for (String memberUid : memberUids) { if (uidToGroupsMap.containsKey(memberUid)) { uidToGroupsMap.get(memberUid).add(groupName); } else { List<String> uidGroupNames = new ArrayList<String>(); uidGroupNames.add(groupName); uidToGroupsMap.put(memberUid, uidGroupNames); } allowedUsers.add(memberUid); } } } } for (String groupName : disallowed) { Group group = getGroup(realm, groupName); if (group != null) { allowedUsers.removeAll(group.getMemberUids()); } } AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)); OrFilter orFilter = new OrFilter(); for (String uid : allowedUsers) { orFilter.or(new EqualsFilter(userSearchAttribute, uid)); } filter.and(orFilter); DistinguishedName dn = new DistinguishedName("ou=" + realm); @SuppressWarnings("unchecked") Collection<User> users = (ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper())); for (User user : users) { user.setGroups(uidToGroupsMap.get(user.getUid())); } if (tenant != null) { users = filterByTenant(users, tenant); } if (edorgs != null) { users = filterByEdorgs(users, edorgs); } return users; } }
LdapServiceImpl implements LdapService { @Override public Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs) { Collection<String> allowed = allowedGroupNames; Collection<String> disallowed = disallowedGroupNames; if (allowed == null) { allowed = new LinkedList<String>(); } if (disallowed == null) { disallowed = new LinkedList<String>(); } Set<String> allowedUsers = new HashSet<String>(); Map<String, List<String>> uidToGroupsMap = new HashMap<String, List<String>>(); for (String groupName : allowed) { Group group = getGroup(realm, groupName); if (group != null) { List<String> memberUids = group.getMemberUids(); if (memberUids != null && memberUids.size() > 0) { for (String memberUid : memberUids) { if (uidToGroupsMap.containsKey(memberUid)) { uidToGroupsMap.get(memberUid).add(groupName); } else { List<String> uidGroupNames = new ArrayList<String>(); uidGroupNames.add(groupName); uidToGroupsMap.put(memberUid, uidGroupNames); } allowedUsers.add(memberUid); } } } } for (String groupName : disallowed) { Group group = getGroup(realm, groupName); if (group != null) { allowedUsers.removeAll(group.getMemberUids()); } } AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)); OrFilter orFilter = new OrFilter(); for (String uid : allowedUsers) { orFilter.or(new EqualsFilter(userSearchAttribute, uid)); } filter.and(orFilter); DistinguishedName dn = new DistinguishedName("ou=" + realm); @SuppressWarnings("unchecked") Collection<User> users = (ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper())); for (User user : users) { user.setGroups(uidToGroupsMap.get(user.getUid())); } if (tenant != null) { users = filterByTenant(users, tenant); } if (edorgs != null) { users = filterByEdorgs(users, edorgs); } return users; } }
LdapServiceImpl implements LdapService { @Override public Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs) { Collection<String> allowed = allowedGroupNames; Collection<String> disallowed = disallowedGroupNames; if (allowed == null) { allowed = new LinkedList<String>(); } if (disallowed == null) { disallowed = new LinkedList<String>(); } Set<String> allowedUsers = new HashSet<String>(); Map<String, List<String>> uidToGroupsMap = new HashMap<String, List<String>>(); for (String groupName : allowed) { Group group = getGroup(realm, groupName); if (group != null) { List<String> memberUids = group.getMemberUids(); if (memberUids != null && memberUids.size() > 0) { for (String memberUid : memberUids) { if (uidToGroupsMap.containsKey(memberUid)) { uidToGroupsMap.get(memberUid).add(groupName); } else { List<String> uidGroupNames = new ArrayList<String>(); uidGroupNames.add(groupName); uidToGroupsMap.put(memberUid, uidGroupNames); } allowedUsers.add(memberUid); } } } } for (String groupName : disallowed) { Group group = getGroup(realm, groupName); if (group != null) { allowedUsers.removeAll(group.getMemberUids()); } } AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)); OrFilter orFilter = new OrFilter(); for (String uid : allowedUsers) { orFilter.or(new EqualsFilter(userSearchAttribute, uid)); } filter.and(orFilter); DistinguishedName dn = new DistinguishedName("ou=" + realm); @SuppressWarnings("unchecked") Collection<User> users = (ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper())); for (User user : users) { user.setGroups(uidToGroupsMap.get(user.getUid())); } if (tenant != null) { users = filterByTenant(users, tenant); } if (edorgs != null) { users = filterByEdorgs(users, edorgs); } return users; } @SuppressWarnings("rawtypes") @Override User getUser(String realm, String uid); @SuppressWarnings("unchecked") @Override Collection<Group> getUserGroups(String realm, String uid); @Override void removeUser(String realm, String uid); @Override String createUser(String realm, User user); @Override boolean updateUser(String realm, User user); @Override Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant); @Override Collection<User> findUsersByAttributes(String realm, Collection<String> attributes); @Override Group getGroup(String realm, String groupName); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant, Collection<String> edorgs); @Override boolean addUserToGroup(String realm, Group group, User user); @Override boolean removeUserFromGroup(String realm, Group group, User user); @Override boolean updateGroup(String realm, Group group); @Override void setLdapTemplate(LdapTemplate ldapTemplate); }
LdapServiceImpl implements LdapService { @Override public Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs) { Collection<String> allowed = allowedGroupNames; Collection<String> disallowed = disallowedGroupNames; if (allowed == null) { allowed = new LinkedList<String>(); } if (disallowed == null) { disallowed = new LinkedList<String>(); } Set<String> allowedUsers = new HashSet<String>(); Map<String, List<String>> uidToGroupsMap = new HashMap<String, List<String>>(); for (String groupName : allowed) { Group group = getGroup(realm, groupName); if (group != null) { List<String> memberUids = group.getMemberUids(); if (memberUids != null && memberUids.size() > 0) { for (String memberUid : memberUids) { if (uidToGroupsMap.containsKey(memberUid)) { uidToGroupsMap.get(memberUid).add(groupName); } else { List<String> uidGroupNames = new ArrayList<String>(); uidGroupNames.add(groupName); uidToGroupsMap.put(memberUid, uidGroupNames); } allowedUsers.add(memberUid); } } } } for (String groupName : disallowed) { Group group = getGroup(realm, groupName); if (group != null) { allowedUsers.removeAll(group.getMemberUids()); } } AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)); OrFilter orFilter = new OrFilter(); for (String uid : allowedUsers) { orFilter.or(new EqualsFilter(userSearchAttribute, uid)); } filter.and(orFilter); DistinguishedName dn = new DistinguishedName("ou=" + realm); @SuppressWarnings("unchecked") Collection<User> users = (ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper())); for (User user : users) { user.setGroups(uidToGroupsMap.get(user.getUid())); } if (tenant != null) { users = filterByTenant(users, tenant); } if (edorgs != null) { users = filterByEdorgs(users, edorgs); } return users; } @SuppressWarnings("rawtypes") @Override User getUser(String realm, String uid); @SuppressWarnings("unchecked") @Override Collection<Group> getUserGroups(String realm, String uid); @Override void removeUser(String realm, String uid); @Override String createUser(String realm, User user); @Override boolean updateUser(String realm, User user); @Override Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant); @Override Collection<User> findUsersByAttributes(String realm, Collection<String> attributes); @Override Group getGroup(String realm, String groupName); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant, Collection<String> edorgs); @Override boolean addUserToGroup(String realm, Group group, User user); @Override boolean removeUserFromGroup(String realm, Group group, User user); @Override boolean updateGroup(String realm, Group group); @Override void setLdapTemplate(LdapTemplate ldapTemplate); static final String OBJECTCLASS; }
@Test public void testNaturalKeyDescriptor() { NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(); Map<String, String> naturalKeys = naturalKeyDescriptor.getNaturalKeys(); assertNotNull("naturalKeys is not null", naturalKeys); assertEquals("naturalKeys has 0 natural keys", 0, naturalKeys.size()); assertEquals("tenantId is empty", "", naturalKeyDescriptor.getTenantId()); assertEquals("entityType is empty", "", naturalKeyDescriptor.getEntityType()); NaturalKeyDescriptor naturalKeyDescriptor2 = new NaturalKeyDescriptor(); assertTrue(naturalKeyDescriptor.equals(naturalKeyDescriptor2)); }
public NaturalKeyDescriptor() { this(null, null, null, null); }
NaturalKeyDescriptor { public NaturalKeyDescriptor() { this(null, null, null, null); } }
NaturalKeyDescriptor { public NaturalKeyDescriptor() { this(null, null, null, null); } NaturalKeyDescriptor(); NaturalKeyDescriptor(Map<String, String> naturalKeys); NaturalKeyDescriptor(Map<String, String> naturalKeys, String tenantId, String entityType, String parentId); }
NaturalKeyDescriptor { public NaturalKeyDescriptor() { this(null, null, null, null); } NaturalKeyDescriptor(); NaturalKeyDescriptor(Map<String, String> naturalKeys); NaturalKeyDescriptor(Map<String, String> naturalKeys, String tenantId, String entityType, String parentId); @Override boolean equals(Object o); @Override int hashCode(); Map<String, String> getNaturalKeys(); void setNaturalKeys(Map<String, String> naturalKeys); String getTenantId(); void setTenantId(String tenantId); String getEntityType(); void setEntityType(String entityType); boolean isNaturalKeysNotNeeded(); void setNaturalKeysNotNeeded(boolean naturalKeysNotNeeded); String getParentId(); void setParentId(String parentId); }
NaturalKeyDescriptor { public NaturalKeyDescriptor() { this(null, null, null, null); } NaturalKeyDescriptor(); NaturalKeyDescriptor(Map<String, String> naturalKeys); NaturalKeyDescriptor(Map<String, String> naturalKeys, String tenantId, String entityType, String parentId); @Override boolean equals(Object o); @Override int hashCode(); Map<String, String> getNaturalKeys(); void setNaturalKeys(Map<String, String> naturalKeys); String getTenantId(); void setTenantId(String tenantId); String getEntityType(); void setEntityType(String entityType); boolean isNaturalKeysNotNeeded(); void setNaturalKeysNotNeeded(boolean naturalKeysNotNeeded); String getParentId(); void setParentId(String parentId); }
@Test public void hashCodeShouldMatchExpected() { Map<String, String> naturalKeysForConstructor = new HashMap<String, String>(); naturalKeysForConstructor.put("key1", "value1"); naturalKeysForConstructor.put("key2", "value2"); String testTenantId = "testTenantId"; String testEntityType = "testEntityType"; NaturalKeyDescriptor naturalKeyDescriptor = new NaturalKeyDescriptor(naturalKeysForConstructor, testTenantId, testEntityType, null); int hashCode = naturalKeyDescriptor.hashCode(); assertEquals(1601434024, hashCode); Map<String, String> naturalKeysForConstructor2 = new HashMap<String, String>(); naturalKeysForConstructor2.put("key1", "value1"); NaturalKeyDescriptor naturalKeyDescriptor2 = new NaturalKeyDescriptor(naturalKeysForConstructor2, testTenantId, testEntityType, null); int hashCode2 = naturalKeyDescriptor2.hashCode(); assertEquals(-741620770, hashCode2); Map<String, String> naturalKeysForConstructor3 = new HashMap<String, String>(); naturalKeysForConstructor3.put("key1", "value1"); naturalKeysForConstructor3.put("key2", "value3"); NaturalKeyDescriptor naturalKeyDescriptor3 = new NaturalKeyDescriptor(naturalKeysForConstructor3, testTenantId, testEntityType, null); int hashCode3 = naturalKeyDescriptor3.hashCode(); assertEquals(1601383371, hashCode3); Map<String, String> naturalKeysForConstructor4 = new HashMap<String, String>(); naturalKeysForConstructor4.put("key1", "value1"); naturalKeysForConstructor4.put("key3", "value2"); NaturalKeyDescriptor naturalKeyDescriptor4 = new NaturalKeyDescriptor(naturalKeysForConstructor4, testTenantId, testEntityType, null); int hashCode4 = naturalKeyDescriptor4.hashCode(); assertEquals(1601585983, hashCode4); NaturalKeyDescriptor naturalKeyDescriptor5 = new NaturalKeyDescriptor(null, testTenantId, testEntityType, null); int hashCode5 = naturalKeyDescriptor5.hashCode(); assertEquals(1210291732, hashCode5); NaturalKeyDescriptor naturalKeyDescriptor6 = new NaturalKeyDescriptor(naturalKeysForConstructor, "testTenantId6", testEntityType, null); int hashCode6 = naturalKeyDescriptor6.hashCode(); assertEquals(326979664, hashCode6); NaturalKeyDescriptor naturalKeyDescriptor7 = new NaturalKeyDescriptor(naturalKeysForConstructor, null, testEntityType, null); int hashCode7 = naturalKeyDescriptor7.hashCode(); assertEquals(784924841, hashCode7); NaturalKeyDescriptor naturalKeyDescriptor8 = new NaturalKeyDescriptor(naturalKeysForConstructor, testTenantId, "testEntityType8", null); int hashCode8 = naturalKeyDescriptor8.hashCode(); assertEquals(-1831432182, hashCode8); NaturalKeyDescriptor naturalKeyDescriptor9 = new NaturalKeyDescriptor(naturalKeysForConstructor, testTenantId, null, null); int hashCode9 = naturalKeyDescriptor9.hashCode(); assertEquals(1286366237, hashCode9); NaturalKeyDescriptor naturalKeyDescriptor10 = new NaturalKeyDescriptor(naturalKeysForConstructor, testTenantId, null, "parentId1"); int hashCode10 = naturalKeyDescriptor10.hashCode(); assertEquals(-938294903, hashCode10); }
@Override public int hashCode() { int result = 42; if (this.getNaturalKeys() != null) { result = 37 * result + this.getNaturalKeys().hashCode(); } if (this.getTenantId() != null) { result = 37 * result + this.getTenantId().hashCode(); } if (this.getEntityType() != null) { result = 37 * result + this.getEntityType().hashCode(); } if (this.getParentId() != null) { result = 37 * result + this.getParentId().hashCode(); } return result; }
NaturalKeyDescriptor { @Override public int hashCode() { int result = 42; if (this.getNaturalKeys() != null) { result = 37 * result + this.getNaturalKeys().hashCode(); } if (this.getTenantId() != null) { result = 37 * result + this.getTenantId().hashCode(); } if (this.getEntityType() != null) { result = 37 * result + this.getEntityType().hashCode(); } if (this.getParentId() != null) { result = 37 * result + this.getParentId().hashCode(); } return result; } }
NaturalKeyDescriptor { @Override public int hashCode() { int result = 42; if (this.getNaturalKeys() != null) { result = 37 * result + this.getNaturalKeys().hashCode(); } if (this.getTenantId() != null) { result = 37 * result + this.getTenantId().hashCode(); } if (this.getEntityType() != null) { result = 37 * result + this.getEntityType().hashCode(); } if (this.getParentId() != null) { result = 37 * result + this.getParentId().hashCode(); } return result; } NaturalKeyDescriptor(); NaturalKeyDescriptor(Map<String, String> naturalKeys); NaturalKeyDescriptor(Map<String, String> naturalKeys, String tenantId, String entityType, String parentId); }
NaturalKeyDescriptor { @Override public int hashCode() { int result = 42; if (this.getNaturalKeys() != null) { result = 37 * result + this.getNaturalKeys().hashCode(); } if (this.getTenantId() != null) { result = 37 * result + this.getTenantId().hashCode(); } if (this.getEntityType() != null) { result = 37 * result + this.getEntityType().hashCode(); } if (this.getParentId() != null) { result = 37 * result + this.getParentId().hashCode(); } return result; } NaturalKeyDescriptor(); NaturalKeyDescriptor(Map<String, String> naturalKeys); NaturalKeyDescriptor(Map<String, String> naturalKeys, String tenantId, String entityType, String parentId); @Override boolean equals(Object o); @Override int hashCode(); Map<String, String> getNaturalKeys(); void setNaturalKeys(Map<String, String> naturalKeys); String getTenantId(); void setTenantId(String tenantId); String getEntityType(); void setEntityType(String entityType); boolean isNaturalKeysNotNeeded(); void setNaturalKeysNotNeeded(boolean naturalKeysNotNeeded); String getParentId(); void setParentId(String parentId); }
NaturalKeyDescriptor { @Override public int hashCode() { int result = 42; if (this.getNaturalKeys() != null) { result = 37 * result + this.getNaturalKeys().hashCode(); } if (this.getTenantId() != null) { result = 37 * result + this.getTenantId().hashCode(); } if (this.getEntityType() != null) { result = 37 * result + this.getEntityType().hashCode(); } if (this.getParentId() != null) { result = 37 * result + this.getParentId().hashCode(); } return result; } NaturalKeyDescriptor(); NaturalKeyDescriptor(Map<String, String> naturalKeys); NaturalKeyDescriptor(Map<String, String> naturalKeys, String tenantId, String entityType, String parentId); @Override boolean equals(Object o); @Override int hashCode(); Map<String, String> getNaturalKeys(); void setNaturalKeys(Map<String, String> naturalKeys); String getTenantId(); void setTenantId(String tenantId); String getEntityType(); void setEntityType(String entityType); boolean isNaturalKeysNotNeeded(); void setNaturalKeysNotNeeded(boolean naturalKeysNotNeeded); String getParentId(); void setParentId(String parentId); }
@Test public void testCreateAndDeleteStudentEntity() { MongoEntityRepository entityRepository = mock(MongoEntityRepository.class); NeutralQuery query = new NeutralQuery(); query.addCriteria(new NeutralCriteria(METADATA_BLOCK + "." + REGION_ID_FIELD, NeutralCriteria.OPERATOR_EQUAL, REGION_ID, false)); query.addCriteria(new NeutralCriteria(METADATA_BLOCK + "." + EXTERNAL_ID_FIELD, NeutralCriteria.OPERATOR_EQUAL, STUDENT_ID, false)); SimpleEntity studentEntity = createStudentEntity(true); List<Entity> le = new ArrayList<Entity>(); le.add(studentEntity); when(entityRepository.findAll(eq("student"), any(NeutralQuery.class))).thenReturn(le); when(entityRepository.updateWithRetries(studentEntity.getType(), studentEntity, totalRetries)).thenReturn(true); CascadeResult mockCascadeResult = new CascadeResult(); mockCascadeResult.setStatus(CascadeResult.Status.SUCCESS); when(entityRepository.safeDelete(eq(studentEntity), eq(studentEntity.getEntityId()), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyInt(), any(AccessibilityCheck.class))).thenReturn(mockCascadeResult); entityPersistHandler.setEntityRepository(entityRepository); AbstractMessageReport errorReport = new DummyMessageReport(); ReportStats reportStats = new SimpleReportStats(); entityPersistHandler.handle(studentEntity, errorReport, reportStats); verify(entityRepository).updateWithRetries(studentEntity.getType(), studentEntity, totalRetries); studentEntity.setAction( ActionVerb.CASCADE_DELETE); studentEntity.setActionAttributes(ImmutableMap.of( "Force", "true", "LogViolations", "true" )); entityPersistHandler.handle( studentEntity, errorReport, reportStats); verify(entityRepository).safeDelete(studentEntity, studentEntity.getEntityId(), true, false, true, true, null, null); Assert.assertFalse("Error report should not contain errors", reportStats.hasErrors()); }
public void setEntityRepository(Repository<Entity> entityRepository) { this.entityRepository = entityRepository; }
EntityPersistHandler extends AbstractIngestionHandler<SimpleEntity, Entity> implements InitializingBean { public void setEntityRepository(Repository<Entity> entityRepository) { this.entityRepository = entityRepository; } }
EntityPersistHandler extends AbstractIngestionHandler<SimpleEntity, Entity> implements InitializingBean { public void setEntityRepository(Repository<Entity> entityRepository) { this.entityRepository = entityRepository; } }
EntityPersistHandler extends AbstractIngestionHandler<SimpleEntity, Entity> implements InitializingBean { public void setEntityRepository(Repository<Entity> entityRepository) { this.entityRepository = entityRepository; } @Override void afterPropertiesSet(); void setEntityRepository(Repository<Entity> entityRepository); EntityConfigFactory getEntityConfigurations(); void setEntityConfigurations(EntityConfigFactory entityConfigurations); @Override String getStageName(); }
EntityPersistHandler extends AbstractIngestionHandler<SimpleEntity, Entity> implements InitializingBean { public void setEntityRepository(Repository<Entity> entityRepository) { this.entityRepository = entityRepository; } @Override void afterPropertiesSet(); void setEntityRepository(Repository<Entity> entityRepository); EntityConfigFactory getEntityConfigurations(); void setEntityConfigurations(EntityConfigFactory entityConfigurations); @Override String getStageName(); static final Logger LOG; }
@Test public void testGetContainerDocument() { final Map<String, ContainerDocument> testContainer = createContainerMap(); testHolder = new ContainerDocumentHolder(testContainer); assertEquals(testContainer.get("test"), testHolder.getContainerDocument("test")); }
public ContainerDocument getContainerDocument(final String entityName) { return containerDocumentMap.get(entityName); }
ContainerDocumentHolder { public ContainerDocument getContainerDocument(final String entityName) { return containerDocumentMap.get(entityName); } }
ContainerDocumentHolder { public ContainerDocument getContainerDocument(final String entityName) { return containerDocumentMap.get(entityName); } ContainerDocumentHolder(); ContainerDocumentHolder(final Map<String, ContainerDocument> containerDocumentMap); }
ContainerDocumentHolder { public ContainerDocument getContainerDocument(final String entityName) { return containerDocumentMap.get(entityName); } ContainerDocumentHolder(); ContainerDocumentHolder(final Map<String, ContainerDocument> containerDocumentMap); ContainerDocument getContainerDocument(final String entityName); boolean isContainerDocument(final String entityName); }
ContainerDocumentHolder { public ContainerDocument getContainerDocument(final String entityName) { return containerDocumentMap.get(entityName); } ContainerDocumentHolder(); ContainerDocumentHolder(final Map<String, ContainerDocument> containerDocumentMap); ContainerDocument getContainerDocument(final String entityName); boolean isContainerDocument(final String entityName); }
@Test public void testIsContainerDocument() { final Map<String, ContainerDocument> testContainer = createContainerMap(); testHolder = new ContainerDocumentHolder(testContainer); assertFalse(testHolder.isContainerDocument("foo")); assertTrue(testHolder.isContainerDocument("test")); }
public boolean isContainerDocument(final String entityName) { return containerDocumentMap.containsKey(entityName); }
ContainerDocumentHolder { public boolean isContainerDocument(final String entityName) { return containerDocumentMap.containsKey(entityName); } }
ContainerDocumentHolder { public boolean isContainerDocument(final String entityName) { return containerDocumentMap.containsKey(entityName); } ContainerDocumentHolder(); ContainerDocumentHolder(final Map<String, ContainerDocument> containerDocumentMap); }
ContainerDocumentHolder { public boolean isContainerDocument(final String entityName) { return containerDocumentMap.containsKey(entityName); } ContainerDocumentHolder(); ContainerDocumentHolder(final Map<String, ContainerDocument> containerDocumentMap); ContainerDocument getContainerDocument(final String entityName); boolean isContainerDocument(final String entityName); }
ContainerDocumentHolder { public boolean isContainerDocument(final String entityName) { return containerDocumentMap.containsKey(entityName); } ContainerDocumentHolder(); ContainerDocumentHolder(final Map<String, ContainerDocument> containerDocumentMap); ContainerDocument getContainerDocument(final String entityName); boolean isContainerDocument(final String entityName); }
@Ignore @Test public void signSamlArtifactResolve() throws JDOMException, TransformerException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, KeyException, MarshalException, XMLSignatureException, KeyStoreException, CertificateException { Document unsignedDocument = getDocument("artifact-resolve-unsigned.xml"); Document signedDom = signatureHelper.signSamlAssertion(unsignedDocument); Assert.assertNotNull(signedDom); boolean foundSignedInfo = false; boolean foundSignatureValue = false; boolean foundKeyInfo = false; NodeList list = signedDom.getChildNodes(); if (list.item(0).getNodeName().equals("samlp:ArtifactResolve")) { NodeList sublist = list.item(0).getChildNodes(); for (int i = 0; i < sublist.getLength(); i++) { if (sublist.item(i).getNodeName().equals("Signature")) { NodeList signatureList = sublist.item(i).getChildNodes(); for (int j = 0; j < signatureList.getLength(); j++) { if (signatureList.item(j).getNodeName().equals("SignedInfo")) { foundSignedInfo = true; } else if (signatureList.item(j).getNodeName().equals("SignatureValue")) { foundSignatureValue = true; } else if (signatureList.item(j).getNodeName().equals("KeyInfo")) { foundKeyInfo = true; } } } } } Assert.assertTrue("Should be true if Signature contains SignedInfo tag", foundSignedInfo); Assert.assertTrue("Should be true if Signature contains SignatureValue tag", foundSignatureValue); Assert.assertTrue("Should be true if Signature contains KeyInfo tag", foundKeyInfo); Assert.assertTrue(validator.isDocumentTrusted(signedDom, "CN=*.slidev.org,OU=Domain Control Validated,O=*.slidev.org")); }
public Document signSamlAssertion(Document document) throws TransformerException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, KeyException, MarshalException, XMLSignatureException { if (document != null) { PrivateKeyEntry entry = getPrivateKeyEntryFromKeystore(); PrivateKey privateKey = entry.getPrivateKey(); X509Certificate certificate = (X509Certificate) entry.getCertificate(); Element signedElement = signSamlAssertion(document, privateKey, certificate); return signedElement.getOwnerDocument(); } return null; }
XmlSignatureHelper { public Document signSamlAssertion(Document document) throws TransformerException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, KeyException, MarshalException, XMLSignatureException { if (document != null) { PrivateKeyEntry entry = getPrivateKeyEntryFromKeystore(); PrivateKey privateKey = entry.getPrivateKey(); X509Certificate certificate = (X509Certificate) entry.getCertificate(); Element signedElement = signSamlAssertion(document, privateKey, certificate); return signedElement.getOwnerDocument(); } return null; } }
XmlSignatureHelper { public Document signSamlAssertion(Document document) throws TransformerException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, KeyException, MarshalException, XMLSignatureException { if (document != null) { PrivateKeyEntry entry = getPrivateKeyEntryFromKeystore(); PrivateKey privateKey = entry.getPrivateKey(); X509Certificate certificate = (X509Certificate) entry.getCertificate(); Element signedElement = signSamlAssertion(document, privateKey, certificate); return signedElement.getOwnerDocument(); } return null; } }
XmlSignatureHelper { public Document signSamlAssertion(Document document) throws TransformerException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, KeyException, MarshalException, XMLSignatureException { if (document != null) { PrivateKeyEntry entry = getPrivateKeyEntryFromKeystore(); PrivateKey privateKey = entry.getPrivateKey(); X509Certificate certificate = (X509Certificate) entry.getCertificate(); Element signedElement = signSamlAssertion(document, privateKey, certificate); return signedElement.getOwnerDocument(); } return null; } Document signSamlAssertion(Document document); Document convertDocumentToDocumentDom(org.jdom.Document doc); Element convertElementToElementDom(org.jdom.Element element); Element convertDocumentToElementDom(org.jdom.Document document); }
XmlSignatureHelper { public Document signSamlAssertion(Document document) throws TransformerException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, KeyException, MarshalException, XMLSignatureException { if (document != null) { PrivateKeyEntry entry = getPrivateKeyEntryFromKeystore(); PrivateKey privateKey = entry.getPrivateKey(); X509Certificate certificate = (X509Certificate) entry.getCertificate(); Element signedElement = signSamlAssertion(document, privateKey, certificate); return signedElement.getOwnerDocument(); } return null; } Document signSamlAssertion(Document document); Document convertDocumentToDocumentDom(org.jdom.Document doc); Element convertElementToElementDom(org.jdom.Element element); Element convertDocumentToElementDom(org.jdom.Document document); }
@Test public void testIsSignatureValidWithValid() throws Exception { Document doc = getDocument("complete-valid2.xml"); Assert.assertTrue(validator.isSignatureValid(doc)); }
@Override public boolean isSignatureValid(Document samlDocument) { try { return getSignature(samlDocument).getSignatureValue().validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate signature", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't validate signature", e); } return false; }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isSignatureValid(Document samlDocument) { try { return getSignature(samlDocument).getSignatureValue().validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate signature", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't validate signature", e); } return false; } }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isSignatureValid(Document samlDocument) { try { return getSignature(samlDocument).getSignatureValue().validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate signature", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't validate signature", e); } return false; } }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isSignatureValid(Document samlDocument) { try { return getSignature(samlDocument).getSignatureValue().validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate signature", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't validate signature", e); } return false; } @Override boolean isSignatureTrusted(XMLSignature signature, String issuer); @Override boolean isDocumentTrustedAndValid(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Element element, String issuer); @Override boolean isDocumentValid(Document samlDocument); @Override boolean isSignatureValid(Document samlDocument); @Override Document signDocumentWithSAMLSigner(Document samlDocument, SAML2Signer signer); }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isSignatureValid(Document samlDocument) { try { return getSignature(samlDocument).getSignatureValue().validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate signature", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't validate signature", e); } return false; } @Override boolean isSignatureTrusted(XMLSignature signature, String issuer); @Override boolean isDocumentTrustedAndValid(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Element element, String issuer); @Override boolean isDocumentValid(Document samlDocument); @Override boolean isSignatureValid(Document samlDocument); @Override Document signDocumentWithSAMLSigner(Document samlDocument, SAML2Signer signer); }
@Test public void testIsSignatureValidWithInvalid() throws Exception { Document doc = getDocument("complete-invalid.xml"); Assert.assertTrue(!validator.isSignatureValid(doc)); }
@Override public boolean isSignatureValid(Document samlDocument) { try { return getSignature(samlDocument).getSignatureValue().validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate signature", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't validate signature", e); } return false; }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isSignatureValid(Document samlDocument) { try { return getSignature(samlDocument).getSignatureValue().validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate signature", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't validate signature", e); } return false; } }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isSignatureValid(Document samlDocument) { try { return getSignature(samlDocument).getSignatureValue().validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate signature", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't validate signature", e); } return false; } }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isSignatureValid(Document samlDocument) { try { return getSignature(samlDocument).getSignatureValue().validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate signature", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't validate signature", e); } return false; } @Override boolean isSignatureTrusted(XMLSignature signature, String issuer); @Override boolean isDocumentTrustedAndValid(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Element element, String issuer); @Override boolean isDocumentValid(Document samlDocument); @Override boolean isSignatureValid(Document samlDocument); @Override Document signDocumentWithSAMLSigner(Document samlDocument, SAML2Signer signer); }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isSignatureValid(Document samlDocument) { try { return getSignature(samlDocument).getSignatureValue().validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate signature", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't validate signature", e); } return false; } @Override boolean isSignatureTrusted(XMLSignature signature, String issuer); @Override boolean isDocumentTrustedAndValid(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Element element, String issuer); @Override boolean isDocumentValid(Document samlDocument); @Override boolean isSignatureValid(Document samlDocument); @Override Document signDocumentWithSAMLSigner(Document samlDocument, SAML2Signer signer); }
@Test public void testValidatingAValidDocument() throws Exception { Document doc = getDocument("complete-valid2.xml"); Assert.assertTrue(validator.isDocumentValid(doc)); }
@Override public boolean isDocumentValid(Document samlDocument) { try { return getSignature(samlDocument).validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate Document", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't extract XML Signature from Document", e); } return false; }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentValid(Document samlDocument) { try { return getSignature(samlDocument).validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate Document", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't extract XML Signature from Document", e); } return false; } }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentValid(Document samlDocument) { try { return getSignature(samlDocument).validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate Document", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't extract XML Signature from Document", e); } return false; } }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentValid(Document samlDocument) { try { return getSignature(samlDocument).validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate Document", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't extract XML Signature from Document", e); } return false; } @Override boolean isSignatureTrusted(XMLSignature signature, String issuer); @Override boolean isDocumentTrustedAndValid(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Element element, String issuer); @Override boolean isDocumentValid(Document samlDocument); @Override boolean isSignatureValid(Document samlDocument); @Override Document signDocumentWithSAMLSigner(Document samlDocument, SAML2Signer signer); }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentValid(Document samlDocument) { try { return getSignature(samlDocument).validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate Document", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't extract XML Signature from Document", e); } return false; } @Override boolean isSignatureTrusted(XMLSignature signature, String issuer); @Override boolean isDocumentTrustedAndValid(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Element element, String issuer); @Override boolean isDocumentValid(Document samlDocument); @Override boolean isSignatureValid(Document samlDocument); @Override Document signDocumentWithSAMLSigner(Document samlDocument, SAML2Signer signer); }
@Test public void testValidatingAnInvalidDocument() throws Exception { Document doc = getDocument("complete-invalid.xml"); Assert.assertTrue(!validator.isDocumentValid(doc)); }
@Override public boolean isDocumentValid(Document samlDocument) { try { return getSignature(samlDocument).validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate Document", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't extract XML Signature from Document", e); } return false; }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentValid(Document samlDocument) { try { return getSignature(samlDocument).validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate Document", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't extract XML Signature from Document", e); } return false; } }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentValid(Document samlDocument) { try { return getSignature(samlDocument).validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate Document", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't extract XML Signature from Document", e); } return false; } }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentValid(Document samlDocument) { try { return getSignature(samlDocument).validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate Document", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't extract XML Signature from Document", e); } return false; } @Override boolean isSignatureTrusted(XMLSignature signature, String issuer); @Override boolean isDocumentTrustedAndValid(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Element element, String issuer); @Override boolean isDocumentValid(Document samlDocument); @Override boolean isSignatureValid(Document samlDocument); @Override Document signDocumentWithSAMLSigner(Document samlDocument, SAML2Signer signer); }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentValid(Document samlDocument) { try { return getSignature(samlDocument).validate(valContext); } catch (MarshalException e) { LOG.warn("Couldn't validate Document", e); } catch (XMLSignatureException e) { LOG.warn("Couldn't extract XML Signature from Document", e); } return false; } @Override boolean isSignatureTrusted(XMLSignature signature, String issuer); @Override boolean isDocumentTrustedAndValid(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Element element, String issuer); @Override boolean isDocumentValid(Document samlDocument); @Override boolean isSignatureValid(Document samlDocument); @Override Document signDocumentWithSAMLSigner(Document samlDocument, SAML2Signer signer); }
@Test public void testIsUntrustedAssertionTrusted() throws Exception { Document doc = getDocument("adfs-invalid.xml"); Assert.assertTrue(!validator.isDocumentTrusted(doc, "CN=*.slidev.org,OU=Domain Control Validated,O=*.slidev.org")); }
@Override public boolean isDocumentTrusted(Document samlDocument, String issuer) throws KeyStoreException, InvalidAlgorithmParameterException, CertificateException, NoSuchAlgorithmException, MarshalException { return isSignatureTrusted(getSignature(samlDocument), issuer); }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentTrusted(Document samlDocument, String issuer) throws KeyStoreException, InvalidAlgorithmParameterException, CertificateException, NoSuchAlgorithmException, MarshalException { return isSignatureTrusted(getSignature(samlDocument), issuer); } }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentTrusted(Document samlDocument, String issuer) throws KeyStoreException, InvalidAlgorithmParameterException, CertificateException, NoSuchAlgorithmException, MarshalException { return isSignatureTrusted(getSignature(samlDocument), issuer); } }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentTrusted(Document samlDocument, String issuer) throws KeyStoreException, InvalidAlgorithmParameterException, CertificateException, NoSuchAlgorithmException, MarshalException { return isSignatureTrusted(getSignature(samlDocument), issuer); } @Override boolean isSignatureTrusted(XMLSignature signature, String issuer); @Override boolean isDocumentTrustedAndValid(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Element element, String issuer); @Override boolean isDocumentValid(Document samlDocument); @Override boolean isSignatureValid(Document samlDocument); @Override Document signDocumentWithSAMLSigner(Document samlDocument, SAML2Signer signer); }
DefaultSAML2Validator implements SAML2Validator { @Override public boolean isDocumentTrusted(Document samlDocument, String issuer) throws KeyStoreException, InvalidAlgorithmParameterException, CertificateException, NoSuchAlgorithmException, MarshalException { return isSignatureTrusted(getSignature(samlDocument), issuer); } @Override boolean isSignatureTrusted(XMLSignature signature, String issuer); @Override boolean isDocumentTrustedAndValid(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Document samlDocument, String issuer); @Override boolean isDocumentTrusted(Element element, String issuer); @Override boolean isDocumentValid(Document samlDocument); @Override boolean isSignatureValid(Document samlDocument); @Override Document signDocumentWithSAMLSigner(Document samlDocument, SAML2Signer signer); }
@Test public void testInitMigration() { initMockMigration(); Mockito.verify(mongoTemplate, Mockito.times(1)).updateFirst(Mockito.any(Query.class), Mockito.any(Update.class), Mockito.any(String.class)); Mockito.verify(mongoTemplate, Mockito.times(1)).insert(Mockito.any(Object.class), Mockito.any(String.class)); }
@PostConstruct public void initMigration() { this.detectMigrations(); this.migrationStrategyMap = this.buildMigrationStrategyMap(); this.warnForEachMissingMigrationStrategyList(); }
SliSchemaVersionValidator { @PostConstruct public void initMigration() { this.detectMigrations(); this.migrationStrategyMap = this.buildMigrationStrategyMap(); this.warnForEachMissingMigrationStrategyList(); } }
SliSchemaVersionValidator { @PostConstruct public void initMigration() { this.detectMigrations(); this.migrationStrategyMap = this.buildMigrationStrategyMap(); this.warnForEachMissingMigrationStrategyList(); } }
SliSchemaVersionValidator { @PostConstruct public void initMigration() { this.detectMigrations(); this.migrationStrategyMap = this.buildMigrationStrategyMap(); this.warnForEachMissingMigrationStrategyList(); } void insertVersionInformation(Entity entity); @PostConstruct void initMigration(); Entity migrate(String collectionName, Entity entity, ValidationWithoutNaturalKeys repo); Iterable<Entity> migrate(String collectionName, Iterable<Entity> entities, ValidationWithoutNaturalKeys repo); MongoTemplate getMongoTemplate(); void setMongoTemplate(MongoTemplate mongoTemplate); }
SliSchemaVersionValidator { @PostConstruct public void initMigration() { this.detectMigrations(); this.migrationStrategyMap = this.buildMigrationStrategyMap(); this.warnForEachMissingMigrationStrategyList(); } void insertVersionInformation(Entity entity); @PostConstruct void initMigration(); Entity migrate(String collectionName, Entity entity, ValidationWithoutNaturalKeys repo); Iterable<Entity> migrate(String collectionName, Iterable<Entity> entities, ValidationWithoutNaturalKeys repo); MongoTemplate getMongoTemplate(); void setMongoTemplate(MongoTemplate mongoTemplate); static final String SARJE; static final String DAL_SV; static final String ID; static final String MONGO_SV; static final String METADATA_COLLECTION; }
@Test public void testIsMigrationNeeded() { String entityType = "student"; Entity entity = new MongoEntity("student", new HashMap<String, Object>()); initMockMigration(); assertTrue("Should be true", sliSchemaVersionValidator.isMigrationNeeded(entityType, entity)); Map<String, Object> metaData = new HashMap<String, Object>(); metaData.put("version", 5); entity = new MongoEntity("student", "someId", new HashMap<String, Object>(), metaData); assertFalse("Should be false", sliSchemaVersionValidator.isMigrationNeeded(entityType, entity)); }
protected boolean isMigrationNeeded(String entityType, Entity entity) { if (this.entityTypesBeingMigrated.containsKey(entityType)) { int entityVersionNumber = this.getEntityVersionNumber(entity); int newVersionNumber = this.entityTypesBeingMigrated.get(entityType); if (entityVersionNumber < newVersionNumber) { return true; } } return false; }
SliSchemaVersionValidator { protected boolean isMigrationNeeded(String entityType, Entity entity) { if (this.entityTypesBeingMigrated.containsKey(entityType)) { int entityVersionNumber = this.getEntityVersionNumber(entity); int newVersionNumber = this.entityTypesBeingMigrated.get(entityType); if (entityVersionNumber < newVersionNumber) { return true; } } return false; } }
SliSchemaVersionValidator { protected boolean isMigrationNeeded(String entityType, Entity entity) { if (this.entityTypesBeingMigrated.containsKey(entityType)) { int entityVersionNumber = this.getEntityVersionNumber(entity); int newVersionNumber = this.entityTypesBeingMigrated.get(entityType); if (entityVersionNumber < newVersionNumber) { return true; } } return false; } }
SliSchemaVersionValidator { protected boolean isMigrationNeeded(String entityType, Entity entity) { if (this.entityTypesBeingMigrated.containsKey(entityType)) { int entityVersionNumber = this.getEntityVersionNumber(entity); int newVersionNumber = this.entityTypesBeingMigrated.get(entityType); if (entityVersionNumber < newVersionNumber) { return true; } } return false; } void insertVersionInformation(Entity entity); @PostConstruct void initMigration(); Entity migrate(String collectionName, Entity entity, ValidationWithoutNaturalKeys repo); Iterable<Entity> migrate(String collectionName, Iterable<Entity> entities, ValidationWithoutNaturalKeys repo); MongoTemplate getMongoTemplate(); void setMongoTemplate(MongoTemplate mongoTemplate); }
SliSchemaVersionValidator { protected boolean isMigrationNeeded(String entityType, Entity entity) { if (this.entityTypesBeingMigrated.containsKey(entityType)) { int entityVersionNumber = this.getEntityVersionNumber(entity); int newVersionNumber = this.entityTypesBeingMigrated.get(entityType); if (entityVersionNumber < newVersionNumber) { return true; } } return false; } void insertVersionInformation(Entity entity); @PostConstruct void initMigration(); Entity migrate(String collectionName, Entity entity, ValidationWithoutNaturalKeys repo); Iterable<Entity> migrate(String collectionName, Iterable<Entity> entities, ValidationWithoutNaturalKeys repo); MongoTemplate getMongoTemplate(); void setMongoTemplate(MongoTemplate mongoTemplate); static final String SARJE; static final String DAL_SV; static final String ID; static final String MONGO_SV; static final String METADATA_COLLECTION; }
@Test @SuppressWarnings("unchecked") public void testParsing() throws Throwable { Resource schema = new ClassPathResource("edfiXsd-SLI/SLI-Interchange-StudentParent.xsd"); Resource xml = new ClassPathResource("parser/InterchangeStudentParent/Student.xml"); RecordVisitor mockVisitor = Mockito.mock(RecordVisitor.class); EdfiRecordUnmarshaller.parse(xml.getInputStream(), schema, tp, mockVisitor, new DummyMessageReport(), new SimpleReportStats(), new JobSource(xml.getFilename())); verify(mockVisitor, atLeastOnce()).visit(any(RecordMeta.class), anyMap()); }
public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } EdfiRecordUnmarshaller(TypeProvider typeProvider, AbstractMessageReport messageReport, ReportStats reportStats, Source source); }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } EdfiRecordUnmarshaller(TypeProvider typeProvider, AbstractMessageReport messageReport, ReportStats reportStats, Source source); static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source); @Override void setDocumentLocator(Locator locator); @Override void startElement(String uri, String localName, String qName, Attributes attributes); @Override void endElement(String uri, String localName, String qName); @Override void characters(char[] ch, int start, int length); Location getCurrentLocation(); @Override void error(SAXParseException exception); @Override void fatalError(SAXParseException exception); void addVisitor(RecordVisitor recordVisitor); }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } EdfiRecordUnmarshaller(TypeProvider typeProvider, AbstractMessageReport messageReport, ReportStats reportStats, Source source); static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source); @Override void setDocumentLocator(Locator locator); @Override void startElement(String uri, String localName, String qName, Attributes attributes); @Override void endElement(String uri, String localName, String qName); @Override void characters(char[] ch, int start, int length); Location getCurrentLocation(); @Override void error(SAXParseException exception); @Override void fatalError(SAXParseException exception); void addVisitor(RecordVisitor recordVisitor); }
@Test public void testPerformMigration() { String entityType = "student"; String collectionName = "student"; Entity entity = new MongoEntity("student", new HashMap<String, Object>()); ValidationWithoutNaturalKeys repo = mock(ValidationWithoutNaturalKeys.class); when(repo.updateWithoutValidatingNaturalKeys(anyString(), any(Entity.class))).thenReturn(true); initMockMigration(); sliSchemaVersionValidator.performMigration(entityType, entity, repo, collectionName, false); Mockito.verify(repo, never()).updateWithoutValidatingNaturalKeys(anyString(), any(Entity.class)); sliSchemaVersionValidator.performMigration(entityType, entity, repo, collectionName, true); Mockito.verify(repo, Mockito.times(1)).updateWithoutValidatingNaturalKeys(anyString(), any(Entity.class)); }
protected Entity performMigration(String entityType, Entity entity, ValidationWithoutNaturalKeys repo, String collectionName, boolean doUpdate) { int newVersionNumber = this.entityTypesBeingMigrated.get(entityType); int entityVersionNumber = this.getEntityVersionNumber(entity); Entity localEntity = entity; for (MigrationStrategy migrationStrategy : this.getMigrationStrategies(entityType, entityVersionNumber, newVersionNumber)) { localEntity = (Entity) migrationStrategy.migrate(localEntity); } localEntity.getMetaData().put(VERSION_NUMBER_FIELD, newVersionNumber); if (doUpdate) { repo.updateWithoutValidatingNaturalKeys(collectionName, localEntity); } return localEntity; }
SliSchemaVersionValidator { protected Entity performMigration(String entityType, Entity entity, ValidationWithoutNaturalKeys repo, String collectionName, boolean doUpdate) { int newVersionNumber = this.entityTypesBeingMigrated.get(entityType); int entityVersionNumber = this.getEntityVersionNumber(entity); Entity localEntity = entity; for (MigrationStrategy migrationStrategy : this.getMigrationStrategies(entityType, entityVersionNumber, newVersionNumber)) { localEntity = (Entity) migrationStrategy.migrate(localEntity); } localEntity.getMetaData().put(VERSION_NUMBER_FIELD, newVersionNumber); if (doUpdate) { repo.updateWithoutValidatingNaturalKeys(collectionName, localEntity); } return localEntity; } }
SliSchemaVersionValidator { protected Entity performMigration(String entityType, Entity entity, ValidationWithoutNaturalKeys repo, String collectionName, boolean doUpdate) { int newVersionNumber = this.entityTypesBeingMigrated.get(entityType); int entityVersionNumber = this.getEntityVersionNumber(entity); Entity localEntity = entity; for (MigrationStrategy migrationStrategy : this.getMigrationStrategies(entityType, entityVersionNumber, newVersionNumber)) { localEntity = (Entity) migrationStrategy.migrate(localEntity); } localEntity.getMetaData().put(VERSION_NUMBER_FIELD, newVersionNumber); if (doUpdate) { repo.updateWithoutValidatingNaturalKeys(collectionName, localEntity); } return localEntity; } }
SliSchemaVersionValidator { protected Entity performMigration(String entityType, Entity entity, ValidationWithoutNaturalKeys repo, String collectionName, boolean doUpdate) { int newVersionNumber = this.entityTypesBeingMigrated.get(entityType); int entityVersionNumber = this.getEntityVersionNumber(entity); Entity localEntity = entity; for (MigrationStrategy migrationStrategy : this.getMigrationStrategies(entityType, entityVersionNumber, newVersionNumber)) { localEntity = (Entity) migrationStrategy.migrate(localEntity); } localEntity.getMetaData().put(VERSION_NUMBER_FIELD, newVersionNumber); if (doUpdate) { repo.updateWithoutValidatingNaturalKeys(collectionName, localEntity); } return localEntity; } void insertVersionInformation(Entity entity); @PostConstruct void initMigration(); Entity migrate(String collectionName, Entity entity, ValidationWithoutNaturalKeys repo); Iterable<Entity> migrate(String collectionName, Iterable<Entity> entities, ValidationWithoutNaturalKeys repo); MongoTemplate getMongoTemplate(); void setMongoTemplate(MongoTemplate mongoTemplate); }
SliSchemaVersionValidator { protected Entity performMigration(String entityType, Entity entity, ValidationWithoutNaturalKeys repo, String collectionName, boolean doUpdate) { int newVersionNumber = this.entityTypesBeingMigrated.get(entityType); int entityVersionNumber = this.getEntityVersionNumber(entity); Entity localEntity = entity; for (MigrationStrategy migrationStrategy : this.getMigrationStrategies(entityType, entityVersionNumber, newVersionNumber)) { localEntity = (Entity) migrationStrategy.migrate(localEntity); } localEntity.getMetaData().put(VERSION_NUMBER_FIELD, newVersionNumber); if (doUpdate) { repo.updateWithoutValidatingNaturalKeys(collectionName, localEntity); } return localEntity; } void insertVersionInformation(Entity entity); @PostConstruct void initMigration(); Entity migrate(String collectionName, Entity entity, ValidationWithoutNaturalKeys repo); Iterable<Entity> migrate(String collectionName, Iterable<Entity> entities, ValidationWithoutNaturalKeys repo); MongoTemplate getMongoTemplate(); void setMongoTemplate(MongoTemplate mongoTemplate); static final String SARJE; static final String DAL_SV; static final String ID; static final String MONGO_SV; static final String METADATA_COLLECTION; }
@Test public void testGetMigrationStrategies() { initMockMigration(); Entity entity = new MongoEntity("staff", new HashMap<String, Object>()); List<MigrationStrategy> strategies = sliSchemaVersionValidator.getMigrationStrategies("staff", 0, 2); assertEquals("Should match", 1, strategies.size()); assertTrue("Should be true", strategies.get(0) instanceof AddStrategy); assertTrue("Should be true", checkEntity((Entity) strategies.get(0).migrate(entity), "somefield", "somevalue")); entity = new MongoEntity("staff", new HashMap<String, Object>()); strategies = sliSchemaVersionValidator.getMigrationStrategies("staff", 0, 3); assertEquals("Should match", 2, strategies.size()); assertTrue("Should be true", strategies.get(0) instanceof AddStrategy); assertTrue("Should be true", checkEntity((Entity) strategies.get(0).migrate(entity), "somefield", "somevalue")); assertTrue("Should be true", strategies.get(1) instanceof AddStrategy); assertTrue("Should be true", checkEntity((Entity) strategies.get(1).migrate(entity), "favoriteColor", "yellow")); entity = new MongoEntity("staff", new HashMap<String, Object>()); strategies = sliSchemaVersionValidator.getMigrationStrategies("staff", 0, 4); assertEquals("Should match", 3, strategies.size()); assertTrue("Should be true", strategies.get(0) instanceof AddStrategy); assertTrue("Should be true", checkEntity((Entity) strategies.get(0).migrate(entity), "somefield", "somevalue")); assertTrue("Should be true", strategies.get(1) instanceof AddStrategy); assertTrue("Should be true", checkEntity((Entity) strategies.get(1).migrate(entity), "favoriteColor", "yellow")); assertTrue("Should be true", strategies.get(2) instanceof AddStrategy); assertTrue("Should be true", checkEntity((Entity) strategies.get(2).migrate(entity), "mascot", "red")); entity = new MongoEntity("staff", new HashMap<String, Object>()); strategies = sliSchemaVersionValidator.getMigrationStrategies("staff", 3, 4); assertEquals("Should match", 1, strategies.size()); assertTrue("Should be true", strategies.get(0) instanceof AddStrategy); assertTrue("Should be true", checkEntity((Entity) strategies.get(0).migrate(entity), "mascot", "red")); strategies = sliSchemaVersionValidator.getMigrationStrategies("staff", 0, 1); assertEquals("Should match", 0, strategies.size()); entity = new MongoEntity("staff", new HashMap<String, Object>()); strategies = sliSchemaVersionValidator.getMigrationStrategies("staff", 2, 4); assertEquals("Should match", 2, strategies.size()); assertTrue("Should be true", strategies.get(0) instanceof AddStrategy); assertTrue("Should be true", checkEntity((Entity) strategies.get(0).migrate(entity), "favoriteColor", "yellow")); assertTrue("Should be true", strategies.get(1) instanceof AddStrategy); assertTrue("Should be true", checkEntity((Entity) strategies.get(1).migrate(entity), "mascot", "red")); strategies = sliSchemaVersionValidator.getMigrationStrategies("staff", 3, 1); assertEquals("Should match", 0, strategies.size()); }
protected List<MigrationStrategy> getMigrationStrategies(String entityType, int entityVersionNumber, int newVersionNumber) { Map<String, List<MigrationStrategy>> entityMigrations = migrationStrategyMap.get(entityType); List<MigrationStrategy> allStrategies = new LinkedList<MigrationStrategy>(); if (entityMigrations != null) { for (Integer version = entityVersionNumber+1; version <= newVersionNumber; version++) { List<MigrationStrategy> strategies = entityMigrations.get(version.toString()); if (strategies != null) { allStrategies.addAll(strategies); } } if (!allStrategies.isEmpty()) { return allStrategies; } } return NO_STRATEGIES_DEFINED; }
SliSchemaVersionValidator { protected List<MigrationStrategy> getMigrationStrategies(String entityType, int entityVersionNumber, int newVersionNumber) { Map<String, List<MigrationStrategy>> entityMigrations = migrationStrategyMap.get(entityType); List<MigrationStrategy> allStrategies = new LinkedList<MigrationStrategy>(); if (entityMigrations != null) { for (Integer version = entityVersionNumber+1; version <= newVersionNumber; version++) { List<MigrationStrategy> strategies = entityMigrations.get(version.toString()); if (strategies != null) { allStrategies.addAll(strategies); } } if (!allStrategies.isEmpty()) { return allStrategies; } } return NO_STRATEGIES_DEFINED; } }
SliSchemaVersionValidator { protected List<MigrationStrategy> getMigrationStrategies(String entityType, int entityVersionNumber, int newVersionNumber) { Map<String, List<MigrationStrategy>> entityMigrations = migrationStrategyMap.get(entityType); List<MigrationStrategy> allStrategies = new LinkedList<MigrationStrategy>(); if (entityMigrations != null) { for (Integer version = entityVersionNumber+1; version <= newVersionNumber; version++) { List<MigrationStrategy> strategies = entityMigrations.get(version.toString()); if (strategies != null) { allStrategies.addAll(strategies); } } if (!allStrategies.isEmpty()) { return allStrategies; } } return NO_STRATEGIES_DEFINED; } }
SliSchemaVersionValidator { protected List<MigrationStrategy> getMigrationStrategies(String entityType, int entityVersionNumber, int newVersionNumber) { Map<String, List<MigrationStrategy>> entityMigrations = migrationStrategyMap.get(entityType); List<MigrationStrategy> allStrategies = new LinkedList<MigrationStrategy>(); if (entityMigrations != null) { for (Integer version = entityVersionNumber+1; version <= newVersionNumber; version++) { List<MigrationStrategy> strategies = entityMigrations.get(version.toString()); if (strategies != null) { allStrategies.addAll(strategies); } } if (!allStrategies.isEmpty()) { return allStrategies; } } return NO_STRATEGIES_DEFINED; } void insertVersionInformation(Entity entity); @PostConstruct void initMigration(); Entity migrate(String collectionName, Entity entity, ValidationWithoutNaturalKeys repo); Iterable<Entity> migrate(String collectionName, Iterable<Entity> entities, ValidationWithoutNaturalKeys repo); MongoTemplate getMongoTemplate(); void setMongoTemplate(MongoTemplate mongoTemplate); }
SliSchemaVersionValidator { protected List<MigrationStrategy> getMigrationStrategies(String entityType, int entityVersionNumber, int newVersionNumber) { Map<String, List<MigrationStrategy>> entityMigrations = migrationStrategyMap.get(entityType); List<MigrationStrategy> allStrategies = new LinkedList<MigrationStrategy>(); if (entityMigrations != null) { for (Integer version = entityVersionNumber+1; version <= newVersionNumber; version++) { List<MigrationStrategy> strategies = entityMigrations.get(version.toString()); if (strategies != null) { allStrategies.addAll(strategies); } } if (!allStrategies.isEmpty()) { return allStrategies; } } return NO_STRATEGIES_DEFINED; } void insertVersionInformation(Entity entity); @PostConstruct void initMigration(); Entity migrate(String collectionName, Entity entity, ValidationWithoutNaturalKeys repo); Iterable<Entity> migrate(String collectionName, Iterable<Entity> entities, ValidationWithoutNaturalKeys repo); MongoTemplate getMongoTemplate(); void setMongoTemplate(MongoTemplate mongoTemplate); static final String SARJE; static final String DAL_SV; static final String ID; static final String MONGO_SV; static final String METADATA_COLLECTION; }
@Test public void testLoadNonExistentFile() { String testFile = "nonExistent"; InputStream in = getClass().getResourceAsStream(testFile); String out = aggregationLoader.loadJavascriptFile(in); assertEquals("", out); }
protected String loadJavascriptFile(InputStream in) { try { if (in == null) { return ""; } StringBuffer fileData = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String temp = br.readLine(); while (temp != null) { fileData.append(temp); fileData.append("\n"); temp = br.readLine(); } br.close(); fileData.append("\n"); return fileData.toString(); } catch (IOException ioe) { LOG.debug("Failed to load definition file"); return ""; } }
AggregationLoader { protected String loadJavascriptFile(InputStream in) { try { if (in == null) { return ""; } StringBuffer fileData = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String temp = br.readLine(); while (temp != null) { fileData.append(temp); fileData.append("\n"); temp = br.readLine(); } br.close(); fileData.append("\n"); return fileData.toString(); } catch (IOException ioe) { LOG.debug("Failed to load definition file"); return ""; } } }
AggregationLoader { protected String loadJavascriptFile(InputStream in) { try { if (in == null) { return ""; } StringBuffer fileData = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String temp = br.readLine(); while (temp != null) { fileData.append(temp); fileData.append("\n"); temp = br.readLine(); } br.close(); fileData.append("\n"); return fileData.toString(); } catch (IOException ioe) { LOG.debug("Failed to load definition file"); return ""; } } }
AggregationLoader { protected String loadJavascriptFile(InputStream in) { try { if (in == null) { return ""; } StringBuffer fileData = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String temp = br.readLine(); while (temp != null) { fileData.append(temp); fileData.append("\n"); temp = br.readLine(); } br.close(); fileData.append("\n"); return fileData.toString(); } catch (IOException ioe) { LOG.debug("Failed to load definition file"); return ""; } } void init(); }
AggregationLoader { protected String loadJavascriptFile(InputStream in) { try { if (in == null) { return ""; } StringBuffer fileData = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String temp = br.readLine(); while (temp != null) { fileData.append(temp); fileData.append("\n"); temp = br.readLine(); } br.close(); fileData.append("\n"); return fileData.toString(); } catch (IOException ioe) { LOG.debug("Failed to load definition file"); return ""; } } void init(); }
@Test public void testGetSystemConnection() { Mongo mongo = Mockito.mock(Mongo.class); DB db = Mockito.mock(DB.class); Mockito.when(db.getMongo()).thenReturn(mongo); Mockito.when(db.getName()).thenReturn("System"); Mockito.when(mongo.getDB(Mockito.anyString())).thenReturn(db); TenantAwareMongoDbFactory cm = new TenantAwareMongoDbFactory(mongo, "System"); Assert.assertNotNull(cm.getDb()); Assert.assertSame("System", cm.getDb().getName()); }
@Override public DB getDb() throws DataAccessException { String tenantId = TenantContext.getTenantId(); boolean isSystemCall = TenantContext.isSystemCall(); if (isSystemCall || tenantId == null) { return super.getDb(); } else { return super.getDb(getTenantDatabaseName(tenantId)); } }
TenantAwareMongoDbFactory extends SimpleMongoDbFactory { @Override public DB getDb() throws DataAccessException { String tenantId = TenantContext.getTenantId(); boolean isSystemCall = TenantContext.isSystemCall(); if (isSystemCall || tenantId == null) { return super.getDb(); } else { return super.getDb(getTenantDatabaseName(tenantId)); } } }
TenantAwareMongoDbFactory extends SimpleMongoDbFactory { @Override public DB getDb() throws DataAccessException { String tenantId = TenantContext.getTenantId(); boolean isSystemCall = TenantContext.isSystemCall(); if (isSystemCall || tenantId == null) { return super.getDb(); } else { return super.getDb(getTenantDatabaseName(tenantId)); } } TenantAwareMongoDbFactory(Mongo mongo, String systemDatabaseName); }
TenantAwareMongoDbFactory extends SimpleMongoDbFactory { @Override public DB getDb() throws DataAccessException { String tenantId = TenantContext.getTenantId(); boolean isSystemCall = TenantContext.isSystemCall(); if (isSystemCall || tenantId == null) { return super.getDb(); } else { return super.getDb(getTenantDatabaseName(tenantId)); } } TenantAwareMongoDbFactory(Mongo mongo, String systemDatabaseName); @Override DB getDb(); static String getTenantDatabaseName(String tenantId); }
TenantAwareMongoDbFactory extends SimpleMongoDbFactory { @Override public DB getDb() throws DataAccessException { String tenantId = TenantContext.getTenantId(); boolean isSystemCall = TenantContext.isSystemCall(); if (isSystemCall || tenantId == null) { return super.getDb(); } else { return super.getDb(getTenantDatabaseName(tenantId)); } } TenantAwareMongoDbFactory(Mongo mongo, String systemDatabaseName); @Override DB getDb(); static String getTenantDatabaseName(String tenantId); }
@Test public void testKeyPrefixing() { NeutralCriteria neutralCriteria1 = new NeutralCriteria("metadata.x", "=", "1"); NeutralCriteria neutralCriteria2 = new NeutralCriteria("metadata.x", "=", "1", false); NeutralCriteria neutralCriteria3 = new NeutralCriteria("_id", "=", "1"); NeutralCriteria neutralCriteria4 = new NeutralCriteria("metadata._id", "=", "1"); assertEquals(MongoQueryConverter.prefixKey(neutralCriteria1), "body.metadata.x"); assertEquals(MongoQueryConverter.prefixKey(neutralCriteria2), "metadata.x"); assertEquals(MongoQueryConverter.prefixKey(neutralCriteria3), "_id"); assertEquals(MongoQueryConverter.prefixKey(neutralCriteria4), "body.metadata._id"); }
protected static String prefixKey(NeutralCriteria neutralCriteria) { LOG.debug(">>>MongoQueryConverter.prefixKey()"); String key = neutralCriteria.getKey(); if (key.equals(MONGO_ID)) { return key; } else if (neutralCriteria.canBePrefixed()) { return MONGO_BODY + key; } else { return key; } }
MongoQueryConverter { protected static String prefixKey(NeutralCriteria neutralCriteria) { LOG.debug(">>>MongoQueryConverter.prefixKey()"); String key = neutralCriteria.getKey(); if (key.equals(MONGO_ID)) { return key; } else if (neutralCriteria.canBePrefixed()) { return MONGO_BODY + key; } else { return key; } } }
MongoQueryConverter { protected static String prefixKey(NeutralCriteria neutralCriteria) { LOG.debug(">>>MongoQueryConverter.prefixKey()"); String key = neutralCriteria.getKey(); if (key.equals(MONGO_ID)) { return key; } else if (neutralCriteria.canBePrefixed()) { return MONGO_BODY + key; } else { return key; } } MongoQueryConverter(); }
MongoQueryConverter { protected static String prefixKey(NeutralCriteria neutralCriteria) { LOG.debug(">>>MongoQueryConverter.prefixKey()"); String key = neutralCriteria.getKey(); if (key.equals(MONGO_ID)) { return key; } else if (neutralCriteria.canBePrefixed()) { return MONGO_BODY + key; } else { return key; } } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { protected static String prefixKey(NeutralCriteria neutralCriteria) { LOG.debug(">>>MongoQueryConverter.prefixKey()"); String key = neutralCriteria.getKey(); if (key.equals(MONGO_ID)) { return key; } else if (neutralCriteria.canBePrefixed()) { return MONGO_BODY + key; } else { return key; } } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test public void testMergeCriteria() { NeutralCriteria neutralCriteria1 = new NeutralCriteria("eventDate", ">=", "2011-09-08"); NeutralCriteria neutralCriteria2 = new NeutralCriteria("eventDate", "<=", "2012-04-08"); List<NeutralCriteria> list = new ArrayList<NeutralCriteria>(); list.add(neutralCriteria1); list.add(neutralCriteria2); Map<String, List<NeutralCriteria>> map = new HashMap<String, List<NeutralCriteria>>(); map.put("eventDate", list); List<Criteria> criteriaMerged = mongoQueryConverter.mergeCriteria(map); assertNotNull("Should not be null", criteriaMerged); assertNotNull("Should not be null", criteriaMerged.get(0)); DBObject obj = criteriaMerged.get(0).getCriteriaObject(); assertTrue("Should not be null", obj.containsField("body.eventDate")); DBObject criteria = (DBObject) obj.get("body.eventDate"); assertNotNull("Should not be null", criteria.get("$gte")); assertNotNull("Should not be null", criteria.get("$lte")); }
protected List<Criteria> mergeCriteria(Map<String, List<NeutralCriteria>> criteriaForFields) { LOG.debug(">>>MongoQueryConverter.mergeCriteria()"); List<Criteria> criteriaList = new ArrayList<Criteria>(); if (criteriaForFields != null) { for (Map.Entry<String, List<NeutralCriteria>> e : criteriaForFields.entrySet()) { List<NeutralCriteria> list = e.getValue(); if (list != null) { Criteria fullCriteria = null; for (NeutralCriteria criteria : list) { fullCriteria = operatorImplementations.get( criteria.getOperator()).generateCriteria(criteria, fullCriteria); } criteriaList.add(fullCriteria); } } } return criteriaList; }
MongoQueryConverter { protected List<Criteria> mergeCriteria(Map<String, List<NeutralCriteria>> criteriaForFields) { LOG.debug(">>>MongoQueryConverter.mergeCriteria()"); List<Criteria> criteriaList = new ArrayList<Criteria>(); if (criteriaForFields != null) { for (Map.Entry<String, List<NeutralCriteria>> e : criteriaForFields.entrySet()) { List<NeutralCriteria> list = e.getValue(); if (list != null) { Criteria fullCriteria = null; for (NeutralCriteria criteria : list) { fullCriteria = operatorImplementations.get( criteria.getOperator()).generateCriteria(criteria, fullCriteria); } criteriaList.add(fullCriteria); } } } return criteriaList; } }
MongoQueryConverter { protected List<Criteria> mergeCriteria(Map<String, List<NeutralCriteria>> criteriaForFields) { LOG.debug(">>>MongoQueryConverter.mergeCriteria()"); List<Criteria> criteriaList = new ArrayList<Criteria>(); if (criteriaForFields != null) { for (Map.Entry<String, List<NeutralCriteria>> e : criteriaForFields.entrySet()) { List<NeutralCriteria> list = e.getValue(); if (list != null) { Criteria fullCriteria = null; for (NeutralCriteria criteria : list) { fullCriteria = operatorImplementations.get( criteria.getOperator()).generateCriteria(criteria, fullCriteria); } criteriaList.add(fullCriteria); } } } return criteriaList; } MongoQueryConverter(); }
MongoQueryConverter { protected List<Criteria> mergeCriteria(Map<String, List<NeutralCriteria>> criteriaForFields) { LOG.debug(">>>MongoQueryConverter.mergeCriteria()"); List<Criteria> criteriaList = new ArrayList<Criteria>(); if (criteriaForFields != null) { for (Map.Entry<String, List<NeutralCriteria>> e : criteriaForFields.entrySet()) { List<NeutralCriteria> list = e.getValue(); if (list != null) { Criteria fullCriteria = null; for (NeutralCriteria criteria : list) { fullCriteria = operatorImplementations.get( criteria.getOperator()).generateCriteria(criteria, fullCriteria); } criteriaList.add(fullCriteria); } } } return criteriaList; } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { protected List<Criteria> mergeCriteria(Map<String, List<NeutralCriteria>> criteriaForFields) { LOG.debug(">>>MongoQueryConverter.mergeCriteria()"); List<Criteria> criteriaList = new ArrayList<Criteria>(); if (criteriaForFields != null) { for (Map.Entry<String, List<NeutralCriteria>> e : criteriaForFields.entrySet()) { List<NeutralCriteria> list = e.getValue(); if (list != null) { Criteria fullCriteria = null; for (NeutralCriteria criteria : list) { fullCriteria = operatorImplementations.get( criteria.getOperator()).generateCriteria(criteria, fullCriteria); } criteriaList.add(fullCriteria); } } } return criteriaList; } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test public void testNullMergeCriteria() { List<Criteria> criteriaMerged = mongoQueryConverter.mergeCriteria(null); assertNotNull("Should not be null", criteriaMerged); assertEquals("Should match", 0, criteriaMerged.size()); }
protected List<Criteria> mergeCriteria(Map<String, List<NeutralCriteria>> criteriaForFields) { LOG.debug(">>>MongoQueryConverter.mergeCriteria()"); List<Criteria> criteriaList = new ArrayList<Criteria>(); if (criteriaForFields != null) { for (Map.Entry<String, List<NeutralCriteria>> e : criteriaForFields.entrySet()) { List<NeutralCriteria> list = e.getValue(); if (list != null) { Criteria fullCriteria = null; for (NeutralCriteria criteria : list) { fullCriteria = operatorImplementations.get( criteria.getOperator()).generateCriteria(criteria, fullCriteria); } criteriaList.add(fullCriteria); } } } return criteriaList; }
MongoQueryConverter { protected List<Criteria> mergeCriteria(Map<String, List<NeutralCriteria>> criteriaForFields) { LOG.debug(">>>MongoQueryConverter.mergeCriteria()"); List<Criteria> criteriaList = new ArrayList<Criteria>(); if (criteriaForFields != null) { for (Map.Entry<String, List<NeutralCriteria>> e : criteriaForFields.entrySet()) { List<NeutralCriteria> list = e.getValue(); if (list != null) { Criteria fullCriteria = null; for (NeutralCriteria criteria : list) { fullCriteria = operatorImplementations.get( criteria.getOperator()).generateCriteria(criteria, fullCriteria); } criteriaList.add(fullCriteria); } } } return criteriaList; } }
MongoQueryConverter { protected List<Criteria> mergeCriteria(Map<String, List<NeutralCriteria>> criteriaForFields) { LOG.debug(">>>MongoQueryConverter.mergeCriteria()"); List<Criteria> criteriaList = new ArrayList<Criteria>(); if (criteriaForFields != null) { for (Map.Entry<String, List<NeutralCriteria>> e : criteriaForFields.entrySet()) { List<NeutralCriteria> list = e.getValue(); if (list != null) { Criteria fullCriteria = null; for (NeutralCriteria criteria : list) { fullCriteria = operatorImplementations.get( criteria.getOperator()).generateCriteria(criteria, fullCriteria); } criteriaList.add(fullCriteria); } } } return criteriaList; } MongoQueryConverter(); }
MongoQueryConverter { protected List<Criteria> mergeCriteria(Map<String, List<NeutralCriteria>> criteriaForFields) { LOG.debug(">>>MongoQueryConverter.mergeCriteria()"); List<Criteria> criteriaList = new ArrayList<Criteria>(); if (criteriaForFields != null) { for (Map.Entry<String, List<NeutralCriteria>> e : criteriaForFields.entrySet()) { List<NeutralCriteria> list = e.getValue(); if (list != null) { Criteria fullCriteria = null; for (NeutralCriteria criteria : list) { fullCriteria = operatorImplementations.get( criteria.getOperator()).generateCriteria(criteria, fullCriteria); } criteriaList.add(fullCriteria); } } } return criteriaList; } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { protected List<Criteria> mergeCriteria(Map<String, List<NeutralCriteria>> criteriaForFields) { LOG.debug(">>>MongoQueryConverter.mergeCriteria()"); List<Criteria> criteriaList = new ArrayList<Criteria>(); if (criteriaForFields != null) { for (Map.Entry<String, List<NeutralCriteria>> e : criteriaForFields.entrySet()) { List<NeutralCriteria> list = e.getValue(); if (list != null) { Criteria fullCriteria = null; for (NeutralCriteria criteria : list) { fullCriteria = operatorImplementations.get( criteria.getOperator()).generateCriteria(criteria, fullCriteria); } criteriaList.add(fullCriteria); } } } return criteriaList; } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test public void testIncludeFieldConvert() { NeutralQuery neutralQuery = new NeutralQuery(); neutralQuery.setIncludeFieldString("populationServed,uniqueSectionCode"); Query query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); DBObject obj = query.getFieldsObject(); assertNotNull("Should not be null", obj); assertEquals("Should match", 1, obj.get("body.populationServed")); assertEquals("Should match", 1, obj.get("body.uniqueSectionCode")); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test public void testOffsetAndLimitConvert() { NeutralQuery neutralQuery = new NeutralQuery(); neutralQuery.setOffset(10); neutralQuery.setLimit(100); Query query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); assertEquals("Should match", 10, query.getSkip()); assertEquals("Should match", 100, query.getLimit()); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test public void testSortConvert() { NeutralQuery neutralQuery = new NeutralQuery(); neutralQuery.setSortBy("populationServed"); neutralQuery.setSortOrder(NeutralQuery.SortOrder.ascending); Query query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); DBObject obj = query.getSortObject(); assertEquals("Should match", 1, obj.get("body.populationServed")); neutralQuery = new NeutralQuery(); neutralQuery.setSortBy("populationServed"); neutralQuery.setSortOrder(NeutralQuery.SortOrder.descending); query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); obj = query.getSortObject(); assertEquals("Should match", -1, obj.get("body.populationServed")); neutralQuery = new NeutralQuery(); neutralQuery.setSortBy(null); query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); assertNull("Should be null", query.getSortObject()); neutralQuery = new NeutralQuery(); neutralQuery.setSortBy("populationServed"); neutralQuery.setSortOrder(null); query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); obj = query.getSortObject(); assertEquals("Should match", 1, obj.get("body.populationServed")); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test(expected = IOException.class) public void testIOExceptionForSchema() throws Throwable { Resource schema = new ClassPathResource("does_not_exists.xsd"); Resource xml = new ClassPathResource("parser/InterchangeStudentParent/Student.xml"); RecordVisitor mockVisitor = Mockito.mock(RecordVisitor.class); EdfiRecordUnmarshaller.parse(xml.getInputStream(), schema, tp, mockVisitor, new DummyMessageReport(), new SimpleReportStats(), new JobSource(xml.getFilename())); }
public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } EdfiRecordUnmarshaller(TypeProvider typeProvider, AbstractMessageReport messageReport, ReportStats reportStats, Source source); }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } EdfiRecordUnmarshaller(TypeProvider typeProvider, AbstractMessageReport messageReport, ReportStats reportStats, Source source); static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source); @Override void setDocumentLocator(Locator locator); @Override void startElement(String uri, String localName, String qName, Attributes attributes); @Override void endElement(String uri, String localName, String qName); @Override void characters(char[] ch, int start, int length); Location getCurrentLocation(); @Override void error(SAXParseException exception); @Override void fatalError(SAXParseException exception); void addVisitor(RecordVisitor recordVisitor); }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } EdfiRecordUnmarshaller(TypeProvider typeProvider, AbstractMessageReport messageReport, ReportStats reportStats, Source source); static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source); @Override void setDocumentLocator(Locator locator); @Override void startElement(String uri, String localName, String qName, Attributes attributes); @Override void endElement(String uri, String localName, String qName); @Override void characters(char[] ch, int start, int length); Location getCurrentLocation(); @Override void error(SAXParseException exception); @Override void fatalError(SAXParseException exception); void addVisitor(RecordVisitor recordVisitor); }
@Test(expected = QueryParseException.class) public void testPIISort() throws QueryParseException { NeutralQuery neutralQuery = new NeutralQuery(); neutralQuery.setSortBy("birthData.birthDate"); neutralQuery.setSortOrder(NeutralQuery.SortOrder.ascending); mongoQueryConverter.convert("student", neutralQuery); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test(expected = QueryParseException.class) public void testPIISearchGreaterThan() throws QueryParseException { NeutralQuery neutralQuery = new NeutralQuery(); neutralQuery.addCriteria(new NeutralCriteria("birthData.birthDate", ">", "1960-01-01")); mongoQueryConverter.convert("student", neutralQuery); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test(expected = QueryParseException.class) public void testPIISearchLessThan() throws QueryParseException { NeutralQuery neutralQuery = new NeutralQuery(); neutralQuery.addCriteria(new NeutralCriteria("birthData.birthDate", "<", "1960-01-01")); mongoQueryConverter.convert("student", neutralQuery); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test(expected = QueryParseException.class) public void testPIISearchNotEqual() throws QueryParseException { NeutralQuery neutralQuery = new NeutralQuery(); neutralQuery.addCriteria(new NeutralCriteria("birthData.birthDate", "~", "1960-01-01")); mongoQueryConverter.convert("student", neutralQuery); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test public void testPIISearchEquals() { NeutralQuery neutralQuery = new NeutralQuery(); neutralQuery.addCriteria(new NeutralCriteria("birthData.birthDate", "=", "1960-01-01")); Query query = mongoQueryConverter.convert("student", neutralQuery); assertNotNull("Should not be null", query); DBObject obj = query.getQueryObject(); assertNotNull("Should not be null", obj); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test public void testFieldsConvert() { NeutralQuery neutralQuery = new NeutralQuery(); neutralQuery.addCriteria(new NeutralCriteria("populationServed", "=", "Regular Students")); Query query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); DBObject obj = query.getQueryObject(); assertNotNull("Should not be null", obj); assertEquals("Should match", "Regular Students", obj.get("body.populationServed")); neutralQuery = new NeutralQuery(); neutralQuery.addCriteria(new NeutralCriteria("populationServed", ">=", "Regular Students")); query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); obj = query.getQueryObject(); assertNotNull("Should not be null", obj); DBObject obj1 = (DBObject) obj.get("body.populationServed"); assertEquals("Should match", "Regular Students", obj1.get("$gte")); neutralQuery = new NeutralQuery(); neutralQuery.addCriteria(new NeutralCriteria("populationServed", "<=", "Regular Students")); query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); obj = query.getQueryObject(); assertNotNull("Should not be null", obj); obj1 = (DBObject) obj.get("body.populationServed"); assertEquals("Should match", "Regular Students", obj1.get("$lte")); List<String> list = new ArrayList<String>(); list.add("Regular Students"); list.add("Irregular Students"); neutralQuery = new NeutralQuery(); neutralQuery.addCriteria(new NeutralCriteria("populationServed", NeutralCriteria.CRITERIA_IN, list)); query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); obj = query.getQueryObject(); assertNotNull("Should not be null", obj); obj1 = (DBObject) obj.get("body.populationServed"); assertNotNull(obj1.get("$in")); neutralQuery = new NeutralQuery(); neutralQuery.addCriteria(new NeutralCriteria("populationServed", NeutralCriteria.CRITERIA_EXISTS, true)); query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); obj = query.getQueryObject(); assertNotNull("Should not be null", obj); obj1 = (DBObject) obj.get("body.populationServed"); assertNotNull(obj1.get("$exists")); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test(expected = QueryParseException.class) public void testInNotList() throws QueryParseException { NeutralQuery neutralQuery = new NeutralQuery(); neutralQuery.addCriteria(new NeutralCriteria("populationServed", NeutralCriteria.CRITERIA_IN, "Regular Students")); mongoQueryConverter.convert("section", neutralQuery); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test public void testOrConvert() { NeutralQuery mainQuery = new NeutralQuery(); mainQuery.addCriteria(new NeutralCriteria("economicDisadvantaged=true")); NeutralQuery orQuery1 = new NeutralQuery(); NeutralQuery orQuery2 = new NeutralQuery(); orQuery2.addCriteria(new NeutralCriteria("studentUniqueStateId", "=", "000000054")); mainQuery.addOrQuery(orQuery1); mainQuery.addOrQuery(orQuery2); Query query = mongoQueryConverter.convert("student", mainQuery); assertNotNull("Should not be null", query); DBObject obj = query.getQueryObject(); assertNotNull("Should not be null", obj); assertNotNull("Should not be null", obj.get("$or")); assertTrue(((BasicBSONList) obj.get("$or")).size() == 1); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test public void testEmptyIncludeFieldConvert() { NeutralQuery neutralQuery = new NeutralQuery(); Query query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); DBObject obj = query.getFieldsObject(); assertNotNull("Should not be null", obj); assertEquals("Should match", 1, obj.get("body")); assertEquals("Should match", 1, obj.get("type")); assertEquals("Should match", 1, obj.get("metaData")); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test public void testEmbeddedFieldConvert() { NeutralQuery neutralQuery = new NeutralQuery(); neutralQuery.setEmbeddedFields(Arrays.asList("studentSectionAssociation", "teacherSectionAssociation")); Query query = mongoQueryConverter.convert("section", neutralQuery); assertNotNull("Should not be null", query); DBObject obj = query.getFieldsObject(); assertNotNull("Should not be null", obj); assertEquals("Should match", 1, obj.get("studentSectionAssociation")); assertEquals("Should match", 1, obj.get("teacherSectionAssociation")); assertEquals("Should match", 1, obj.get("body")); assertEquals("Should match", 1, obj.get("type")); assertEquals("Should match", 1, obj.get("metaData")); }
public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
MongoQueryConverter { public Query convert(String entityName, NeutralQuery neutralQuery) { LOG.debug(">>>MongoQueryConverter.convery(entityName, neutralQuery)"); return convert(entityName, neutralQuery, false); } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema); }
@Test @SuppressWarnings("unchecked") public void testSourceLocation() throws Throwable { Resource schema = new ClassPathResource("edfiXsd-SLI/SLI-Interchange-StudentParent.xsd"); Resource xml = new ClassPathResource("parser/InterchangeStudentParent/ThirteenStudents.xml"); RecordVisitor mockVisitor = Mockito.mock(RecordVisitor.class); EdfiRecordUnmarshaller.parse(xml.getInputStream(), schema, tp, mockVisitor, new DummyMessageReport(), new SimpleReportStats(), new JobSource(xml.getFilename())); ArgumentCaptor<RecordMeta> recordMetaCaptor = ArgumentCaptor.forClass(RecordMeta.class); verify(mockVisitor, times(13)).visit(recordMetaCaptor.capture(), any(Map.class)); int recordCount = 0; for (RecordMeta recordMeta : recordMetaCaptor.getAllValues()) { recordCount++; if (recordCount == 11) { assertEquals(1574, recordMeta.getSourceStartLocation().getLineNumber()); assertEquals(1730, recordMeta.getSourceEndLocation().getLineNumber()); } else if (recordCount == 13) { assertEquals(1888, recordMeta.getSourceStartLocation().getLineNumber()); assertEquals(2044, recordMeta.getSourceEndLocation().getLineNumber()); } } }
public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } EdfiRecordUnmarshaller(TypeProvider typeProvider, AbstractMessageReport messageReport, ReportStats reportStats, Source source); }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } EdfiRecordUnmarshaller(TypeProvider typeProvider, AbstractMessageReport messageReport, ReportStats reportStats, Source source); static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source); @Override void setDocumentLocator(Locator locator); @Override void startElement(String uri, String localName, String qName, Attributes attributes); @Override void endElement(String uri, String localName, String qName); @Override void characters(char[] ch, int start, int length); Location getCurrentLocation(); @Override void error(SAXParseException exception); @Override void fatalError(SAXParseException exception); void addVisitor(RecordVisitor recordVisitor); }
EdfiRecordUnmarshaller extends EdfiRecordParser { public static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source) throws SAXException, IOException, XmlParseException { EdfiRecordUnmarshaller parser = new EdfiRecordUnmarshaller(typeProvider, messageReport, reportStats, source); parser.addVisitor(visitor); parser.process(input, schemaResource); } EdfiRecordUnmarshaller(TypeProvider typeProvider, AbstractMessageReport messageReport, ReportStats reportStats, Source source); static void parse(InputStream input, Resource schemaResource, TypeProvider typeProvider, RecordVisitor visitor, AbstractMessageReport messageReport, ReportStats reportStats, Source source); @Override void setDocumentLocator(Locator locator); @Override void startElement(String uri, String localName, String qName, Attributes attributes); @Override void endElement(String uri, String localName, String qName); @Override void characters(char[] ch, int start, int length); Location getCurrentLocation(); @Override void error(SAXParseException exception); @Override void fatalError(SAXParseException exception); void addVisitor(RecordVisitor recordVisitor); }
@Test(expected = MissingArgumentException.class) public void missingPortValue() throws ParseException, MissingConfigException { String[] args = new String[] { "-u", "user", "-pass", "password", "-s", "server", "-d", "localDir", "-port" }; propUtils.getUploadProperties(args); }
public UploadProperties getUploadProperties(String[] args) throws ParseException, MissingConfigException { CommandLine cmd = parser.parse(OPTIONS, args); String user = cmd.getOptionValue(FLAG_USER); if (user == null) { throw new MissingConfigException(FLAG_USER); } String password = cmd.getOptionValue(FLAG_PASSWORD); if (password == null) { throw new MissingConfigException(FLAG_PASSWORD); } String server = cmd.getOptionValue(FLAG_SFTP_SERVER); if (server == null) { throw new MissingConfigException(FLAG_SFTP_SERVER); } String localDir = cmd.getOptionValue(FLAG_LOCAL_DIRECTORY); if (localDir == null) { throw new MissingConfigException(FLAG_LOCAL_DIRECTORY); } int port; try { port = Integer.parseInt(cmd.getOptionValue(FLAG_PORT)); } catch (NumberFormatException e) { throw new MissingConfigException(FLAG_PORT); } return new UploadProperties(user, password, server, localDir, port); }
PropertyUtils { public UploadProperties getUploadProperties(String[] args) throws ParseException, MissingConfigException { CommandLine cmd = parser.parse(OPTIONS, args); String user = cmd.getOptionValue(FLAG_USER); if (user == null) { throw new MissingConfigException(FLAG_USER); } String password = cmd.getOptionValue(FLAG_PASSWORD); if (password == null) { throw new MissingConfigException(FLAG_PASSWORD); } String server = cmd.getOptionValue(FLAG_SFTP_SERVER); if (server == null) { throw new MissingConfigException(FLAG_SFTP_SERVER); } String localDir = cmd.getOptionValue(FLAG_LOCAL_DIRECTORY); if (localDir == null) { throw new MissingConfigException(FLAG_LOCAL_DIRECTORY); } int port; try { port = Integer.parseInt(cmd.getOptionValue(FLAG_PORT)); } catch (NumberFormatException e) { throw new MissingConfigException(FLAG_PORT); } return new UploadProperties(user, password, server, localDir, port); } }
PropertyUtils { public UploadProperties getUploadProperties(String[] args) throws ParseException, MissingConfigException { CommandLine cmd = parser.parse(OPTIONS, args); String user = cmd.getOptionValue(FLAG_USER); if (user == null) { throw new MissingConfigException(FLAG_USER); } String password = cmd.getOptionValue(FLAG_PASSWORD); if (password == null) { throw new MissingConfigException(FLAG_PASSWORD); } String server = cmd.getOptionValue(FLAG_SFTP_SERVER); if (server == null) { throw new MissingConfigException(FLAG_SFTP_SERVER); } String localDir = cmd.getOptionValue(FLAG_LOCAL_DIRECTORY); if (localDir == null) { throw new MissingConfigException(FLAG_LOCAL_DIRECTORY); } int port; try { port = Integer.parseInt(cmd.getOptionValue(FLAG_PORT)); } catch (NumberFormatException e) { throw new MissingConfigException(FLAG_PORT); } return new UploadProperties(user, password, server, localDir, port); } PropertyUtils(CommandLineParser parser); }
PropertyUtils { public UploadProperties getUploadProperties(String[] args) throws ParseException, MissingConfigException { CommandLine cmd = parser.parse(OPTIONS, args); String user = cmd.getOptionValue(FLAG_USER); if (user == null) { throw new MissingConfigException(FLAG_USER); } String password = cmd.getOptionValue(FLAG_PASSWORD); if (password == null) { throw new MissingConfigException(FLAG_PASSWORD); } String server = cmd.getOptionValue(FLAG_SFTP_SERVER); if (server == null) { throw new MissingConfigException(FLAG_SFTP_SERVER); } String localDir = cmd.getOptionValue(FLAG_LOCAL_DIRECTORY); if (localDir == null) { throw new MissingConfigException(FLAG_LOCAL_DIRECTORY); } int port; try { port = Integer.parseInt(cmd.getOptionValue(FLAG_PORT)); } catch (NumberFormatException e) { throw new MissingConfigException(FLAG_PORT); } return new UploadProperties(user, password, server, localDir, port); } PropertyUtils(CommandLineParser parser); UploadProperties getUploadProperties(String[] args); }
PropertyUtils { public UploadProperties getUploadProperties(String[] args) throws ParseException, MissingConfigException { CommandLine cmd = parser.parse(OPTIONS, args); String user = cmd.getOptionValue(FLAG_USER); if (user == null) { throw new MissingConfigException(FLAG_USER); } String password = cmd.getOptionValue(FLAG_PASSWORD); if (password == null) { throw new MissingConfigException(FLAG_PASSWORD); } String server = cmd.getOptionValue(FLAG_SFTP_SERVER); if (server == null) { throw new MissingConfigException(FLAG_SFTP_SERVER); } String localDir = cmd.getOptionValue(FLAG_LOCAL_DIRECTORY); if (localDir == null) { throw new MissingConfigException(FLAG_LOCAL_DIRECTORY); } int port; try { port = Integer.parseInt(cmd.getOptionValue(FLAG_PORT)); } catch (NumberFormatException e) { throw new MissingConfigException(FLAG_PORT); } return new UploadProperties(user, password, server, localDir, port); } PropertyUtils(CommandLineParser parser); UploadProperties getUploadProperties(String[] args); static final String KEY_USER; static final String KEY_PASSWORD; static final String KEY_SFTP_SERVER; static final String KEY_LOCAL_DIRECTORY; static final String KEY_PORT; final static Options OPTIONS; }
@Test public void testGetChildren() throws Exception { List<String> children = nodeService.getChildren("local_test", "/test"); Assert.assertNotNull(children); Assert.assertEquals(0, children.size()); }
public List<String> getChildren(String cluster, String path) throws ShepherException { List<String> children = nodeDAO.getChildren(cluster, path); Collections.sort(children); return children; }
NodeService { public List<String> getChildren(String cluster, String path) throws ShepherException { List<String> children = nodeDAO.getChildren(cluster, path); Collections.sort(children); return children; } }
NodeService { public List<String> getChildren(String cluster, String path) throws ShepherException { List<String> children = nodeDAO.getChildren(cluster, path); Collections.sort(children); return children; } }
NodeService { public List<String> getChildren(String cluster, String path) throws ShepherException { List<String> children = nodeDAO.getChildren(cluster, path); Collections.sort(children); return children; } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
NodeService { public List<String> getChildren(String cluster, String path) throws ShepherException { List<String> children = nodeDAO.getChildren(cluster, path); Collections.sort(children); return children; } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
@Test public void testAll() throws Exception { List<Cluster> clusters = clusterAdminService.all(); Assert.assertNotNull(clusters); Assert.assertEquals(1, clusters.size()); }
public List<Cluster> all() { return clusterAdminBiz.all(); }
ClusterAdminService { public List<Cluster> all() { return clusterAdminBiz.all(); } }
ClusterAdminService { public List<Cluster> all() { return clusterAdminBiz.all(); } }
ClusterAdminService { public List<Cluster> all() { return clusterAdminBiz.all(); } void create(String name, String config); void update(String name, String config); void delete(String name); List<Cluster> all(); }
ClusterAdminService { public List<Cluster> all() { return clusterAdminBiz.all(); } void create(String name, String config); void update(String name, String config); void delete(String name); List<Cluster> all(); }
@Test public void testCreate() throws Exception { long userId = 2; String teamName = "test_team"; String cluster = "local_test"; String path = "/test"; boolean createResult = teamService.create(userId, teamName, cluster, path); Assert.assertEquals(true, createResult); }
@Transactional public boolean create(long userId, String teamName, String cluster, String path) throws ShepherException { long teamId = teamBiz.create(teamName, userId).getId(); userTeamBiz.create(userId, teamId, Role.MASTER, Status.AGREE); long permissionId = permissionBiz.createIfNotExists(cluster, path); permissionTeamBiz.create(permissionId, teamId, Status.PENDING); return true; }
TeamService { @Transactional public boolean create(long userId, String teamName, String cluster, String path) throws ShepherException { long teamId = teamBiz.create(teamName, userId).getId(); userTeamBiz.create(userId, teamId, Role.MASTER, Status.AGREE); long permissionId = permissionBiz.createIfNotExists(cluster, path); permissionTeamBiz.create(permissionId, teamId, Status.PENDING); return true; } }
TeamService { @Transactional public boolean create(long userId, String teamName, String cluster, String path) throws ShepherException { long teamId = teamBiz.create(teamName, userId).getId(); userTeamBiz.create(userId, teamId, Role.MASTER, Status.AGREE); long permissionId = permissionBiz.createIfNotExists(cluster, path); permissionTeamBiz.create(permissionId, teamId, Status.PENDING); return true; } }
TeamService { @Transactional public boolean create(long userId, String teamName, String cluster, String path) throws ShepherException { long teamId = teamBiz.create(teamName, userId).getId(); userTeamBiz.create(userId, teamId, Role.MASTER, Status.AGREE); long permissionId = permissionBiz.createIfNotExists(cluster, path); permissionTeamBiz.create(permissionId, teamId, Status.PENDING); return true; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { @Transactional public boolean create(long userId, String teamName, String cluster, String path) throws ShepherException { long teamId = teamBiz.create(teamName, userId).getId(); userTeamBiz.create(userId, teamId, Role.MASTER, Status.AGREE); long permissionId = permissionBiz.createIfNotExists(cluster, path); permissionTeamBiz.create(permissionId, teamId, Status.PENDING); return true; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testAddApplyForUserIdTeamIdRole() throws Exception { long userId = 2; long teamId = 5; Role role = Role.MEMBER; UserTeam userTeam = teamService.addApply(userId, teamId, role); Assert.assertNotNull(userTeam); Assert.assertNotEquals(1, userTeam.getId()); }
public UserTeam addApply(long userId, long teamId, Role role) throws ShepherException { return userTeamBiz.create(userId, teamId, role, Status.PENDING); }
TeamService { public UserTeam addApply(long userId, long teamId, Role role) throws ShepherException { return userTeamBiz.create(userId, teamId, role, Status.PENDING); } }
TeamService { public UserTeam addApply(long userId, long teamId, Role role) throws ShepherException { return userTeamBiz.create(userId, teamId, role, Status.PENDING); } }
TeamService { public UserTeam addApply(long userId, long teamId, Role role) throws ShepherException { return userTeamBiz.create(userId, teamId, role, Status.PENDING); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public UserTeam addApply(long userId, long teamId, Role role) throws ShepherException { return userTeamBiz.create(userId, teamId, role, Status.PENDING); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testAddMember() throws Exception { }
@Transactional public void addMember(User member, long teamId, Role role, User creator) throws ShepherException { if (member == null || creator == null) { throw ShepherException.createIllegalParameterException(); } if (userTeamBiz.listUserByTeamId(teamId).contains(member.getName())) { throw ShepherException.createUserExistsException(); } userTeamBiz.create(member.getId(), teamId, role, Status.AGREE); Team team = this.get(teamId); if (team == null) { throw ShepherException.createNoSuchTeamException(); } Set<String> receivers = new HashSet<>(); receivers.add(member.getName()); mailSenderFactory.getMailSender().noticeJoinTeamHandled(receivers, creator.getName(), Status.AGREE, team.getName(), serverUrl + "/teams/" + teamId + "/members"); }
TeamService { @Transactional public void addMember(User member, long teamId, Role role, User creator) throws ShepherException { if (member == null || creator == null) { throw ShepherException.createIllegalParameterException(); } if (userTeamBiz.listUserByTeamId(teamId).contains(member.getName())) { throw ShepherException.createUserExistsException(); } userTeamBiz.create(member.getId(), teamId, role, Status.AGREE); Team team = this.get(teamId); if (team == null) { throw ShepherException.createNoSuchTeamException(); } Set<String> receivers = new HashSet<>(); receivers.add(member.getName()); mailSenderFactory.getMailSender().noticeJoinTeamHandled(receivers, creator.getName(), Status.AGREE, team.getName(), serverUrl + "/teams/" + teamId + "/members"); } }
TeamService { @Transactional public void addMember(User member, long teamId, Role role, User creator) throws ShepherException { if (member == null || creator == null) { throw ShepherException.createIllegalParameterException(); } if (userTeamBiz.listUserByTeamId(teamId).contains(member.getName())) { throw ShepherException.createUserExistsException(); } userTeamBiz.create(member.getId(), teamId, role, Status.AGREE); Team team = this.get(teamId); if (team == null) { throw ShepherException.createNoSuchTeamException(); } Set<String> receivers = new HashSet<>(); receivers.add(member.getName()); mailSenderFactory.getMailSender().noticeJoinTeamHandled(receivers, creator.getName(), Status.AGREE, team.getName(), serverUrl + "/teams/" + teamId + "/members"); } }
TeamService { @Transactional public void addMember(User member, long teamId, Role role, User creator) throws ShepherException { if (member == null || creator == null) { throw ShepherException.createIllegalParameterException(); } if (userTeamBiz.listUserByTeamId(teamId).contains(member.getName())) { throw ShepherException.createUserExistsException(); } userTeamBiz.create(member.getId(), teamId, role, Status.AGREE); Team team = this.get(teamId); if (team == null) { throw ShepherException.createNoSuchTeamException(); } Set<String> receivers = new HashSet<>(); receivers.add(member.getName()); mailSenderFactory.getMailSender().noticeJoinTeamHandled(receivers, creator.getName(), Status.AGREE, team.getName(), serverUrl + "/teams/" + teamId + "/members"); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { @Transactional public void addMember(User member, long teamId, Role role, User creator) throws ShepherException { if (member == null || creator == null) { throw ShepherException.createIllegalParameterException(); } if (userTeamBiz.listUserByTeamId(teamId).contains(member.getName())) { throw ShepherException.createUserExistsException(); } userTeamBiz.create(member.getId(), teamId, role, Status.AGREE); Team team = this.get(teamId); if (team == null) { throw ShepherException.createNoSuchTeamException(); } Set<String> receivers = new HashSet<>(); receivers.add(member.getName()); mailSenderFactory.getMailSender().noticeJoinTeamHandled(receivers, creator.getName(), Status.AGREE, team.getName(), serverUrl + "/teams/" + teamId + "/members"); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testListUserTeamsPending() throws Exception { long userId = 2; long teamId = 5; Role role = Role.MEMBER; Team team = teamService.get(teamId); teamService.addApply(userId, teamId, role); List<UserTeam> applies = teamService.listUserTeamsPending(team); Assert.assertNotNull(applies); Assert.assertEquals(1, applies.size()); }
public List<UserTeam> listUserTeamsPending(Team team) throws ShepherException { if (team == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByTeam(team.getId(), Status.PENDING); }
TeamService { public List<UserTeam> listUserTeamsPending(Team team) throws ShepherException { if (team == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByTeam(team.getId(), Status.PENDING); } }
TeamService { public List<UserTeam> listUserTeamsPending(Team team) throws ShepherException { if (team == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByTeam(team.getId(), Status.PENDING); } }
TeamService { public List<UserTeam> listUserTeamsPending(Team team) throws ShepherException { if (team == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByTeam(team.getId(), Status.PENDING); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public List<UserTeam> listUserTeamsPending(Team team) throws ShepherException { if (team == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByTeam(team.getId(), Status.PENDING); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testListUserTeamsAgree() throws Exception { long teamId = 1; Team team = teamService.get(teamId); List<UserTeam> applies = teamService.listUserTeamsAgree(team); Assert.assertNotNull(applies); Assert.assertEquals(3, applies.size()); }
public List<UserTeam> listUserTeamsAgree(Team team) throws ShepherException { if (team == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByTeam(team.getId(), Status.AGREE); }
TeamService { public List<UserTeam> listUserTeamsAgree(Team team) throws ShepherException { if (team == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByTeam(team.getId(), Status.AGREE); } }
TeamService { public List<UserTeam> listUserTeamsAgree(Team team) throws ShepherException { if (team == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByTeam(team.getId(), Status.AGREE); } }
TeamService { public List<UserTeam> listUserTeamsAgree(Team team) throws ShepherException { if (team == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByTeam(team.getId(), Status.AGREE); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public List<UserTeam> listUserTeamsAgree(Team team) throws ShepherException { if (team == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByTeam(team.getId(), Status.AGREE); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testListUserTeamsJoined() throws Exception { long userId = 3; User user = new User(); user.setId(userId); List<UserTeam> joinedTeams = teamService.listUserTeamsJoined(user); Assert.assertNotNull(joinedTeams); Assert.assertEquals(2, joinedTeams.size()); }
public List<UserTeam> listUserTeamsJoined(User user) throws ShepherException { if (user == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByUser(user.getId(), Status.AGREE); }
TeamService { public List<UserTeam> listUserTeamsJoined(User user) throws ShepherException { if (user == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByUser(user.getId(), Status.AGREE); } }
TeamService { public List<UserTeam> listUserTeamsJoined(User user) throws ShepherException { if (user == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByUser(user.getId(), Status.AGREE); } }
TeamService { public List<UserTeam> listUserTeamsJoined(User user) throws ShepherException { if (user == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByUser(user.getId(), Status.AGREE); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public List<UserTeam> listUserTeamsJoined(User user) throws ShepherException { if (user == null) { throw ShepherException.createIllegalParameterException(); } return userTeamBiz.listByUser(user.getId(), Status.AGREE); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testListTeamsToJoin() throws Exception { long userId = 4; String cluster = "local_test"; String path = "/test/sub1"; List<Team> teams = teamService.listTeamsToJoin(userId, cluster, path); Assert.assertNotNull(teams); Assert.assertEquals(1, teams.size()); }
public List<Team> listTeamsToJoin(long userId, String cluster, String path) { return teamBiz.listTeamsByPathAndUser(userId, cluster, path, false); }
TeamService { public List<Team> listTeamsToJoin(long userId, String cluster, String path) { return teamBiz.listTeamsByPathAndUser(userId, cluster, path, false); } }
TeamService { public List<Team> listTeamsToJoin(long userId, String cluster, String path) { return teamBiz.listTeamsByPathAndUser(userId, cluster, path, false); } }
TeamService { public List<Team> listTeamsToJoin(long userId, String cluster, String path) { return teamBiz.listTeamsByPathAndUser(userId, cluster, path, false); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public List<Team> listTeamsToJoin(long userId, String cluster, String path) { return teamBiz.listTeamsByPathAndUser(userId, cluster, path, false); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testListTeamsJoined() throws Exception { long userId = 3; String cluster = "local_test"; String path = "/test/sub1"; List<Team> teams = teamService.listTeamsJoined(userId, cluster, path); Assert.assertNotNull(teams); Assert.assertEquals(1, teams.size()); }
public List<Team> listTeamsJoined(long userId, String cluster, String path) { return teamBiz.listTeamsByPathAndUser(userId, cluster, path, true); }
TeamService { public List<Team> listTeamsJoined(long userId, String cluster, String path) { return teamBiz.listTeamsByPathAndUser(userId, cluster, path, true); } }
TeamService { public List<Team> listTeamsJoined(long userId, String cluster, String path) { return teamBiz.listTeamsByPathAndUser(userId, cluster, path, true); } }
TeamService { public List<Team> listTeamsJoined(long userId, String cluster, String path) { return teamBiz.listTeamsByPathAndUser(userId, cluster, path, true); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public List<Team> listTeamsJoined(long userId, String cluster, String path) { return teamBiz.listTeamsByPathAndUser(userId, cluster, path, true); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testGetTeamName() throws Exception { String teamName = "admin"; Team team = teamService.get(teamName); Assert.assertNotNull(team); Assert.assertEquals(1, team.getId()); }
public Team get(String teamName) throws ShepherException { return teamBiz.getByName(teamName); }
TeamService { public Team get(String teamName) throws ShepherException { return teamBiz.getByName(teamName); } }
TeamService { public Team get(String teamName) throws ShepherException { return teamBiz.getByName(teamName); } }
TeamService { public Team get(String teamName) throws ShepherException { return teamBiz.getByName(teamName); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public Team get(String teamName) throws ShepherException { return teamBiz.getByName(teamName); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testGetData() throws Exception { String data = nodeService.getData("local_test", "/test"); Assert.assertNull(data); }
public String getData(String cluster, String path) throws ShepherException { return nodeDAO.getData(cluster, path); }
NodeService { public String getData(String cluster, String path) throws ShepherException { return nodeDAO.getData(cluster, path); } }
NodeService { public String getData(String cluster, String path) throws ShepherException { return nodeDAO.getData(cluster, path); } }
NodeService { public String getData(String cluster, String path) throws ShepherException { return nodeDAO.getData(cluster, path); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
NodeService { public String getData(String cluster, String path) throws ShepherException { return nodeDAO.getData(cluster, path); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
@Test public void testGetTeamId() throws Exception { long teamId = 1; Team team = teamService.get(teamId); Assert.assertNotNull(team); Assert.assertEquals("admin", team.getName()); }
public Team get(String teamName) throws ShepherException { return teamBiz.getByName(teamName); }
TeamService { public Team get(String teamName) throws ShepherException { return teamBiz.getByName(teamName); } }
TeamService { public Team get(String teamName) throws ShepherException { return teamBiz.getByName(teamName); } }
TeamService { public Team get(String teamName) throws ShepherException { return teamBiz.getByName(teamName); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public Team get(String teamName) throws ShepherException { return teamBiz.getByName(teamName); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testUpdateStatus() throws Exception { long id = 3; Status status = Status.DELETE; int updateResult = teamService.updateStatus(id, status); Assert.assertEquals(RESULT_OK, updateResult); }
public int updateStatus(long id, Status status) throws ShepherException { return userTeamBiz.updateStatus(id, status); }
TeamService { public int updateStatus(long id, Status status) throws ShepherException { return userTeamBiz.updateStatus(id, status); } }
TeamService { public int updateStatus(long id, Status status) throws ShepherException { return userTeamBiz.updateStatus(id, status); } }
TeamService { public int updateStatus(long id, Status status) throws ShepherException { return userTeamBiz.updateStatus(id, status); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public int updateStatus(long id, Status status) throws ShepherException { return userTeamBiz.updateStatus(id, status); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testAgreeJoin() throws Exception { }
public int agreeJoin(User user, long id, long teamId) throws ShepherException { int result = this.updateStatus(id, Status.AGREE); this.noticeJoinTeamHandled(id, user, teamId, Status.AGREE); return result; }
TeamService { public int agreeJoin(User user, long id, long teamId) throws ShepherException { int result = this.updateStatus(id, Status.AGREE); this.noticeJoinTeamHandled(id, user, teamId, Status.AGREE); return result; } }
TeamService { public int agreeJoin(User user, long id, long teamId) throws ShepherException { int result = this.updateStatus(id, Status.AGREE); this.noticeJoinTeamHandled(id, user, teamId, Status.AGREE); return result; } }
TeamService { public int agreeJoin(User user, long id, long teamId) throws ShepherException { int result = this.updateStatus(id, Status.AGREE); this.noticeJoinTeamHandled(id, user, teamId, Status.AGREE); return result; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public int agreeJoin(User user, long id, long teamId) throws ShepherException { int result = this.updateStatus(id, Status.AGREE); this.noticeJoinTeamHandled(id, user, teamId, Status.AGREE); return result; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testRefuseJoin() throws Exception { }
public int refuseJoin(User user, long id, long teamId) throws ShepherException { int result = this.updateStatus(id, Status.REFUSE); this.noticeJoinTeamHandled(id, user, teamId, Status.REFUSE); return result; }
TeamService { public int refuseJoin(User user, long id, long teamId) throws ShepherException { int result = this.updateStatus(id, Status.REFUSE); this.noticeJoinTeamHandled(id, user, teamId, Status.REFUSE); return result; } }
TeamService { public int refuseJoin(User user, long id, long teamId) throws ShepherException { int result = this.updateStatus(id, Status.REFUSE); this.noticeJoinTeamHandled(id, user, teamId, Status.REFUSE); return result; } }
TeamService { public int refuseJoin(User user, long id, long teamId) throws ShepherException { int result = this.updateStatus(id, Status.REFUSE); this.noticeJoinTeamHandled(id, user, teamId, Status.REFUSE); return result; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public int refuseJoin(User user, long id, long teamId) throws ShepherException { int result = this.updateStatus(id, Status.REFUSE); this.noticeJoinTeamHandled(id, user, teamId, Status.REFUSE); return result; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testUpdateRole() throws Exception { long id = 3; Role role = Role.MEMBER; int updateResult = teamService.updateRole(id, role); Assert.assertEquals(RESULT_OK, updateResult); }
public int updateRole(long id, Role role) throws ShepherException { return userTeamBiz.updateRole(id, role); }
TeamService { public int updateRole(long id, Role role) throws ShepherException { return userTeamBiz.updateRole(id, role); } }
TeamService { public int updateRole(long id, Role role) throws ShepherException { return userTeamBiz.updateRole(id, role); } }
TeamService { public int updateRole(long id, Role role) throws ShepherException { return userTeamBiz.updateRole(id, role); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public int updateRole(long id, Role role) throws ShepherException { return userTeamBiz.updateRole(id, role); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testHasApplied() throws Exception { long teamId = 5; String cluster = "local_test"; String path = "/test/sub1"; boolean hasApplied = teamService.hasApplied(teamId, cluster, path); Assert.assertEquals(true, hasApplied); }
public boolean hasApplied(long teamId, String cluster, String path) throws ShepherException { boolean accepted = permissionTeamBiz.get(teamId, cluster, path, Status.AGREE) != null; boolean pending = permissionTeamBiz.get(teamId, cluster, path, Status.PENDING) != null; return accepted || pending; }
TeamService { public boolean hasApplied(long teamId, String cluster, String path) throws ShepherException { boolean accepted = permissionTeamBiz.get(teamId, cluster, path, Status.AGREE) != null; boolean pending = permissionTeamBiz.get(teamId, cluster, path, Status.PENDING) != null; return accepted || pending; } }
TeamService { public boolean hasApplied(long teamId, String cluster, String path) throws ShepherException { boolean accepted = permissionTeamBiz.get(teamId, cluster, path, Status.AGREE) != null; boolean pending = permissionTeamBiz.get(teamId, cluster, path, Status.PENDING) != null; return accepted || pending; } }
TeamService { public boolean hasApplied(long teamId, String cluster, String path) throws ShepherException { boolean accepted = permissionTeamBiz.get(teamId, cluster, path, Status.AGREE) != null; boolean pending = permissionTeamBiz.get(teamId, cluster, path, Status.PENDING) != null; return accepted || pending; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public boolean hasApplied(long teamId, String cluster, String path) throws ShepherException { boolean accepted = permissionTeamBiz.get(teamId, cluster, path, Status.AGREE) != null; boolean pending = permissionTeamBiz.get(teamId, cluster, path, Status.PENDING) != null; return accepted || pending; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testIsMaster() throws Exception { long userId = 1; long teamId = 1; boolean isMaster = teamService.isMaster(userId, teamId); Assert.assertEquals(true, isMaster); }
public boolean isMaster(long userId, long teamId) throws ShepherException { return userTeamBiz.getRoleValue(userId, teamId, Status.AGREE) == Role.MASTER.getValue(); }
TeamService { public boolean isMaster(long userId, long teamId) throws ShepherException { return userTeamBiz.getRoleValue(userId, teamId, Status.AGREE) == Role.MASTER.getValue(); } }
TeamService { public boolean isMaster(long userId, long teamId) throws ShepherException { return userTeamBiz.getRoleValue(userId, teamId, Status.AGREE) == Role.MASTER.getValue(); } }
TeamService { public boolean isMaster(long userId, long teamId) throws ShepherException { return userTeamBiz.getRoleValue(userId, teamId, Status.AGREE) == Role.MASTER.getValue(); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public boolean isMaster(long userId, long teamId) throws ShepherException { return userTeamBiz.getRoleValue(userId, teamId, Status.AGREE) == Role.MASTER.getValue(); } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testIsOwner() throws Exception { long userId = 1; long teamId = 1; boolean isOwner = teamService.isOwner(userId, teamId); Assert.assertEquals(true, isOwner); }
public boolean isOwner(long userId, long teamId) { Team team = teamBiz.getById(teamId); return team != null && team.getOwner() == userId; }
TeamService { public boolean isOwner(long userId, long teamId) { Team team = teamBiz.getById(teamId); return team != null && team.getOwner() == userId; } }
TeamService { public boolean isOwner(long userId, long teamId) { Team team = teamBiz.getById(teamId); return team != null && team.getOwner() == userId; } }
TeamService { public boolean isOwner(long userId, long teamId) { Team team = teamBiz.getById(teamId); return team != null && team.getOwner() == userId; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public boolean isOwner(long userId, long teamId) { Team team = teamBiz.getById(teamId); return team != null && team.getOwner() == userId; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testIsAdmin() throws Exception { long userId = 1; boolean isAdmin = teamService.isAdmin(userId); Assert.assertEquals(true, isAdmin); }
public boolean isAdmin(long userId) throws ShepherException { Team team = teamBiz.getByName(ShepherConstants.ADMIN); return userTeamBiz.getRoleValue(userId, team.getId(), Status.AGREE) > ShepherConstants.DEFAULT_ROLEVALUE; }
TeamService { public boolean isAdmin(long userId) throws ShepherException { Team team = teamBiz.getByName(ShepherConstants.ADMIN); return userTeamBiz.getRoleValue(userId, team.getId(), Status.AGREE) > ShepherConstants.DEFAULT_ROLEVALUE; } }
TeamService { public boolean isAdmin(long userId) throws ShepherException { Team team = teamBiz.getByName(ShepherConstants.ADMIN); return userTeamBiz.getRoleValue(userId, team.getId(), Status.AGREE) > ShepherConstants.DEFAULT_ROLEVALUE; } }
TeamService { public boolean isAdmin(long userId) throws ShepherException { Team team = teamBiz.getByName(ShepherConstants.ADMIN); return userTeamBiz.getRoleValue(userId, team.getId(), Status.AGREE) > ShepherConstants.DEFAULT_ROLEVALUE; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
TeamService { public boolean isAdmin(long userId) throws ShepherException { Team team = teamBiz.getByName(ShepherConstants.ADMIN); return userTeamBiz.getRoleValue(userId, team.getId(), Status.AGREE) > ShepherConstants.DEFAULT_ROLEVALUE; } @Transactional boolean create(long userId, String teamName, String cluster, String path); UserTeam addApply(long userId, long teamId, Role role); @Transactional void addApply(User user, long teamId, Role role); @Transactional void addMember(User member, long teamId, Role role, User creator); List<UserTeam> listUserTeamsPending(Team team); List<UserTeam> listUserTeamsAgree(Team team); List<UserTeam> listUserTeamsJoined(User user); List<Team> listTeamsToJoin(long userId, String cluster, String path); List<Team> listTeamsJoined(long userId, String cluster, String path); Team get(String teamName); Team get(long teamId); int updateStatus(long id, Status status); int agreeJoin(User user, long id, long teamId); int refuseJoin(User user, long id, long teamId); int updateRole(long id, Role role); boolean hasApplied(long teamId, String cluster, String path); boolean isMaster(long userId, long teamId); boolean isOwner(long userId, long teamId); boolean isAdmin(long userId); }
@Test public void testCreate() throws Exception { }
@Transactional public long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus) throws ShepherException { if (creator == null) { throw ShepherException.createIllegalParameterException(); } Stat stat = nodeDAO.getStat(cluster, path, true); long snapshotId = snapshotBiz.getOriginalId(path, cluster, ReviewUtil.DEFAULT_CREATOR, stat, action, true); long newSnapshotId = snapshotBiz.create(cluster, path, data, creator.getName(), action, ReviewUtil.DEFAULT_MTIME, ReviewStatus.NEW, stat.getVersion() + 1, ReviewUtil.DEFAULT_REVIEWER).getId(); Set<String> masters = teamBiz.listUserNamesByPathAndUser(creator.getId(), cluster, path, Role.MASTER); String reviewers = this.asStringReviewers(masters); long reviewId = reviewBiz.create(cluster, path, snapshotId, newSnapshotId, reviewStatus, creator.getName(), ReviewUtil.DEFAULT_REVIEWER, action).getId(); logger.info("Create review request, reviewId={}, creator={}, reviewers={}", reviewId, creator, reviewers); mailSenderFactory.getMailSender().noticeUpdate(masters, creator.getName(), path, cluster, serverUrl + "/reviews/" + reviewId); return reviewId; }
ReviewService { @Transactional public long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus) throws ShepherException { if (creator == null) { throw ShepherException.createIllegalParameterException(); } Stat stat = nodeDAO.getStat(cluster, path, true); long snapshotId = snapshotBiz.getOriginalId(path, cluster, ReviewUtil.DEFAULT_CREATOR, stat, action, true); long newSnapshotId = snapshotBiz.create(cluster, path, data, creator.getName(), action, ReviewUtil.DEFAULT_MTIME, ReviewStatus.NEW, stat.getVersion() + 1, ReviewUtil.DEFAULT_REVIEWER).getId(); Set<String> masters = teamBiz.listUserNamesByPathAndUser(creator.getId(), cluster, path, Role.MASTER); String reviewers = this.asStringReviewers(masters); long reviewId = reviewBiz.create(cluster, path, snapshotId, newSnapshotId, reviewStatus, creator.getName(), ReviewUtil.DEFAULT_REVIEWER, action).getId(); logger.info("Create review request, reviewId={}, creator={}, reviewers={}", reviewId, creator, reviewers); mailSenderFactory.getMailSender().noticeUpdate(masters, creator.getName(), path, cluster, serverUrl + "/reviews/" + reviewId); return reviewId; } }
ReviewService { @Transactional public long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus) throws ShepherException { if (creator == null) { throw ShepherException.createIllegalParameterException(); } Stat stat = nodeDAO.getStat(cluster, path, true); long snapshotId = snapshotBiz.getOriginalId(path, cluster, ReviewUtil.DEFAULT_CREATOR, stat, action, true); long newSnapshotId = snapshotBiz.create(cluster, path, data, creator.getName(), action, ReviewUtil.DEFAULT_MTIME, ReviewStatus.NEW, stat.getVersion() + 1, ReviewUtil.DEFAULT_REVIEWER).getId(); Set<String> masters = teamBiz.listUserNamesByPathAndUser(creator.getId(), cluster, path, Role.MASTER); String reviewers = this.asStringReviewers(masters); long reviewId = reviewBiz.create(cluster, path, snapshotId, newSnapshotId, reviewStatus, creator.getName(), ReviewUtil.DEFAULT_REVIEWER, action).getId(); logger.info("Create review request, reviewId={}, creator={}, reviewers={}", reviewId, creator, reviewers); mailSenderFactory.getMailSender().noticeUpdate(masters, creator.getName(), path, cluster, serverUrl + "/reviews/" + reviewId); return reviewId; } }
ReviewService { @Transactional public long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus) throws ShepherException { if (creator == null) { throw ShepherException.createIllegalParameterException(); } Stat stat = nodeDAO.getStat(cluster, path, true); long snapshotId = snapshotBiz.getOriginalId(path, cluster, ReviewUtil.DEFAULT_CREATOR, stat, action, true); long newSnapshotId = snapshotBiz.create(cluster, path, data, creator.getName(), action, ReviewUtil.DEFAULT_MTIME, ReviewStatus.NEW, stat.getVersion() + 1, ReviewUtil.DEFAULT_REVIEWER).getId(); Set<String> masters = teamBiz.listUserNamesByPathAndUser(creator.getId(), cluster, path, Role.MASTER); String reviewers = this.asStringReviewers(masters); long reviewId = reviewBiz.create(cluster, path, snapshotId, newSnapshotId, reviewStatus, creator.getName(), ReviewUtil.DEFAULT_REVIEWER, action).getId(); logger.info("Create review request, reviewId={}, creator={}, reviewers={}", reviewId, creator, reviewers); mailSenderFactory.getMailSender().noticeUpdate(masters, creator.getName(), path, cluster, serverUrl + "/reviews/" + reviewId); return reviewId; } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
ReviewService { @Transactional public long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus) throws ShepherException { if (creator == null) { throw ShepherException.createIllegalParameterException(); } Stat stat = nodeDAO.getStat(cluster, path, true); long snapshotId = snapshotBiz.getOriginalId(path, cluster, ReviewUtil.DEFAULT_CREATOR, stat, action, true); long newSnapshotId = snapshotBiz.create(cluster, path, data, creator.getName(), action, ReviewUtil.DEFAULT_MTIME, ReviewStatus.NEW, stat.getVersion() + 1, ReviewUtil.DEFAULT_REVIEWER).getId(); Set<String> masters = teamBiz.listUserNamesByPathAndUser(creator.getId(), cluster, path, Role.MASTER); String reviewers = this.asStringReviewers(masters); long reviewId = reviewBiz.create(cluster, path, snapshotId, newSnapshotId, reviewStatus, creator.getName(), ReviewUtil.DEFAULT_REVIEWER, action).getId(); logger.info("Create review request, reviewId={}, creator={}, reviewers={}", reviewId, creator, reviewers); mailSenderFactory.getMailSender().noticeUpdate(masters, creator.getName(), path, cluster, serverUrl + "/reviews/" + reviewId); return reviewId; } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
@Test public void testGetStatForClusterPath() throws Exception { Stat stat = nodeService.getStat("local_test", "/test"); Assert.assertNotNull(stat); }
public Stat getStat(String cluster, String path) throws ShepherException { return this.getStat(cluster, path, true); }
NodeService { public Stat getStat(String cluster, String path) throws ShepherException { return this.getStat(cluster, path, true); } }
NodeService { public Stat getStat(String cluster, String path) throws ShepherException { return this.getStat(cluster, path, true); } }
NodeService { public Stat getStat(String cluster, String path) throws ShepherException { return this.getStat(cluster, path, true); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
NodeService { public Stat getStat(String cluster, String path) throws ShepherException { return this.getStat(cluster, path, true); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
@Test public void testUpdate() throws Exception { int result = reviewService.update(ReviewStatus.ACCEPTED, 1L, "reviewer", 0L, 0L); Assert.assertNotEquals(0, result); }
@Transactional public int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime) throws ShepherException { snapshotBiz.update(snapshotId, reviewStatus, reviewer, zkMtime); return reviewBiz.update(id, reviewStatus, reviewer); }
ReviewService { @Transactional public int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime) throws ShepherException { snapshotBiz.update(snapshotId, reviewStatus, reviewer, zkMtime); return reviewBiz.update(id, reviewStatus, reviewer); } }
ReviewService { @Transactional public int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime) throws ShepherException { snapshotBiz.update(snapshotId, reviewStatus, reviewer, zkMtime); return reviewBiz.update(id, reviewStatus, reviewer); } }
ReviewService { @Transactional public int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime) throws ShepherException { snapshotBiz.update(snapshotId, reviewStatus, reviewer, zkMtime); return reviewBiz.update(id, reviewStatus, reviewer); } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
ReviewService { @Transactional public int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime) throws ShepherException { snapshotBiz.update(snapshotId, reviewStatus, reviewer, zkMtime); return reviewBiz.update(id, reviewStatus, reviewer); } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }