Search in sources :

Example 6 with TransactionSummaryType

use of net.opengis.cat.csw.v_2_0_2.TransactionSummaryType 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)

Example 7 with TransactionSummaryType

use of net.opengis.cat.csw.v_2_0_2.TransactionSummaryType in project ddf by codice.

the class TestRegistryStore method testUpdate.

@Test
public void testUpdate() throws Exception {
    Csw csw = mock(Csw.class);
    TransactionResponseType responseType = mock(TransactionResponseType.class);
    TransactionSummaryType tst = new TransactionSummaryType();
    tst.setTotalUpdated(new BigInteger("1"));
    when(responseType.getTransactionSummary()).thenReturn(tst);
    when(factory.getClientForSubject(any())).thenReturn(csw);
    when(csw.transaction(any())).thenReturn(responseType);
    when(transformer.getTransformerIdForSchema(any())).thenReturn(null);
    UpdateRequestImpl request = new UpdateRequestImpl("testId", getDefaultMetacard());
    MetacardImpl updatedMcard = getDefaultMetacard();
    updatedMcard.setId("newTestId");
    OperationTransactionImpl opTrans = new OperationTransactionImpl(OperationTransaction.OperationType.UPDATE, Collections.singletonList(updatedMcard));
    request.getProperties().put(Constants.OPERATION_TRANSACTION_KEY, opTrans);
    queryResults.add(new ResultImpl(getDefaultMetacard()));
    registryStore.update(request);
    assertThat(request.getUpdates().get(0).getValue().getMetadata().contains("value=\"newTestId\""), is(true));
}
Also used : OperationTransactionImpl(ddf.catalog.operation.impl.OperationTransactionImpl) Csw(org.codice.ddf.spatial.ogc.csw.catalog.common.Csw) BigInteger(java.math.BigInteger) ResultImpl(ddf.catalog.data.impl.ResultImpl) UpdateRequestImpl(ddf.catalog.operation.impl.UpdateRequestImpl) TransactionSummaryType(net.opengis.cat.csw.v_2_0_2.TransactionSummaryType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) TransactionResponseType(net.opengis.cat.csw.v_2_0_2.TransactionResponseType) Test(org.junit.Test)

Example 8 with TransactionSummaryType

use of net.opengis.cat.csw.v_2_0_2.TransactionSummaryType in project ddf by codice.

the class TestCswEndpoint method testIngestTransaction.

@Test
public void testIngestTransaction() throws CswException, SourceUnavailableException, FederationException, IngestException {
    CswTransactionRequest request = new CswTransactionRequest();
    request.getInsertActions().add(new InsertAction(CswConstants.CSW_TYPE, null, Arrays.asList(new MetacardImpl())));
    TransactionResponseType response = csw.transaction(request);
    assertThat(response, notNullValue());
    assertThat(response.getInsertResult().isEmpty(), is(true));
    assertThat(response.getTransactionSummary(), notNullValue());
    TransactionSummaryType summary = response.getTransactionSummary();
    assertThat(summary.getTotalDeleted().intValue(), is(0));
    assertThat(summary.getTotalUpdated().intValue(), is(0));
    assertThat(summary.getTotalInserted().intValue(), is(1));
    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 : CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) InsertAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.InsertAction) TransactionSummaryType(net.opengis.cat.csw.v_2_0_2.TransactionSummaryType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) TransactionResponseType(net.opengis.cat.csw.v_2_0_2.TransactionResponseType) Test(org.junit.Test)

Aggregations

TransactionResponseType (net.opengis.cat.csw.v_2_0_2.TransactionResponseType)8 TransactionSummaryType (net.opengis.cat.csw.v_2_0_2.TransactionSummaryType)8 Test (org.junit.Test)7 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)6 CswTransactionRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest)6 ResultImpl (ddf.catalog.data.impl.ResultImpl)3 ArrayList (java.util.ArrayList)3 InsertAction (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.InsertAction)3 UpdateAction (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction)3 Metacard (ddf.catalog.data.Metacard)2 Result (ddf.catalog.data.Result)2 QueryRequest (ddf.catalog.operation.QueryRequest)2 QueryResponse (ddf.catalog.operation.QueryResponse)2 Update (ddf.catalog.operation.Update)2 UpdateRequest (ddf.catalog.operation.UpdateRequest)2 UpdateResponse (ddf.catalog.operation.UpdateResponse)2 OperationTransactionImpl (ddf.catalog.operation.impl.OperationTransactionImpl)2 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)2 UpdateImpl (ddf.catalog.operation.impl.UpdateImpl)2 UpdateResponseImpl (ddf.catalog.operation.impl.UpdateResponseImpl)2