Skip to content

Commit

Permalink
Migrate tests to new rule-related signatures and names
Browse files Browse the repository at this point in the history
  • Loading branch information
FloBoJa committed Nov 22, 2023
1 parent 5d2c760 commit 3d5e390
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.palladiosimulator.pcm.repository.PrimitiveTypeEnum;
import org.palladiosimulator.pcm.repository.Repository;
import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard;
import org.palladiosimulator.somox.analyzer.rules.engine.IRule;
import org.palladiosimulator.somox.analyzer.rules.engine.Rule;
import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration;
import org.palladiosimulator.somox.analyzer.rules.impl.JaxRSRules;
import org.palladiosimulator.somox.analyzer.rules.main.RuleEngineException;
Expand All @@ -32,7 +32,7 @@
public class BasicTest extends RuleEngineTest {

private static final String PROJECT_NAME = "BasicProject";
private static final IRule[] RULES = { new JaxRSRules() };
private static final Rule[] RULES = { new JaxRSRules() };

protected BasicTest() {
super(PROJECT_NAME, RULES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import java.util.stream.Collectors;

import org.apache.log4j.Logger;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.InvalidRegistryObjectException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.CommonPlugin;
import org.eclipse.emf.common.util.Diagnostic;
Expand All @@ -41,12 +39,10 @@
import org.palladiosimulator.pcm.system.System;
import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard;
import org.palladiosimulator.somox.analyzer.rules.configuration.RuleEngineConfigurationImpl;
import org.palladiosimulator.somox.analyzer.rules.engine.IRule;
import org.palladiosimulator.somox.analyzer.rules.engine.Rule;
import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration;
import org.palladiosimulator.somox.analyzer.rules.engine.ServiceConfiguration;
import org.palladiosimulator.somox.analyzer.rules.workflow.RuleEngineJob;
import org.palladiosimulator.somox.discoverer.Discoverer;
import org.palladiosimulator.somox.discoverer.DiscovererCollection;

import com.google.common.collect.Sets;

Expand Down Expand Up @@ -76,7 +72,7 @@ public static void validate(EObject eObject) {
private System system;
private ResourceEnvironment resourceEnvironment;
private Allocation allocation;
private final Set<IRule> rules;
private final Set<Rule> rules;

/**
* Tests the basic functionality of the RuleEngineAnalyzer. Requires it to execute without an
Expand All @@ -87,7 +83,7 @@ public static void validate(EObject eObject) {
* @param rules
* the rules to execute
*/
protected RuleEngineTest(String projectDirectory, IRule... rules) {
protected RuleEngineTest(String projectDirectory, Rule... rules) {
this.rules = Set.of(rules);

outDir = TEST_DIR.appendSegment("out")
Expand All @@ -97,19 +93,9 @@ protected RuleEngineTest(String projectDirectory, IRule... rules) {
config.setInputFolder(TEST_DIR.appendSegments(projectDirectory.split("/")));
config.setOutputFolder(outDir);

ServiceConfiguration<IRule> ruleConfig = config.getConfig(IRule.class);
for (IRule rule : rules) {
ruleConfig.setSelected(rule, true);
}

// Enable all discoverers.
ServiceConfiguration<Discoverer> discovererConfig = config.getConfig(Discoverer.class);
try {
for (Discoverer discoverer : new DiscovererCollection().getServices()) {
discovererConfig.setSelected(discoverer, true);
}
} catch (InvalidRegistryObjectException | CoreException e) {
logger.error(e);
ServiceConfiguration<Rule> ruleConfig = config.getConfig(Rule.class);
for (Rule rule : rules) {
ruleConfig.select(rule);
}

ruleEngine = new RuleEngineJob(config);
Expand Down Expand Up @@ -353,7 +339,7 @@ public RuleEngineBlackboard getBlackboard() {
return ruleEngine.getBlackboard();
}

public Set<IRule> getRules() {
public Set<Rule> getRules() {
return Collections.unmodifiableSet(rules);
}

Expand Down

0 comments on commit 3d5e390

Please sign in to comment.