use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.
the class CswRecordMapperFilterVisitorTest method testVisitPropertyIsEqualToFunction.
@Test
public void testVisitPropertyIsEqualToFunction() {
Expression val = factory.literal(true);
ExtendedGeotoolsFunctionFactory geotoolsFunctionFactory = new ExtendedGeotoolsFunctionFactory();
Function function = geotoolsFunctionFactory.function("proximity", Arrays.asList(attrExpr, factory.literal(1), factory.literal("Marry little")), null);
PropertyIsEqualTo filter = factory.equals(function, val);
PropertyIsEqualTo duplicate = (PropertyIsEqualTo) visitor.visit(filter, null);
assertThat(duplicate.getExpression1(), Matchers.instanceOf(Function.class));
Function dupFunction = (Function) duplicate.getExpression1();
assertThat(dupFunction.getFunctionName(), is(function.getFunctionName()));
assertThat(dupFunction.getParameters(), is(function.getParameters()));
assertThat(duplicate.getExpression2(), is(val));
assertThat(duplicate.isMatchingCase(), is(true));
}
use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.
the class CswRecordMapperFilterVisitorTest method testVisitPropertyIsEqualToCaseInsensitive.
@Test
public void testVisitPropertyIsEqualToCaseInsensitive() {
Expression val = factory.literal("foo");
PropertyIsEqualTo filter = factory.equal(attrExpr, val, false);
PropertyIsEqualTo duplicate = (PropertyIsEqualTo) visitor.visit(filter, null);
assertThat(duplicate.getExpression1(), is(attrExpr));
assertThat(duplicate.getExpression2(), is(val));
assertThat(duplicate.isMatchingCase(), is(false));
}
use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.
the class CswQueryFactoryTest method testPostGetRecordsFunctionCQLQuery.
@Test
public void testPostGetRecordsFunctionCQLQuery() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException {
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();
constraint.setCqlText(CQL_CONTEXTUAL_FUNCTION_QUERY);
query.setConstraint(constraint);
JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
grr.setAbstractQuery(jaxbQuery);
QueryRequest queryRequest = queryFactory.getQuery(grr);
QueryImpl frameworkQuery = (QueryImpl) queryRequest.getQuery();
Filter queryFilter = ((QueryImpl) frameworkQuery.getFilter()).getFilter();
assertThat(queryFilter, instanceOf(PropertyIsEqualTo.class));
PropertyIsEqualTo equalTo = (PropertyIsEqualTo) queryFilter;
assertThat(equalTo.getExpression1(), instanceOf(Function.class));
Function function = (Function) equalTo.getExpression1();
assertThat(equalTo.getExpression2(), instanceOf(Literal.class));
Literal literal = (Literal) equalTo.getExpression2();
assertThat(function.getName(), is("proximity"));
assertThat(function.getParameters().get(0).evaluate(null), is(CONTEXTUAL_TEST_ATTRIBUTE));
assertThat(function.getParameters().get(1).evaluate(null), is(1L));
assertThat(function.getParameters().get(2).evaluate(null), is(CQL_CONTEXTUAL_PATTERN));
assertThat(literal.getValue(), is(true));
}
Aggregations