Search in sources :

Example 1 with ModelToXmlSchemaQuery

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);
}
Also used : ModelToXmlSchemaQuery(org.whole.lang.xsd.codebase.ModelToXmlSchemaQuery) PathExpression(org.whole.lang.queries.model.PathExpression) StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Model(org.whole.lang.models.model.Model) ITemplateManager(org.whole.lang.templates.ITemplateManager) IPersistenceProvider(org.whole.lang.codebase.IPersistenceProvider) ILanguageKit(org.whole.lang.reflect.ILanguageKit) Test(org.junit.Test)

Example 2 with ModelToXmlSchemaQuery

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());
    }
}
Also used : ModelToXmlSchemaQuery(org.whole.lang.xsd.codebase.ModelToXmlSchemaQuery) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) StreamPersistenceProvider(org.whole.lang.codebase.StreamPersistenceProvider) File(java.io.File) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 3 with ModelToXmlSchemaQuery

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());
    }
}
Also used : ModelToXmlSchemaQuery(org.whole.lang.xsd.codebase.ModelToXmlSchemaQuery) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 IBindingManager (org.whole.lang.bindings.IBindingManager)3 IEntity (org.whole.lang.model.IEntity)3 PathExpression (org.whole.lang.queries.model.PathExpression)3 ModelToXmlSchemaQuery (org.whole.lang.xsd.codebase.ModelToXmlSchemaQuery)3 ClasspathPersistenceProvider (org.whole.lang.codebase.ClasspathPersistenceProvider)2 File (java.io.File)1 Category (org.junit.experimental.categories.Category)1 IPersistenceProvider (org.whole.lang.codebase.IPersistenceProvider)1 StreamPersistenceProvider (org.whole.lang.codebase.StreamPersistenceProvider)1 StringPersistenceProvider (org.whole.lang.codebase.StringPersistenceProvider)1 Model (org.whole.lang.models.model.Model)1 ILanguageKit (org.whole.lang.reflect.ILanguageKit)1 ITemplateManager (org.whole.lang.templates.ITemplateManager)1