Package org.emftrace.metamodel.RuleModel

Examples of org.emftrace.metamodel.RuleModel.Rule


    }
   
    @Test
    public void testCleanUpRuleOrphansProject()
    {
        Rule r1 = RuleModelFactory.eINSTANCE.createRule();
        Rule r2 = RuleModelFactory.eINSTANCE.createRule();
       
        accessLayer.addElement(project, r1);
        accessLayer.addElement(project, r2);
       
        RuleCatalog c1 = RuleModelFactory.eINSTANCE.createRuleCatalog();
       
        accessLayer.addElement(project, c1);
       
        c1.getRules().add(r1);
       
        assertEquals(1, c1.getRules().size());
        assertEquals(1, accessLayer.getElements(project, "RuleCatalog").size());
        assertEquals(2, accessLayer.getElements(project, "Rule").size());
        projectCleaner.cleanUpRuleOrphans(project);
        assertEquals(1, c1.getRules().size());
        assertEquals(2, accessLayer.getElements(project, "Rule").size());
        assertEquals(2, accessLayer.getElements(project, "RuleCatalog").size());
       
        Rule r3 = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, r3);
       
        assertEquals(3, accessLayer.getElements(project, "Rule").size());
        projectCleaner.cleanUpLinkTypeOrphans(project);
        assertEquals(3, accessLayer.getElements(project, "Rule").size());
View Full Code Here


    }
   
    @Test
    public void testUpdateRuleCatalogsProject()
    {
        Rule r1 = RuleModelFactory.eINSTANCE.createRule();
        Rule r2 = RuleModelFactory.eINSTANCE.createRule();
       
        accessLayer.addElement(project, r1);
        accessLayer.addElement(project, r2);
       
        RuleCatalog c1 = RuleModelFactory.eINSTANCE.createRuleCatalog();
View Full Code Here

        result.add(new ArrayList<EObject>());
       
        result.get(0).add(c1);
        result.get(1).add(c2);
       
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule);
       
        ActionDefinition action = RuleModelFactory.eINSTANCE.createActionDefinition();
        accessLayer.addElement(project, action);
       
        rule.getActions().add(action);       
       
        action.setSourceElement("e1");
        action.setTargetElement("e2");
        action.setResultType("Test");
        action.setActionType(ActionType.CREATE_LINK);
       
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e1);
        accessLayer.addElement(project, e2);
        e1.setAlias("e1");
        e2.setAlias("e2");
        e1.setType("Concern");
        e2.setType("Concern");
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
        rule.setRuleID("TestRule");
       
        LinkType type = LinkModelFactory.eINSTANCE.createLinkType();
        accessLayer.addElement(project, type);
        type.setName("Test_");
       
View Full Code Here

        tuples.add(new EObject[3]);
        tuples.get(0)[0] = c1;
        tuples.get(0)[1] = c2;
        tuples.get(0)[2] = type;

        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule);
       
        ActionDefinition action = RuleModelFactory.eINSTANCE.createActionDefinition();
        accessLayer.addElement(project, action);
       
        rule.getActions().add(action);       
       
        action.setSourceElement("e1");
        action.setImpactedElement("e2");
        action.setResultType("Test");
        action.setActionType(ActionType.REPORT_IMPACT);
       
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        ElementDefinition e3 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e1);
        accessLayer.addElement(project, e2);
        accessLayer.addElement(project, e3);
        e1.setAlias("e1");
        e2.setAlias("e2");
        e3.setAlias("e3");
        e1.setType("Concern");
        e2.setType("Concern");
        e3.setType("AtomicChangeType");
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
        rule.getElements().add(e3);
        rule.setRuleID("TestRule");
       
        type.setName("Test");
               
        assertEquals(0, resultProcessor.getImpactSet().size());
        resultProcessor.processReportImpactResult(project, rule, result, tuples, 0);
View Full Code Here

        accessLayer.addElement(project, c2);
       
        c1.setId("test_user");
        c2.setId("test_user");
               
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule);
       
        LogicCondition cnd1 = RuleModelFactory.eINSTANCE.createLogicCondition();
        accessLayer.addElement(project, cnd1);
        BaseCondition cnd2 = RuleModelFactory.eINSTANCE.createBaseCondition();
        accessLayer.addElement(project, cnd2);
         
        rule.setRuleID("TestRule");
        rule.setConditions(cnd1);
        cnd1.getBaseConditions().add(cnd2);
        cnd2.setSource("e1::Id");
        cnd2.setTarget("e2::Id");
       
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e1);
        accessLayer.addElement(project, e2);
        e1.setAlias("e1");
        e2.setAlias("e2");
        e1.setType("Concern");
        e2.setType("Actor");
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
       
        LinkType l1 = LinkModelFactory.eINSTANCE.createLinkType();
        accessLayer.addElement(project, l1);
        l1.setName("Test");
       
        ActionDefinition a1 = RuleModelFactory.eINSTANCE.createActionDefinition();
        accessLayer.addElement(project, a1);
        a1.setSourceElement("e1");
        a1.setTargetElement("e2");
        a1.setResultType("Test");
        a1.setActionType(ActionType.CREATE_LINK);
       
        rule.getActions().add(a1);
       
        assertEquals(0, accessLayer.getElements(project, "TraceLink").size());
        ruleEngine.applyRule(null, null, rule);
        assertEquals(0, accessLayer.getElements(project, "TraceLink").size());
        ruleEngine.applyRule(project, null, null);
View Full Code Here

        tuples.add(new ArrayList<EObject[]>());
        tuples.get(0).add(new EObject[2]);
        tuples.get(0).get(0)[0] = c1;
        tuples.get(0).get(0)[1] = c2;

        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule);
       
        LogicCondition cnd1 = RuleModelFactory.eINSTANCE.createLogicCondition();
        accessLayer.addElement(project, cnd1);
        BaseCondition cnd2 = RuleModelFactory.eINSTANCE.createBaseCondition();
        accessLayer.addElement(project, cnd2);
         
        rule.setConditions(cnd1);
        cnd1.getBaseConditions().add(cnd2);
        cnd2.setSource("Test");
        cnd2.setTarget("Test");
       
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e1);
        accessLayer.addElement(project, e2);
        e1.setAlias("e1");
        e2.setAlias("e2");
        e1.setType("Concern");
        e2.setType("Concern");
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
        rule.setRuleID("TestRule");
       
        LinkType l1 = LinkModelFactory.eINSTANCE.createLinkType();
        accessLayer.addElement(project, l1);
        l1.setName("Test");
       
        ActionDefinition a1 = RuleModelFactory.eINSTANCE.createActionDefinition();
        accessLayer.addElement(project, a1);
        a1.setSourceElement("e1");
        a1.setTargetElement("e2");
        a1.setResultType("Test");
        a1.setActionType(ActionType.CREATE_LINK);
       
        BaseCondition baseCondition = RuleModelFactory.eINSTANCE.createBaseCondition();
        baseCondition.setSource("e1");
        baseCondition.setTarget("e2");
               
        LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
        logicCondition.getBaseConditions().add(baseCondition);
       
        rule.setConditions(logicCondition);
       
        rule.getActions().add(a1);
       
        joinProcessor.run(project, rule, result, tuples);
       
        resultProcessor.run(null, rule, result, tuples);
        assertEquals(0, accessLayer.getElements(project, "TraceLink").size());
View Full Code Here

        accessLayer.addElement(project, c2);
       
        c1.setName("42");
        c2.setName("42");
       
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule);
       
        LogicCondition lc1 = RuleModelFactory.eINSTANCE.createLogicCondition();
        accessLayer.addElement(project, lc1);
        LogicCondition lc2 = RuleModelFactory.eINSTANCE.createLogicCondition();
        accessLayer.addElement(project, lc2);
        LogicCondition lc3 = RuleModelFactory.eINSTANCE.createLogicCondition();
        accessLayer.addElement(project, lc3);
        BaseCondition bc1 = RuleModelFactory.eINSTANCE.createBaseCondition();
        accessLayer.addElement(project, bc1);
        BaseCondition bc2 = RuleModelFactory.eINSTANCE.createBaseCondition();
        accessLayer.addElement(project, bc2);
        BaseCondition bc3 = RuleModelFactory.eINSTANCE.createBaseCondition();
        accessLayer.addElement(project, bc3);
       
        lc2.setType(LogicConditionType.NOT);
         
        rule.setRuleID("TestRule");
        rule.setConditions(lc1);
        lc1.getBaseConditions().add(bc1);
        lc1.getLogicConditions().add(lc2);
        bc1.setSource("e1::name");
        bc1.setTarget("e2::name");
       
        bc2.setSource("e1::name");
        bc2.setValue("test");
       
        bc3.setSource("e1::name");
        bc3.setValue("test2");
       
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e1);
        accessLayer.addElement(project, e2);
        e1.setAlias("e1");
        e2.setAlias("e2");
        e1.setType("Concern");
        e2.setType("Concern");
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
       
        LinkType l1 = LinkModelFactory.eINSTANCE.createLinkType();
        accessLayer.addElement(project, l1);
        l1.setName("Test");
       
        LinkType l2 = LinkModelFactory.eINSTANCE.createLinkType();
        accessLayer.addElement(project, l2);
        l2.setName("TestRelation");
       
        ActionDefinition a1 = RuleModelFactory.eINSTANCE.createActionDefinition();
        accessLayer.addElement(project, a1);
        a1.setSourceElement("e1");
        a1.setTargetElement("e2");
        a1.setResultType("Test");
        a1.setActionType(ActionType.CREATE_LINK);
       
        rule.getActions().add(a1);
       
        /*
         * case 1:
         *
         * <and>
 
View Full Code Here

    }

    @Test
    public void testValidateTraceRule()
    {
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule);
       
        LogicCondition cnd1 = RuleModelFactory.eINSTANCE.createLogicCondition();
        accessLayer.addElement(project, cnd1);
        BaseCondition cnd2 = RuleModelFactory.eINSTANCE.createBaseCondition();
        accessLayer.addElement(project, cnd2);
         
        rule.setConditions(cnd1);
        cnd1.getBaseConditions().add(cnd2);
        cnd2.setSource("e1::creator");
        cnd2.setTarget("e2::creator");
       
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e1);
        accessLayer.addElement(project, e2);
        e1.setAlias("e1");
        e2.setAlias("e2");
        e1.setType("Concern");
        e2.setType("Actor");
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
       
        LinkType l1 = LinkModelFactory.eINSTANCE.createLinkType();
        accessLayer.addElement(project, l1);
        l1.setName("Test");
       
        ActionDefinition a1 = RuleModelFactory.eINSTANCE.createActionDefinition();
        accessLayer.addElement(project, a1);
        a1.setSourceElement("e1");
        a1.setTargetElement("e2");
        a1.setResultType("Test");
        a1.setActionType(ActionType.CREATE_LINK);
       
        rule.getActions().add(a1);
       
        assertTrue(ruleValidator.validateRule(project, rule));
        a1.setSourceElement("42");
        assertFalse(ruleValidator.validateRule(project, rule));
    }
View Full Code Here

        results.get(0).clear();
       
        List<EObject> models = new ArrayList<EObject>();
        models.add(link);
       
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule);
       
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e1);
        e1.setType("TraceLink");
        rule.getElements().add(e1);
       
        assertEquals(1, results.size());
        assertEquals(0, results.get(0).size());
        elementProcessor.retrieveElements(project, rule, models, results);
        assertEquals(1, results.size());
View Full Code Here

    }

    @Test
    public void testRunProjectTraceRuleListOfListOfQueryElementListOfModelElement()
    {
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule);
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e1);
        e1.setType("TraceLink");
        e1.setAlias("e1");
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e2);
        e2.setType("Concern");
        e2.setAlias("e2");
        rule.getElements().add(e1);
        rule.getElements().add(e2);
        TraceLink link = LinkModelFactory.eINSTANCE.createTraceLink();
        accessLayer.addElement(project, link);
        Concern concern = URNModelFactory.eINSTANCE.createConcern();
        accessLayer.addElement(project, concern);
       
View Full Code Here

TOP

Related Classes of org.emftrace.metamodel.RuleModel.Rule

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.