本文整理汇总了Java中net.ssehub.easy.varModel.model.Project.add方法的典型用法代码示例。如果您正苦于以下问题:Java Project.add方法的具体用法?Java Project.add怎么用?Java Project.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.ssehub.easy.varModel.model.Project
的用法示例。
在下文中一共展示了Project.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpBeforeClass
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* SetupBefore Class method, creating a project for testing.
* @throws ValueDoesNotMatchTypeException Should not occur,
* otherwise there exist an error in the {@link ValueFactory} class.
* @throws CSTSemanticException Should not occur, otherwise there exist an error in the {@link Constraint} class.
*/
@BeforeClass
public static void setUpBeforeClass() throws ValueDoesNotMatchTypeException, CSTSemanticException {
//Create Project and Variables
project = new Project("TestProject");
DecisionVariableDeclaration intA = new DecisionVariableDeclaration("intA", IntegerType.TYPE, project);
DecisionVariableDeclaration intB = new DecisionVariableDeclaration("intB", IntegerType.TYPE, project);
project.add(intA);
project.add(intB);
//Create AssignmentConstraint
Variable varA = new Variable(intA);
Value constValueA = ValueFactory.createValue(intA.getType(), "1");
ConstantValue constA = new ConstantValue(constValueA);
OCLFeatureCall assingment = new OCLFeatureCall(varA, OclKeyWords.ASSIGNMENT, constA);
assingmentConstraint = new Constraint(assingment, project);
project.add(assingmentConstraint);
//Create normal constraint
Variable varA2 = new Variable(intA);
Variable varB = new Variable(intB);
OCLFeatureCall unequal = new OCLFeatureCall(varA2, OclKeyWords.UNEQUALS, varB);
unequalConstraint = new Constraint(unequal, project);
project.add(unequalConstraint);
}
示例2: testSequenceProject
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
*Method to test the operation Isempty on seq.
*
*
* @throws ValueDoesNotMatchTypeException Should not occur
* if the values are configured correctly in relation to the datatype.
* @throws CSTSemanticException Must not occur, otherwise
* there is an error inside the CST package
*
*/
// @Test
public void testSequenceProject() throws CSTSemanticException, ValueDoesNotMatchTypeException {
Project project = new Project("testSequenceProject");
DecisionVariableDeclaration seqDec = new DecisionVariableDeclaration("seq_var", Sequence.TYPE, project);
Configuration conf = new Configuration(project);
project.add(seqDec);
DecisionVariableDeclaration boolA = new DecisionVariableDeclaration("boolA", BooleanType.TYPE, project);
project.add(boolA);
Variable var1 = new Variable(seqDec);
Variable var2 = new Variable(boolA);
OCLFeatureCall ocl1 = new OCLFeatureCall(var1, OclKeyWords.IS_EMPTY);
OCLFeatureCall ocl2 = new OCLFeatureCall(var2, OclKeyWords.EQUALS, ocl1);
Constraint cons1 = new Constraint(ocl2, null);
project.add(cons1);
engine = new DroolsReasoner();
ReasoningResult r = engine.check(project, conf, null, null);
Assert.assertFalse(r.hasConflict());
System.out.println(" .. has conflict?");
}
示例3: testAliasesAreNotConsidered
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests whether instances of typedefs ({@link DerivedDatatype}) are <b>not</b> considered if they do not contain
* a constraint, i.e., are only an alias.
* @throws CSTSemanticException Must not occur, otherwise {@link Constraint}s are broken.
*/
@Test
public void testAliasesAreNotConsidered() throws CSTSemanticException {
Project project = new Project("testAliasesAreNotConsidered");
DerivedDatatype aliasType = new DerivedDatatype("Alias", IntegerType.TYPE, project);
project.add(aliasType);
DecisionVariableDeclaration aliasDecl = new DecisionVariableDeclaration("aliasInt", aliasType, project);
project.add(aliasDecl);
// Create configuration out of valid project
ProjectTestUtilities.validateProject(project);
Configuration config = new Configuration(project);
// Check importance
MandatoryDeclarationClassifier finder = new MandatoryDeclarationClassifier(config, FilterType.ALL);
project.accept(finder);
VariableContainer importances = finder.getImportances();
// Test correct behavior: alias is not mandatory
assertVariable(config.getDecision(aliasDecl), false, importances);
}
示例4: testDeclarationWithDependingType
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests whether declarations can be copied. This method tests a declaration:
* <ul>
* <li>No {@link Attribute}s</li>
* <li>Depending data type (compound which is defined later)</li>
* <li>No default value</li>
* </ul>
*/
@Test
public void testDeclarationWithDependingType() {
Project original = new Project("testDeclarationWithDependingType");
Compound cType = new Compound("cType", original);
DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", cType, original);
original.add(decl);
original.add(cType);
Project copy = copyProject(original);
// Attention: Ordering has changed!
DecisionVariableDeclaration copieddecl = (DecisionVariableDeclaration) copy.getElement(1);
Map<AbstractVariable, IModelElement> copyMapping = new HashMap<AbstractVariable, IModelElement>();
copyMapping.put(decl, copy);
assertDeclaration(decl, copieddecl, copyMapping);
}
示例5: testOperationDependingCompletely
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests whether a {@link OperationDefinition} can be copied, which depends on an unresolved type.
*/
@Test
public void testOperationDependingCompletely() {
Project original = new Project("testOperationDependingCompletely");
DerivedDatatype aliasType = new DerivedDatatype("boolAlias", BooleanType.TYPE, original);
OperationDefinition operation = new OperationDefinition(original);
ExplicitTypeVariableDeclaration parameterDecl = new ExplicitTypeVariableDeclaration("param1", aliasType,
operation);
ConstantValue constTrueFunc = new ConstantValue(BooleanValue.TRUE);
CustomOperation func = new CustomOperation(aliasType, "returnsTrue", original.getType(), constTrueFunc,
new DecisionVariableDeclaration[] {parameterDecl});
operation.setOperation(func);
original.add(operation);
original.add(aliasType);
Project copy = copyProject(original);
// Attention: Ordering has changed!
OperationDefinition copiedOp = (OperationDefinition) copy.getElement(1);
assertUserOperation(operation, copiedOp, copy);
}
示例6: addFreezeBlock
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Adds the freeze block to the project.
*
* @param freezables the freezables
* @param project the IVML project to add to
* @param fallbackForType in case that <code>project</code> is being written the first time, may be <b>null</b>
*/
public static void addFreezeBlock(List<IFreezable> freezables, Project project, Project fallbackForType) {
if (freezables.size() > 0) {
IFreezable[] freezes = freezables.toArray(new IFreezable[freezables.size()]);
FreezeBlock block = createFreezeBlock(freezes, project, fallbackForType);
if (null != block) {
project.add(block);
}
}
}
示例7: saveFreezeStates
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
@Override
protected void saveFreezeStates(Project confProject) {
// Find (all) frozen elements
List<IFreezable> frozenElements = new ArrayList<IFreezable>();
for (IDecisionVariable decisionVariable : getConfiguration()) {
if (decisionVariable.getState() == AssignmentState.FROZEN
&& decisionVariable.getDeclaration() instanceof IFreezable) {
frozenElements.add((IFreezable) decisionVariable.getDeclaration());
}
}
// Filter elements: Only elements which are frozen in this project
/*
* QualiMaster has cycling imports and saves into a new srcProject, but will also overwrite this.
* For this reason, the original (srcConfig.getProject()) not the destProject must be used for the
* FrozenElementsFinder. Thats the only change in this method.
*/
FrozenElementsFinder finder = new FrozenElementsFinder(getConfiguration().getProject(),
FilterType.ONLY_IMPORTS);
List<IFreezable> alreadyFrozenElements = finder.getFrozenElements();
frozenElements.removeAll(alreadyFrozenElements);
// Freeze elements, which are frozen in this Configuration/Project.
if (frozenElements.size() > 0) {
IFreezable[] freezables = new IFreezable[frozenElements.size()];
frozenElements.toArray(freezables);
FreezeBlock freeze = createFreezeBlock(freezables, confProject);
confProject.add(freeze);
}
}
示例8: createFreezeBlock
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Adds a freeze block to the project containing all elements.
*
* @param project
* the IVML project to freeze
* @return the created freeze block
* @throws CSTSemanticException
* in case of CST errors
* @throws ValueDoesNotMatchTypeException
* in case of unmatching values
* @throws ModelQueryException
* in case of model access problems
*/
public static FreezeBlock createFreezeBlock(Project project)
throws CSTSemanticException, ValueDoesNotMatchTypeException, ModelQueryException {
List<IFreezable> freezables = new ArrayList<IFreezable>();
for (int e = 0; e < project.getElementCount(); e++) {
ContainableModelElement elt = project.getElement(e);
if (elt instanceof IFreezable) {
freezables.add((IFreezable) elt);
}
}
FreezeBlock result = createFreezeBlock(freezables, project, project);
project.add(result);
return result;
}
示例9: testFreezeBlockDependningDeclaration
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests copying a {@link FreezeBlock}. It tests:
* <ul>
* <li>A depending declaration</li>
* <li>No But expression</li>
* </ul>
*/
@Test
public void testFreezeBlockDependningDeclaration() {
Project orgProject = new Project("testFreezeBlockDependningDeclaration");
DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", RealType.TYPE, orgProject);
FreezeBlock freeze = new FreezeBlock(new IFreezable[] {decl}, null, null, orgProject);
orgProject.add(freeze);
orgProject.add(decl);
java.util.Set<Project> allCopiedProjects = new HashSet<Project>();
Project copiedProject = copyProject(orgProject, allCopiedProjects);
// Attention: Ordering has changed
FreezeBlock copiedBlock = (FreezeBlock) copiedProject.getElement(1);
assertFreezeBlock(freeze, copiedBlock, copiedProject, allCopiedProjects);
}
示例10: testOmmitFrozenConstraint
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests whether filtering of constraints which contain only frozen variables work.
* @throws ValueDoesNotMatchTypeException Must not occur, otherwise the {@link ValueFactory} or
* {@link net.ssehub.easy.varModel.model.AbstractVariable#setValue(String)} are broken.
* @throws CSTSemanticException Must not occur, otherwise
* {@link Constraint#setConsSyntax(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree)} is broken.
*/
@Test
public void testOmmitFrozenConstraint() throws ValueDoesNotMatchTypeException, CSTSemanticException {
// Create original project with two declarations, 2 constraints, and freeze one of these variables
Project p = new Project("testProjectFrozenConstraint");
DecisionVariableDeclaration declA = new DecisionVariableDeclaration("varA", IntegerType.TYPE, p);
declA.setValue(10);
p.add(declA);
DecisionVariableDeclaration declB = new DecisionVariableDeclaration("varB", IntegerType.TYPE, p);
declB.setValue(10);
p.add(declB);
Constraint constraintA = new Constraint(p);
OCLFeatureCall comparisonA = new OCLFeatureCall(new Variable(declA), OclKeyWords.GREATER,
new ConstantValue(ValueFactory.createValue(IntegerType.TYPE, 5)));
constraintA.setConsSyntax(comparisonA);
p.add(constraintA);
Constraint constraintB = new Constraint(p);
OCLFeatureCall comparisonB = new OCLFeatureCall(new Variable(declB), OclKeyWords.GREATER,
new ConstantValue(ValueFactory.createValue(IntegerType.TYPE, 5)));
constraintB.setConsSyntax(comparisonB);
p.add(constraintB);
p.add(new FreezeBlock(new IFreezable[] {declA}, null, null, p));
// Project should be valid
ProjectTestUtilities.validateProject(p);
Configuration config = new Configuration(p);
// Create copy while omitting "frozen" constraints
ProjectRewriteVisitor copynator = new ProjectRewriteVisitor(p, FilterType.NO_IMPORTS);
FrozenConstraintsFilter ommiter = new FrozenConstraintsFilter(config);
copynator.addModelCopyModifier(ommiter);
p.accept(copynator);
// Copied project should contain the first constraint (constraintA)
ProjectTestUtilities.validateProject(p);
assertProjectContainment(p, constraintA, false, 4);
assertProjectContainment(p, constraintB, true, 4);
}
示例11: testSimpleExplicitDeclarationCopy
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests whether {@link ExplicitTypeVariableDeclaration}s can be copied
* (usually used inside {@link OperationDefinition}s). Here it is used outside of a operation, this test may fail
* if future implementation of our variability model becomes more restrictive.
*/
@Test
public void testSimpleExplicitDeclarationCopy() {
Project original = new Project("testSimpleExplicitDeclarationCopy");
IDatatype basisType = RealType.TYPE;
ExplicitTypeVariableDeclaration decl = new ExplicitTypeVariableDeclaration("decl", basisType, original);
original.add(decl);
Project copy = copyProject(original);
AbstractVariable copieddecl = (AbstractVariable) copy.getElement(0);
Map<AbstractVariable, IModelElement> copyMapping = new HashMap<AbstractVariable, IModelElement>();
copyMapping.put(decl, copy);
assertDeclaration(decl, copieddecl, copyMapping);
}
示例12: testForAllContainerOperation
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests the "forAll" container operation.
*
* @throws ValueDoesNotMatchTypeException in case that value assignments fail (shall not occur)
* @throws ConfigurationException in case that initial assignment of values fail (shall not occur)
* @throws CSTSemanticException in case that the expressions created during this test are not
* valid (shall not occur)
*/
@Test
public void testForAllContainerOperation() throws ValueDoesNotMatchTypeException, ConfigurationException,
CSTSemanticException {
Project project = new Project("Test");
// Types
Sequence seqType = new Sequence("mySeq", IntegerType.TYPE, project);
// Declarations
DecisionVariableDeclaration decl1 = new DecisionVariableDeclaration("intA", seqType, project);
project.add(decl1);
// Assign value
Configuration config = new Configuration(project);
IDecisionVariable var = config.getDecision(decl1);
var.setValue(ValueFactory.createValue(seqType, new Object[]{1, 2, 3, 4, 5}), AssignmentState.ASSIGNED);
DecisionVariableDeclaration localDecl = new DecisionVariableDeclaration("a", IntegerType.TYPE, null);
ConstantValue const0 = new ConstantValue(ValueFactory.createValue(IntegerType.TYPE, 0));
ConstraintSyntaxTree itExpression = Utils.createCall(
localDecl, IntegerType.GREATER_EQUALS_INTEGER_INTEGER, const0);
itExpression.inferDatatype();
ConstraintSyntaxTree containerOp = Utils.createContainerCall(decl1, Sequence.FORALL, itExpression, localDecl);
containerOp.inferDatatype();
EvaluationVisitor visitor = new EvaluationVisitor();
visitor.init(config, AssignmentState.DEFAULT, false, null);
containerOp.accept(visitor);
Assert.assertEquals(BooleanValue.TRUE, visitor.getResult());
visitor.clear();
var.setValue(ValueFactory.createValue(seqType, new Object[]{1, -2, 3, 4, 5}), AssignmentState.ASSIGNED);
visitor.init(config, AssignmentState.DEFAULT, false, null);
containerOp.accept(visitor);
Assert.assertEquals(BooleanValue.FALSE, visitor.getResult());
visitor.clear();
var.setValue(ValueFactory.createValue(seqType, new Object[]{}), AssignmentState.ASSIGNED);
visitor.init(config, AssignmentState.DEFAULT, false, null);
containerOp.accept(visitor);
Assert.assertEquals(BooleanValue.TRUE, visitor.getResult());
visitor.clear();
}
示例13: testNonEmptyProjectImport
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests that a {@link ProjectImport} with a non empty project can be copied.
* The importing project has a declaration with a default value to the imported project.
* @throws ModelManagementException If {@link ProjectImport#setResolved(Project)} is not working
* @throws CSTSemanticException If {@link DecisionVariableDeclaration#setValue(ConstraintSyntaxTree)} is not working
* @throws ValueDoesNotMatchTypeException If {@link DecisionVariableDeclaration#setValue(ConstraintSyntaxTree)}
* is not working
*/
@Test
public void testNonEmptyProjectImport() throws ModelManagementException, ValueDoesNotMatchTypeException,
CSTSemanticException {
Project importedProject = new Project("importedProject_of_testNonEmptyProjectImport");
DecisionVariableDeclaration decl1 = new DecisionVariableDeclaration("importedDecl", IntegerType.TYPE,
importedProject);
importedProject.add(decl1);
Project mainProject = new Project("mainProject_of_testNonEmptyProjectImport");
ProjectImport pImport = new ProjectImport(importedProject.getName());
pImport.setResolved(importedProject);
mainProject.addImport(pImport);
DecisionVariableDeclaration decl2 = new DecisionVariableDeclaration("mainDecl", IntegerType.TYPE, mainProject);
Variable defltValue = new Variable(decl1);
decl2.setValue(defltValue);
mainProject.add(decl2);
Project copiedMain = copyProject(mainProject);
DecisionVariableDeclaration copiedDecl2 = (DecisionVariableDeclaration) copiedMain.getElement(0);
Project copiedImported = copiedMain.getImport(0).getResolved();
DecisionVariableDeclaration copiedDecl1 = (DecisionVariableDeclaration) copiedImported.getElement(0);
// Tuple (original declaration, expected copied parent)
Map<AbstractVariable, IModelElement> mapping = new HashMap<AbstractVariable, IModelElement>();
mapping.put(decl1, copiedImported);
mapping.put(decl2, copiedMain);
assertDeclaration(decl1, copiedDecl1, mapping);
assertDeclaration(decl2, copiedDecl2, mapping);
}
示例14: createCompoundProject
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Creates content of {@link #cmpProject}.
* Part of the {@link #setUp()} method.
*/
private void createCompoundProject() {
cmpProject = new Project("Compounds");
// Basic Compound
Compound basicCompound = new Compound(BASIC_COMPOUND_NAME, cmpProject);
DecisionVariableDeclaration slot1Decl = new DecisionVariableDeclaration(SLOT_1_NAME, IntegerType.TYPE,
basicCompound);
basicCompound.add(slot1Decl);
cmpProject.add(basicCompound);
// RefinedCompound1 refines BasicCompound
Compound refinedCompound1 = createRefinedCompound(REFINED_COMPOUND_1_NAME, SLOT_2_NAME, basicCompound);
// RefinedCompound2 refines RefinedCompound1
Compound refinedCompound2 = createRefinedCompound(REFINED_COMPOUND_2_NAME, SLOT_3_NAME, refinedCompound1);
//Create instances for the three compounds
cmp1Decl = new DecisionVariableDeclaration(COMPOUND_INSTANCE_NAME_1, basicCompound, cmpProject);
cmpProject.add(cmp1Decl);
cmp2Decl = new DecisionVariableDeclaration(COMPOUND_INSTANCE_NAME_2, refinedCompound1, cmpProject);
cmpProject.add(cmp2Decl);
cmp3Decl = new DecisionVariableDeclaration(COMPOUND_INSTANCE_NAME_3, refinedCompound2, cmpProject);
cmpProject.add(cmp3Decl);
ProjectTestUtilities.validateProject(cmpProject);
}
示例15: testLet
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests the let construct.
*
* @throws ValueDoesNotMatchTypeException in case that value assignments fail (shall not occur)
* @throws ConfigurationException in case that initial assignment of values fail (shall not occur)
* @throws CSTSemanticException in case that the expressions created during this test are not
* valid (shall not occur)
*/
@Test
public void testLet() throws ValueDoesNotMatchTypeException, ConfigurationException, CSTSemanticException {
Project project = new Project("Test");
DecisionVariableDeclaration decl = new DecisionVariableDeclaration("a", IntegerType.TYPE, project);
project.add(decl);
Configuration config = new Configuration(project);
config.getDecision(decl).setValue(ValueFactory.createValue(IntegerType.TYPE, 7), AssignmentState.ASSIGNED);
// int a = 7; let t = a * 7 in t > 0;
DecisionVariableDeclaration letVar = new DecisionVariableDeclaration("t", IntegerType.TYPE, null);
ConstraintSyntaxTree const7 = new ConstantValue(ValueFactory.createValue(IntegerType.TYPE, 7));
ConstraintSyntaxTree const0 = new ConstantValue(ValueFactory.createValue(IntegerType.TYPE, 0));
ConstraintSyntaxTree defltVal = Utils.createCall(decl, IntegerType.MULT_INTEGER_INTEGER, const7);
defltVal.inferDatatype();
letVar.setValue(defltVal);
ConstraintSyntaxTree inExpr = Utils.createCall(letVar, IntegerType.GREATER_INTEGER_INTEGER, const0);
inExpr.inferDatatype();
ConstraintSyntaxTree letExpr = new Let(letVar, inExpr);
letExpr.inferDatatype();
EvaluationVisitor visitor = new EvaluationVisitor();
visitor.init(config, AssignmentState.DEFAULT, false, null);
letExpr.accept(visitor);
Assert.assertEquals(BooleanValue.TRUE, visitor.getResult());
visitor.clear();
}