Skip to content

Commit 80418d5

Browse files
author
Dennis Labordus
committed
Changed Namespace URIs, add validation constraint and common exception handling.
Signed-off-by: Dennis Labordus <dennis.labordus@alliander.com>
1 parent e42f03d commit 80418d5

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

commons/src/test/java/org/lfenergy/compas/core/commons/constraint/impl/XmlAnyElementConstraintValidatorTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ void isValid_WhenCalledWithMultipleElementAndOneIncorrect_ThenViolationFound() {
6565
assertEquals(1, violations.size());
6666
}
6767

68+
@Test
69+
void isValid_WhenCalledWithMultipleElementAndOneIncorrectNS_ThenViolationFound() {
70+
var simplePojo = new SimplePojo();
71+
simplePojo.getElements().add(document.createElementNS("https://OtherNS.org", ELEMENT_NAME));
72+
simplePojo.getElements().add(document.createElementNS(ELEMENT_NS, ELEMENT_NAME));
73+
simplePojo.getElements().add(document.createElementNS(ELEMENT_NS, ELEMENT_NAME));
74+
75+
var violations = validator.validate(simplePojo);
76+
assertEquals(1, violations.size());
77+
}
78+
6879
private static final class SimplePojo {
6980
@XmlAnyElementValid(elementName = ELEMENT_NAME, elementNamespace = ELEMENT_NS)
7081
private List<Element> elements = new ArrayList<>();

0 commit comments

Comments
 (0)