Package org.openengsb.core.workflow.api.model

Examples of org.openengsb.core.workflow.api.model.RuleBaseElementId


        workflowDeployer.install(ruleFile);
        workflowDeployer.install(processFile);

        String modifiedRule = "it doesnt matter";
        FileUtils.writeStringToFile(ruleFile, modifiedRule);
        RuleBaseElementId idRule = new RuleBaseElementId(RuleBaseElementType.Rule, "org.openengsb", "rule");

        workflowDeployer.update(ruleFile);
        verify(ruleManager, times(1)).addOrUpdate(idRule, modifiedRule);

        String process = FileUtils.readFileToString(processFile);
        String modifiedProcess = process.replace("org.openengsb", "new.package");
        FileUtils.writeStringToFile(processFile, modifiedProcess);

        workflowDeployer.update(processFile);
        RuleBaseElementId idProcess = new RuleBaseElementId(RuleBaseElementType.Process, "org.openengsb", "process");
        verify(ruleManager, times(1)).delete(idProcess);
        idProcess.setPackageName("new.package");
        verify(ruleManager, times(1)).addOrUpdate(idProcess, modifiedProcess);
    }
View Full Code Here


        workflowDeployer.install(processFile);

        workflowDeployer.uninstall(ruleFile);
        workflowDeployer.uninstall(processFile);

        RuleBaseElementId idRule = new RuleBaseElementId(RuleBaseElementType.Rule, "org.openengsb", "rule");
        RuleBaseElementId idProcess = new RuleBaseElementId(RuleBaseElementType.Process, "org.openengsb", "process");

        verify(ruleManager, times(1)).delete(idRule);
        verify(ruleManager, times(1)).delete(idProcess);
    }
View Full Code Here

            ""));

        workflowDeployer.install(testRuleFile);
        workflowDeployer.install(globalFile);
        workflowDeployer.install(importFile);
        assertThat(ruleManager.get(new RuleBaseElementId(RuleBaseElementType.Rule, "test1")), not(nullValue()));
    }
View Full Code Here

        assertThat(listImports, hasItem("java.util.Map"));
    }

    @Test
    public void testAddRule_shouldAddRule() throws Exception {
        RuleBaseElementId id = new RuleBaseElementId(RuleBaseElementType.Rule, "org.openengsb", "test3");
        ruleManager.add(id, "when\n" + "  e : Event()\n" + "then\n"
                + "  example2.doSomethingWithMessage(\"this rule was added by the addrule-function\");\n");
        executeTestSession();
        assertTrue(listener.haveRulesFired("test3"));
    }
View Full Code Here

        assertThat(ruleManager.listImports(), not(hasItem("java.util.Currency")));
    }

    @Test
    public void testRuleCallingFunctionUsingImport_shouldFireRules() throws Exception {
        RuleBaseElementId testFunctionId = new RuleBaseElementId(RuleBaseElementType.Function, "org.openengsb", "test");
        ruleManager.add(testFunctionId, "function void test(Object message) {\n"
                + "System.out.println(\"notify: \" + message);\n}");
        ruleManager.addImport("java.util.Random");
        RuleBaseElementId testRuleId = new RuleBaseElementId(RuleBaseElementType.Rule, "org.openengsb", "test");
        ruleManager.add(testRuleId, "when\n" + "  e : Event()\n" + "then\n" + "  test(new Random());\n");
        executeTestSession();
        assertTrue(listener.haveRulesFired("org.openengsb.test"));
    }
View Full Code Here

    }

    @Test
    public void testAddGlobal_shouldAddGlobal() throws Exception {
        ruleManager.addGlobal("java.util.Random", "bla");
        ruleManager.add(new RuleBaseElementId(RuleBaseElementType.Rule, "bla"),
            "when\n then example2.doSomethingWithMessage(\"\" + bla.nextInt());");
        createSession();
        session.setGlobal("bla", new Random());
        sendEventToSession();
        assertTrue(listener.haveRulesFired("bla"));
View Full Code Here

        assertThat(result, is("java.util.Random"));
    }

    @Test
    public void testInvalidAddRule_shouldFail() throws Exception {
        RuleBaseElementId id = new RuleBaseElementId(RuleBaseElementType.Rule, "org.openengsb", "test");
        try {
            ruleManager.add(id, "this_makes_no_sense_at_all");
            fail("add successful");
        } catch (RuleBaseException e) {
            // expected
View Full Code Here

        assertThat(list, not(hasItem(id)));
    }

    @Test(expected = RuleBaseException.class)
    public void testAddExistingRule_shouldThrowException() throws Exception {
        RuleBaseElementId id = new RuleBaseElementId(RuleBaseElementType.Rule, "org.openengsb", "hello1");
        ruleManager.add(id, "when\nthen\nexample.doSomething(\"bla\");");
        ruleManager.add(id, "when\nthen\nexample.doSomething(\"bla\");");
    }
View Full Code Here

        ruleManager.add(id, "when\nthen\nexample.doSomething(\"bla\");");
    }

    @Test
    public void testAddOtherPackages_shouldWork() throws Exception {
        RuleBaseElementId id = new RuleBaseElementId(RuleBaseElementType.Rule, "at.ac.tuwien", "hello42");
        ruleManager.add(id, "when\nthen\nexample2.doSomethingWithMessage(\"bla\");");
        executeTestSession();
        assertTrue(listener.haveRulesFired("at.ac.tuwien.hello42"));
    }
View Full Code Here

        assertTrue(listener.haveRulesFired("at.ac.tuwien.hello42"));
    }

    @Test
    public void testRulesInDifferentPackages_shouldFireRules() throws Exception {
        RuleBaseElementId id = new RuleBaseElementId(RuleBaseElementType.Rule, "at.ac.tuwien", "hello42");
        ruleManager.add(id, "when\nthen\nexample2.doSomethingWithMessage(\"bla\");");
        id = new RuleBaseElementId(RuleBaseElementType.Rule, "org.openengsb", "hello42");
        ruleManager.add(id, "when\nthen\nexample2.doSomethingWithMessage(\"bla\");");
        executeTestSession();
        assertTrue(listener.haveRulesFired("org.openengsb.hello42", "at.ac.tuwien.hello42"));
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.workflow.api.model.RuleBaseElementId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.