use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class ExactTestCase method requireThatValueIsNotChanged.
@Test
public void requireThatValueIsNotChanged() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("FOO"));
new ExactExpression().execute(ctx);
assertEquals("FOO", String.valueOf(ctx.getValue()));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class ExactTestCase method requireThatValueIsAnnotated.
@Test
public void requireThatValueIsAnnotated() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new StringFieldValue("FOO"));
new ExactExpression().execute(ctx);
assertAnnotation(0, 3, new StringFieldValue("foo"), (StringFieldValue) ctx.getValue());
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class ExpressionTestCase method requireThatInputTypeIsCheckedBeforeExecute.
@Test
public void requireThatInputTypeIsCheckedBeforeExecute() {
assertExecute(newRequiredInput(DataType.INT), null);
assertExecute(newRequiredInput(DataType.INT), new IntegerFieldValue(69));
assertExecuteThrows(newRequiredInput(DataType.INT), new StringFieldValue("foo"), new IllegalArgumentException("expected int input, got string"));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class DocumentToPathUpdateTestCase method requireThatStringAssignIsConverted.
@Test
public void requireThatStringAssignIsConverted() {
DocumentType docType = new DocumentType("my_type");
docType.addField(new Field("my_str", DataType.STRING));
FieldPathUpdate upd = new AssignFieldPathUpdate(docType, "my_str", "", new StringFieldValue("69"));
Document doc = FieldPathUpdateHelper.newPartialDocument(null, upd);
assertNotNull(doc);
doc.setFieldValue("my_str", new StringFieldValue("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("my_str", upd.getOriginalFieldPath());
assertEquals(new StringFieldValue("96"), ((AssignFieldPathUpdate) upd).getNewValue());
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class DocumentUpdateTestCase method requireThatArrayOfStructElementAddIsProcessedCorrectly.
@Test
public void requireThatArrayOfStructElementAddIsProcessedCorrectly() throws ParseException {
DocumentType docType = new DocumentType("my_input");
docType.addField(new Field("my_str", DataType.getArray(DataType.STRING)));
docType.addField(new Field("my_pos", DataType.getArray(PositionDataType.INSTANCE)));
DocumentUpdate docUpdate = new DocumentUpdate(docType, "doc:scheme:");
docUpdate.addFieldUpdate(FieldUpdate.createAdd(docType.getField("my_str"), new StringFieldValue("6;9")));
docUpdate = Expression.execute(Expression.fromString("input my_str | for_each { to_pos } | index my_pos"), docUpdate);
assertNotNull(docUpdate);
assertEquals(0, docUpdate.getFieldPathUpdates().size());
assertEquals(1, docUpdate.getFieldUpdates().size());
FieldUpdate fieldUpd = docUpdate.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_pos"), fieldUpd.getField());
assertEquals(1, fieldUpd.getValueUpdates().size());
ValueUpdate valueUpd = fieldUpd.getValueUpdate(0);
assertNotNull(valueUpd);
assertTrue(valueUpd instanceof AddValueUpdate);
Object val = valueUpd.getValue();
assertNotNull(val);
assertTrue(val instanceof Struct);
Struct pos = (Struct) val;
assertEquals(PositionDataType.INSTANCE, pos.getDataType());
assertEquals(new IntegerFieldValue(6), PositionDataType.getXValue(pos));
assertEquals(new IntegerFieldValue(9), PositionDataType.getYValue(pos));
}
Aggregations