use of io.crate.analyze.ValuesResolver in project crate by crate.
the class ExcludedFieldProviderTest method testResolveFieldsAndValues.
@Test
public void testResolveFieldsAndValues() {
QualifiedName normalField1 = QualifiedName.of("field1");
QualifiedName normalField2 = QualifiedName.of("normal", "field2");
QualifiedName excludedName = QualifiedName.of("excluded", "field3");
FieldProvider<?> fieldProvider = (qualifiedName, path, operation, errorOnUnknownObjectKey) -> new ScopedSymbol(new RelationName("doc", "dummy"), new ColumnIdent(qualifiedName.toString()), DataTypes.INTEGER);
ValuesResolver valuesResolver = argumentColumn -> {
assertThat(argumentColumn, isField("field3"));
return Literal.of(42);
};
ExcludedFieldProvider excludedFieldProvider = new ExcludedFieldProvider(fieldProvider, valuesResolver);
assertThat(excludedFieldProvider.resolveField(normalField1, null, Operation.READ, DEFAULT_ERROR_ON_UNKNOWN_OBJECT_KEY), isField(normalField1.toString()));
assertThat(excludedFieldProvider.resolveField(normalField2, null, Operation.READ, DEFAULT_ERROR_ON_UNKNOWN_OBJECT_KEY), isField(normalField2.toString()));
assertThat(excludedFieldProvider.resolveField(excludedName, null, Operation.READ, DEFAULT_ERROR_ON_UNKNOWN_OBJECT_KEY), isLiteral(42));
}
Aggregations