Search in sources :

Example 1 with DeleteResponseImpl

use of ddf.catalog.operation.impl.DeleteResponseImpl in project ddf by codice.

the class RegistryIdPostIngestPluginTest method testProcessDeleteLocal.

@Test
public void testProcessDeleteLocal() throws Exception {
    MetacardImpl metacard = getDefaultMetacard();
    metacard.setAttribute(RegistryObjectMetacardType.REGISTRY_LOCAL_NODE, true);
    CreateResponse createResponse = new CreateResponseImpl(null, null, Collections.singletonList(metacard));
    registryIdPostIngestPlugin.process(createResponse);
    assertThat(registryIdPostIngestPlugin.getLocalRegistryIds().size(), equalTo(1));
    DeleteResponse deleteResponse = new DeleteResponseImpl(null, null, Collections.singletonList(metacard));
    registryIdPostIngestPlugin.process(deleteResponse);
    assertThat(registryIdPostIngestPlugin.getLocalRegistryIds().size(), equalTo(0));
}
Also used : DeleteResponse(ddf.catalog.operation.DeleteResponse) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) CreateResponse(ddf.catalog.operation.CreateResponse) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) Test(org.junit.Test)

Example 2 with DeleteResponseImpl

use of ddf.catalog.operation.impl.DeleteResponseImpl in project ddf by codice.

the class RegistryIdPostIngestPluginTest method testProcessDelete.

@Test
public void testProcessDelete() throws Exception {
    CreateResponse createResponse = new CreateResponseImpl(null, null, Collections.singletonList(getDefaultMetacard()));
    registryIdPostIngestPlugin.process(createResponse);
    DeleteResponse deleteResponse = new DeleteResponseImpl(null, null, Collections.singletonList(getDefaultMetacard()));
    registryIdPostIngestPlugin.process(deleteResponse);
    assertThat(registryIdPostIngestPlugin.getRegistryIds().size(), equalTo(0));
}
Also used : DeleteResponse(ddf.catalog.operation.DeleteResponse) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) CreateResponse(ddf.catalog.operation.CreateResponse) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) Test(org.junit.Test)

Example 3 with DeleteResponseImpl

use of ddf.catalog.operation.impl.DeleteResponseImpl in project ddf by codice.

the class CachingFederationStrategyTest method testProcessDeleteResponse.

@Test
public void testProcessDeleteResponse() throws Exception {
    Map<String, Serializable> testMap = new HashMap<>();
    testMap.put(Constants.SERVICE_TITLE, MOCK_RESPONSE_TITLE);
    DeleteResponse response = new DeleteResponseImpl(mock(DeleteRequestImpl.class), testMap, new ArrayList<>());
    response = strategy.process(response);
    assertThat(response.getPropertyValue(Constants.SERVICE_TITLE), is(MOCK_RESPONSE_TITLE));
}
Also used : Serializable(java.io.Serializable) DeleteResponse(ddf.catalog.operation.DeleteResponse) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) HashMap(java.util.HashMap) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) Test(org.junit.Test)

Example 4 with DeleteResponseImpl

use of ddf.catalog.operation.impl.DeleteResponseImpl in project ddf by codice.

the class TestCswEndpoint method testDeleteTransaction.

@Test
public void testDeleteTransaction() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException, IngestException {
    DeleteType deleteType = mock(DeleteType.class);
    doReturn(CswConstants.CSW_RECORD).when(deleteType).getTypeName();
    doReturn("").when(deleteType).getHandle();
    QueryConstraintType queryConstraintType = new QueryConstraintType();
    queryConstraintType.setCqlText("title = \"foo\"");
    doReturn(queryConstraintType).when(deleteType).getConstraint();
    List<Result> results = new ArrayList<>();
    results.add(new ResultImpl(new MetacardImpl()));
    results.add(new ResultImpl(new MetacardImpl()));
    QueryResponse queryResponse = new QueryResponseImpl(null, results, results.size());
    doReturn(queryResponse).when(catalogFramework).query(any(QueryRequest.class));
    List<Metacard> deletedMetacards = new ArrayList<>();
    deletedMetacards.add(new MetacardImpl());
    deletedMetacards.add(new MetacardImpl());
    DeleteResponse deleteResponse = new DeleteResponseImpl(null, null, deletedMetacards);
    doReturn(deleteResponse).when(catalogFramework).delete(any(DeleteRequest.class));
    DeleteAction deleteAction = new DeleteAction(deleteType, DefaultCswRecordMap.getDefaultCswRecordMap().getPrefixToUriMapping());
    CswTransactionRequest deleteRequest = new CswTransactionRequest();
    deleteRequest.getDeleteActions().add(deleteAction);
    deleteRequest.setVersion(CswConstants.VERSION_2_0_2);
    deleteRequest.setService(CswConstants.CSW);
    deleteRequest.setVerbose(false);
    TransactionResponseType response = csw.transaction(deleteRequest);
    assertThat(response, notNullValue());
    TransactionSummaryType summary = response.getTransactionSummary();
    assertThat(summary, notNullValue());
    assertThat(summary.getTotalDeleted().intValue(), is(2));
    assertThat(summary.getTotalInserted().intValue(), is(0));
    assertThat(summary.getTotalUpdated().intValue(), is(0));
    verifyMarshalResponse(response, "net.opengis.cat.csw.v_2_0_2:net.opengis.filter.v_1_1_0:net.opengis.gml.v_3_1_1", cswQnameOutPutSchema);
}
Also used : QueryRequest(ddf.catalog.operation.QueryRequest) ArrayList(java.util.ArrayList) ResultImpl(ddf.catalog.data.impl.ResultImpl) TransactionSummaryType(net.opengis.cat.csw.v_2_0_2.TransactionSummaryType) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result) TransactionResponseType(net.opengis.cat.csw.v_2_0_2.TransactionResponseType) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) Metacard(ddf.catalog.data.Metacard) DeleteResponse(ddf.catalog.operation.DeleteResponse) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) QueryResponse(ddf.catalog.operation.QueryResponse) DeleteAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.DeleteAction) DeleteType(net.opengis.cat.csw.v_2_0_2.DeleteType) DeleteRequest(ddf.catalog.operation.DeleteRequest) Test(org.junit.Test)

Example 5 with DeleteResponseImpl

use of ddf.catalog.operation.impl.DeleteResponseImpl in project ddf by codice.

the class RemoteDeleteOperationsTest method setUpDeleteRequest.

private void setUpDeleteRequest() {
    MetacardImpl metacard = new MetacardImpl();
    ArrayList<Metacard> metacardList = new ArrayList<>();
    metacard.setId("Bob");
    metacard.setTitle("Bob's Title");
    metacardList.add(metacard);
    metacard = new MetacardImpl();
    metacard.setId("Bobbert");
    metacard.setTitle("Bobbert's Title");
    metacardList.add(metacard);
    deleteRequest = new DeleteRequestImpl(metacard.getId());
    deleteResponse = new DeleteResponseImpl(deleteRequest, new HashMap(), metacardList);
}
Also used : Metacard(ddf.catalog.data.Metacard) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) HashMap(java.util.HashMap) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) ArrayList(java.util.ArrayList) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Aggregations

DeleteResponseImpl (ddf.catalog.operation.impl.DeleteResponseImpl)18 DeleteResponse (ddf.catalog.operation.DeleteResponse)15 Test (org.junit.Test)13 Metacard (ddf.catalog.data.Metacard)11 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 DeleteRequest (ddf.catalog.operation.DeleteRequest)8 DeleteRequestImpl (ddf.catalog.operation.impl.DeleteRequestImpl)8 Serializable (java.io.Serializable)5 DeletedMetacard (ddf.catalog.core.versioning.DeletedMetacard)3 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)3 CreateResponse (ddf.catalog.operation.CreateResponse)3 CreateResponseImpl (ddf.catalog.operation.impl.CreateResponseImpl)3 IngestException (ddf.catalog.source.IngestException)3 List (java.util.List)3 DeleteStorageRequest (ddf.catalog.content.operation.DeleteStorageRequest)2 DeleteStorageRequestImpl (ddf.catalog.content.operation.impl.DeleteStorageRequestImpl)2 ResultImpl (ddf.catalog.data.impl.ResultImpl)2 Update (ddf.catalog.operation.Update)2 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)2