use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class NormalizeTestCase method requireThatInputIsNormalized.
@Test
public void requireThatInputIsNormalized() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setLanguage(Language.ENGLISH);
ctx.setValue(new StringFieldValue("b\u00e9yonc\u00e8"));
new NormalizeExpression(new SimpleLinguistics()).execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertEquals("beyonce", ((StringFieldValue) val).getString());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class OptimizePredicateTestCase method requireThatOptimizerIsCalledWithCloneOfInput.
@Test
public void requireThatOptimizerIsCalledWithCloneOfInput() {
final Predicate predicateA = Mockito.mock(Predicate.class);
final Predicate predicateB = Mockito.mock(Predicate.class);
final PredicateFieldValue input = new PredicateFieldValue(predicateA);
ExecutionContext ctx = new ExecutionContext().setValue(input).setVariable("arity", new IntegerFieldValue(10));
FieldValue output = new OptimizePredicateExpression((predicate, options) -> {
assertNotSame(predicateA, predicate);
return predicateB;
}).execute(ctx);
assertNotSame(output, input);
assertTrue(output instanceof PredicateFieldValue);
assertSame(predicateB, ((PredicateFieldValue) output).getPredicate());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class RandomTestCase method requireThatRandomValueIsSet.
@Test
public void requireThatRandomValueIsSet() {
for (int i = 0; i < 666; ++i) {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
new RandomExpression(69).execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof IntegerFieldValue);
assertTrue(((IntegerFieldValue) val).getInteger() < 69);
}
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class RandomTestCase method requireThatInputValueIsParsedAsMaxIfNoneIsConfigured.
@Test
public void requireThatInputValueIsParsedAsMaxIfNoneIsConfigured() {
for (int i = 0; i < 666; ++i) {
ExecutionContext ctx = new ExecutionContext().setValue(new IntegerFieldValue(69));
new RandomExpression().execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof IntegerFieldValue);
assertTrue(((IntegerFieldValue) val).getInteger() < 69);
}
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class SplitTestCase method requireThatValueIsSplit.
@Test
public void requireThatValueIsSplit() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("6;9"));
new SplitExpression(";").execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val.getDataType().equals(DataType.getArray(DataType.STRING)));
assertTrue(val instanceof Array);
Array arr = (Array) val;
assertEquals(new StringFieldValue("6"), arr.get(0));
assertEquals(new StringFieldValue("9"), arr.get(1));
}
Aggregations