Search in sources :

Example 1 with CswFilterFactory

use of org.codice.ddf.spatial.ogc.csw.catalog.common.source.CswFilterFactory in project ddf by codice.

the class TestRegistryStore method testDelete.

@Test
public void testDelete() throws Exception {
    ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
    Csw csw = mock(Csw.class);
    TransactionResponseType transResponse = mock(TransactionResponseType.class);
    TransactionSummaryType transSummary = mock(TransactionSummaryType.class);
    when(transResponse.getTransactionSummary()).thenReturn(transSummary);
    when(transSummary.getTotalDeleted()).thenReturn(new BigInteger("1"));
    when(csw.transaction(any(CswTransactionRequest.class))).thenReturn(transResponse);
    when(factory.getClientForSubject(any())).thenReturn(csw);
    when(transformer.getTransformerIdForSchema(any())).thenReturn(null);
    FilterAdapter mockAdaptor = mock(FilterAdapter.class);
    CswFilterFactory filterFactory = new CswFilterFactory(CswAxisOrder.LAT_LON, false);
    FilterType filterType = filterFactory.buildPropertyIsLikeFilter(Metacard.ID, "testId", false);
    when(mockAdaptor.adapt(any(Filter.class), any(FilterDelegate.class))).thenReturn(filterType);
    registryStore.setFilterAdapter(mockAdaptor);
    DeleteRequestImpl request = new DeleteRequestImpl(Collections.singletonList(RegistryObjectMetacardType.REGISTRY_ID), "registryId", new HashMap<>());
    OperationTransactionImpl opTrans = new OperationTransactionImpl(OperationTransaction.OperationType.DELETE, Collections.singletonList(getDefaultMetacard()));
    request.getProperties().put(Constants.OPERATION_TRANSACTION_KEY, opTrans);
    registryStore.delete(request);
    verify(filterBuilder).attribute(captor.capture());
    assertThat(captor.getValue(), is("id"));
}
Also used : OperationTransactionImpl(ddf.catalog.operation.impl.OperationTransactionImpl) FilterDelegate(ddf.catalog.filter.FilterDelegate) Csw(org.codice.ddf.spatial.ogc.csw.catalog.common.Csw) DeleteRequestImpl(ddf.catalog.operation.impl.DeleteRequestImpl) FilterAdapter(ddf.catalog.filter.FilterAdapter) TransactionSummaryType(net.opengis.cat.csw.v_2_0_2.TransactionSummaryType) TransactionResponseType(net.opengis.cat.csw.v_2_0_2.TransactionResponseType) FilterType(net.opengis.filter.v_1_1_0.FilterType) Filter(org.opengis.filter.Filter) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) CswFilterFactory(org.codice.ddf.spatial.ogc.csw.catalog.common.source.CswFilterFactory) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Aggregations

FilterAdapter (ddf.catalog.filter.FilterAdapter)1 FilterDelegate (ddf.catalog.filter.FilterDelegate)1 DeleteRequestImpl (ddf.catalog.operation.impl.DeleteRequestImpl)1 OperationTransactionImpl (ddf.catalog.operation.impl.OperationTransactionImpl)1 BigInteger (java.math.BigInteger)1 TransactionResponseType (net.opengis.cat.csw.v_2_0_2.TransactionResponseType)1 TransactionSummaryType (net.opengis.cat.csw.v_2_0_2.TransactionSummaryType)1 FilterType (net.opengis.filter.v_1_1_0.FilterType)1 Csw (org.codice.ddf.spatial.ogc.csw.catalog.common.Csw)1 CswFilterFactory (org.codice.ddf.spatial.ogc.csw.catalog.common.source.CswFilterFactory)1 CswTransactionRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest)1 Test (org.junit.Test)1 Filter (org.opengis.filter.Filter)1