SchemaDrivenJSONToXmlConverter { static PlexusConfiguration convertToXml(Map<String, ModelNode> extensionSchemas, ModelNode jsonConfig) throws IOException { if (jsonConfig.getType() == ModelType.LIST) { return convertNewStyleConfigToXml(extensionSchemas, jsonConfig); } else { return convertOldStyleConfigToXml(extensionSchemas, jsonConfig); } } private  SchemaDrivenJSONToXmlConverter();   }
@Test public void testNestedSchemasConverted() throws Exception { ModelNode topSchema = json("{\"type\": \"object\", \"properties\": {\"a\": {\"type\": \"string\"}}}"); ModelNode nestedSchema = json("{\"type\": \"boolean\"}"); Map<String, ModelNode> extensionSchemas = new HashMap<>(); extensionSchemas.put("top", topSchema); extensionSchemas.put("top.nested", nestedSchema); ModelNode config = json("{\"top\": {\"a\": \"kachny\", \"nested\": true}}"); PlexusConfiguration xml = SchemaDrivenJSONToXmlConverter.convertToXml(extensionSchemas, config); assertEquals(2, xml.getChildCount()); PlexusConfiguration topXml = xml.getChild("top"); assertNotNull(topXml); assertEquals("top", topXml.getName()); assertEquals(1, topXml.getChildCount()); assertEquals("a", topXml.getChild(0).getName()); assertEquals("kachny", topXml.getChild("a").getValue()); PlexusConfiguration nested = xml.getChild("top.nested"); assertNotNull(nested); assertEquals(0, nested.getChildCount()); assertEquals("true", nested.getValue()); }