Assert.assertEquals(4, validationErrors.size());
Iterator> validationErrorIterator = validationErrors.entrySet().iterator();
<<<<<<< HEAD
assertValidationErrorContains(testExmlFilename, 4,
words("cvc-datatype-valid.1.2.3", "wrongType", "Number"),
validationErrorIterator.next());
assertValidationErrorContains(testExmlFilename, 4,
words("cvc-attribute.3", "wrongType", "x", "panel", "Number"),
validationErrorIterator.next());
assertValidationErrorContains(testExmlFilename, 4,
words("cvc-complex-type.3.2.2", "wrongAttribute", "panel"),
validationErrorIterator.next());
assertValidationErrorContains(testExmlFilename, 5,
words("cvc-complex-type.3.2.2", "anotherWrongAttribute", "baseAction"),
validationErrorIterator.next());
}
private void assertValidationErrorContains(String expectedFilename, int expectedLine, Set expectedWords, Map.Entry validationError) {
Assert.assertEquals("Expected file name", expectedFilename, validationError.getKey().getFileName());
Assert.assertEquals("Expected line number", expectedLine, validationError.getKey().getLine());
for (String expectedWord : expectedWords) {
Assert.assertTrue("Message should contain '" + expectedWord + "'", validationError.getValue().contains(expectedWord));
}
=======
// "cvc-datatype-valid.1.2.3: 'wrongType' is not a valid value of union type 'Number'."
assertValidationErrorEquals(testExmlFilename, 4,
new String[]{"cvc-datatype-valid.1.2.3:", "wrongType", "Number"},
validationErrorIterator.next());
// "cvc-attribute.3: The value 'wrongType' of attribute 'x' on element 'panel' is not valid with respect to its type, 'Number'."
assertValidationErrorEquals(testExmlFilename, 4,
new String[]{"cvc-attribute.3:", "wrongType", "x", "panel", "Number"},
validationErrorIterator.next());
// "cvc-complex-type.3.2.2: Attribute 'wrongAttribute' is not allowed to appear in element 'panel'."
assertValidationErrorEquals(testExmlFilename, 4,
new String[]{"cvc-complex-type.3.2.2:", "wrongAttribute", "panel"},
validationErrorIterator.next());
// "cvc-complex-type.3.2.2: Attribute 'anotherWrongAttribute' is not allowed to appear in element 'baseAction'."
assertValidationErrorEquals(testExmlFilename, 5,
new String[]{"cvc-complex-type.3.2.2:", "anotherWrongAttribute", "baseAction"},
validationErrorIterator.next());
}
private void assertValidationErrorEquals(String expectedFilename, int expectedLine, String[] expectedMessageTokens, Map.Entry validationError) {
Assert.assertEquals(expectedFilename, validationError.getKey().getFileName());
for (String expectedMessageToken : expectedMessageTokens) {
Assert.assertTrue("Validation error '" + validationError.getValue() + "' contains phrase '" + expectedMessageToken + "'.", validationError.getValue().contains(expectedMessageToken));
}
Assert.assertEquals(expectedLine, validationError.getKey().getLine());
>>>>>>> d2b375e8604c6c0e8dc798befd84e3970c04ab1c
}
private File getFile(String path) throws URISyntaxException { |