Skip to content

Commit

Permalink
Merge branch 'update_decorator_tests' into 'dev'
Browse files Browse the repository at this point in the history
extend setup in DecoratorTestCase

See merge request monticore/monticore!855
  • Loading branch information
maritabreuer committed Aug 28, 2023
2 parents 70e2be1 + 669fa76 commit 4cf21fe
Show file tree
Hide file tree
Showing 85 changed files with 406 additions and 772 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
package de.monticore.codegen.cd2java;

import de.monticore.ast.ASTNode;
import de.monticore.cd4code.prettyprint.CD4CodeFullPrettyPrinter;
import de.monticore.cd.facade.CDModifier;
import de.monticore.cd4code.prettyprint.CD4CodeFullPrettyPrinter;
import de.monticore.types.MCTypeFacade;
import de.monticore.types.mcbasictypes._ast.ASTMCPrimitiveType;
import de.monticore.types.mcbasictypes._ast.ASTMCType;
import de.monticore.types.mcfullgenerictypes.MCFullGenericTypesMill;
import de.monticore.umlmodifier._ast.ASTModifier;
import de.se_rwth.commons.logging.Log;
import de.se_rwth.commons.logging.LogStub;
import org.junit.Before;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import com.google.common.collect.Lists;
import de.monticore.cd._symboltable.BuiltInTypes;
import de.monticore.cd.codegen.CdUtilsPrinter;
import de.monticore.cd.methodtemplates.CD4C;
import de.monticore.cd4analysis.CD4AnalysisMill;
import de.monticore.cd4code.CD4CodeMill;
import de.monticore.cd4code._parser.CD4CodeParser;
Expand All @@ -11,6 +13,8 @@
import de.monticore.cdbasis._ast.ASTCDCompilationUnit;
import de.monticore.cdbasis._ast.ASTCDDefinition;
import de.monticore.cdbasis._ast.ASTCDPackage;
import de.monticore.generating.GeneratorSetup;
import de.monticore.generating.templateengine.GlobalExtensionManagement;
import de.monticore.symboltable.ImportStatement;
import de.monticore.types.mcbasictypes._ast.ASTMCImportStatement;
import de.se_rwth.commons.Joiners;
Expand All @@ -29,6 +33,8 @@ public abstract class DecoratorTestCase {
protected static final String MODEL_PATH = "src/test/resources/";
protected ASTCDPackage packageDir;

protected GlobalExtensionManagement glex;

@Before
public void initLog() {
LogStub.init();
Expand All @@ -41,7 +47,13 @@ public void setUpDecoratorTestCase() {
CD4CodeMill.init();
ICD4CodeGlobalScope globalScope = CD4CodeMill.globalScope();
BuiltInTypes.addBuiltInTypes(globalScope);
// globalScope.setModelPath(new ModelPath(Paths.get(MODEL_PATH)));
GeneratorSetup generatorSetup = new GeneratorSetup();
glex = new GlobalExtensionManagement();
generatorSetup.setGlex(glex);
CD4C.init(generatorSetup);
this.glex.setGlobalValue("astHelper", DecorationHelper.getInstance());
this.glex.setGlobalValue("cdPrinter", new CdUtilsPrinter());
// globalScope.setModelPath(new ModelPath(Paths.get(MODEL_PATH)));
packageDir = CD4CodeMill.cDPackageBuilder().
setMCQualifiedName(CD4CodeMill.mCQualifiedNameBuilder().build()).build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.codegen.cd2java;

import de.monticore.cd4codebasis._ast.*;
import de.monticore.cdbasis._ast.*;
import de.monticore.cdinterfaceandenum._ast.*;
import de.monticore.cd4codebasis._ast.ASTCDMethod;
import de.monticore.cdbasis._ast.ASTCDAttribute;
import de.monticore.cdbasis._ast.ASTCDClass;
import de.monticore.cdbasis._ast.ASTCDCompilationUnit;
import de.monticore.cdinterfaceandenum._ast.ASTCDEnum;
import de.monticore.cdinterfaceandenum._ast.ASTCDInterface;

import java.util.Arrays;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.codegen.cd2java;

import de.monticore.cd.codegen.CdUtilsPrinter;
import de.monticore.cd.methodtemplates.CD4C;
import de.monticore.cd4analysis.CD4AnalysisMill;
import de.monticore.cdbasis._ast.*;
import de.monticore.cdinterfaceandenum._ast.*;
import de.monticore.cdbasis._ast.ASTCDClass;
import de.monticore.cdbasis._ast.ASTCDCompilationUnit;
import de.monticore.cdinterfaceandenum._ast.ASTCDEnum;
import de.monticore.cdinterfaceandenum._ast.ASTCDInterface;
import de.monticore.codegen.cd2java._ast.ast_class.ASTDecorator;
import de.monticore.codegen.cd2java._ast.ast_class.ASTScopeDecorator;
import de.monticore.codegen.cd2java._ast.ast_class.ASTService;
Expand All @@ -17,32 +17,33 @@
import de.monticore.codegen.cd2java._cocos.CoCoInterfaceDecorator;
import de.monticore.codegen.cd2java._cocos.CoCoService;
import de.monticore.codegen.cd2java._symboltable.SymbolTableService;
import de.monticore.codegen.cd2java._symboltable.symbol.*;
import de.monticore.codegen.cd2java._symboltable.symbol.SymbolBuilderDecorator;
import de.monticore.codegen.cd2java._symboltable.symbol.SymbolDecorator;
import de.monticore.codegen.cd2java._symboltable.symbol.SymbolResolverInterfaceDecorator;
import de.monticore.codegen.cd2java._symboltable.symbol.SymbolSurrogateBuilderDecorator;
import de.monticore.codegen.cd2java._symboltable.symbol.SymbolSurrogateDecorator;
import de.monticore.codegen.cd2java._symboltable.symbol.symbolsurrogatemutator.MandatoryMutatorSymbolSurrogateDecorator;
import de.monticore.codegen.cd2java._visitor.VisitorService;
import de.monticore.codegen.cd2java.methods.AccessorDecorator;
import de.monticore.codegen.cd2java.methods.MethodDecorator;
import de.monticore.generating.GeneratorSetup;
import de.monticore.generating.templateengine.GlobalExtensionManagement;
import de.monticore.types.MCTypeFacade;
import de.se_rwth.commons.logging.Log;
import de.se_rwth.commons.logging.LogStub;
import org.junit.Before;
import org.junit.Test;

import java.util.List;
import java.util.Optional;

import static de.monticore.codegen.cd2java.DecoratorTestUtil.*;
import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy;
import static de.monticore.codegen.cd2java.DecoratorTestUtil.getEnumBy;
import static de.monticore.codegen.cd2java.DecoratorTestUtil.getInterfaceBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class
DeprecatedTest extends DecoratorTestCase {

private GlobalExtensionManagement glex = new GlobalExtensionManagement();

private MCTypeFacade mcTypeFacade = MCTypeFacade.getInstance();

private ASTCDClass clazzA;
Expand All @@ -67,12 +68,6 @@ public void setup() {
compilationUnit = this.parse("de", "monticore", "codegen", "deprecated", "DeprecatedProds");

this.glex.setGlobalValue("service", new AbstractService(compilationUnit));
this.glex.setGlobalValue("astHelper", DecorationHelper.getInstance());
this.glex.setGlobalValue("cdPrinter", new CdUtilsPrinter());

GeneratorSetup generatorSetup = new GeneratorSetup();
generatorSetup.setGlex(glex);
CD4C.init(generatorSetup);

clazzA = getClassBy("A", compilationUnit);
interfaceI = getInterfaceBy("I", compilationUnit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import de.monticore.cdbasis._ast.ASTCDCompilationUnit;
import de.monticore.codegen.cd2java._ast.ast_class.ASTService;
import de.se_rwth.commons.logging.Log;
import de.se_rwth.commons.logging.LogStub;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@
import com.github.javaparser.ParseResult;
import com.github.javaparser.ParserConfiguration;
import de.monticore.cd.codegen.CD2JavaTemplates;
import de.monticore.cd.codegen.CdUtilsPrinter;
import de.monticore.cd.facade.CDModifier;
import de.monticore.cd.methodtemplates.CD4C;
import de.monticore.cd4codebasis._ast.ASTCDMethod;
import de.monticore.cdbasis._ast.ASTCDAttribute;
import de.monticore.cdbasis._ast.ASTCDClass;
import de.monticore.cdbasis._ast.ASTCDCompilationUnit;
import de.monticore.codegen.cd2java.AbstractService;
import de.monticore.codegen.cd2java.DecorationHelper;
import de.monticore.codegen.cd2java.DecoratorTestCase;
import de.monticore.codegen.cd2java._ast.constants.ASTConstantsDecorator;
import de.monticore.generating.GeneratorEngine;
import de.monticore.generating.GeneratorSetup;
import de.monticore.generating.templateengine.GlobalExtensionManagement;
import de.se_rwth.commons.logging.Log;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -27,25 +24,19 @@
import static de.monticore.codegen.cd2java.DecoratorAssert.assertInt;
import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy;
import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class ASTConstantsDecoratorTest extends DecoratorTestCase {

private ASTCDClass constantClass;

private GlobalExtensionManagement glex;

private ASTCDCompilationUnit decoratedCompilationUnit;

private ASTCDCompilationUnit originalCompilationUnit;

@Before
public void setUp() {
// LogStub.initPlusLog(); // for manual testing purpose only
this.glex = new GlobalExtensionManagement();

this.glex.setGlobalValue("astHelper", DecorationHelper.getInstance());
this.glex.setGlobalValue("cdPrinter", new CdUtilsPrinter());
decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton");
originalCompilationUnit = decoratedCompilationUnit.deepClone();
this.glex.setGlobalValue("service", new AbstractService(decoratedCompilationUnit));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.github.javaparser.ParseResult;
import com.github.javaparser.ParserConfiguration;
import de.monticore.cd.codegen.CD2JavaTemplates;
import de.monticore.cd.codegen.CdUtilsPrinter;
import de.monticore.cd.methodtemplates.CD4C;
import de.monticore.cd4analysis.CD4AnalysisMill;
import de.monticore.cd4codebasis._ast.ASTCDMethod;
Expand Down Expand Up @@ -43,16 +42,10 @@ public class ASTInterfaceDecoratorTest extends DecoratorTestCase {

private ASTCDInterface dataInterface;

private GlobalExtensionManagement glex = new GlobalExtensionManagement();

@Before
public void setUp() {
this.glex = new GlobalExtensionManagement();

ASTCDCompilationUnit astcdCompilationUnit = this.parse("de", "monticore", "codegen", "data", "DataInterface");
this.glex.setGlobalValue("service", new AbstractService(astcdCompilationUnit));
this.glex.setGlobalValue("astHelper", DecorationHelper.getInstance());
this.glex.setGlobalValue("cdPrinter", new CdUtilsPrinter());
SymbolTableService symbolTableService = new SymbolTableService(astcdCompilationUnit);
ASTCDInterface interfaceBy = getInterfaceBy("ASTA", astcdCompilationUnit);
ASTInterfaceDecorator decorator = new ASTInterfaceDecorator(this.glex, new ASTService(astcdCompilationUnit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.github.javaparser.ParseResult;
import com.github.javaparser.ParserConfiguration;
import de.monticore.cd.codegen.CD2JavaTemplates;
import de.monticore.cd.codegen.CdUtilsPrinter;
import de.monticore.cd.methodtemplates.CD4C;
import de.monticore.cd4codebasis._ast.ASTCDMethod;
import de.monticore.cdbasis._ast.ASTCDCompilationUnit;
Expand All @@ -16,7 +15,6 @@
import de.monticore.codegen.cd2java._visitor.VisitorService;
import de.monticore.generating.GeneratorEngine;
import de.monticore.generating.GeneratorSetup;
import de.monticore.generating.templateengine.GlobalExtensionManagement;
import de.monticore.types.mcbasictypes._ast.ASTMCType;
import de.se_rwth.commons.logging.Log;
import org.junit.Before;
Expand All @@ -37,14 +35,11 @@ public class ASTLanguageInterfaceDecoratorTest extends DecoratorTestCase {

private ASTCDCompilationUnit decoratedCompilationUnit;

private GlobalExtensionManagement glex = new GlobalExtensionManagement();

@Before
public void setUp() {
this.MCTypeFacade = MCTypeFacade.getInstance();
originalCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton");
this.glex.setGlobalValue("service", new AbstractService(originalCompilationUnit));
this.glex.setGlobalValue("cdPrinter", new CdUtilsPrinter());

ASTService astService = new ASTService(originalCompilationUnit);
VisitorService visitorService = new VisitorService(originalCompilationUnit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
import com.github.javaparser.ParseResult;
import com.github.javaparser.ParserConfiguration;
import de.monticore.cd.codegen.CD2JavaTemplates;
import de.monticore.cd.codegen.CdUtilsPrinter;
import de.monticore.cd.methodtemplates.CD4C;
import de.monticore.cd4analysis.CD4AnalysisMill;
import de.monticore.cd4codebasis._ast.ASTCDMethod;
import de.monticore.cd4codebasis._ast.ASTCDParameter;
import de.monticore.cdbasis._ast.ASTCDCompilationUnit;
import de.monticore.cdinterfaceandenum._ast.ASTCDInterface;
import de.monticore.codegen.cd2java.AbstractService;
import de.monticore.codegen.cd2java.DecorationHelper;
import de.monticore.codegen.cd2java.DecoratorTestCase;
import de.monticore.codegen.cd2java._ast.ast_class.ASTScopeDecorator;
import de.monticore.codegen.cd2java._ast.ast_class.ASTService;
Expand All @@ -26,7 +24,6 @@
import de.monticore.codegen.cd2java.methods.MethodDecorator;
import de.monticore.generating.GeneratorEngine;
import de.monticore.generating.GeneratorSetup;
import de.monticore.generating.templateengine.GlobalExtensionManagement;
import de.monticore.types.mcbasictypes._ast.ASTMCObjectType;
import de.se_rwth.commons.logging.Log;
import org.junit.Before;
Expand All @@ -37,26 +34,22 @@
import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals;
import static de.monticore.codegen.cd2java.DecoratorTestUtil.getInterfaceBy;
import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class FullASTInterfaceDecoratorTest extends DecoratorTestCase {

private ASTCDInterface astcdInterface;

private GlobalExtensionManagement glex = new GlobalExtensionManagement();

private static final String NAME_DEFINITION = "de.monticore.codegen.ast.referencedsymbol._ast.ASTFoo";

private static final String NAME_SYMBOL = "de.monticore.codegen.ast.referencedsymbol._symboltable.FooSymbol";

@Before
public void setUp() {
this.glex = new GlobalExtensionManagement();

ASTCDCompilationUnit astcdCompilationUnit = this.parse("de", "monticore", "codegen", "data", "DataInterface");
this.glex.setGlobalValue("service", new AbstractService(astcdCompilationUnit));
this.glex.setGlobalValue("astHelper", DecorationHelper.getInstance());
this.glex.setGlobalValue("cdPrinter", new CdUtilsPrinter());

SymbolTableService symbolTableService = new SymbolTableService(astcdCompilationUnit);
ASTCDInterface interfaceBy = getInterfaceBy("ASTA", astcdCompilationUnit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
import com.github.javaparser.ParseResult;
import com.github.javaparser.ParserConfiguration;
import de.monticore.cd.codegen.CD2JavaTemplates;
import de.monticore.cd.codegen.CdUtilsPrinter;
import de.monticore.cd.methodtemplates.CD4C;
import de.monticore.cdbasis._ast.ASTCDClass;
import de.monticore.cdbasis._ast.ASTCDCompilationUnit;
import de.monticore.cdinterfaceandenum._ast.ASTCDInterface;
import de.monticore.codegen.cd2java.AbstractService;
import de.monticore.codegen.cd2java.DecorationHelper;
import de.monticore.codegen.cd2java.DecoratorTestCase;
import de.monticore.codegen.cd2java._ast.ASTCDDecorator;
import de.monticore.codegen.cd2java._ast.ast_class.*;
import de.monticore.codegen.cd2java._ast.ast_class.ASTDecorator;
import de.monticore.codegen.cd2java._ast.ast_class.ASTFullDecorator;
import de.monticore.codegen.cd2java._ast.ast_class.ASTScopeDecorator;
import de.monticore.codegen.cd2java._ast.ast_class.ASTService;
import de.monticore.codegen.cd2java._ast.ast_class.ASTSymbolDecorator;
import de.monticore.codegen.cd2java._ast.ast_class.reference.ASTReferenceDecorator;
import de.monticore.codegen.cd2java._ast.ast_interface.ASTInterfaceDecorator;
import de.monticore.codegen.cd2java._ast.ast_interface.ASTLanguageInterfaceDecorator;
Expand All @@ -32,30 +34,23 @@
import de.monticore.codegen.cd2java.methods.MethodDecorator;
import de.monticore.generating.GeneratorEngine;
import de.monticore.generating.GeneratorSetup;
import de.monticore.generating.templateengine.GlobalExtensionManagement;
import de.se_rwth.commons.logging.Log;
import org.junit.Before;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;

import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy;
import static org.junit.Assert.*;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;


public class ASTCDDecoratorTest extends DecoratorTestCase {

private GlobalExtensionManagement glex = new GlobalExtensionManagement();

private ASTCDCompilationUnit decoratedCompilationUnit;

private ASTCDCompilationUnit originalCompilationUnit;

@Before
public void setup() {
this.glex.setGlobalValue("astHelper", DecorationHelper.getInstance());
this.glex.setGlobalValue("cdPrinter", new CdUtilsPrinter());
this.originalCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "AST");
this.glex.setGlobalValue("service", new AbstractService(originalCompilationUnit));

Expand Down
Loading

0 comments on commit 4cf21fe

Please sign in to comment.