use of org.xml.sax.SAXParseException in project gocd by gocd.
the class XsdErrorTranslatorTest method shouldOnlyRememberTheFirstValidationError.
@Test
public void shouldOnlyRememberTheFirstValidationError() throws Exception {
translator.error(new SAXParseException("cvc-attribute.3: The value 'abc!!!' of attribute 'name' on element 'environment' is not valid with respect to its type, 'nameType'", null));
translator.error(new SAXParseException("cvc-elt.1: Cannot find the declaration of element 'element'", null));
assertThat(translator.translate(), is("\"abc!!!\" is invalid for Environment name"));
}
use of org.xml.sax.SAXParseException in project gocd by gocd.
the class XsdErrorTranslatorTest method shouldReturnOriginalErrorIfErrorMessageDoesNotContainCVCPattern.
@Test
public void shouldReturnOriginalErrorIfErrorMessageDoesNotContainCVCPattern() throws Exception {
translator.error(new SAXParseException("Duplicate unique value [coverage] declared for identity constraint of element \"properties\".", null));
assertThat(translator.translate(), is("Duplicate unique value [coverage] declared for identity constraint of element \"properties\"."));
}
use of org.xml.sax.SAXParseException in project gocd by gocd.
the class XsdErrorTranslatorTest method shouldHumanizeTheNameTypeInTheErrorMessage.
@Test
public void shouldHumanizeTheNameTypeInTheErrorMessage() throws SAXException {
translator.error(new SAXParseException("cvc-pattern-valid: Value 'abc!!' is not facet-valid with respect to pattern '[Some-Pattern]' for type 'environmentName'.", null));
assertThat(translator.translate(), is("Environment name is invalid. \"abc!!\" should conform to the pattern - [Some-Pattern]"));
}
use of org.xml.sax.SAXParseException in project gocd by gocd.
the class XsdErrorTranslatorTest method shouldTranslateEvenIfSomeArgumentsAreEmpty.
@Test
public void shouldTranslateEvenIfSomeArgumentsAreEmpty() throws Exception {
translator.error(new SAXParseException("cvc-attribute.3: The value '' of attribute 'name' on element 'environment' is not valid with respect to its type, 'nameType'", null));
assertThat(translator.translate(), is("\"\" is invalid for Environment name"));
}
use of org.xml.sax.SAXParseException in project gocd by gocd.
the class XsdErrorTranslatorTest method shouldTranslateXsdErrorIfMappingDefined.
@Test
public void shouldTranslateXsdErrorIfMappingDefined() throws Exception {
translator.error(new SAXParseException("cvc-attribute.3: The value 'abc!!!' of attribute 'name' on element 'environment' is not valid with respect to its type, 'nameType'", null));
assertThat(translator.translate(), is("\"abc!!!\" is invalid for Environment name"));
}
Aggregations