Search in sources :

Example 1 with ProtoConstraint

use of co.cask.cdap.proto.ProtoConstraint 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);
}
Also used : Constraint(co.cask.cdap.internal.schedule.constraint.Constraint) ProtoConstraint(co.cask.cdap.proto.ProtoConstraint)

Aggregations

Constraint (co.cask.cdap.internal.schedule.constraint.Constraint)1 ProtoConstraint (co.cask.cdap.proto.ProtoConstraint)1