use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class MetacardValidityFilterPluginTest method filterPluginResponseHelper.
private PolicyResponse filterPluginResponseHelper(Result result, Metacard metacard, boolean filterErrors, boolean filterWarnings) throws Exception {
List<String> attributeMapping = Collections.singletonList("sample=test1,test2");
metacardValidityFilterPlugin.setAttributeMap(attributeMapping);
metacardValidityFilterPlugin.setFilterErrors(filterErrors);
metacardValidityFilterPlugin.setFilterWarnings(filterWarnings);
if (result != null) {
when(result.getMetacard()).thenReturn(metacard);
}
PolicyResponse response = metacardValidityFilterPlugin.processPostQuery(result, new HashMap<>());
return response;
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class MetacardValidityFilterPluginTest method testFilterWarningsOnly.
@Test
public void testFilterWarningsOnly() throws Exception {
Result result = mock(Result.class);
PolicyResponse response = filterPluginResponseHelper(result, getWarningsMetacard(), false, true);
assertThat(response.itemPolicy().get("sample").contains("test1"), is(true));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class ResourceUriPolicyTest method testInputUriNotEmptyButCatalogUriEmpty.
@Test
public void testInputUriNotEmptyButCatalogUriEmpty() throws URISyntaxException, StopProcessingException {
PolicyResponse response = getPolicyPlugin().processPreUpdate(getMockMetacard("sampleURI"), getMockProperties(""));
assertNotEmpty(response, "If metacard has no resource URI, but update does, policy needed to ensure no overwriting occurs");
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class ResourceUriPolicyTest method testNonLocalRequest.
@Test
public void testNonLocalRequest() throws URISyntaxException, StopProcessingException {
Map<String, Serializable> properties = getMockProperties("fizzle");
properties.put(LOCAL_DESTINATION_KEY, false);
PolicyResponse response = getPolicyPlugin().processPreCreate(getMockMetacard("sampleURI"), properties);
assertEmptyResponse(response);
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class ResourceUriPolicyTest method testTwoEmptyUris.
@Test
public void testTwoEmptyUris() throws URISyntaxException, StopProcessingException {
PolicyResponse response = getPolicyPlugin().processPreUpdate(getMockMetacard(""), getMockProperties(""));
assertEmptyResponse(response);
}
Aggregations