Search in sources :

Example 1 with MapKeyTest

use of com.twitter.elephantbird.pig.test.thrift.MapKeyTest in project elephant-bird by twitter.

the class TestPigToThrift method testSupportedMapKeyTypes.

@Test
public void testSupportedMapKeyTypes() {
    MapKeyTest expected = new MapKeyTest().setBooleans(ImmutableMap.of(true, 1)).setBytes(ImmutableMap.of((byte) 1, 1)).setShorts(ImmutableMap.of((short) 1, 1)).setInts(ImmutableMap.of(1, 1)).setLongs(ImmutableMap.of(1L, 1)).setDoubles(ImmutableMap.of(1D, 1)).setEnums(ImmutableMap.of(KeyEnum.A, 1)).setStrings(ImmutableMap.of("a", 1)).setBinaries(ImmutableMap.of(ByteBuffer.wrap("1".getBytes(Charsets.UTF_8)), 1));
    MapKeyTest actual = PigToThrift.newInstance(MapKeyTest.class).getThriftObject(tuple(ImmutableMap.of("true", 1), ImmutableMap.of("1", 1), ImmutableMap.of("1", 1), ImmutableMap.of("1", 1), ImmutableMap.of("1", 1), ImmutableMap.of("1.0", 1), ImmutableMap.of(KeyEnum.A.name(), 1), ImmutableMap.of("a", 1), ImmutableMap.of("1", 1)));
    assertEquals(expected, actual);
}
Also used : MapKeyTest(com.twitter.elephantbird.pig.test.thrift.MapKeyTest) Test(org.junit.Test) MapKeyTest(com.twitter.elephantbird.pig.test.thrift.MapKeyTest)

Example 2 with MapKeyTest

use of com.twitter.elephantbird.pig.test.thrift.MapKeyTest in project elephant-bird by twitter.

the class TestPigToThrift method testMapKeyConversionFailure.

@Test
public void testMapKeyConversionFailure() {
    MapKeyTest fail = PigToThrift.newInstance(MapKeyTest.class).getThriftObject(tuple(null, ImmutableMap.of("notabyte", 1)));
    assertNotNull(fail);
    assertNull(fail.getBytes());
}
Also used : MapKeyTest(com.twitter.elephantbird.pig.test.thrift.MapKeyTest) Test(org.junit.Test) MapKeyTest(com.twitter.elephantbird.pig.test.thrift.MapKeyTest)

Aggregations

MapKeyTest (com.twitter.elephantbird.pig.test.thrift.MapKeyTest)2 Test (org.junit.Test)2