@Override public Iterable<SchemaEntry> allEntries() { String path = getName() + "/all"; Iterable<SchemaEntry> entries = Collections.emptyList(); try { String entriesStr = webResource.path(path) .accept(MediaType.APPLICATION_JSON) .get(String.class); entries = jsonUtil.schemasFromJson(entriesStr); } catch (RuntimeException e) { handleException(e, format("Failed to retrieve all schema entries in subject %s", getName()), false); } return entries; }
@Override public Iterable<SchemaEntry> allEntries() { String path = getName() + "/all"; Iterable<SchemaEntry> entries = Collections.emptyList(); try { String entriesStr = webResource.path(path) .accept(MediaType.APPLICATION_JSON) .get(String.class); entries = jsonUtil.schemasFromJson(entriesStr); } catch (RuntimeException e) { handleException(e, format("Failed to retrieve all schema entries in subject %s", getName()), false); } return entries; }
@Test public void testSchemasToFromString() { SchemaEntry e1 = new SchemaEntry("id1", "s1"); SchemaEntry e2 = new SchemaEntry("id2", "s2"); ArrayList<SchemaEntry> empty = new ArrayList<SchemaEntry>(); ArrayList<SchemaEntry> vals = new ArrayList<SchemaEntry>(); vals.add(e1); vals.add(e2); Iterable<SchemaEntry> emptyResult = jsonUtil .schemasFromJson(jsonUtil.schemasToJson(empty)); Iterable<SchemaEntry> emptyResult2 = jsonUtil.schemasFromJson(null); Iterable<SchemaEntry> emptyResult3 = jsonUtil.schemasFromJson(""); Assert.assertEquals(empty, emptyResult); Assert.assertEquals(emptyResult, emptyResult2); Assert.assertEquals(emptyResult, emptyResult3); Iterable<SchemaEntry> result = jsonUtil .schemasFromJson(jsonUtil.schemasToJson(vals)); Assert.assertEquals(vals, result); }