/** * Method createRuleSetSetup * * @throws ExecutionException * @throws NotDefinedException * @throws NotEnabledException * @throws NotHandledException * @throws ResourceHandlingException * @throws OutOfSyncException */ public void createRuleSetSetup() { // Create a Rule Set R4EUIRuleSet newRuleSet = fProxy .getRuleSetProxy() .createRuleSet( TestUtils.FSharedFolder, TestConstants.RULE_SET_TEST_NAME, TestConstants.RULE_SET_TEST_VERSION); Assert.assertNotNull(newRuleSet); Assert.assertEquals(TestConstants.RULE_SET_TEST_VERSION, newRuleSet.getRuleSet().getVersion()); Assert.assertEquals( new Path(TestUtils.FSharedFolder).toPortableString(), newRuleSet.getRuleSet().getFolder()); Assert.assertEquals(TestConstants.RULE_SET_TEST_NAME, newRuleSet.getRuleSet().getName()); // Create a second Rule Set R4EUIRuleSet newRuleSet2 = fProxy .getRuleSetProxy() .createRuleSet( TestUtils.FSharedFolder, TestConstants.RULE_SET_TEST_NAME2, TestConstants.RULE_SET_TEST_VERSION); String newRuleSet2Name = newRuleSet2.getName(); Assert.assertNotNull(newRuleSet2); Assert.assertEquals(TestConstants.RULE_SET_TEST_VERSION, newRuleSet2.getRuleSet().getVersion()); Assert.assertEquals( new Path(TestUtils.FSharedFolder).toPortableString(), newRuleSet2.getRuleSet().getFolder()); Assert.assertEquals(TestConstants.RULE_SET_TEST_NAME2, newRuleSet2.getRuleSet().getName()); // Create Rule Area R4EUIRuleArea newRuleArea = fProxy.getRuleAreaProxy().createRuleArea(newRuleSet, TestConstants.RULE_AREA_TEST_NAME); Assert.assertNotNull(newRuleArea); Assert.assertEquals(TestConstants.RULE_AREA_TEST_NAME, newRuleArea.getArea().getName()); // Create Rule Violation R4EUIRuleViolation newRuleViolation = fProxy .getRuleViolationProxy() .createRuleViolation(newRuleArea, TestConstants.RULE_VIOLATION_TEST_NAME); Assert.assertNotNull(newRuleViolation); Assert.assertEquals( TestConstants.RULE_VIOLATION_TEST_NAME, newRuleViolation.getViolation().getName()); // Create Rule R4EUIRule newRule = fProxy .getRuleProxy() .createRule( newRuleViolation, TestConstants.RULE_TEST_ID, TestConstants.RULE_TEST_TITLE, TestConstants.RULE_TEST_DESCRIPTION, UIUtils.getClassFromString(TestConstants.RULE_TEST_CLASS), UIUtils.getRankFromString(TestConstants.RULE_TEST_RANK)); Assert.assertNotNull(newRule); Assert.assertEquals(TestConstants.RULE_TEST_ID, newRule.getRule().getId()); Assert.assertEquals(TestConstants.RULE_TEST_TITLE, newRule.getRule().getTitle()); Assert.assertEquals(TestConstants.RULE_TEST_DESCRIPTION, newRule.getRule().getDescription()); Assert.assertEquals( UIUtils.getClassFromString(TestConstants.RULE_TEST_CLASS), newRule.getRule().getClass_()); Assert.assertEquals( UIUtils.getRankFromString(TestConstants.RULE_TEST_RANK), newRule.getRule().getRank()); // Close a Rule Set fProxy.getCommandProxy().closeElement(newRuleSet); Assert.assertFalse(newRuleSet.isOpen()); // Open the closed Rule Set fProxy.getCommandProxy().openElement(newRuleSet); Assert.assertTrue(newRuleSet.isOpen()); Assert.assertEquals( TestConstants.RULE_TEST_ID, ((R4EUIRule) newRuleSet.getChildren()[0].getChildren()[0].getChildren()[0]) .getRule() .getId()); // Remove Rule Set from preferences String prefsRuleSet = newRuleSet2.getRuleSet().eResource().getURI().toFileString(); fProxy.getPreferencesProxy().removeRuleSetFromPreferences(prefsRuleSet); for (R4EUIRuleSet ruleSet : R4EUIModelController.getRootElement().getRuleSets()) { if (ruleSet.getRuleSet().getName().equals(newRuleSet2.getRuleSet().getName())) { fail( "RuleSet " + prefsRuleSet + " should not be present since it was removed from preferences"); } } // Add back Rule Set to preferences boolean ruleSetFound = false; fProxy.getPreferencesProxy().addRuleSetToPreferences(prefsRuleSet); for (R4EUIRuleSet ruleSet : R4EUIModelController.getRootElement().getRuleSets()) { if (ruleSet.getRuleSet().getName().equals(newRuleSet2.getRuleSet().getName())) { ruleSetFound = true; break; } } Assert.assertTrue(ruleSetFound); for (IR4EUIModelElement elem : R4EUIModelController.getRootElement().getChildren()) { if (newRuleSet2Name.equals(elem.getName())) { newRuleSet2 = (R4EUIRuleSet) elem; } } fProxy.getCommandProxy().openElement(newRuleSet2); Assert.assertTrue(newRuleSet2.isOpen()); }