Search in sources :

Example 1 with DeltaWrapper

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));
}
Also used : CompilationUnit(abs.frontend.ast.CompilationUnit) DeltaWrapper(apet.absunit.DeltaForGetSetFieldsBuilder.DeltaWrapper) Model(abs.frontend.ast.Model) ModuleDecl(abs.frontend.ast.ModuleDecl)

Example 2 with DeltaWrapper

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);
}
Also used : ProductDecl(abs.frontend.ast.ProductDecl) ProductFeatureSet(abs.frontend.ast.ProductFeatureSet) Feature(abs.frontend.ast.Feature) AppCondFeature(abs.frontend.ast.AppCondFeature) AppCondFeature(abs.frontend.ast.AppCondFeature) DeltaClause(abs.frontend.ast.DeltaClause) DeltaWrapper(apet.absunit.DeltaForGetSetFieldsBuilder.DeltaWrapper) Deltaspec(abs.frontend.ast.Deltaspec) DeltaID(abs.frontend.ast.DeltaID) AppCond(abs.frontend.ast.AppCond) ProductLine(abs.frontend.ast.ProductLine) HashSet(java.util.HashSet)

Example 3 with DeltaWrapper

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;
}
Also used : DeltaAccess(abs.frontend.ast.DeltaAccess) DeltaWrapper(apet.absunit.DeltaForGetSetFieldsBuilder.DeltaWrapper) ASTNode(abs.frontend.ast.ASTNode) ArrayList(java.util.ArrayList) DeltaDecl(abs.frontend.ast.DeltaDecl) HashSet(java.util.HashSet)

Aggregations

DeltaWrapper (apet.absunit.DeltaForGetSetFieldsBuilder.DeltaWrapper)3 HashSet (java.util.HashSet)2 ASTNode (abs.frontend.ast.ASTNode)1 AppCond (abs.frontend.ast.AppCond)1 AppCondFeature (abs.frontend.ast.AppCondFeature)1 CompilationUnit (abs.frontend.ast.CompilationUnit)1 DeltaAccess (abs.frontend.ast.DeltaAccess)1 DeltaClause (abs.frontend.ast.DeltaClause)1 DeltaDecl (abs.frontend.ast.DeltaDecl)1 DeltaID (abs.frontend.ast.DeltaID)1 Deltaspec (abs.frontend.ast.Deltaspec)1 Feature (abs.frontend.ast.Feature)1 Model (abs.frontend.ast.Model)1 ModuleDecl (abs.frontend.ast.ModuleDecl)1 ProductDecl (abs.frontend.ast.ProductDecl)1 ProductFeatureSet (abs.frontend.ast.ProductFeatureSet)1 ProductLine (abs.frontend.ast.ProductLine)1 ArrayList (java.util.ArrayList)1