Search in sources :

Example 11 with MetacardValidator

use of ddf.catalog.validation.MetacardValidator 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 12 with MetacardValidator

use of ddf.catalog.validation.MetacardValidator 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)

Aggregations

MetacardValidator (ddf.catalog.validation.MetacardValidator)12 Metacard (ddf.catalog.data.Metacard)6 ValidationException (ddf.catalog.validation.ValidationException)6 Describable (ddf.catalog.util.Describable)5 ArrayList (java.util.ArrayList)4 RequiredAttributesMetacardValidator (ddf.catalog.validation.impl.validator.RequiredAttributesMetacardValidator)3 HashSet (java.util.HashSet)3 CreateRequest (ddf.catalog.operation.CreateRequest)2 UpdateRequest (ddf.catalog.operation.UpdateRequest)2 List (java.util.List)2 Callable (java.util.concurrent.Callable)2 Test (org.junit.Test)2 BundleContext (org.osgi.framework.BundleContext)2 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)1 MetacardType (ddf.catalog.data.MetacardType)1 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)1 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)1 Serializable (java.io.Serializable)1 Hashtable (java.util.Hashtable)1 Set (java.util.Set)1