use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class NGramTestCase method testNGrams.
@Test
public void testNGrams() {
ExecutionContext context = new ExecutionContext(new SimpleTestAdapter());
context.setValue(new StringFieldValue("en gul Bille sang... "));
new NGramExpression(new SimpleLinguistics(), 3).execute(context);
StringFieldValue value = (StringFieldValue) context.getValue();
assertEquals("Grams are pure annotations - field value is unchanged", "en gul Bille sang... ", value.getString());
SpanTree gramTree = value.getSpanTree(SpanTrees.LINGUISTICS);
assertNotNull(gramTree);
SpanList grams = (SpanList) gramTree.getRoot();
Iterator<SpanNode> i = grams.childIterator();
// en
assertSpan(0, 2, true, i, gramTree);
// <space>
assertSpan(2, 1, false, i, gramTree);
// gul
assertSpan(3, 3, true, i, gramTree);
// <space>
assertSpan(6, 1, false, i, gramTree);
// Bil
assertSpan(7, 3, true, i, gramTree, "bil");
assertSpan(8, 3, true, i, gramTree);
assertSpan(9, 3, true, i, gramTree);
// <space>
assertSpan(12, 1, false, i, gramTree);
assertSpan(13, 3, true, i, gramTree);
assertSpan(14, 3, true, i, gramTree);
// <...space>
assertSpan(17, 4, false, i, gramTree);
assertFalse(i.hasNext());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class ToArrayTestCase method requireThatValueIsConverted.
@Test
public void requireThatValueIsConverted() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("69")).execute(new ToArrayExpression());
FieldValue val = ctx.getValue();
assertEquals(Array.class, val.getClass());
Array arr = (Array) val;
ArrayDataType type = arr.getDataType();
assertEquals(DataType.STRING, type.getNestedType());
assertEquals(1, arr.size());
assertEquals(new StringFieldValue("69"), arr.get(0));
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class ToPositionTestCase method requireThatPositionIsParsed.
@Test
public void requireThatPositionIsParsed() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("6;9")).execute(new ToPositionExpression());
FieldValue out = ctx.getValue();
assertTrue(out instanceof StructuredFieldValue);
assertEquals(PositionDataType.INSTANCE, out.getDataType());
FieldValue val = ((StructuredFieldValue) out).getFieldValue("x");
assertTrue(val instanceof IntegerFieldValue);
assertEquals(6, ((IntegerFieldValue) val).getInteger());
val = ((StructuredFieldValue) out).getFieldValue("y");
assertTrue(val instanceof IntegerFieldValue);
assertEquals(9, ((IntegerFieldValue) val).getInteger());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class ThisTestCase method requireThatValueIsPreserved.
@Test
public void requireThatValueIsPreserved() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("69"));
new ThisExpression().execute(ctx);
assertEquals(new StringFieldValue("69"), ctx.getValue());
}
use of com.yahoo.vespa.indexinglanguage.SimpleTestAdapter in project vespa by vespa-engine.
the class ToByteTestCase method requireThatValueIsConverted.
@Test
public void requireThatValueIsConverted() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("69")).execute(new ToByteExpression());
FieldValue val = ctx.getValue();
assertTrue(val instanceof ByteFieldValue);
assertEquals(69, ((ByteFieldValue) val).getByte());
}
Aggregations