Search in sources :

Example 6 with DeltaAccess

use of abs.frontend.ast.DeltaAccess 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

DeltaAccess (abs.frontend.ast.DeltaAccess)6 DeltaDecl (abs.frontend.ast.DeltaDecl)6 ModifyClassModifier (abs.frontend.ast.ModifyClassModifier)4 ClassDecl (abs.frontend.ast.ClassDecl)3 CompilationUnit (abs.frontend.ast.CompilationUnit)3 List (abs.frontend.ast.List)3 MethodImpl (abs.frontend.ast.MethodImpl)3 MethodSig (abs.frontend.ast.MethodSig)3 Model (abs.frontend.ast.Model)3 Test (org.junit.Test)3 AddMethodModifier (abs.frontend.ast.AddMethodModifier)2 Block (abs.frontend.ast.Block)2 SkipStmt (abs.frontend.ast.SkipStmt)2 ASTNode (abs.frontend.ast.ASTNode)1 AddInterfaceModifier (abs.frontend.ast.AddInterfaceModifier)1 FieldDecl (abs.frontend.ast.FieldDecl)1 InterfaceDecl (abs.frontend.ast.InterfaceDecl)1 InterfaceTypeUse (abs.frontend.ast.InterfaceTypeUse)1 ModifyMethodModifier (abs.frontend.ast.ModifyMethodModifier)1 RemoveMethodModifier (abs.frontend.ast.RemoveMethodModifier)1