use of org.whole.lang.xsd.codebase.ModelToXmlSchemaQuery in project whole by wholeplatform.
the class XsdMappingTest method testModelsToXmlSchemaXXX.
@Test
public void testModelsToXmlSchemaXXX() throws Exception {
IBindingManager bm = BindingManagerFactory.instance.createArguments();
PathExpression path = new ModelToXmlSchemaQuery().create();
Model model = (Model) ModelsTemplateManager.instance().create("Models model");
String uri = model.getUri().getValue();
ILanguageKit lk = ReflectionFactory.getLanguageKit(uri);
IEntity tuple = BehaviorUtils.evaluateFirstResult(path, model, bm);
Assert.assertNotNull(tuple);
InterpreterOperation.interpret(tuple.wGet(1));
ITemplateManager tm = lk.getTemplateManager();
IEntity entity = tm.create("Editors model");
IPersistenceProvider pp = new StringPersistenceProvider();
XsiPersistenceKit.instance().writeModel(entity, pp);
IEntity entity2 = XsiPersistenceKit.instance().readModel(pp);
boolean matches = Matcher.match(entity, entity2);
Assert.assertTrue(matches);
}
use of org.whole.lang.xsd.codebase.ModelToXmlSchemaQuery in project whole by wholeplatform.
the class XsdLanguageTest method testArtifactsMappedModel.
@Category(KnownFailingTests.class)
@Test
public void testArtifactsMappedModel() {
try {
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
PathExpression path = new ModelToXmlSchemaQuery().create();
IEntity model = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/artifacts/ArtifactsModel.xwl"));
Assert.assertNotNull(BehaviorUtils.evaluateFirstResult(path, model, bm));
InterpreterOperation.interpret(bm.wGet("mapping"));
bm.wDefValue("folderLocation", new File("test/org/whole/lang/xsd/util").getAbsolutePath());
bm.wDefValue("packageName", "");
IEntity artifacts = XsiPersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream("Artifacts.xml"), null, bm));
Assert.assertTrue(Matcher.match(new Artifacts().create(), artifacts));
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
use of org.whole.lang.xsd.codebase.ModelToXmlSchemaQuery in project whole by wholeplatform.
the class XsdLanguageTest method testModelToXsdMapping.
@Test
public void testModelToXsdMapping() {
try {
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
PathExpression path = new ModelToXmlSchemaQuery().create();
IEntity model = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/artifacts/ArtifactsModel.xwl"));
Assert.assertNotNull(BehaviorUtils.evaluateFirstResult(path, model, bm));
IEntity mappedXsd = bm.wGet("schema");
IEntity xsd = loadXsd("artifacts.xsd");
Assert.assertTrue(OrderedMatcher.match(xsd, mappedXsd, comparatorsMap));
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
Aggregations