use of org.codice.ddf.spatial.ogc.csw.catalog.actions.DeleteAction in project ddf by codice.
the class TransactionRequestConverterTest method testUnmarshalDelete.
@Test
public void testUnmarshalDelete() throws Exception {
String deleteRequest = IOUtils.toString(TransactionRequestConverterTest.class.getResourceAsStream("/deleteRequest.xml"));
CswTransactionRequest request = (CswTransactionRequest) xStream.fromXML(deleteRequest);
assertThat(request.getDeleteActions(), hasSize(1));
assertThat(request.getUpdateActions(), emptyCollectionOf(UpdateAction.class));
assertThat(request.getInsertActions(), emptyCollectionOf(InsertAction.class));
DeleteAction action = request.getDeleteActions().get(0);
assertThat(action.getTypeName(), is(CswConstants.CSW_RECORD));
}
use of org.codice.ddf.spatial.ogc.csw.catalog.actions.DeleteAction 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));
}
Aggregations