use of net.opengis.wfs.v_2_0_0.QueryType in project ddf by codice.
the class TestCswEndpoint method testPostGetRecordsValidate.
@Test
public void testPostGetRecordsValidate() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException {
GetRecordsType grr = createDefaultPostRecordsRequest();
grr.setResultType(ResultType.VALIDATE);
QueryType query = new QueryType();
List<QName> typeNames = new ArrayList<>();
typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
query.setTypeNames(typeNames);
QueryConstraintType constraint = new QueryConstraintType();
constraint.setCqlText(CQL_CONTEXTUAL_LIKE_QUERY);
query.setConstraint(constraint);
JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
grr.setAbstractQuery(jaxbQuery);
when(catalogFramework.query(argument.capture())).thenReturn(getQueryResponse());
CswRecordCollection collection = csw.getRecords(grr);
assertThat(collection.getCswRecords(), is(empty()));
assertThat(collection.getNumberOfRecordsMatched(), is(0L));
assertThat(collection.getNumberOfRecordsReturned(), is(0L));
}
use of net.opengis.wfs.v_2_0_0.QueryType in project ddf by codice.
the class CswQueryFactoryTest method ogcSpatialQuery.
/**
* Runs a binary Spatial OGC Query, verifying that the right filter class is generated based on OGC Filter
*
* @param spatialOps BinarySpatialOps query
* @throws UnsupportedQueryException
* @throws SourceUnavailableException
* @throws FederationException
* @throws CswException
*/
private <N extends BinarySpatialOperator> void ogcSpatialQuery(Class<N> clz, JAXBElement<BinarySpatialOpType> spatialOps) throws UnsupportedQueryException, SourceUnavailableException, FederationException, CswException {
GetRecordsType grr = createDefaultPostRecordsRequest();
QueryType query = new QueryType();
List<QName> typeNames = new ArrayList<>();
typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
query.setTypeNames(typeNames);
QueryConstraintType constraint = new QueryConstraintType();
FilterType filter = new FilterType();
filter.setSpatialOps(spatialOps);
constraint.setFilter(filter);
query.setConstraint(constraint);
JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
grr.setAbstractQuery(jaxbQuery);
QueryImpl frameworkQuery = (QueryImpl) queryFactory.getQuery(grr).getQuery();
assertThat(frameworkQuery.getFilter(), instanceOf(clz));
@SuppressWarnings("unchecked") N spatial = (N) frameworkQuery.getFilter();
assertThat(((LiteralExpressionImpl) spatial.getExpression2()).getValue(), is(polygon));
assertThat(((AttributeExpressionImpl) spatial.getExpression1()).getPropertyName(), is(SPATIAL_TEST_ATTRIBUTE));
}
use of net.opengis.wfs.v_2_0_0.QueryType in project ddf by codice.
the class TestCswEndpoint method testPostGetRecordsResults.
@Test
public void testPostGetRecordsResults() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException {
GetRecordsType grr = createDefaultPostRecordsRequest();
grr.setResultType(ResultType.RESULTS);
QueryType query = new QueryType();
List<QName> typeNames = new ArrayList<>();
typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
query.setTypeNames(typeNames);
QueryConstraintType constraint = new QueryConstraintType();
constraint.setCqlText(CQL_CONTEXTUAL_LIKE_QUERY);
query.setConstraint(constraint);
ElementSetNameType esnt = new ElementSetNameType();
esnt.setValue(ElementSetType.SUMMARY);
query.setElementSetName(esnt);
JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
grr.setAbstractQuery(jaxbQuery);
final String exampleSchema = CswConstants.CSW_OUTPUT_SCHEMA;
grr.setOutputSchema(exampleSchema);
final String exampleMime = "application/xml";
grr.setOutputFormat(exampleMime);
CswRecordCollection collection = csw.getRecords(grr);
assertThat(collection.getMimeType(), is(exampleMime));
assertThat(collection.getOutputSchema(), is(exampleSchema));
assertThat(collection.getSourceResponse(), notNullValue());
assertThat(collection.getResultType(), is(ResultType.RESULTS));
assertThat(collection.getElementSetType(), is(ElementSetType.SUMMARY));
}
use of net.opengis.wfs.v_2_0_0.QueryType in project ddf by codice.
the class TestCswEndpoint method testPostGetRecordsValidElementNames.
/**
* Test Valid GetRecords request, no exceptions should be thrown
*/
@Test
public void testPostGetRecordsValidElementNames() throws CswException {
GetRecordsType grr = createDefaultPostRecordsRequest();
QueryType query = new QueryType();
JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
List<QName> elementNameList = Arrays.asList(new QName("brief"), new QName("summary"), new QName("full"));
query.setElementName(elementNameList);
grr.setAbstractQuery(jaxbQuery);
csw.getRecords(grr);
}
use of net.opengis.wfs.v_2_0_0.QueryType in project ddf by codice.
the class TestCswEndpoint method createDefaultPostRecordsRequest.
/**
* Creates default GetRecordsType POST request, with no sections specified
*
* @return Vanilla valid GetRecordsType object
*/
private GetRecordsType createDefaultPostRecordsRequest() {
GetRecordsType grr = new GetRecordsType();
grr.setOutputFormat(CswConstants.OUTPUT_FORMAT_XML);
grr.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
QueryType query = new QueryType();
List<QName> typeNames = new ArrayList<>();
typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
query.setTypeNames(typeNames);
JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
grr.setAbstractQuery(jaxbQuery);
return grr;
}
Aggregations