use of org.geotoolkit.csw.xml.v202.SearchResultsType in project ddf by codice.
the class CswSubscriptionEndpointTest method testCreateEventInvalidSchema.
@Test(expected = CswException.class)
public void testCreateEventInvalidSchema() throws Exception {
GetRecordsResponseType getRecordsResponse = new GetRecordsResponseType();
SearchResultsType searchResults = new SearchResultsType();
searchResults.setRecordSchema(CswConstants.CSW_OUTPUT_SCHEMA);
getRecordsResponse.setSearchResults(searchResults);
cswSubscriptionEndpoint.createEvent(getRecordsResponse);
}
use of org.geotoolkit.csw.xml.v202.SearchResultsType in project ddf by codice.
the class CswSubscriptionEndpointTest method testDeleteEventInvalidSchema.
@Test(expected = CswException.class)
public void testDeleteEventInvalidSchema() throws Exception {
GetRecordsResponseType getRecordsResponse = new GetRecordsResponseType();
SearchResultsType searchResults = new SearchResultsType();
searchResults.setRecordSchema(CswConstants.CSW_OUTPUT_SCHEMA);
getRecordsResponse.setSearchResults(searchResults);
cswSubscriptionEndpoint.deleteEvent(getRecordsResponse);
}
use of org.geotoolkit.csw.xml.v202.SearchResultsType in project ddf by codice.
the class CswSubscriptionEndpointTest method getRecordsResponse.
private GetRecordsResponseType getRecordsResponse(int metacardCount) throws IOException, CatalogTransformerException {
InputTransformer inputTransformer = mock(InputTransformer.class);
when(mockInputManager.getTransformerBySchema(METACARD_SCHEMA)).thenReturn(inputTransformer);
Metacard metacard = mock(Metacard.class);
when(inputTransformer.transform(any(InputStream.class))).thenReturn(metacard);
GetRecordsResponseType getRecordsResponse = new GetRecordsResponseType();
SearchResultsType searchResults = new SearchResultsType();
searchResults.setRecordSchema(METACARD_SCHEMA);
getRecordsResponse.setSearchResults(searchResults);
List<Object> any = new ArrayList<>();
Node node = mock(Node.class);
for (int i = 0; i < metacardCount; i++) {
any.add(node);
}
searchResults.setAny(any);
return getRecordsResponse;
}
use of org.geotoolkit.csw.xml.v202.SearchResultsType in project ddf by codice.
the class GetRecordsResponseConverterTest method testMarshalRecordCollectionHits.
@Ignore
@Test
public void testMarshalRecordCollectionHits() throws UnsupportedEncodingException, JAXBException {
final int totalResults = 5;
XStream xstream = createXStream(CswConstants.GET_RECORDS_RESPONSE);
GetRecordsType getRecords = new GetRecordsType();
QueryType query = new QueryType();
ElementSetNameType set = new ElementSetNameType();
set.setValue(ElementSetType.FULL);
query.setElementSetName(set);
ObjectFactory objectFactory = new ObjectFactory();
getRecords.setAbstractQuery(objectFactory.createAbstractQuery(query));
CswRecordCollection collection = createCswRecordCollection(getRecords, totalResults);
collection.setElementSetType(ElementSetType.FULL);
collection.setResultType(ResultType.HITS);
String xml = xstream.toXML(collection);
// Verify the context arguments were set correctly
verify(mockProvider, never()).marshal(any(Object.class), any(HierarchicalStreamWriter.class), any(MarshallingContext.class));
JAXBElement<GetRecordsResponseType> jaxb = (JAXBElement<GetRecordsResponseType>) getJaxBContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xml.getBytes("UTF-8")));
GetRecordsResponseType response = jaxb.getValue();
// Assert the GetRecordsResponse elements and attributes
assertThat(response, not(nullValue()));
SearchResultsType resultsType = response.getSearchResults();
assertThat(resultsType, not(nullValue()));
assertThat(resultsType.getElementSet(), is(ElementSetType.FULL));
assertThat(resultsType.getNumberOfRecordsMatched().intValue(), is(totalResults));
assertThat(resultsType.getNumberOfRecordsReturned().intValue(), is(0));
assertThat(resultsType.getRecordSchema(), is(CswConstants.CSW_OUTPUT_SCHEMA));
}
use of org.geotoolkit.csw.xml.v202.SearchResultsType in project ddf by codice.
the class GetRecordsResponseConverterTest method testMarshalRecordCollectionGetBrief.
@Ignore
@Test
public void testMarshalRecordCollectionGetBrief() throws UnsupportedEncodingException, JAXBException {
final int totalResults = 5;
XStream xstream = createXStream(CswConstants.GET_RECORDS_RESPONSE);
GetRecordsType getRecords = new GetRecordsType();
QueryType query = new QueryType();
ElementSetNameType set = new ElementSetNameType();
set.setValue(ElementSetType.BRIEF);
query.setElementSetName(set);
ObjectFactory objectFactory = new ObjectFactory();
getRecords.setAbstractQuery(objectFactory.createAbstractQuery(query));
CswRecordCollection collection = createCswRecordCollection(getRecords, totalResults);
collection.setElementSetType(ElementSetType.BRIEF);
ArgumentCaptor<MarshallingContext> captor = ArgumentCaptor.forClass(MarshallingContext.class);
String xml = xstream.toXML(collection);
// Verify the context arguments were set correctly
verify(mockProvider, times(totalResults)).marshal(any(Object.class), any(HierarchicalStreamWriter.class), captor.capture());
MarshallingContext context = captor.getValue();
assertThat(context, not(nullValue()));
assertThat(context.get(CswConstants.OUTPUT_SCHEMA_PARAMETER), is(CswConstants.CSW_OUTPUT_SCHEMA));
assertThat(context.get(CswConstants.ELEMENT_SET_TYPE), is(ElementSetType.BRIEF));
JAXBElement<GetRecordsResponseType> jaxb = (JAXBElement<GetRecordsResponseType>) getJaxBContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xml.getBytes("UTF-8")));
GetRecordsResponseType response = jaxb.getValue();
// Assert the GetRecordsResponse elements and attributes
assertThat(response, not(nullValue()));
SearchResultsType resultsType = response.getSearchResults();
assertThat(resultsType, not(nullValue()));
assertThat(resultsType.getElementSet(), is(ElementSetType.BRIEF));
assertThat(resultsType.getNumberOfRecordsMatched().intValue(), is(totalResults));
assertThat(resultsType.getNumberOfRecordsReturned().intValue(), is(totalResults));
assertThat(resultsType.getRecordSchema(), is(CswConstants.CSW_OUTPUT_SCHEMA));
}
Aggregations