01: package org.ontoware.rdfreactor.generator;
02:
03: import java.io.File;
04:
05: import org.junit.Test;
06: import org.ontoware.rdf2go.model.node.impl.URIImpl;
07: import org.ontoware.rdfreactor.generator.java.JClass;
08: import org.ontoware.rdfreactor.generator.java.JModel;
09: import org.ontoware.rdfreactor.generator.java.JPackage;
10: import org.ontoware.rdfreactor.generator.java.JProperty;
11:
12: /**
13: * TODO add assertions, currently this test test nothing
14: *
15: * @author voelkel
16: *
17: */
18: public class SourceCodeWriterTest {
19:
20: public static final String outdir = "./target/test-gen";
21:
22: @Test
23: public void testWrite() throws Exception {
24: JModel jm = new JModel(JClass.RDFS_CLASS);
25: JPackage jp = new JPackage("test");
26: jm.addPackage(jp);
27: JClass jc1 = new JClass(jp, "Person", new URIImpl(
28: "urn:ex:Person"));
29: jc1.setComment("All persons in the world");
30: jc1.setJavaSuperclass(new JClass(new JPackage(""),
31: "org.ontoware.rdfreactor.runtime.ReactorRuntimeEntity",
32: new URIImpl("urn:ex:object")));
33: jp.getClasses().add(jc1);
34:
35: // deprecated
36: // JProperty jprop1 = new JProperty("age", new
37: // JAttribute(Integer.class),
38: // URIUtils.createURI("schema://age"), 1, 1);
39: // jc1.getProperties().add(jprop1);
40: JProperty jprop2 = new JProperty(jc1, "friend", new URIImpl(
41: "urn:ex:knows"), JProperty.NOT_SET, JProperty.NOT_SET);
42: jprop2
43: .setComment("A persons knows other persons. They can be considered friends.");
44: jprop2.addType(jc1);
45: jc1.getProperties().add(jprop2);
46: SourceCodeWriter.write(jm, new File(outdir),
47: SourceCodeWriter.TEMPLATE_CLASS, "Prefix");
48:
49: }
50: }
|