Search in sources :

Example 6 with ValidationException

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;
}
Also used : Metacard(ddf.catalog.data.Metacard) ValidationException(ddf.catalog.validation.ValidationException) MetacardValidator(ddf.catalog.validation.MetacardValidator) Describable(ddf.catalog.util.Describable)

Example 7 with ValidationException

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;
}
Also used : Metacard(ddf.catalog.data.Metacard) ValidationException(ddf.catalog.validation.ValidationException) MetacardValidator(ddf.catalog.validation.MetacardValidator) Describable(ddf.catalog.util.Describable)

Example 8 with ValidationException

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;
}
Also used : ValidationException(ddf.catalog.validation.ValidationException) MetacardValidator(ddf.catalog.validation.MetacardValidator) Describable(ddf.catalog.util.Describable)

Example 9 with ValidationException

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();
        }
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ValidationException(ddf.catalog.validation.ValidationException) XMLStreamException(javax.xml.stream.XMLStreamException) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) SAXException(org.xml.sax.SAXException)

Aggregations

ValidationException (ddf.catalog.validation.ValidationException)9 MetacardValidator (ddf.catalog.validation.MetacardValidator)6 Metacard (ddf.catalog.data.Metacard)4 Describable (ddf.catalog.util.Describable)4 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)2 Geometry (com.vividsolutions.jts.geom.Geometry)1 Result (ddf.catalog.data.Result)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1 SAXException (org.xml.sax.SAXException)1