use of org.geotoolkit.csw.xml.v202.InsertResultType in project ddf by codice.
the class TestRegistryStore method testCreateNoExistingMetacard.
@Test
public void testCreateNoExistingMetacard() throws Exception {
Metacard mcard = getDefaultMetacard();
Csw csw = mock(Csw.class);
TransactionResponseType responseType = mock(TransactionResponseType.class);
InsertResultType insertResultType = mock(InsertResultType.class);
BriefRecordType briefRecord = mock(BriefRecordType.class);
JAXBElement identifier = mock(JAXBElement.class);
SimpleLiteral literal = mock(SimpleLiteral.class);
when(literal.getContent()).thenReturn(Collections.singletonList(mcard.getId()));
when(identifier.getValue()).thenReturn(literal);
when(briefRecord.getIdentifier()).thenReturn(Collections.singletonList(identifier));
when(insertResultType.getBriefRecord()).thenReturn(Collections.singletonList(briefRecord));
when(responseType.getInsertResult()).thenReturn(Collections.singletonList(insertResultType));
when(factory.getClientForSubject(any())).thenReturn(csw);
when(csw.transaction(any())).thenReturn(responseType);
when(transformer.getTransformerIdForSchema(any())).thenReturn("myInsertType");
queryResults.add(new ResultImpl(mcard));
CreateRequest request = new CreateRequestImpl(mcard);
CreateResponse response = registryStore.create(request);
assertThat(response.getCreatedMetacards().get(0), is(mcard));
}
use of org.geotoolkit.csw.xml.v202.InsertResultType in project arctic-sea by 52North.
the class InsertResultRequestEncoder method create.
@Override
protected XmlObject create(InsertResultRequest request) throws EncodingException {
validateInput(request);
InsertResultDocument doc = InsertResultDocument.Factory.newInstance(getXmlOptions());
InsertResultType insertResult = doc.addNewInsertResult();
insertResult.setService(request.getService());
insertResult.setVersion(request.getVersion());
insertResult.setTemplate(request.getTemplateIdentifier());
addResultValues(request, insertResult);
return doc;
}
use of org.geotoolkit.csw.xml.v202.InsertResultType in project arctic-sea by 52North.
the class InsertResultRequestEncoderTest method shouldEncodeInsertResultRequest.
@Test
public void shouldEncodeInsertResultRequest() throws EncodingException {
String version = Sos2Constants.SERVICEVERSION;
String service = SosConstants.SOS;
String templateIdentifier = "test-template-identifier";
String resultValues = "test-result-values";
InsertResultRequest request = new InsertResultRequest(service, version);
request.setTemplateIdentifier(templateIdentifier);
request.setResultValues(resultValues);
XmlObject encodedRequest = encoder.create(request);
assertThat(encodedRequest, Matchers.instanceOf(InsertResultDocument.class));
assertThat(((InsertResultDocument) encodedRequest).getInsertResult(), Matchers.notNullValue());
InsertResultType xbRequest = ((InsertResultDocument) encodedRequest).getInsertResult();
assertThat(xbRequest.getService(), Is.is(service));
assertThat(xbRequest.getVersion(), Is.is(version));
assertThat(xbRequest.getTemplate(), Is.is(templateIdentifier));
assertThat(xbRequest.getResultValues(), Matchers.instanceOf(XmlString.class));
assertThat(((XmlString) xbRequest.getResultValues()).getStringValue(), Is.is(resultValues));
}
use of org.geotoolkit.csw.xml.v202.InsertResultType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method transactionResponseMarshalingTest.
@Test
public void transactionResponseMarshalingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
Marshaller marshaller = pool.acquireMarshaller();
SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
SimpleLiteral title = new SimpleLiteral("(JASON-1)");
SimpleLiteral type = new SimpleLiteral("clearinghouse");
List<BoundingBoxType> bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
Object record = new BriefRecordType(id, title, type, bbox);
final List<InsertResultType> inserteds = new ArrayList<>();
inserteds.add(new InsertResultType(Arrays.asList(record), null));
TransactionSummaryType summ = new TransactionSummaryType(2, 0, 1, "rid");
TransactionResponseType request = new TransactionResponseType(summ, inserteds, "2.0.2");
String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<csw:TransactionResponse version=\"2.0.2\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:ows=\"http://www.opengis.net/ows\">\n" + " <csw:TransactionSummary requestId=\"rid\">\n" + " <csw:totalInserted>2</csw:totalInserted>\n" + " <csw:totalUpdated>0</csw:totalUpdated>\n" + " <csw:totalDeleted>1</csw:totalDeleted>\n" + " </csw:TransactionSummary>\n" + " <csw:InsertResult>\n" + " <csw:BriefRecord>\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " </csw:BriefRecord>\n" + " </csw:InsertResult>\n" + "</csw:TransactionResponse>\n";
StringWriter sw = new StringWriter();
marshaller.marshal(request, sw);
String result = sw.toString();
assertXmlEquals(expResult, result, "xmlns:*");
pool.recycle(marshaller);
}
use of org.geotoolkit.csw.xml.v202.InsertResultType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method transactionResponseUnmarshalingTest.
/**
* Test simple Record Marshalling.
*/
@Test
public void transactionResponseUnmarshalingTest() throws JAXBException {
Unmarshaller unmarshaller = pool.acquireUnmarshaller();
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<csw:TransactionResponse version=\"2.0.2\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:ows=\"http://www.opengis.net/ows\">\n" + " <csw:TransactionSummary requestId=\"rid\">\n" + " <csw:totalInserted>2</csw:totalInserted>\n" + " <csw:totalUpdated>0</csw:totalUpdated>\n" + " <csw:totalDeleted>1</csw:totalDeleted>\n" + " </csw:TransactionSummary>\n" + " <csw:InsertResult>\n" + " <csw:BriefRecord>\n" + " <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + " <dc:title>(JASON-1)</dc:title>\n" + " <dc:type>clearinghouse</dc:type>\n" + " <ows:WGS84BoundingBox dimensions=\"2\">\n" + " <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + " <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + " </ows:WGS84BoundingBox>\n" + " </csw:BriefRecord>\n" + " </csw:InsertResult>\n" + "</csw:TransactionResponse>\n";
TransactionResponseType result = ((JAXBElement<TransactionResponseType>) unmarshaller.unmarshal(new StringReader(xml))).getValue();
SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
SimpleLiteral title = new SimpleLiteral("(JASON-1)");
SimpleLiteral type = new SimpleLiteral("clearinghouse");
List<BoundingBoxType> bbox = new ArrayList<>();
bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
Object record = new BriefRecordType(id, title, type, bbox);
final List<InsertResultType> inserteds = new ArrayList<>();
inserteds.add(new InsertResultType(Arrays.asList(record), null));
TransactionSummaryType summ = new TransactionSummaryType(2, 0, 1, "rid");
TransactionResponseType expResult = new TransactionResponseType(summ, inserteds, "2.0.2");
assertEquals(expResult.getTransactionSummary(), result.getTransactionSummary());
assertEquals(expResult.getInsertResult(), result.getInsertResult());
assertEquals(expResult, result);
pool.recycle(unmarshaller);
}
Aggregations