@Test public void testSerializationWithJobsList() { ProducerJob job1 = new SimpleProducerJob("p1", "2016-11-22", "2016-11-22"); ProducerJob job2 = new SimpleProducerJob("p2", "2016-11-23", "2016-11-23"); ArrayList<ProducerJob> jobs = new ArrayList<>(); jobs.add(job1); jobs.add(job2); String json = ProducerJob.serialize(jobs); List<ProducerJob> deserialized = SimpleProducerJob.deserialize(json); Assert.assertEquals(job1, deserialized.get(0)); Assert.assertEquals(job2, deserialized.get(1)); }
public static String serialize(Collection<ProducerJob> jobs) { Collection<ProducerJob> producerJobs = new ArrayList<>(jobs.size()); for (ProducerJob job : jobs) { producerJobs.add(new SimpleProducerJob(job)); } Gson gson = gsonBuilder.create(); return gson.toJson(producerJobs); }
ProducerJob { public static String serialize(Collection<ProducerJob> jobs) { Collection<ProducerJob> producerJobs = new ArrayList<>(jobs.size()); for (ProducerJob job : jobs) { producerJobs.add(new SimpleProducerJob(job)); } Gson gson = gsonBuilder.create(); return gson.toJson(producerJobs); } }
ProducerJob { public static String serialize(Collection<ProducerJob> jobs) { Collection<ProducerJob> producerJobs = new ArrayList<>(jobs.size()); for (ProducerJob job : jobs) { producerJobs.add(new SimpleProducerJob(job)); } Gson gson = gsonBuilder.create(); return gson.toJson(producerJobs); }  }
ProducerJob { public static String serialize(Collection<ProducerJob> jobs) { Collection<ProducerJob> producerJobs = new ArrayList<>(jobs.size()); for (ProducerJob job : jobs) { producerJobs.add(new SimpleProducerJob(job)); } Gson gson = gsonBuilder.create(); return gson.toJson(producerJobs); }  abstract String getPage(); abstract String getStartDate(); abstract String getEndDate(); abstract GoogleWebmasterFilter.FilterOperator getOperator(); abstract int getPagesSize(); List<? extends ProducerJob> partitionJobs(); static String serialize(Collection<ProducerJob> jobs); }
ProducerJob { public static String serialize(Collection<ProducerJob> jobs) { Collection<ProducerJob> producerJobs = new ArrayList<>(jobs.size()); for (ProducerJob job : jobs) { producerJobs.add(new SimpleProducerJob(job)); } Gson gson = gsonBuilder.create(); return gson.toJson(producerJobs); }  abstract String getPage(); abstract String getStartDate(); abstract String getEndDate(); abstract GoogleWebmasterFilter.FilterOperator getOperator(); abstract int getPagesSize(); List<? extends ProducerJob> partitionJobs(); static String serialize(Collection<ProducerJob> jobs);  }