Search in sources :

Example 81 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class WorkflowsInterpreterVisitorTest method testForeachLoop.

@Test
public void testForeachLoop() {
    IEntity foreachLoopTest = WorkflowsTestTemplateManager.instance().create("foreachLoopTest");
    IBindingManager args = BindingManagerFactory.instance.createArguments();
    InterpreterOperation.interpret(foreachLoopTest, args);
    Assert.assertTrue(args.wIsSet("count"));
    Assert.assertEquals(5, args.wIntValue("count"));
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Test(org.junit.Test)

Example 82 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class WorkflowsInterpreterVisitorTest method testTask.

@Test
public void testTask() {
    IEntity taskTest = WorkflowsTestTemplateManager.instance().create("taskTest");
    IBindingManager args = BindingManagerFactory.instance.createArguments();
    args.wDefValue("reader", new StringReader("yep!\n"));
    try {
        InterpreterOperation.interpret(taskTest, args, (Reader) null, (Writer) null);
    } catch (VisitException e) {
        Assert.fail();
    }
    args.wDefValue("reader", new StringReader("NO\n"));
    try {
        InterpreterOperation.interpret(taskTest, args, (Reader) null, (Writer) null);
        Assert.fail();
    } catch (VisitException e) {
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) VisitException(org.whole.lang.visitors.VisitException) IBindingManager(org.whole.lang.bindings.IBindingManager) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 83 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class WorkflowsInterpreterVisitorTest method testCreateModel.

@Test
public void testCreateModel() {
    IEntity createModelTest = WorkflowsTestTemplateManager.instance().create("createModelTest");
    IBindingManager args = BindingManagerFactory.instance.createArguments();
    InterpreterOperation.interpret(createModelTest, args);
    ModelsEntityFactory mef = ModelsEntityFactory.instance;
    SimpleEntity se = mef.createSimpleEntity(mef.createEntityModifiers(mef.createEntityModifier(EntityModifierEnum._abstract)), mef.createSimpleName("Entity1"), mef.createTypes(0), mef.createFeatures(mef.buildFeature().set(ModelsFeatureDescriptorEnum.type, mef.createSimpleName("FType")).set(ModelsFeatureDescriptorEnum.name, mef.createSimpleName("fname")).getResult()));
    Assert.assertTrue(args.wIsSet("model"));
    IEntity model = args.wGet("model");
    Matcher.removeVars(model, false);
    Assert.assertTrue(Matcher.match(se, model));
}
Also used : IEntity(org.whole.lang.model.IEntity) SimpleEntity(org.whole.lang.models.model.SimpleEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ModelsEntityFactory(org.whole.lang.models.factories.ModelsEntityFactory) Test(org.junit.Test)

Example 84 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class WorkflowsInterpreterVisitorTest method testCreateEntity.

@Test
public void testCreateEntity() {
    IEntity createEntityTest = WorkflowsTestTemplateManager.instance().create("createEntityTest");
    IBindingManager args = BindingManagerFactory.instance.createArguments();
    InterpreterOperation.interpret(createEntityTest, args);
    ModelsEntityFactory mef = ModelsEntityFactory.instance(RegistryConfigurations.RESOLVER);
    Assert.assertTrue(args.wIsSet("entity"));
    Assert.assertTrue(Matcher.match(mef.buildSimpleEntity().set(ModelsFeatureDescriptorEnum.modifiers, mef.createEntityModifiers(0)).set(ModelsFeatureDescriptorEnum.name, mef.createSimpleName("EntityName")).set(ModelsFeatureDescriptorEnum.types, mef.createTypes(mef.createSimpleName("Type"))).set(ModelsFeatureDescriptorEnum.features, mef.createFeatures(mef.buildFeature().set(ModelsFeatureDescriptorEnum.type, mef.createSimpleName("FType")).set(ModelsFeatureDescriptorEnum.name, mef.createSimpleName("fname")).getResult())).getResult(), args.wGet("entity")));
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) ModelsEntityFactory(org.whole.lang.models.factories.ModelsEntityFactory) Test(org.junit.Test)

Example 85 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class WorkflowsInterpreterVisitorTest method testCreateJavaClassInstance.

@Test
public void testCreateJavaClassInstance() {
    IEntity createJavaClassInstanceTest = WorkflowsTestTemplateManager.instance().create("createJavaClassInstanceTest");
    IBindingManager args = BindingManagerFactory.instance.createArguments();
    InterpreterOperation.interpret(createJavaClassInstanceTest, args);
    Assert.assertTrue(args.wIsSet("value"));
    Assert.assertEquals(new BigDecimal("1231.84587345"), args.wGetValue("value"));
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

IBindingManager (org.whole.lang.bindings.IBindingManager)223 IEntity (org.whole.lang.model.IEntity)141 Test (org.junit.Test)91 PathExpression (org.whole.lang.queries.model.PathExpression)49 ITemplateManager (org.whole.lang.templates.ITemplateManager)40 Grammar (org.whole.lang.grammars.model.Grammar)28 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)27 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)17 Model (org.whole.lang.models.model.Model)15 Production (org.whole.lang.grammars.model.Production)14 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)14 File (java.io.File)12 QueriesGrammar (org.whole.lang.grammars.codebase.QueriesGrammar)12 XmlModel (org.whole.lang.models.codebase.XmlModel)11 SimpleEntity (org.whole.lang.models.model.SimpleEntity)10 VisitException (org.whole.lang.visitors.VisitException)9 IBindingScope (org.whole.lang.bindings.IBindingScope)6 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)6 HashMap (java.util.HashMap)5 IFile (org.eclipse.core.resources.IFile)5