use of io.cdap.cdap.internal.schedule.constraint.Constraint in project cdap by caskdata.
the class ConstraintCodecTest method testSerDeser.
private void testSerDeser(ProtoConstraint proto, Constraint constraint) {
String jsonOfConstraint = GSON.toJson(constraint);
String jsonOfConstraintAsConstraint = GSON.toJson(constraint, Constraint.class);
String jsonOfProto = GSON.toJson(proto);
String jsonOfProtoAsConstraint = GSON.toJson(proto, Constraint.class);
String jsonOfConstraintByProto = GSON_PROTO.toJson(constraint);
String jsonOfConstraintAsConstraintByProto = GSON_PROTO.toJson(constraint, Constraint.class);
String jsonOfProtoByProto = GSON_PROTO.toJson(proto);
String jsonOfProtoAsConstraintByProto = GSON_PROTO.toJson(proto, Constraint.class);
Assert.assertEquals(jsonOfConstraint, jsonOfConstraintAsConstraint);
Assert.assertEquals(jsonOfConstraint, jsonOfProto);
Assert.assertEquals(jsonOfConstraint, jsonOfProtoAsConstraint);
Assert.assertEquals(jsonOfConstraint, jsonOfConstraintByProto);
Assert.assertEquals(jsonOfConstraint, jsonOfConstraintAsConstraintByProto);
Assert.assertEquals(jsonOfConstraint, jsonOfProtoByProto);
Assert.assertEquals(jsonOfConstraint, jsonOfProtoAsConstraintByProto);
Constraint deserialized = GSON.fromJson(jsonOfConstraint, Constraint.class);
Constraint deserializedAsProto = GSON_PROTO.fromJson(jsonOfConstraint, Constraint.class);
Assert.assertEquals(constraint, deserialized);
Assert.assertEquals(proto, deserializedAsProto);
}
Aggregations