ThingsFieldExpressionFactoryImpl implements ThingsFieldExpressionFactory { @Override public ExistsFieldExpression existsBy(final String propertyNameWithOptionalLeadingSlash) { requireNonNull(propertyNameWithOptionalLeadingSlash); final String propertyName = stripLeadingSlash(propertyNameWithOptionalLeadingSlash); return FieldExpressionUtil.parseFeatureField(requireNonNull(propertyName)) .flatMap(f -> f.getFeatureId() .map(id -> f.getProperty() .<ExistsFieldExpression>map(property -> new FeatureIdPropertyExpressionImpl(id, property)) .orElseGet(() -> new FeatureExpressionImpl(id)) ) ) .orElseGet(() -> (ExistsFieldExpression) 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(expected = NullPointerException.class) public void existsByWithNullPropertyName() { ef.existsBy(null); }
@Test(expected = IllegalArgumentException.class) public void existsByWithUnknownPropertyName() { ef.existsBy("unknown"); }
@Test public void existsByWithFeaturePropertyWithId() { final FieldExpression fieldExpression = ef.existsBy(KNOWN_FEATURE_PROPERTY_WITH_ID); final ExistsFieldExpression expected = new FeatureIdPropertyExpressionImpl(KNOWN_FEATURE_ID, KNOWN_STRING); assertThat(fieldExpression).isEqualTo(expected); }
@Test public void existsByWithFeature() { final FieldExpression fieldExpression = ef.existsBy(KNOWN_FEATURE); final ExistsFieldExpression expected = new FeatureExpressionImpl(KNOWN_FEATURE_ID); assertThat(fieldExpression).isEqualTo(expected); }
@Test public void existsByWithJsonPointer() { final FieldExpression fieldExpression = ef.existsBy(SLASH + KNOWN_FEATURE); final ExistsFieldExpression expected = new FeatureExpressionImpl(KNOWN_FEATURE_ID); assertThat(fieldExpression).isEqualTo(expected); }
@Test public void existsByWithDefinition() { final FieldExpression fieldExpression = ef.existsBy(KNOWN_THING_DEFINITION); final ExistsFieldExpression expected = new SimpleFieldExpressionImpl(KNOWN_THING_DEFINITION); assertThat(fieldExpression).isEqualTo(expected); }