ThingsFieldExpressionFactoryImpl implements ThingsFieldExpressionFactory { @Override public SortFieldExpression sortBy(final String propertyNameWithOptionalLeadingSlash) throws IllegalArgumentException { requireNonNull(propertyNameWithOptionalLeadingSlash); final String propertyName = stripLeadingSlash(propertyNameWithOptionalLeadingSlash); return FieldExpressionUtil.parseFeatureField(requireNonNull(propertyName)) .flatMap(f -> f.getFeatureId() .flatMap(id -> f.getProperty() .flatMap(property -> Optional .of((SortFieldExpression) new FeatureIdPropertyExpressionImpl(id, property)) ) ) ) .orElseGet(() -> (SortFieldExpression) common(propertyName)); } ThingsFieldExpressionFactoryImpl();  ThingsFieldExpressionFactoryImpl(final Map<String, String> simpleFieldMappings); @Override FilterFieldExpression filterBy(final String propertyNameWithOptionalLeadingSlash); @Override ExistsFieldExpression existsBy(final String propertyNameWithOptionalLeadingSlash); @Override SortFieldExpression sortBy(final String propertyNameWithOptionalLeadingSlash);  }
@Test public void sortByWithFeatureProperty() { final FieldExpression fieldExpression = ef.sortBy(KNOWN_FEATURE_PROPERTY_WITH_ID); final SortFieldExpression expected = new FeatureIdPropertyExpressionImpl(KNOWN_FEATURE_ID, KNOWN_STRING); assertThat(fieldExpression).isEqualTo(expected); }
@Test public void sortByWithJsonPointer() { final FieldExpression fieldExpression = ef.sortBy(SLASH + KNOWN_FEATURE_PROPERTY_WITH_ID); final SortFieldExpression expected = new FeatureIdPropertyExpressionImpl(KNOWN_FEATURE_ID, KNOWN_STRING); assertThat(fieldExpression).isEqualTo(expected); }
@Test(expected = IllegalArgumentException.class) public void sortByWithFeaturePropertyInvalid1() { ef.sortBy(KNOWN_FEATURE); }
@Test public void sortByDefinition() { final SortFieldExpression fieldExpression = ef.sortBy(KNOWN_THING_DEFINITION); final SortFieldExpression expected = new SimpleFieldExpressionImpl(KNOWN_THING_DEFINITION); assertThat(fieldExpression).isEqualTo(expected); }