public static void toJson(ServiceEntryList obj, java.util.Map<String, Object> json) { json.put("index", obj.getIndex()); if (obj.getList() != null) { JsonArray array = new JsonArray(); obj.getList().forEach(item -> array.add(item.toJson())); json.put("list", array); } } }
public static void toJson(PreparedQueryExecuteResponse obj, java.util.Map<String, Object> json) { if (obj.getDc() != null) { json.put("dc", obj.getDc()); } if (obj.getDnsTtl() != null) { json.put("dnsTtl", obj.getDnsTtl()); } json.put("failovers", obj.getFailovers()); if (obj.getNodes() != null) { JsonArray array = new JsonArray(); obj.getNodes().forEach(item -> array.add(item.toJson())); json.put("nodes", array); } if (obj.getService() != null) { json.put("service", obj.getService()); } } }
@Test public void testServiceEntryCopy() { ServiceEntry entry = randomServiceEntry(); checkServiceEntry(entry, new ServiceEntry(entry)); checkServiceEntry(entry, new ServiceEntry(entry.toJson())); List<Check> shuffledChecks = new ArrayList<>(); shuffledChecks.add(entry.getChecks().get(1)); shuffledChecks.add(entry.getChecks().get(0)); ServiceEntry shuffled = new ServiceEntry(entry) .setChecks(shuffledChecks); checkServiceEntry(entry, shuffled); }