Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #178 from viadee/issue177
Browse files Browse the repository at this point in the history
Fix for #177: Default path for ruleSet now src/test/resource
  • Loading branch information
TamaraGunkel authored Jul 1, 2020
2 parents a6cb0be + d86bf09 commit a114e4e
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
/*
* BSD 3-Clause License
*
* Copyright © 2020, viadee Unternehmensberatung AG
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package de.viadee.bpm.vPAV;

import de.viadee.bpm.vPAV.beans.BeanMappingGenerator;
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/de/viadee/bpm/vPAV/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,15 @@ public RuleSet readConfig() {

final RuleSetOutputWriter ruleSetOutputWriter = new RuleSetOutputWriter();
try {
String ruleSetPath = ConfigConstants.getInstance().getBasepath() + ConfigConstants.getInstance().getRuleSetFileName();
String ruleSetPath = ConfigConstants.getInstance().getRuleSetPath() + ConfigConstants.getInstance().getRuleSetFileName();
if (new File(ruleSetPath).exists()) {
RuleSet localRule = new XmlConfigReader().read(ConfigConstants.getInstance().getRuleSetFileName());
RuleSet localRules = new XmlConfigReader().read(ConfigConstants.getInstance().getRuleSetFileName());

if (localRule.hasParentRuleSet()) {
rules = mergeRuleSet(localRule, new XmlConfigReader().read(ConfigConstants.getInstance().getParentRuleSetFileName()));
if (localRules.hasParentRuleSet()) {
rules = mergeRuleSet(localRules, new XmlConfigReader().read(ConfigConstants.getInstance().getParentRuleSetFileName()));
}
else {
rules = localRules;
}
} else {
rules = new XmlConfigReader().read(ConfigConstants.RULESETDEFAULT);
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/de/viadee/bpm/vPAV/constants/ConfigConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
*/
package de.viadee.bpm.vPAV.constants;

import de.viadee.bpm.vPAV.RuntimeConfig;
import de.viadee.bpm.vPAV.config.reader.PropertiesReader;

import java.util.Locale;
import java.util.Properties;
import java.util.logging.Logger;

import de.viadee.bpm.vPAV.RuntimeConfig;
import de.viadee.bpm.vPAV.config.reader.PropertiesReader;

/**
* Class to hold global constants
*/
Expand Down Expand Up @@ -150,6 +150,10 @@ public void setProperties(Properties newProperties) {
this.properties = newProperties;
}

public String getRuleSetPath() {
return properties.getProperty("ruleSetPath", ConfigConstants.TEST_BASEPATH);
}

public String getBasepath() {
if (RuntimeConfig.getInstance().isTest()) {
return properties.getProperty("basepath", ConfigConstants.TEST_BASEPATH);
Expand Down
1 change: 1 addition & 0 deletions src/test/java/de/viadee/bpm/vPAV/spring/SpringTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void validateModel() {
RuntimeConfig.getInstance().setTest(true);
Properties properties = new Properties();
properties.put("basepath", ConfigConstants.getInstance().getBasepath() + "spring/");
properties.put("ruleSetPath", ConfigConstants.getInstance().getBasepath() + "spring/");
ConfigConstants.getInstance().setProperties(properties);
Collection<CheckerIssue> issues = ProcessApplicationValidator.findModelInconsistencies(ctx);
Assert.assertEquals(1, issues.size());
Expand Down
153 changes: 153 additions & 0 deletions src/test/resources/spring/ruleSetDefault.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!DOCTYPE xml>
<ruleSet>
<rule>
<name>MessageEventChecker</name>
<state>true</state>
</rule>
<rule>
<name>OverlapChecker</name>
<state>true</state>
</rule>
<rule>
<name>ExtensionChecker</name>
<state>true</state>
<settings>
<setting name="CALLBACK_TIMEOUT" type="ServiceTask">\d+</setting>
</settings>
</rule>
<rule>
<name>XorConventionChecker</name>
<state>true</state>
<settings>
<setting name="requiredDefault">false</setting>
</settings>
<elementConventions>
<elementConvention>
<name>xorGateway</name>
<description>gateway name has to end with an question mark</description>
<pattern>.*\?</pattern>
</elementConvention>
<elementConvention>
<name>edges</name>
<description>gateway edge has to be named</description>
<pattern>.*</pattern>
</elementConvention>
</elementConventions>
</rule>
<rule>
<name>TimerExpressionChecker</name>
<state>true</state>
</rule>
<rule>
<name>NoScriptChecker</name>
<state>true</state>
<settings>
</settings>
</rule>
<rule>
<name>JavaDelegateChecker</name>
<state>true</state>
</rule>
<rule>
<name>BoundaryErrorChecker</name>
<state>true</state>
</rule>
<rule>
<name>FieldInjectionChecker</name>
<state>false</state>
</rule>
<rule>
<name>EmbeddedGroovyScriptChecker</name>
<state>true</state>
</rule>
<rule>
<name>NoExpressionChecker</name>
<state>true</state>
<settings>
<setting name="ServiceTask"/>
</settings>
</rule>
<rule>
<name>VersioningChecker</name>
<state>false</state>
<settings>
<setting name="versioningSchemeClass">([^_]*)_{1}([0-9][_][0-9]{1})\.(class|groovy)
</setting>
</settings>
</rule>
<rule>
<name>DmnTaskChecker</name>
<state>false</state>
</rule>
<rule>
<name>DataFlowChecker</name>
<state>true</state>
</rule>
<rule>
<name>ProcessVariablesModelChecker</name>
<state>true</state>
<settings>
<setting name="UseStaticAnalysisBoolean">true</setting>
</settings>
</rule>
<rule>
<name>ProcessVariablesNameConventionChecker</name>
<state>false</state>
<elementConventions>
<elementConvention>
<name>internal</name>
<!-- field types for process variables -->
<elementFieldTypes excluded="true">
<elementFieldType>Class</elementFieldType>
<elementFieldType>ExternalScript</elementFieldType>
<elementFieldType>DMN</elementFieldType>
<elementFieldType>DelegateExpression</elementFieldType>
</elementFieldTypes>
<description>Variable has to start with "int_"</description>
<pattern>int_[a-zA-Z]+</pattern>
</elementConvention>
<elementConvention>
<name>external</name>
<!-- field types for process variables -->
<elementFieldTypes>
<elementFieldType>Class</elementFieldType>
<elementFieldType>ExternalScript</elementFieldType>
<elementFieldType>DMN</elementFieldType>
<elementFieldType>DelegateExpression</elementFieldType>
</elementFieldTypes>
<description>Variable has to start with "ext_"</description>
<pattern>ext_[a-zA-Z]+</pattern>
</elementConvention>
</elementConventions>
</rule>
<rule>
<name>TaskNamingConventionChecker</name>
<state>false</state>
<elementConventions>
<elementConvention>
<name>convention</name>
<description>taskname has to start with a capital letter followed by
letters,hyphens or spaces
</description>
<pattern>[A-ZÄÖÜ][a-zäöü\\\-\\\s]+</pattern>
</elementConvention>
</elementConventions>
</rule>
<rule>
<name>ElementIdConventionChecker</name>
<state>false</state>
<elementConventions>
<elementConvention>
<name>ServiceTask</name>
<description>ServiceTask has to starts with "serviceTask" followed
by at least two
words starting with a capital letter
</description>
<pattern>serviceTask[A-Z]([A-Z0-9]*[a-z][a-z0-9]*[A-Z]|[a-z0-9]*[A-Z][A-Z0-9]*[a-z])[A-Za-z0-9]*
</pattern>
</elementConvention>
</elementConventions>
</rule>

</ruleSet>

0 comments on commit a114e4e

Please sign in to comment.