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