Search in sources :

Example 41 with PolicyResponse

use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.

the class CatalogPolicyTest method testPostResources.

@Test
public void testPostResources() throws StopProcessingException {
    ResourceResponse resourceResponse = mock(ResourceResponse.class);
    PolicyResponse response = policyPlugin.processPostResource(resourceResponse, mock(Metacard.class));
    assertThat(response.itemPolicy().size(), equalTo(0));
    assertThat(response.operationPolicy().size(), equalTo(0));
}
Also used : Metacard(ddf.catalog.data.Metacard) ResourceResponse(ddf.catalog.operation.ResourceResponse) PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Example 42 with PolicyResponse

use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.

the class ResourceUriPolicyTest method testInputUriNotEmptyAndDifferentThanCatalogUri.

@Test
public void testInputUriNotEmptyAndDifferentThanCatalogUri() throws URISyntaxException, StopProcessingException {
    PolicyResponse response = getPolicyPlugin().processPreUpdate(getMockMetacard("differentURI"), getMockProperties("foo"));
    assertNotEmpty(response, "If metacard and update each has resource URI, but differ, policy needed to ensure no overwriting occurs");
}
Also used : PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Example 43 with PolicyResponse

use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.

the class ResourceUriPolicyTest method testInputUriNotEmptyAndMatchesCatalogUri.

@Test
public void testInputUriNotEmptyAndMatchesCatalogUri() throws URISyntaxException, StopProcessingException {
    PolicyResponse response = getPolicyPlugin().processPreUpdate(getMockMetacard("sampleURI"), getMockProperties("sampleURI"));
    assertEmptyResponse(response);
}
Also used : PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Example 44 with PolicyResponse

use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.

the class ResourceUriPolicyTest method testCreatePermission.

@Test
public void testCreatePermission() throws URISyntaxException, StopProcessingException {
    PolicyResponse response = getPolicyPlugin().processPreCreate(getMockMetacard("sampleURI"), getMockProperties("zoom"));
    Map<String, Set<String>> itemPolicy = response.itemPolicy();
    assertThat("Creating a metacard with a resource URI requires special permissions", itemPolicy.containsKey("fizzle"), is(true));
    assertThat(itemPolicy.get("fizzle"), containsInAnyOrder("bang"));
}
Also used : Set(java.util.Set) PolicyResponse(ddf.catalog.plugin.PolicyResponse) Test(org.junit.Test)

Example 45 with PolicyResponse

use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.

the class ResourceUriPolicyTest method testInputUriEmptyButCatalogUriNotEmpty.

@Test
public void testInputUriEmptyButCatalogUriNotEmpty() throws URISyntaxException, StopProcessingException {
    PolicyResponse response = getPolicyPlugin().processPreUpdate(getMockMetacard(""), getMockProperties("sampleURI"));
    assertNotEmpty(response, "If metacard has resource URI, but update does not, policy needed to ensure no overwriting occurs");
}
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