use of org.qi4j.library.rdf.model.Model2XML in project qi4j-sdk by Qi4j.
the class Model2XMLTest method testModel2XML.
@Test
public void testModel2XML() throws AssemblyException, TransformerException {
Energy4Java is = new Energy4Java();
ApplicationDescriptor model = is.newApplicationModel(new ApplicationAssembler() {
@Override
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
ApplicationAssembly assembly = applicationFactory.newApplicationAssembly();
assembly.setName("Test application");
LayerAssembly webLayer = assembly.layer("Web");
LayerAssembly domainLayer = assembly.layer("Domain");
LayerAssembly infrastructureLayer = assembly.layer("Infrastructure");
webLayer.uses(domainLayer, infrastructureLayer);
domainLayer.uses(infrastructureLayer);
ModuleAssembly rest = webLayer.module("REST");
rest.transients(TestTransient.class).visibleIn(Visibility.layer);
domainLayer.module("Domain");
infrastructureLayer.module("Database");
return assembly;
}
});
Document document = new Model2XML().map(model);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty("indent", "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.transform(new DOMSource(document), new StreamResult(System.out));
}
Aggregations