### Question:
Task { @Override public String toString() { return "Task{" + "id=" + id + ", name='" + name + '\'' + ", executionTime=" + executionTime + ", payload='" + payload + '\'' + '}'; } Task(
            String id,
            String name,
            long executionTime,
            String payload); private  Task(); final String getId(); final String getName(); final long getExecutionTime(); void setExecutionTime(long executionTime); final String getPayload(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void serializeDeserializeTaskTest() throws Exception { Task task = new Task(UUID.randomUUID().toString(), "task", System.currentTimeMillis(), "payload"); Object serializedTask = PostgresUtil.objectToJsonBParameter(task, null); Task deserializedTask = PostgresUtil.fromJsonB(((PGobject) serializedTask).getValue(), Task.class); Assert.assertEquals(task, deserializedTask); }
@Test public void serializeDeserializeOneOffTaskTest() throws Exception { String id = UUID.randomUUID().toString(); OneOffTask task = new OneOffTask(id, "task", System.currentTimeMillis(), "payload", "consumer"); Object serializedTask = PostgresUtil.objectToJsonBParameter(task, null); Task deserializedTask = PostgresUtil.fromJsonB(((PGobject) serializedTask).getValue(), Task.class); Assert.assertEquals(task, deserializedTask); }
@Test public void serializeDeserializeRecurringTaskTest() throws Exception { String id = UUID.randomUUID().toString(); Task task = new RecurringTask(id, "task", System.currentTimeMillis(), "payload", "function", 5); Object serializedTask = PostgresUtil.objectToJsonBParameter(task, null); Task deserializedTask = PostgresUtil.fromJsonB(((PGobject) serializedTask).getValue(), Task.class); Assert.assertEquals(task, deserializedTask); }