Search in sources :

Example 56 with CreateResponse

use of ddf.catalog.operation.CreateResponse in project ddf by codice.

the class SolrProviderCreate method testCreateNullList.

@Test
public void testCreateNullList() throws IngestException, UnsupportedQueryException {
    deleteAll(provider);
    CreateResponse response = provider.create(new CreateRequest() {

        @Override
        public boolean hasProperties() {
            return false;
        }

        @Override
        public Serializable getPropertyValue(String name) {
            return null;
        }

        @Override
        public Set<String> getPropertyNames() {
            return null;
        }

        @Override
        public Map<String, Serializable> getProperties() {
            return null;
        }

        @Override
        public boolean containsPropertyName(String name) {
            return false;
        }

        @Override
        public List<Metacard> getMetacards() {
            return null;
        }
    });
    assertThat(response.getCreatedMetacards().size(), is(0));
}
Also used : Serializable(java.io.Serializable) Set(java.util.Set) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequest(ddf.catalog.operation.CreateRequest) ArrayList(java.util.ArrayList) List(java.util.List) Matchers.containsString(org.hamcrest.Matchers.containsString) Map(java.util.Map) SolrProviderTest(ddf.catalog.source.solr.SolrProviderTest) Test(org.junit.Test)

Example 57 with CreateResponse

use of ddf.catalog.operation.CreateResponse in project ddf by codice.

the class SolrProviderCreate method testCreatePendingNrtIndex.

@Test
public void testCreatePendingNrtIndex() throws Exception {
    deleteAll(provider);
    ConfigurationStore.getInstance().setForceAutoCommit(false);
    try {
        MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
        CreateResponse response = create(metacard, provider);
        String createdId = response.getCreatedMetacards().get(0).getId();
        Filter titleFilter = getFilterBuilder().attribute(Metacard.TITLE).like().text(MockMetacard.DEFAULT_TITLE);
        Filter idFilter = getFilterBuilder().attribute(Metacard.ID).equalTo().text(createdId);
        SourceResponse titleResponse = provider.query(new QueryRequestImpl(new QueryImpl(titleFilter)));
        SourceResponse idResponse = provider.query(new QueryRequestImpl(new QueryImpl(idFilter)));
        assertThat(titleResponse.getResults().size(), is(0));
        assertThat(idResponse.getResults().size(), is(1));
    } finally {
        ConfigurationStore.getInstance().setForceAutoCommit(true);
    }
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) SourceResponse(ddf.catalog.operation.SourceResponse) Filter(org.opengis.filter.Filter) CreateResponse(ddf.catalog.operation.CreateResponse) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) Matchers.containsString(org.hamcrest.Matchers.containsString) SolrProviderTest(ddf.catalog.source.solr.SolrProviderTest) Test(org.junit.Test)

Example 58 with CreateResponse

use of ddf.catalog.operation.CreateResponse in project ddf by codice.

the class SolrProviderDelete method testDeletePendingNrtIndex.

@Test
public void testDeletePendingNrtIndex() throws Exception {
    deleteAll(provider);
    ConfigurationStore.getInstance().setForceAutoCommit(false);
    try {
        MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
        CreateResponse createResponse = create(metacard, provider);
        DeleteResponse deleteResponse = delete(createResponse.getCreatedMetacards().get(0).getId(), provider);
        Metacard deletedMetacard = deleteResponse.getDeletedMetacards().get(0);
        verifyDeletedRecord(metacard, createResponse, deleteResponse, deletedMetacard);
    } finally {
        ConfigurationStore.getInstance().setForceAutoCommit(true);
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) DeleteResponse(ddf.catalog.operation.DeleteResponse) CreateResponse(ddf.catalog.operation.CreateResponse) SolrProviderTest(ddf.catalog.source.solr.SolrProviderTest) Test(org.junit.Test)

Example 59 with CreateResponse

use of ddf.catalog.operation.CreateResponse in project ddf by codice.

the class SolrProviderDelete method testDeleteAlternativeAttribute.

/**
 * Testing if another attribute can be used to delete records other than {@link Metacard#ID}
 */
@Test
public void testDeleteAlternativeAttribute() throws IngestException, UnsupportedQueryException {
    deleteAll(provider);
    MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
    CreateResponse createResponse = create(metacard, provider);
    DeleteResponse deleteResponse = provider.delete(new DeleteRequest() {

        @Override
        public boolean hasProperties() {
            return false;
        }

        @Override
        public Serializable getPropertyValue(String name) {
            return null;
        }

        @Override
        public Set<String> getPropertyNames() {
            return null;
        }

        @Override
        public Map<String, Serializable> getProperties() {
            return null;
        }

        @Override
        public boolean containsPropertyName(String name) {
            return false;
        }

        @Override
        public List<? extends Serializable> getAttributeValues() {
            return Collections.singletonList(MockMetacard.DEFAULT_TITLE);
        }

        @Override
        public String getAttributeName() {
            return Metacard.TITLE;
        }
    });
    Metacard deletedMetacard = deleteResponse.getDeletedMetacards().get(0);
    verifyDeletedRecord(metacard, createResponse, deleteResponse, deletedMetacard);
    // verify it is really not in SOLR
    Filter filter = getFilterBuilder().attribute(Metacard.TITLE).like().text(MockMetacard.DEFAULT_TITLE);
    QueryImpl query = new QueryImpl(filter);
    SourceResponse sourceResponse = provider.query(new QueryRequestImpl(query));
    List<Result> results = sourceResponse.getResults();
    assertEquals(0, results.size());
}
Also used : Serializable(java.io.Serializable) Set(java.util.Set) SourceResponse(ddf.catalog.operation.SourceResponse) CreateResponse(ddf.catalog.operation.CreateResponse) Result(ddf.catalog.data.Result) Metacard(ddf.catalog.data.Metacard) QueryImpl(ddf.catalog.operation.impl.QueryImpl) DeleteResponse(ddf.catalog.operation.DeleteResponse) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) ArrayList(java.util.ArrayList) List(java.util.List) DeleteRequest(ddf.catalog.operation.DeleteRequest) Map(java.util.Map) SolrProviderTest(ddf.catalog.source.solr.SolrProviderTest) Test(org.junit.Test)

Example 60 with CreateResponse

use of ddf.catalog.operation.CreateResponse in project ddf by codice.

the class SolrProviderTest method testUpdateOperationSimple.

/**
     * Testing that if records are properly updated.
     *
     * @throws IngestException
     * @throws UnsupportedQueryException
     */
@Test
public void testUpdateOperationSimple() throws IngestException, UnsupportedQueryException {
    // Single Update
    deleteAllIn(provider);
    MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
    CreateResponse createResponse = create(metacard);
    String id = createResponse.getCreatedMetacards().get(0).getId();
    metacard.setContentTypeName("newContentType");
    UpdateResponse response = update(id, metacard);
    Update update = response.getUpdatedMetacards().get(0);
    Metacard newMetacard = update.getNewMetacard();
    Metacard oldMetacard = update.getOldMetacard();
    assertEquals(1, response.getUpdatedMetacards().size());
    assertEquals("newContentType", newMetacard.getContentTypeName());
    assertEquals(MockMetacard.DEFAULT_TYPE, oldMetacard.getContentTypeName());
}
Also used : UpdateResponse(ddf.catalog.operation.UpdateResponse) Metacard(ddf.catalog.data.Metacard) CreateResponse(ddf.catalog.operation.CreateResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) Update(ddf.catalog.operation.Update) Test(org.junit.Test)

Aggregations

CreateResponse (ddf.catalog.operation.CreateResponse)111 Test (org.junit.Test)82 Metacard (ddf.catalog.data.Metacard)76 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)44 ArrayList (java.util.ArrayList)42 CreateRequest (ddf.catalog.operation.CreateRequest)36 QueryImpl (ddf.catalog.operation.impl.QueryImpl)29 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)29 CreateResponseImpl (ddf.catalog.operation.impl.CreateResponseImpl)27 HashMap (java.util.HashMap)25 Serializable (java.io.Serializable)23 List (java.util.List)23 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)22 DeleteResponse (ddf.catalog.operation.DeleteResponse)22 UpdateResponse (ddf.catalog.operation.UpdateResponse)21 Filter (org.opengis.filter.Filter)21 IngestException (ddf.catalog.source.IngestException)20 SourceResponse (ddf.catalog.operation.SourceResponse)18 QueryRequest (ddf.catalog.operation.QueryRequest)17 MetacardType (ddf.catalog.data.MetacardType)16