use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class ToStringTestCase method requireThatValueIsConverted.
@Test
public void requireThatValueIsConverted() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
ctx.setValue(new IntegerFieldValue(69)).execute(new ToStringExpression());
FieldValue val = ctx.getValue();
assertTrue(val instanceof StringFieldValue);
assertEquals("69", ((StringFieldValue) val).getString());
}
use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class SimpleExpressionTestCase method requireThatAccessorsWork.
@Test
public void requireThatAccessorsWork() {
SimpleExpression exp = new SimpleExpression();
assertNull(exp.requiredInputType());
assertNull(exp.createdOutputType());
assertNull(exp.execute());
assertNull(exp.verify());
assertEquals(DataType.INT, new SimpleExpression().setRequiredInput(DataType.INT).requiredInputType());
assertEquals(DataType.INT, new SimpleExpression().setCreatedOutput(DataType.INT).createdOutputType());
assertEquals(DataType.INT, new SimpleExpression().setVerifyValue(DataType.INT).verify());
assertEquals(new IntegerFieldValue(69), new SimpleExpression().setExecuteValue(new IntegerFieldValue(69)).execute());
}
use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class SimpleExpressionTestCase method requireThatHashCodeAndEqualsAreImplemented.
@Test
public void requireThatHashCodeAndEqualsAreImplemented() {
Expression exp = new SimpleExpression();
assertFalse(exp.equals(new Object()));
assertEquals(exp, new SimpleExpression());
assertEquals(exp.hashCode(), new SimpleExpression().hashCode());
exp = new SimpleExpression().setExecuteValue(null);
assertFalse(exp.equals(new SimpleExpression()));
assertEquals(exp, new SimpleExpression().setExecuteValue(null));
exp = new SimpleExpression().setExecuteValue(new IntegerFieldValue(69));
assertFalse(exp.equals(new SimpleExpression().setExecuteValue(new IntegerFieldValue(96))));
assertEquals(exp, new SimpleExpression().setExecuteValue(new IntegerFieldValue(69)));
exp = new SimpleExpression().setVerifyValue(null);
assertFalse(exp.equals(new SimpleExpression()));
assertEquals(exp, new SimpleExpression().setVerifyValue(null));
exp = new SimpleExpression().setVerifyValue(DataType.INT);
assertFalse(exp.equals(new SimpleExpression().setVerifyValue(DataType.STRING)));
assertEquals(exp, new SimpleExpression().setVerifyValue(DataType.INT));
exp = new SimpleExpression().setRequiredInput(DataType.INT);
assertFalse(exp.equals(new SimpleExpression().setRequiredInput(DataType.STRING)));
assertEquals(exp, new SimpleExpression().setRequiredInput(DataType.INT));
exp = new SimpleExpression().setCreatedOutput(DataType.INT);
assertFalse(exp.equals(new SimpleExpression().setCreatedOutput(DataType.STRING)));
assertEquals(exp, new SimpleExpression().setCreatedOutput(DataType.INT));
}
use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class StatementTestCase method requireThatStatementIsExecuted.
@Test
public void requireThatStatementIsExecuted() {
ExecutionContext ctx = new ExecutionContext(new SimpleTestAdapter());
StatementExpression statement = newStatement(new SetValueExpression(new IntegerFieldValue(69)));
newStatement(statement).execute(ctx);
FieldValue val = ctx.getValue();
assertTrue(val instanceof IntegerFieldValue);
assertEquals(69, ((IntegerFieldValue) val).getInteger());
}
use of com.yahoo.document.datatypes.IntegerFieldValue in project vespa by vespa-engine.
the class ArithmeticTestCase method requireThatNonNumericOperandThrows.
@Test
public void requireThatNonNumericOperandThrows() {
try {
newArithmetic(new SetValueExpression(new IntegerFieldValue(6)), Operator.ADD, new SetValueExpression(new StringFieldValue("9"))).execute();
fail();
} catch (IllegalArgumentException e) {
assertEquals("Unsupported operation: [int] + [string]", e.getMessage());
}
try {
newArithmetic(new SetValueExpression(new StringFieldValue("6")), Operator.ADD, new SetValueExpression(new IntegerFieldValue(9))).execute();
fail();
} catch (IllegalArgumentException e) {
assertEquals("Unsupported operation: [string] + [int]", e.getMessage());
}
}
Aggregations