Package org.emftrace.metamodel.RuleModel

Examples of org.emftrace.metamodel.RuleModel.Rule


      changeType2.setName("delete");
     
      changeTypes.getChangeTypes().add(changeType1);
      changeTypes.getChangeTypes().add(changeType2);
     
      Rule impactRule1 = RuleModelFactory.eINSTANCE.createRule();
      Rule impactRule2 = RuleModelFactory.eINSTANCE.createRule();
     
      accessLayer.addElement(project, impactRule1);
      accessLayer.addElement(project, impactRule2);
     
      ElementDefinition rule1ED1 = RuleModelFactory.eINSTANCE.createElementDefinition();
      ElementDefinition rule1ED2 = RuleModelFactory.eINSTANCE.createElementDefinition();
      ElementDefinition rule1ED3 = RuleModelFactory.eINSTANCE.createElementDefinition();
      ElementDefinition rule2ED1 = RuleModelFactory.eINSTANCE.createElementDefinition();
      ElementDefinition rule2ED2 = RuleModelFactory.eINSTANCE.createElementDefinition();
      ElementDefinition rule2ED3 = RuleModelFactory.eINSTANCE.createElementDefinition();
     
      accessLayer.addElement(project, rule1ED1);
      accessLayer.addElement(project, rule1ED2);
      accessLayer.addElement(project, rule1ED3);
      accessLayer.addElement(project, rule2ED1);
      accessLayer.addElement(project, rule2ED2);
      accessLayer.addElement(project, rule2ED3);
     
      rule1ED1.setType("Concern");
      rule1ED1.setAlias("e1");
      rule1ED2.setType("Concern");
      rule1ED2.setAlias("e2");
      rule1ED3.setType("AtomicChangeType");
      rule1ED3.setAlias("e3");
     
      rule2ED1.setType("Concern");
      rule2ED1.setAlias("e1");
      rule2ED2.setType("Concern");
      rule2ED2.setAlias("e2");
      rule2ED3.setType("AtomicChangeType");
      rule2ED3.setAlias("e3");
     
      impactRule1.getElements().add(rule1ED1);
      impactRule1.getElements().add(rule1ED2);
      impactRule1.getElements().add(rule1ED3);
     
      impactRule2.getElements().add(rule2ED1);
      impactRule2.getElements().add(rule2ED2);
      impactRule2.getElements().add(rule2ED3);
     
      ActionDefinition rule1Action = RuleModelFactory.eINSTANCE.createActionDefinition();
      ActionDefinition rule2Action = RuleModelFactory.eINSTANCE.createActionDefinition();
     
      accessLayer.addElement(project, rule1Action);
      accessLayer.addElement(project, rule2Action);
     
      rule1Action.setActionType(ActionType.REPORT_IMPACT);
      rule1Action.setResultType("rename");
      rule1Action.setSourceElement("e1");
      rule1Action.setImpactedElement("e2");
     
      rule2Action.setActionType(ActionType.REPORT_IMPACT);
      rule2Action.setResultType("delete");
      rule2Action.setSourceElement("e1");
      rule2Action.setImpactedElement("e2");
     
      impactRule1.getActions().add(rule1Action);
      impactRule2.getActions().add(rule2Action);
     
      LogicCondition rule1LC = RuleModelFactory.eINSTANCE.createLogicCondition();
      LogicCondition rule2LC = RuleModelFactory.eINSTANCE.createLogicCondition();
     
      accessLayer.addElement(project, rule1LC);
      accessLayer.addElement(project, rule2LC);
     
      rule1LC.setType(LogicConditionType.AND);
      rule2LC.setType(LogicConditionType.AND);
     
      impactRule1.setConditions(rule1LC);
      impactRule2.setConditions(rule2LC);
     
      BaseCondition rule1BC1 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition rule1BC2 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition rule2BC1 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition rule2BC2 = RuleModelFactory.eINSTANCE.createBaseCondition();
View Full Code Here


    }
   
    @Test
    public void testFindElementsForDeletion()
    {
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
        BaseCondition baseCondition = RuleModelFactory.eINSTANCE.createBaseCondition();
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        e1.setAlias("e1");
        e2.setAlias("e2");
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
              
        rule.setConditions(logicCondition);
               
        List<Integer> paths = new ArrayList<Integer>();
       
        ConditionProcessorHelper.findElementsForDeletion(paths, rule, logicCondition);
        assertTrue(paths.isEmpty());
View Full Code Here

        l1.get(1).add(c2);
        l2.add(new ArrayList<EObject>());
        l2.add(new ArrayList<EObject>());
        l2.get(1).add(c2);
       
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
        BaseCondition baseCondition = RuleModelFactory.eINSTANCE.createBaseCondition();
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        e1.setAlias("e1");
        e2.setAlias("e2");
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
       
        baseCondition.setSource("e2");
       
        rule.setConditions(logicCondition);
        logicCondition.getBaseConditions().add(baseCondition);
       
        assertEquals(1, l1.get(0).size());
        assertEquals(1, l1.get(1).size());
        assertEquals(0, l2.get(0).size());
View Full Code Here

       
        tuples.get(0).get(0)[0] = c1;
        tuples.get(0).get(0)[1] = c2;
        tuples.get(1).get(0)[0] = c3;
       
      Rule rule = RuleModelFactory.eINSTANCE.createRule();
     
      LogicCondition lc1 = RuleModelFactory.eINSTANCE.createLogicCondition();
      LogicCondition lc2 = RuleModelFactory.eINSTANCE.createLogicCondition();
     
      accessLayer.addElement(project, rule);
      accessLayer.addElement(project, lc1);
      accessLayer.addElement(project, lc2);
     
      rule.setConditions(lc1);
     
      BaseCondition bc1 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition bc2 = RuleModelFactory.eINSTANCE.createBaseCondition();
     
      accessLayer.addElement(project, bc1);
View Full Code Here

    public void testCreateTupleListDiff2()
    {
      List<List<EObject[]>> tuples = new ArrayList<List<EObject[]>>();
      List<List<EObject[]>> copy   = new ArrayList<List<EObject[]>>();
     
      Rule rule = RuleModelFactory.eINSTANCE.createRule();
     
      LogicCondition lc1 = RuleModelFactory.eINSTANCE.createLogicCondition();
      LogicCondition lc2 = RuleModelFactory.eINSTANCE.createLogicCondition();
     
      accessLayer.addElement(project, rule);
      accessLayer.addElement(project, lc1);
      accessLayer.addElement(project, lc2);
     
      rule.setConditions(lc1);
     
      BaseCondition bc1 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition bc2 = RuleModelFactory.eINSTANCE.createBaseCondition();
     
      accessLayer.addElement(project, bc1);
View Full Code Here

    @Test
    public void testPrepareTupleLists()
    {
      List<List<EObject[]>> tuples = new ArrayList<List<EObject[]>>();
     
      Rule rule = RuleModelFactory.eINSTANCE.createRule();
     
      LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
     
      accessLayer.addElement(project, rule);
      accessLayer.addElement(project, logicCondition);
     
      rule.setConditions(logicCondition);
     
      BaseCondition bc1 = RuleModelFactory.eINSTANCE.createBaseCondition();
      BaseCondition bc2 = RuleModelFactory.eINSTANCE.createBaseCondition();
     
      accessLayer.addElement(project, bc1);
View Full Code Here

        result.add(new ArrayList<EObject>());
        result.get(0).add(c1);
        result.add(new ArrayList<EObject>());
        result.get(1).add(c2);
       
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule);
       
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e1);
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e2);
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
       
        e1.setAlias("number_1");
        e2.setAlias("number_2");
       
        BaseCondition baseCondition = RuleModelFactory.eINSTANCE.createBaseCondition();
        LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
        accessLayer.addElement(project, baseCondition);
        accessLayer.addElement(project, logicCondition);
       
        rule.setConditions(logicCondition);
        logicCondition.getBaseConditions().add(baseCondition);
        logicCondition.setType(LogicConditionType.AND);
        baseCondition.setSource("number_1::Id");
        baseCondition.setTarget("number_2::Id");
       
View Full Code Here

        result.add(new ArrayList<EObject>());
        result.get(0).add(c1);
        result.add(new ArrayList<EObject>());
        result.get(1).add(c2);
               
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule);
       
        ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e1);
        ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
        accessLayer.addElement(project, e2);
       
        rule.getElements().add(e1);
        rule.getElements().add(e2);
       
        e1.setAlias("number_1");
        e2.setAlias("number_2");
       
        BaseCondition baseCondition1 = RuleModelFactory.eINSTANCE.createBaseCondition();
        BaseCondition baseCondition2 = RuleModelFactory.eINSTANCE.createBaseCondition();
        LogicCondition logicCondition = RuleModelFactory.eINSTANCE.createLogicCondition();
        accessLayer.addElement(project, baseCondition1);
        accessLayer.addElement(project, baseCondition2);
        accessLayer.addElement(project, logicCondition);
       
        rule.setConditions(logicCondition);
        logicCondition.getBaseConditions().add(baseCondition1);
        logicCondition.getBaseConditions().add(baseCondition2);
        baseCondition1.setSource("number_1::Id");
        baseCondition1.setTarget("number_2::Id");
        baseCondition1.setType(BaseConditionType.VALUE_EQUALS);
        baseCondition2.setSource("number_1::name");
        baseCondition2.setTarget("number_2::name");
        baseCondition2.setType(BaseConditionType.VALUE_EQUALS);
       
        List<List<EObject[]>> tuples = new ArrayList<List<EObject[]>>();
        tuples.add(new ArrayList<EObject[]>());
        tuples.add(new ArrayList<EObject[]>());
       
        // test "AND":
        c1.setId("creator");
        c2.setId("creator");
        c1.setName("name");
        c2.setName("name");
        logicCondition.setType(LogicConditionType.AND);
        assertTrue(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
        c1.setId("creator__");
        assertFalse(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
        result.get(0).clear();
        result.get(0).add(c1);
        result.get(1).clear();
        result.get(1).add(c2);
       
        // test "OR":
        logicCondition.setType(LogicConditionType.OR);
        assertTrue(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
        c2.setName("name___");
        assertFalse(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
        result.get(0).clear();
        result.get(0).add(c1);
        result.get(1).clear();
        result.get(1).add(c2);
       
        // test "XOR":
        c1.setId("creator");
        logicCondition.setType(LogicConditionType.XOR);
        assertTrue(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
        c1.setId("creator");
        c2.setId("creator");
        c1.setName("name");
        c2.setName("name");
        result.get(0).clear();
        result.get(0).add(c1);
        result.get(1).clear();
        result.get(1).add(c2);
        assertFalse(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
        result.get(0).clear();
        result.get(0).add(c1);
        result.get(1).clear();
        result.get(1).add(c2);
       
        // test "NOT":
        c1.setId("creator__");
        logicCondition.setType(LogicConditionType.NOT);
        logicCondition.getBaseConditions().remove(baseCondition2);
        assertEquals(2, result.size());
        assertTrue(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
        result.get(0).clear();
        result.get(0).add(c1);
        result.get(1).clear();
        result.get(1).add(c2);
        c1.setId("creator");
        assertFalse(conditionProcessor.executeLogicCondition(rule, result, rule.getConditions(), tuples));
    }
View Full Code Here

    }

    @Test
    public void testExecuteCompareConditionListOfQueryElementStringListOfQueryElementStringBaseConditionType()
    {
        Rule rule1 = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule1);
        Rule rule2 = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule2);              
        List<EObject> l1 = new ArrayList<EObject>();
        l1.add(rule1);
        List<EObject> l2 = new ArrayList<EObject>();
        l2.add(rule2);
       
        rule1.setRuleID("test");
        rule2.setRuleID("test");
       
        List<List<EObject>> results = new ArrayList<List<EObject>>();
        results.add(l1);
        results.add(l2);
       
        List<EObject[]> tuples = new ArrayList<EObject[]>();
       
        // test "EQUALS":
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_EQUALS, tuples));
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        rule1.setRuleID("test__");
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_EQUALS, tuples));
        assertEquals(0, l1.size());
        assertEquals(0, l2.size());
        l1.add(rule1);
        l2.add(rule2);
       
        // test "STARTS_WITH":
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_STARTS_WITH, tuples));
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        rule1.setRuleID("_test");
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_STARTS_WITH, tuples));
        assertEquals(0, l1.size());
        assertEquals(0, l2.size());
        l1.add(rule1);
        l2.add(rule2);
       
        // test "ENDS_WITH":
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_ENDS_WITH, tuples));
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        rule1.setRuleID("test_");
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_ENDS_WITH, tuples));
        assertEquals(0, l1.size());
        assertEquals(0, l2.size());
        l1.add(rule1);
        l2.add(rule2);
       
        // test "CONTAINS":
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_CONTAINS, tuples));
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        rule1.setRuleID("tes");
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_CONTAINS, tuples));
        assertEquals(0, l1.size());
        assertEquals(0, l2.size());
        l1.add(rule1);
        l2.add(rule2);
       
        // test "LESSER_THAN":
        rule1.setRuleID("1");
        rule2.setRuleID("2");
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_LESSER_THAN, tuples));
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        rule1.setRuleID("2");
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_LESSER_THAN, tuples));
        assertEquals(0, l1.size());
        assertEquals(0, l2.size());
        l1.add(rule1);
        l2.add(rule2);
        rule1.setRuleID("no_number"); // test if the input ain't a number
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_LESSER_THAN, tuples));
        assertEquals(0, l1.size());
        assertEquals(0, l2.size());
        l1.add(rule1);
        l2.add(rule2);
       
        // test "GREATER_THAN":
        rule1.setRuleID("2");
        rule2.setRuleID("1");
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_GREATER_THAN, tuples));
        assertEquals(1, l1.size());
        assertEquals(1, l2.size());
        rule2.setRuleID("2");
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", l2, "RuleID", BaseConditionType.VALUE_GREATER_THAN, tuples));
        assertEquals(0, l1.size());
        assertEquals(0, l2.size());
        l1.add(rule1);
        l2.add(rule2);
View Full Code Here

    }

    @Test
    public void testExecuteCompareConditionListOfQueryElementStringStringBaseConditionType()
    {
        Rule rule = RuleModelFactory.eINSTANCE.createRule();
        accessLayer.addElement(project, rule);
              
        List<EObject> l1 = new ArrayList<EObject>();
        l1.add(rule);
        rule.setRuleID("TestRule");
       
        List<List<EObject>> results = new ArrayList<List<EObject>>();
        results.add(l1);
       
        List<EObject[]> tuples = new ArrayList<EObject[]>();
       
        // test "EQUALS":
        assertEquals(1, l1.size());
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", "TestRule", BaseConditionType.VALUE_EQUALS, tuples));
        assertEquals(1, l1.size());
        rule.setRuleID("TestRule___");
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", "TestRule", BaseConditionType.VALUE_EQUALS, tuples));
        assertEquals(0, l1.size());
        l1.add(rule);
        rule.setRuleID("TestRule");
       
        // test "STARTS_WITH"
        assertEquals(1, l1.size());
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", "Test", BaseConditionType.VALUE_STARTS_WITH, tuples));
        assertEquals(1, l1.size());
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", "Rule", BaseConditionType.VALUE_STARTS_WITH, tuples));
        assertEquals(0, l1.size());
        l1.add(rule);
       
        // test "ENDS_WITH"
        assertEquals(1, l1.size());
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", "Rule", BaseConditionType.VALUE_ENDS_WITH, tuples));
        assertEquals(1, l1.size());
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", "Test", BaseConditionType.VALUE_ENDS_WITH, tuples));
        assertEquals(0, l1.size());
        l1.add(rule);
       
        // test "CONTAINS"
        assertEquals(1, l1.size());
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", "TestRule", BaseConditionType.VALUE_CONTAINS, tuples));
        assertEquals(1, l1.size());
        rule.setRuleID("TestRul");
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", "TestRule", BaseConditionType.VALUE_CONTAINS, tuples));
        assertEquals(0, l1.size());
        l1.add(rule);
       
        // test "LESSER_THAN":
        assertEquals(1, l1.size());
        rule.setRuleID("1");
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", "2", BaseConditionType.VALUE_LESSER_THAN, tuples));
        assertEquals(1, l1.size());
        rule.setRuleID("2");
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", "2", BaseConditionType.VALUE_LESSER_THAN, tuples));
        assertEquals(0, l1.size());
        l1.add(rule);
        rule.setRuleID("no_number"); // test if the input ain't a number
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", "2", BaseConditionType.VALUE_LESSER_THAN, tuples));
        assertEquals(0, l1.size());
        l1.add(rule);
       
        // test "GREATER_THAN":
        rule.setRuleID("2");
        assertEquals(1, l1.size());
        assertTrue(conditionProcessor.executeCompareCondition(l1, "RuleID", "1", BaseConditionType.VALUE_GREATER_THAN, tuples));
        assertEquals(1, l1.size());
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", "2", BaseConditionType.VALUE_GREATER_THAN, tuples));
        assertEquals(0, l1.size());
        l1.add(rule);
        rule.setRuleID("no_number"); // test if the input ain't a number
        assertFalse(conditionProcessor.executeCompareCondition(l1, "RuleID", "2", BaseConditionType.VALUE_GREATER_THAN, tuples));
        assertEquals(0, l1.size());
       
        // test "NOT_NULL":
        l1.add(rule);
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.