use of ddf.catalog.validation.ValidationException in project ddf by codice.
the class MetacardValidityMarkerPluginTest method getMockFailingValidatorWithWarnings.
private MetacardValidator getMockFailingValidatorWithWarnings() throws ValidationException {
ValidationException validationException = mock(ValidationException.class);
when(validationException.getWarnings()).thenReturn(Collections.singletonList(SAMPLE_WARNING));
MetacardValidator metacardValidator = mock(MetacardValidator.class, withSettings().extraInterfaces(Describable.class));
doThrow(validationException).when(metacardValidator).validate(any(Metacard.class));
when(((Describable) metacardValidator).getId()).thenReturn(ID);
return metacardValidator;
}
use of ddf.catalog.validation.ValidationException in project ddf by codice.
the class MetacardValidityMarkerPluginTest method getMockFailingValidatorWithErrors.
private MetacardValidator getMockFailingValidatorWithErrors() throws ValidationException {
ValidationException validationException = mock(ValidationException.class);
when(validationException.getErrors()).thenReturn(Collections.singletonList(SAMPLE_ERROR));
MetacardValidator metacardValidator = mock(MetacardValidator.class, withSettings().extraInterfaces(Describable.class));
doThrow(validationException).when(metacardValidator).validate(any(Metacard.class));
when(((Describable) metacardValidator).getId()).thenReturn(ID);
return metacardValidator;
}
use of ddf.catalog.validation.ValidationException in project ddf by codice.
the class MetacardValidityMarkerPluginTest method getMockEnforcedFailingValidatorWithId.
private MetacardValidator getMockEnforcedFailingValidatorWithId(String id) throws ValidationException {
ValidationException validationException = mock(ValidationException.class);
when(validationException.getErrors()).thenReturn(Collections.singletonList(SAMPLE_ERROR));
MetacardValidator metacardValidator = mock(MetacardValidator.class, withSettings().extraInterfaces(Describable.class));
doThrow(validationException).when(metacardValidator).validate(argThat(isMetacardWithTitle(FIRST)));
when(((Describable) metacardValidator).getId()).thenReturn(id);
return metacardValidator;
}
use of ddf.catalog.validation.ValidationException in project ddf by codice.
the class GmlHandler method endElement.
/**
* Takes in a sax event from {@link org.codice.ddf.transformer.xml.streaming.lib.SaxEventHandlerDelegate}, and if it is a gml:Point or a sub-element of a gml:Point, it will
* * hand the event off to the GML handler for further parsing.
* If it is a gml:Point, the point is stored as a WKT in the attributes list
*
* @param namespaceURI the namespaceURI that is passed in by {@link org.codice.ddf.transformer.xml.streaming.lib.SaxEventHandlerDelegate}
* @param localName the localName that is passed in by {@link org.codice.ddf.transformer.xml.streaming.lib.SaxEventHandlerDelegate}
* @param qName the qName that is passed in by {@link org.codice.ddf.transformer.xml.streaming.lib.SaxEventHandlerDelegate}
*/
@Override
public void endElement(String namespaceURI, String localName, String qName) {
if (readingGml) {
try {
gml3Element.toElement(namespaceURI, localName);
} catch (XMLStreamException e) {
LOGGER.debug("Error writing to element in SaxEventToXmlConverter()", e);
}
if (!readingGml3) {
try {
gh.endElement(namespaceURI, localName, qName);
} catch (SAXException e) {
LOGGER.debug("GML threw a SAX exception", e);
}
}
state.pop();
if (state.size() == 0) {
readingGml = false;
if (!readingGml3) {
Geometry geo = gh.getGeometry();
attributes.add(new AttributeImpl(Metacard.GEOGRAPHY, wktWriter.write(geo)));
} else {
try {
attributes.add(new AttributeImpl(Metacard.GEOGRAPHY, gml3Converter.convert(gml3Element.toString())));
} catch (ValidationException e) {
this.attributes.add(new AttributeImpl(Validation.VALIDATION_ERRORS, "geospatial-handler"));
}
}
readingGml3 = false;
gml3Element.reset();
}
}
}
Aggregations