-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(deps): update dependency featureide to v3.8.3 (#6)
* chore(deps): update dependency featureide to v3.8.3 * feat: migrate to featureide v3.8.3 (#13) * feat: new version * test: unify tests * feat: more migration code Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Kriese <[email protected]>
- Loading branch information
1 parent
c3c0eb4
commit 0284696
Showing
11 changed files
with
511 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "interactive" | ||
"java.configuration.updateBuildConfiguration": "automatic" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.prop4j.Implies; | ||
import org.prop4j.Literal; | ||
import org.prop4j.Not; | ||
import org.prop4j.Or; | ||
|
||
import de.ovgu.featureide.fm.core.analysis.cnf.formula.FeatureModelFormula; | ||
import de.ovgu.featureide.fm.core.base.IFeatureModel; | ||
import de.ovgu.featureide.fm.core.base.IFeatureStructure; | ||
import de.ovgu.featureide.fm.core.configuration.Configuration; | ||
import de.ovgu.featureide.fm.core.configuration.ConfigurationAnalyzer; | ||
import de.ovgu.featureide.fm.core.configuration.Selection; | ||
|
||
class AlternateModelTests { | ||
|
||
private IFeatureModel model; | ||
private IFeatureStructure root; | ||
|
||
@BeforeEach | ||
void BeforeEach() { | ||
model = Utils.CreateModel(); | ||
root = Utils.addFeature(model, "Root", true); | ||
root.setMandatory(true); | ||
model.getStructure().setRoot(root); | ||
} | ||
|
||
@Test | ||
void simple() { | ||
root.addChild(Utils.addFeature(model, "CORE1")); | ||
root.addChild(Utils.addFeature(model, "CORE2")); | ||
root.changeToAlternative(); | ||
|
||
var formula = new FeatureModelFormula(model); | ||
var config = new Configuration(formula); | ||
var configAnalyzer = new ConfigurationAnalyzer(formula, config); | ||
|
||
configAnalyzer.update(true); | ||
|
||
System.out.println(formula.getCNFNode().toString()); | ||
|
||
assertTrue(configAnalyzer.canBeValid(), "canbeValid"); | ||
assertFalse(configAnalyzer.isValid(), "isValid"); | ||
} | ||
|
||
@Test | ||
void canBeValid() { | ||
root.addChild(Utils.addFeature(model, "CORE1")); | ||
root.addChild(Utils.addFeature(model, "CORE2")); | ||
|
||
Utils.add(model, new Or( | ||
new Literal("CORE1"), | ||
new Literal("CORE2"))); | ||
Utils.add(model, new Implies( | ||
new Literal("CORE1"), | ||
new Not( | ||
new Literal("CORE2")))); | ||
Utils.add(model, new Implies( | ||
new Literal("CORE2"), | ||
new Not( | ||
new Literal("CORE1")))); | ||
|
||
var formula = new FeatureModelFormula(model); | ||
var config = new Configuration(formula); | ||
var configAnalyzer = new ConfigurationAnalyzer(formula, config); | ||
|
||
configAnalyzer.update(true); | ||
|
||
System.out.println(formula.getCNFNode().toString()); | ||
|
||
assertTrue(configAnalyzer.canBeValid(), "canbeValid"); | ||
assertFalse(configAnalyzer.isValid(), "isValid"); | ||
} | ||
|
||
@Test | ||
void shouldBeValid() { | ||
root.addChild(Utils.addFeature(model, "CORE")); | ||
|
||
Utils.add(model, new Or(new Literal("CORE"))); | ||
|
||
var formula = new FeatureModelFormula(model); | ||
var config = new Configuration(formula); | ||
var configAnalyzer = new ConfigurationAnalyzer(formula, config); | ||
|
||
configAnalyzer.update(true); | ||
|
||
System.out.println(formula.getCNFNode().toString()); | ||
|
||
assertTrue(configAnalyzer.canBeValid(), "canBeValid"); | ||
assertTrue(configAnalyzer.isValid(), "isValid"); | ||
|
||
var sfCore = config.getSelectableFeature("CORE"); | ||
assertNotNull(sfCore); | ||
assertEquals(Selection.SELECTED, sfCore.getAutomatic(), "isAutoSelected"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,44 @@ | ||
using org.prop4j; | ||
using org.prop4j.explain.solvers; | ||
|
||
namespace de.ovgu.featureide.fm.test | ||
{ | ||
internal class Prop4jTests | ||
{ | ||
private readonly long Timeout = (long)TimeSpan.FromSeconds(5).TotalMilliseconds; | ||
private org.prop4j.explain.solvers.SatSolver solver; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
solver = SatSolverFactory.getDefault().getSatSolver(); | ||
} | ||
|
||
[Test] | ||
public void Simple() | ||
{ | ||
var formula = new And(); | ||
|
||
var solver = new SatSolver(formula, Timeout); | ||
|
||
|
||
Expect(solver.isSatisfiable()).To.Be.True(); | ||
|
||
solver.addFormula(formula); | ||
|
||
Expect(solver.isSatisfiable()).To.Be.True(); | ||
} | ||
|
||
[Test] | ||
public void CanBeValid() | ||
{ | ||
var formula = new And( | ||
new Implies(new Literal("CORE1"), new Not(new Literal("CORE2"))), | ||
new Implies(new Literal("CORE2"), new Not(new Literal("CORE1"))) | ||
); | ||
var solver = new SatSolver(formula, Timeout); | ||
solver.addFormula(new Implies(new Literal("CORE1"), new Not(new Literal("CORE2")))); | ||
solver.addFormula(new Implies(new Literal("CORE2"), new Not(new Literal("CORE1")))); | ||
|
||
Expect(solver.isSatisfiable()).To.Be.True(); | ||
|
||
|
||
var map = solver.getAssumptions(); | ||
var m = solver.getModel(); | ||
Console.WriteLine("assumptions: " + map.keySet().Cast<string>().ToArray()); | ||
} | ||
} | ||
} |
Oops, something went wrong.