use of io.cdap.cdap.proto.ProtoTrigger in project cdap by caskdata.
the class TriggerCodecTest method testSerDeserYieldsTrigger.
private void testSerDeserYieldsTrigger(ProtoTrigger proto, Trigger trigger) {
String jsonOfTrigger = GSON.toJson(trigger);
String jsonOfTriggerAsTrigger = GSON.toJson(trigger, Trigger.class);
String jsonOfProto = GSON.toJson(proto);
String jsonOfProtoAsTrigger = GSON.toJson(proto, Trigger.class);
String jsonOfTriggerByProto = GSON_PROTO.toJson(trigger);
String jsonOfTriggerAsTriggerByProto = GSON_PROTO.toJson(trigger, Trigger.class);
String jsonOfProtoByProto = GSON_PROTO.toJson(proto);
String jsonOfProtoAsTriggerByProto = GSON_PROTO.toJson(proto, Trigger.class);
Assert.assertEquals(jsonOfTrigger, jsonOfTriggerAsTrigger);
Assert.assertEquals(jsonOfTrigger, jsonOfProto);
Assert.assertEquals(jsonOfTrigger, jsonOfProtoAsTrigger);
Assert.assertEquals(jsonOfTrigger, jsonOfTriggerByProto);
Assert.assertEquals(jsonOfTrigger, jsonOfTriggerAsTriggerByProto);
Assert.assertEquals(jsonOfTrigger, jsonOfProtoByProto);
Assert.assertEquals(jsonOfTrigger, jsonOfProtoAsTriggerByProto);
Trigger deserialized = GSON.fromJson(jsonOfTrigger, Trigger.class);
Trigger deserializedAsProto = GSON_PROTO.fromJson(jsonOfTrigger, Trigger.class);
Assert.assertEquals(trigger, deserialized);
Assert.assertEquals(proto, deserializedAsProto);
}
Aggregations