Search in sources :

Example 11 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.

the class TestRegistryStore method testNonRegistryQuery.

@Test
public void testNonRegistryQuery() throws Exception {
    Filter filter = filterBuilder.attribute(RegistryObjectMetacardType.REGISTRY_ID).is().like().text("registryId");
    QueryRequest testRequest = new QueryRequestImpl(new QueryImpl(filter));
    queryResults.add(new ResultImpl(getDefaultMetacard()));
    SourceResponse answer = registryStore.query(testRequest);
    List<Result> testResults = answer.getResults();
    assertThat(testResults.size(), is(0));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 12 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.

the class TestRegistryStore method testInit.

@Test
public void testInit() throws Exception {
    RegistryStoreImpl registryStore = spy(new RegistryStoreImpl(context, cswSourceConfiguration, provider, factory, encryptionService) {

        @Override
        protected void validateOperation() {
        }

        @Override
        public boolean isAvailable() {
            return availability;
        }

        @Override
        protected SourceResponse query(QueryRequest queryRequest, ElementSetType elementSetName, List<QName> elementNames, Csw csw) throws UnsupportedQueryException {
            if (queryResults == null) {
                throw new UnsupportedQueryException("Test - Bad Query");
            }
            return new SourceResponseImpl(queryRequest, queryResults);
        }

        @Override
        public SourceResponse query(QueryRequest request) throws UnsupportedQueryException {
            return new SourceResponseImpl(request, Collections.singletonList(new Result() {

                @Override
                public Metacard getMetacard() {
                    MetacardImpl metacard = new MetacardImpl();
                    metacard.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, "registryId");
                    metacard.setAttribute(Metacard.TITLE, "title");
                    return metacard;
                }

                @Override
                public Double getRelevanceScore() {
                    return null;
                }

                @Override
                public Double getDistanceInMeters() {
                    return null;
                }
            }));
        }

        @Override
        protected CapabilitiesType getCapabilities() {
            return mock(CapabilitiesType.class);
        }

        @Override
        public void configureCswSource() {
        }

        ;

        @Override
        protected Subject getSystemSubject() {
            return subject;
        }

        @Override
        BundleContext getBundleContext() {
            return context;
        }
    });
    registryStore.setFilterBuilder(filterBuilder);
    registryStore.setFilterAdapter(filterAdapter);
    registryStore.setConfigAdmin(configAdmin);
    registryStore.setMetacardMarshaller(new MetacardMarshaller(parser));
    registryStore.setSchemaTransformerManager(transformer);
    registryStore.setAutoPush(true);
    registryStore.setRegistryUrl("http://test.url:0101/example");
    properties = new Hashtable<>();
    properties.put(RegistryStoreImpl.ID, "registryId");
    registryStore.setMetacardMarshaller(marshaller);
    Csw csw = mock(Csw.class);
    when(factory.getClientForSubject(any())).thenReturn(csw);
    cswSourceConfiguration.setCswUrl("https://localhost");
    cswSourceConfiguration.setPollIntervalMinutes(1);
    queryResults.add(new ResultImpl(getDefaultMetacard()));
    registryStore.init();
    assertThat(registryStore.getRegistryId(), is("registryId"));
}
Also used : QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) QName(javax.xml.namespace.QName) Csw(org.codice.ddf.spatial.ogc.csw.catalog.common.Csw) MetacardMarshaller(org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) ResultImpl(ddf.catalog.data.impl.ResultImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Subject(ddf.security.Subject) Result(ddf.catalog.data.Result) Metacard(ddf.catalog.data.Metacard) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) ElementSetType(net.opengis.cat.csw.v_2_0_2.ElementSetType) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 13 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.

the class TestRegistryStore method testRegistryQuery.

@Test
public void testRegistryQuery() throws Exception {
    Filter filter = filterBuilder.attribute(Metacard.TAGS).is().like().text(RegistryConstants.REGISTRY_TAG);
    queryResults.add(new ResultImpl(getDefaultMetacard()));
    QueryRequest testRequest = new QueryRequestImpl(new QueryImpl(filter));
    SourceResponse answer = registryStore.query(testRequest);
    List<Result> testResults = answer.getResults();
    assertThat(testResults.size(), is(1));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 14 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.

the class RegistryPolicyPluginTest method testBlackListPostQuery.

@Test
public void testBlackListPostQuery() throws Exception {
    Metacard mcard = new MetacardImpl();
    mcard.setAttribute(new AttributeImpl(Metacard.TAGS, RegistryConstants.REGISTRY_TAG));
    mcard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_ID, "validId"));
    mcard.setAttribute(new AttributeImpl(Metacard.ID, "1234567890abcdefg987654321"));
    RegistryPolicyPlugin rpp = createRegistryPlugin();
    rpp.setRegistryBypassPolicyStrings(Collections.singletonList("role=system-admin"));
    PolicyResponse response = rpp.processPostQuery(new ResultImpl(mcard), null);
    assertThat(response.operationPolicy().size(), is(0));
    assertThat(response.itemPolicy().size(), is(0));
    rpp.setRegistryEntryIds(Collections.singleton("1234567890abcdefg987654321"));
    response = rpp.processPostQuery(new ResultImpl(mcard), null);
    assertThat(response.itemPolicy(), equalTo(rpp.getBypassAccessPolicy()));
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) PolicyResponse(ddf.catalog.plugin.PolicyResponse) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 15 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.

the class RegistryPolicyPluginTest method testNoRegistryBypassPermissions.

@Test
public void testNoRegistryBypassPermissions() throws Exception {
    Metacard mcard = new MetacardImpl();
    mcard.setAttribute(new AttributeImpl(Metacard.TAGS, RegistryConstants.REGISTRY_TAG));
    mcard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_ID, "validId"));
    mcard.setAttribute(new AttributeImpl(Metacard.ID, "1234567890abcdefg987654321"));
    RegistryPolicyPlugin rpp = createRegistryPlugin();
    rpp.setRegistryBypassPolicyStrings(null);
    PolicyResponse response = rpp.processPostQuery(new ResultImpl(mcard), null);
    assertThat(response.itemPolicy().isEmpty(), is(true));
}
Also used : Metacard(ddf.catalog.data.Metacard) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) PolicyResponse(ddf.catalog.plugin.PolicyResponse) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Aggregations

ResultImpl (ddf.catalog.data.impl.ResultImpl)114 Result (ddf.catalog.data.Result)74 Test (org.junit.Test)73 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)61 Metacard (ddf.catalog.data.Metacard)47 ArrayList (java.util.ArrayList)45 QueryRequest (ddf.catalog.operation.QueryRequest)33 SourceResponse (ddf.catalog.operation.SourceResponse)30 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)23 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)21 QueryResponse (ddf.catalog.operation.QueryResponse)20 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)18 DAG (org.codice.alliance.nsili.common.UCO.DAG)17 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)15 BinaryContent (ddf.catalog.data.BinaryContent)10 MetacardTransformer (ddf.catalog.transform.MetacardTransformer)10 QueryImpl (ddf.catalog.operation.impl.QueryImpl)9 Product (org.codice.alliance.nsili.common.UID.Product)9 Query (ddf.catalog.operation.Query)7 PolicyResponse (ddf.catalog.plugin.PolicyResponse)7