use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class TestField method testDate.
@Test
public void testDate() throws Exception {
Type type = DATE;
Date expected = new Date(new GregorianCalendar(1999, 0, 1).getTime().getTime());
Field f1 = new Field(expected, type);
assertEquals(f1.getDate(), expected);
assertEquals(f1.getObject(), expected);
assertEquals(f1.getType(), type);
assertEquals(f1.toString(), "DATE '1999-01-01'");
Field f2 = new Field(f1);
assertEquals(f2, f1);
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class TestField method testSmallInt.
@Test
public void testSmallInt() throws Exception {
Type type = SMALLINT;
Short expected = 12345;
Field f1 = new Field(expected, type);
assertEquals(f1.getShort(), expected);
assertEquals(f1.getObject(), expected);
assertEquals(f1.getType(), type);
assertEquals(f1.toString(), "12345");
Field f2 = new Field(f1);
assertEquals(f2, f1);
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class AbstractTestAccumuloRowSerializer method testVarbinary.
@Test
public void testVarbinary() throws Exception {
AccumuloRowSerializer serializer = serializerClass.getConstructor().newInstance();
Type type = VARBINARY;
byte[] expected = b(UUID.randomUUID().toString());
byte[] data = serializer.encode(type, expected);
byte[] actual = serializer.decode(type, data);
assertEquals(actual, expected);
deserializeData(serializer, data);
actual = serializer.getVarbinary(COLUMN_NAME);
assertEquals(actual, expected);
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class AbstractTestAccumuloRowSerializer method testSmallInt.
@Test
public void testSmallInt() throws Exception {
AccumuloRowSerializer serializer = serializerClass.getConstructor().newInstance();
Type type = SMALLINT;
Short expected = 12345;
byte[] data = serializer.encode(type, expected);
Short actual = ((Long) serializer.decode(type, data)).shortValue();
assertEquals(actual, expected);
deserializeData(serializer, data);
actual = serializer.getShort(COLUMN_NAME);
assertEquals(actual, expected);
}
use of com.facebook.presto.spi.type.Type in project presto by prestodb.
the class AbstractTestAccumuloRowSerializer method testInt.
@Test
public void testInt() throws Exception {
AccumuloRowSerializer serializer = serializerClass.getConstructor().newInstance();
Type type = INTEGER;
Integer expected = 123456;
byte[] data = serializer.encode(type, expected);
@SuppressWarnings("unchecked") Integer actual = ((Long) serializer.decode(type, data)).intValue();
assertEquals(actual, expected);
deserializeData(serializer, data);
actual = serializer.getInt(COLUMN_NAME);
assertEquals(actual, expected);
}
Aggregations