protected List<Document> readResources(String prefix, String... resources) throws IOException { List<Document> documents = new ArrayList<>(); for (String resource : resources) { String content = Testing.Files.readResourceAsString(prefix + resource); Array array = null; try { Document doc = DocumentReader.defaultReader().read(content); array = doc.getArray("entityChanges"); } catch (IOException e) { array = ArrayReader.defaultReader().readArray(content); } array.forEach(entry -> documents.add(entry.getValue().asDocument())); } return documents; }
protected void readAsStringAndBytes( String resourceFile ) throws IOException { String content = Testing.Files.readResourceAsString(resourceFile); Array doc = ArrayReader.defaultReader().readArray(content); byte[] bytes = SERDES.serialize("topicA",doc); Array reconstituted = SERDES.deserialize("topicA",bytes); assertThat((Object)reconstituted).isEqualTo(doc); }
protected void readAsStringAndBytes(String resourceFile) throws IOException { String content = Testing.Files.readResourceAsString(resourceFile); Document doc = DocumentReader.defaultReader().read(content); roundTrip(doc, size -> Testing.print("message size " + size + " bytes: \n" + doc)); }