use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class GetVarTestCase method requireThatSymbolIsRead.
@Test
public void requireThatSymbolIsRead() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setVariable("in", new IntegerFieldValue(69));
new GetVarExpression("in").execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof IntegerFieldValue);
assertEquals(69, ((IntegerFieldValue) val).getInteger());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class DocumentToPathUpdateTestCase method requireThatStructAssignIsConverted.
@Test
public void requireThatStructAssignIsConverted() {
DocumentType docType = new DocumentType("my_type");
StructDataType structType = new StructDataType("my_struct");
structType.addField(new Field("b", DataType.INT));
docType.addField(new Field("a", structType));
Struct struct = structType.createFieldValue();
struct.setFieldValue("b", new IntegerFieldValue(69));
FieldPathUpdate upd = new AssignFieldPathUpdate(docType, "a", "", struct);
Document doc = FieldPathUpdateHelper.newPartialDocument(null, upd);
assertNotNull(doc);
FieldValue obj = doc.getFieldValue("a");
assertTrue(obj instanceof Struct);
struct = (Struct) obj;
struct.setFieldValue("b", new IntegerFieldValue(96));
DocumentUpdate docUpd = new FieldPathUpdateAdapter(new SimpleDocumentAdapter(null, doc), upd).getOutput();
assertNotNull(docUpd);
assertEquals(1, docUpd.getFieldPathUpdates().size());
assertNotNull(upd = docUpd.getFieldPathUpdates().get(0));
assertTrue(upd instanceof AssignFieldPathUpdate);
assertEquals("a", upd.getOriginalFieldPath());
assertEquals(struct, ((AssignFieldPathUpdate) upd).getNewValue());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class DocumentToPathUpdateTestCase method requireThatStructElementAssignIsConverted.
@Test
public void requireThatStructElementAssignIsConverted() {
DocumentType docType = new DocumentType("my_type");
StructDataType structType = new StructDataType("my_struct");
structType.addField(new Field("b", DataType.INT));
docType.addField(new Field("a", structType));
FieldPathUpdate upd = new AssignFieldPathUpdate(docType, "a.b", "", new IntegerFieldValue(69));
Document doc = FieldPathUpdateHelper.newPartialDocument(null, upd);
assertNotNull(doc);
FieldValue obj = doc.getFieldValue("a");
assertTrue(obj instanceof Struct);
Struct struct = (Struct) obj;
struct.setFieldValue("b", new IntegerFieldValue(96));
DocumentUpdate docUpd = new FieldPathUpdateAdapter(new SimpleDocumentAdapter(null, doc), upd).getOutput();
assertNotNull(docUpd);
assertEquals(1, docUpd.getFieldPathUpdates().size());
assertNotNull(upd = docUpd.getFieldPathUpdates().get(0));
assertTrue(upd instanceof AssignFieldPathUpdate);
assertEquals("a.b", upd.getOriginalFieldPath());
obj = ((AssignFieldPathUpdate) upd).getNewValue();
assertTrue(obj instanceof IntegerFieldValue);
assertEquals(96, ((IntegerFieldValue) obj).getInteger());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class ExecutionContextTestCase method requireThatValueCanBeSet.
@Test
public void requireThatValueCanBeSet() {
ExecutionContext ctx = new ExecutionContext();
FieldValue val = new StringFieldValue("foo");
ctx.setValue(val);
assertSame(val, ctx.getValue());
}
use of com.yahoo.document.datatypes.FieldValue in project vespa by vespa-engine.
the class HexEncodeTestCase method requireThatInputIsEncoded.
@Test
public void requireThatInputIsEncoded() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new LongFieldValue(489210573L));
new HexEncodeExpression().execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertEquals("1d28c2cd", ((StringFieldValue) val).getString());
}
Aggregations