Search in sources :

Example 1 with PartitionKeyCodec

use of co.cask.cdap.api.dataset.lib.partitioned.PartitionKeyCodec in project cdap by caskdata.

the class PartitionKeyCodecTest method testSerDe.

@Test
public void testSerDe() {
    PartitionKey key = PartitionKey.builder().addField("a", "value,").addField("b", 1L).addField("c", -17).addField("d", true).addIntField("e", 42).addLongField("f", 15).addStringField("g", "value]}").build();
    Gson gson = new GsonBuilder().registerTypeAdapter(PartitionKey.class, new PartitionKeyCodec()).create();
    String serialized = gson.toJson(key);
    Assert.assertEquals(key, gson.fromJson(serialized, PartitionKey.class));
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) PartitionKeyCodec(co.cask.cdap.api.dataset.lib.partitioned.PartitionKeyCodec) PartitionKey(co.cask.cdap.api.dataset.lib.PartitionKey) Gson(com.google.gson.Gson) Test(org.junit.Test)

Aggregations

PartitionKey (co.cask.cdap.api.dataset.lib.PartitionKey)1 PartitionKeyCodec (co.cask.cdap.api.dataset.lib.partitioned.PartitionKeyCodec)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 Test (org.junit.Test)1