use of org.codice.ddf.spatial.ogc.csw.catalog.actions.InsertAction in project ddf by codice.
the class TransactionRequestConverterTest method testMultipleOperations.
@Test
public void testMultipleOperations() throws Exception {
CswTransactionRequest transactionRequest = new CswTransactionRequest();
MetacardImpl metacard = new MetacardImpl();
metacard.setId(METACARD_ID);
transactionRequest.setService(CswConstants.CSW);
transactionRequest.setVerbose(true);
transactionRequest.setVersion(CswConstants.VERSION_2_0_2);
InsertAction insertAction = new InsertActionImpl(CswConstants.CSW_METACARD_TYPE_NAME, null, Arrays.asList(metacard));
transactionRequest.getInsertActions().add(insertAction);
UpdateAction updateAction = new UpdateActionImpl(metacard, CswConstants.CSW_METACARD_TYPE_NAME, null);
transactionRequest.getUpdateActions().add(updateAction);
DeleteType deleteType = new DeleteType();
QueryConstraintType queryConstraintType = new QueryConstraintType();
queryConstraintType.setCqlText("identifier = " + METACARD_ID);
deleteType.setConstraint(queryConstraintType);
DeleteAction deleteAction = new DeleteActionImpl(deleteType, null);
transactionRequest.getDeleteActions().add(deleteAction);
String xml = xStream.toXML(transactionRequest);
Diff diff = XMLUnit.compareXML(xml, EXPECTED_MULTI_OP_XML);
assertThat(diff.similar(), is(true));
}
use of org.codice.ddf.spatial.ogc.csw.catalog.actions.InsertAction in project ddf by codice.
the class TransactionRequestConverterTest method testUnmarshalInsert.
@Test
public void testUnmarshalInsert() throws Exception {
String insertRequest = IOUtils.toString(TransactionRequestConverterTest.class.getResourceAsStream("/insertRequest.xml"));
CswTransactionRequest request = (CswTransactionRequest) xStream.fromXML(insertRequest);
assertThat(request.getDeleteActions(), emptyCollectionOf(DeleteAction.class));
assertThat(request.getUpdateActions(), emptyCollectionOf(UpdateAction.class));
assertThat(request.getInsertActions(), hasSize(1));
InsertAction action = request.getInsertActions().get(0);
assertThat(action.getTypeName(), is(CswConstants.CSW_RECORD));
}
Aggregations