Search in sources :

Example 36 with PolicyResponse

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;
}
Also used : PolicyResponse(ddf.catalog.plugin.PolicyResponse)

Example 37 with PolicyResponse

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));
}
Also used : PolicyResponse(ddf.catalog.plugin.PolicyResponse) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 38 with PolicyResponse

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");
}
Also used : PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Example 39 with PolicyResponse

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);
}
Also used : Serializable(java.io.Serializable) PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Example 40 with PolicyResponse

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);
}
Also used : PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Aggregations

PolicyResponse (ddf.catalog.plugin.PolicyResponse)75 Test (org.junit.Test)64 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)20 Metacard (ddf.catalog.data.Metacard)19 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)14 Serializable (java.io.Serializable)14 Set (java.util.Set)14 Result (ddf.catalog.data.Result)13 HashMap (java.util.HashMap)12 PolicyPlugin (ddf.catalog.plugin.PolicyPlugin)10 HashSet (java.util.HashSet)7 ResultImpl (ddf.catalog.data.impl.ResultImpl)6 ResourceResponse (ddf.catalog.operation.ResourceResponse)6 Query (ddf.catalog.operation.Query)5 StopProcessingException (ddf.catalog.plugin.StopProcessingException)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 ResourceRequest (ddf.catalog.operation.ResourceRequest)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 OPERATION_TRANSACTION_KEY (ddf.catalog.Constants.OPERATION_TRANSACTION_KEY)2