Search in sources :

Example 6 with UpdateAction

use of org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction in project ddf by codice.

the class TestTransactionRequestConverter method testValidUpdateMarshal.

@Test
public void testValidUpdateMarshal() throws SAXException, IOException, XpathException {
    CswTransactionRequest transactionRequest = new CswTransactionRequest();
    MetacardImpl metacard = new MetacardImpl();
    metacard.setId(METACARD_ID);
    UpdateAction updateAction = new UpdateAction(metacard, CswConstants.CSW_METACARD_TYPE_NAME, null);
    transactionRequest.getUpdateActions().add(updateAction);
    transactionRequest.setService(CswConstants.CSW);
    transactionRequest.setVerbose(true);
    transactionRequest.setVersion(CswConstants.VERSION_2_0_2);
    String xml = xStream.toXML(transactionRequest);
    Diff diff = XMLUnit.compareXML(xml, EXPECTED_UPDATE_XML);
    assertThat(diff.similar(), is(true));
}
Also used : UpdateAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction) Diff(org.custommonkey.xmlunit.Diff) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 7 with UpdateAction

use of org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction in project ddf by codice.

the class TestTransactionRequestConverter method testUnmarshalUpdateWholeRecord.

@Test
public void testUnmarshalUpdateWholeRecord() throws Exception {
    String updateRequest = IOUtils.toString(TestTransactionRequestConverter.class.getResourceAsStream("/updateWholeRecordRequest.xml"));
    CswTransactionRequest request = (CswTransactionRequest) xStream.fromXML(updateRequest);
    assertThat(request.getDeleteActions(), emptyCollectionOf(DeleteAction.class));
    assertThat(request.getUpdateActions(), hasSize(1));
    assertThat(request.getInsertActions(), emptyCollectionOf(InsertAction.class));
    UpdateAction action = request.getUpdateActions().get(0);
    assertThat(action.getTypeName(), is(CswConstants.CSW_RECORD));
}
Also used : UpdateAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) InsertAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.InsertAction) DeleteAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.DeleteAction) Test(org.junit.Test)

Example 8 with UpdateAction

use of org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction in project ddf by codice.

the class TestTransactionRequestConverter method testUnmarshalByProperty.

@Test
public void testUnmarshalByProperty() throws Exception {
    String updateRequest = IOUtils.toString(TestTransactionRequestConverter.class.getResourceAsStream("/updateByPropertyRequest.xml"));
    CswTransactionRequest request = (CswTransactionRequest) xStream.fromXML(updateRequest);
    assertThat(request.getDeleteActions(), emptyCollectionOf(DeleteAction.class));
    assertThat(request.getUpdateActions(), hasSize(1));
    assertThat(request.getInsertActions(), emptyCollectionOf(InsertAction.class));
    UpdateAction action = request.getUpdateActions().get(0);
    assertThat(action.getTypeName(), is(CswConstants.CSW_RECORD));
    assertThat(action.getConstraint(), notNullValue());
    assertThat(action.getRecordProperties().size(), is(5));
    assertThat(action.getRecordProperties().get("title"), is("Updated Title"));
    assertThat(action.getRecordProperties().get("created"), is(CswUnmarshallHelper.convertToDate("2015-08-25")));
    assertThat(action.getRecordProperties().get("datatype"), is(Arrays.asList("ABC", "DEF", "GHI")));
    assertThat(action.getRecordProperties().get("language"), is(""));
    assertThat(action.getRecordProperties().get("language"), is(""));
}
Also used : UpdateAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) InsertAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.InsertAction) DeleteAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.DeleteAction) Test(org.junit.Test)

Example 9 with UpdateAction

use of org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction in project ddf by codice.

the class TestTransactionMessageBodyReader method testReadUpdateByNewRecordFrom.

@Test
public void testReadUpdateByNewRecordFrom() throws IOException, ParseException {
    TransactionMessageBodyReader reader = new TransactionMessageBodyReader(cswRecordConverter, CswQueryFactoryTest.getCswMetacardType(), registry);
    CswTransactionRequest request = reader.readFrom(CswTransactionRequest.class, null, null, null, null, IOUtils.toInputStream(UPDATE_REQUEST_BY_RECORD_XML));
    assertThat(request, notNullValue());
    assertThat(request.getInsertActions().size(), is(0));
    assertThat(request.getDeleteActions().size(), is(0));
    assertThat(request.getUpdateActions().size(), is(1));
    UpdateAction updateAction = request.getUpdateActions().get(0);
    assertThat(updateAction, notNullValue());
    assertThat(updateAction.getMetacard(), notNullValue());
    Metacard metacard = updateAction.getMetacard();
    assertThat(metacard.getId(), is("123"));
    assertThat(metacard.getTitle(), is("Aliquam fermentum purus quis arcu"));
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date date = simpleDateFormat.parse("2008-08-10");
    assertThat(metacard.getModifiedDate(), is(date));
    assertThat(metacard.getLocation(), is("POLYGON ((1.0 2.0, 3.0 2.0, 3.0 4.0, 1.0 4.0, 1.0 2.0))"));
    assertThat(request.getService(), is(CswConstants.CSW));
    assertThat(request.getVersion(), is(CswConstants.VERSION_2_0_2));
    assertThat(request.isVerbose(), is(false));
}
Also used : Metacard(ddf.catalog.data.Metacard) UpdateAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Aggregations

CswTransactionRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest)9 UpdateAction (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction)9 Test (org.junit.Test)9 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)4 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)4 Metacard (ddf.catalog.data.Metacard)3 Serializable (java.io.Serializable)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3 DeleteAction (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.DeleteAction)3 InsertAction (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.InsertAction)3 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)3 Update (ddf.catalog.operation.Update)2 UpdateRequest (ddf.catalog.operation.UpdateRequest)2 UpdateResponse (ddf.catalog.operation.UpdateResponse)2 UpdateImpl (ddf.catalog.operation.impl.UpdateImpl)2 UpdateResponseImpl (ddf.catalog.operation.impl.UpdateResponseImpl)2 ArrayList (java.util.ArrayList)2 TransactionResponseType (net.opengis.cat.csw.v_2_0_2.TransactionResponseType)2 TransactionSummaryType (net.opengis.cat.csw.v_2_0_2.TransactionSummaryType)2