Search in sources :

Example 16 with IntegerFieldValue

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());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 17 with IntegerFieldValue

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());
}
Also used : IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 18 with IntegerFieldValue

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));
}
Also used : IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 19 with IntegerFieldValue

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());
}
Also used : SimpleTestAdapter(com.yahoo.vespa.indexinglanguage.SimpleTestAdapter) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Example 20 with IntegerFieldValue

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());
    }
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue) Test(org.junit.Test)

Aggregations

IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)69 Test (org.junit.Test)56 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)39 FieldValue (com.yahoo.document.datatypes.FieldValue)23 SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)14 LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)13 Array (com.yahoo.document.datatypes.Array)12 ByteFieldValue (com.yahoo.document.datatypes.ByteFieldValue)10 DoubleFieldValue (com.yahoo.document.datatypes.DoubleFieldValue)10 FloatFieldValue (com.yahoo.document.datatypes.FloatFieldValue)10 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)10 Struct (com.yahoo.document.datatypes.Struct)10 Field (com.yahoo.document.Field)8 DocumentType (com.yahoo.document.DocumentType)7 WeightedSet (com.yahoo.document.datatypes.WeightedSet)7 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)7 Document (com.yahoo.document.Document)5 DocumentUpdate (com.yahoo.document.DocumentUpdate)5 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)4 PredicateFieldValue (com.yahoo.document.datatypes.PredicateFieldValue)4