-
- private static FileReader getFileReader(String path) {
- String fullPath = YangAndXmlToJsonConversionJsonReaderTest.class.getResource(path).getPath();
- assertNotNull("Path to file can't be null.", fullPath);
- File file = new File(fullPath);
- assertNotNull("File can't be null", file);
- FileReader fileReader = null;
- try {
- fileReader = new FileReader(file);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- assertNotNull("File reader can't be null.", fileReader);
- return fileReader;
+
+ public static String writeCompNodeWithSchemaContextToOutput(CompositeNode compositeNode, Set<Module> modules,
+ DataSchemaNode dataSchemaNode, MessageBodyWriter<StructuredData> messageBodyWriter) throws IOException,
+ WebApplicationException {
+
+ assertNotNull(dataSchemaNode);
+ assertNotNull("Composite node can't be null", compositeNode);
+ ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
+
+ ControllerContext.getInstance().setSchemas(loadSchemaContext(modules));
+
+ messageBodyWriter.writeTo(new StructuredData(compositeNode, dataSchemaNode, null), null, null, null, null, null,
+ byteArrayOS);
+
+ return byteArrayOS.toString();