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"));
}
Aggregations