Search in sources :

Example 6 with Constraint

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

Aggregations

Constraint (io.cdap.cdap.internal.schedule.constraint.Constraint)6 ScheduleProgramInfo (io.cdap.cdap.api.workflow.ScheduleProgramInfo)4 ScheduleDetail (io.cdap.cdap.proto.ScheduleDetail)4 ApplicationId (io.cdap.cdap.proto.id.ApplicationId)4 ProtoConstraint (io.cdap.cdap.proto.ProtoConstraint)3 ArtifactSummary (io.cdap.cdap.api.artifact.ArtifactSummary)2 CommandInputError (io.cdap.cdap.cli.exception.CommandInputError)2 DelayConstraint (io.cdap.cdap.internal.app.runtime.schedule.constraint.DelayConstraint)2 TimeTrigger (io.cdap.cdap.internal.app.runtime.schedule.trigger.TimeTrigger)2 ProtoTrigger (io.cdap.cdap.proto.ProtoTrigger)2 ScheduledRuntime (io.cdap.cdap.proto.ScheduledRuntime)2 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)2 ProgramId (io.cdap.cdap.proto.id.ProgramId)2 ScheduleId (io.cdap.cdap.proto.id.ScheduleId)2 HttpResponse (io.cdap.common.http.HttpResponse)2 Test (org.junit.Test)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 ScheduleTaskRunner (io.cdap.cdap.internal.app.runtime.schedule.ScheduleTaskRunner)1 CheckableConstraint (io.cdap.cdap.internal.app.runtime.schedule.constraint.CheckableConstraint)1 BatchProgramSchedule (io.cdap.cdap.proto.BatchProgramSchedule)1