use of apet.absunit.DeltaForGetSetFieldsBuilder.DeltaWrapper in project abstools by abstools.
the class ABSUnitTestCaseTranslator method validateOutput.
private void validateOutput() {
CompilationUnit unit = new CompilationUnit();
ModuleDecl cm = module.treeCopyNoTransform();
unit.addModuleDecl(cm);
for (DeltaWrapper d : deltas) {
unit.addDeltaDecl(d.getDelta().treeCopyNoTransform());
}
unit.setProductLine(productline.treeCopyNoTransform());
unit.addProductDecl(product.treeCopyNoTransform());
Model copy = model.treeCopyNoTransform();
copy.addCompilationUnit(unit);
validateOutput(copy.treeCopyNoTransform(), null);
validateOutput(copy.treeCopyNoTransform(), module.getName().concat(".").concat(PRODUCT_NAME));
}
use of apet.absunit.DeltaForGetSetFieldsBuilder.DeltaWrapper in project abstools by abstools.
the class ABSUnitTestCaseTranslator method buildProductLine.
void buildProductLine(ModuleDecl module) {
if (deltas.isEmpty()) {
return;
}
console("Generating product line description...");
productline = new ProductLine();
productline.setName(CONFIGURATION_NAME);
Feature feature = new Feature();
feature.setName(FEATURE_NAME);
productline.addFeature(feature);
AppCond ac = new AppCondFeature(FEATURE_NAME);
Set<String> applicationConditions = new HashSet<String>();
DeltaClause lastClause = null;
for (DeltaWrapper d : deltas) {
DeltaClause clause = new DeltaClause();
Deltaspec spec = new Deltaspec();
String name = d.getDelta().getName();
spec.setDeltaID(name);
clause.setDeltaspec(spec);
clause.setAppCond(ac);
if (d.isLast()) {
lastClause = clause;
} else {
applicationConditions.add(name);
}
productline.addDeltaClause(clause);
}
if (lastClause != null) {
for (String n : applicationConditions) {
lastClause.addAfterDeltaID(new DeltaID(n));
}
}
product = new ProductDecl();
product.setName(PRODUCT_NAME);
ProductFeatureSet featureSet = new ProductFeatureSet();
featureSet.addFeature(feature);
product.setProductExpr(featureSet);
}
use of apet.absunit.DeltaForGetSetFieldsBuilder.DeltaWrapper in project abstools by abstools.
the class ABSUnitTestCaseTranslator method generateABSUnitTests.
/**
* Generates an ABS module {@link ModuleDecl} that defines the
* given test suite.
*
* @param suite
* @param validate
* @return
*/
@SuppressWarnings("rawtypes")
public ModuleDecl generateABSUnitTests(ApetTestSuite suite, boolean validate) {
console("Add basic imports...");
for (String key : suite.keySet()) {
console("Generating test suite for " + key + "...");
generateABSUnitTest(suite.get(key), key);
}
Set<DeltaDecl> deltaDecls = new HashSet<DeltaDecl>();
for (DeltaWrapper w : deltas) {
DeltaDecl delta = w.getDelta();
deltaDecls.add(delta);
abs.frontend.ast.List<DeltaAccess> access = delta.getDeltaAccesss();
if (access.hasChildren()) {
String use = access.getChild(0).getModuleName();
importModules.add(use);
}
}
addImports(module);
buildProductLine(module);
console("Pretty printing ABSUnit tests...");
List<ASTNode<ASTNode>> nodes = new ArrayList<ASTNode<ASTNode>>();
nodes.add(module);
nodes.addAll(deltaDecls);
nodes.add(productline);
nodes.add(product);
printToFile(nodes, outputFile);
if (validate) {
console("Validating ABSUnit tests...");
validateOutput();
}
console("ABSUnit tests generation successful");
return module;
}
Aggregations