diff --git a/gradle.properties b/gradle.properties index 15ccb34a26..3bc21f46d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,7 +20,8 @@ previous_mc_version =7.8.0 commons_cli_version = 1.4 se_commons_version =7.8.0 antlr_version =4.12.0 -junit_version =5.10.3 +junit_version = 5.14.1 +junit_platform_version = 1.14.1 emf_compare_version =1.2.0 ecore_version =2.16.0 commons_lang3_version = 3.8.1 diff --git a/monticore-generator/build.gradle b/monticore-generator/build.gradle index 504b1e8220..5a16a7ffc0 100644 --- a/monticore-generator/build.gradle +++ b/monticore-generator/build.gradle @@ -76,8 +76,8 @@ allprojects { } dependencies { testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" - testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" } diff --git a/monticore-generator/gradle-plugin/build.gradle b/monticore-generator/gradle-plugin/build.gradle index 6739a73dd3..000882e53b 100644 --- a/monticore-generator/gradle-plugin/build.gradle +++ b/monticore-generator/gradle-plugin/build.gradle @@ -23,6 +23,11 @@ dependencies { mcTool project(":") // depend on the generator subproject testImplementation gradleTestKit() + + testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" } sourceSets { diff --git a/monticore-generator/gradle-plugin/src/test/java/de/monticore/IncCheckerTest.java b/monticore-generator/gradle-plugin/src/test/java/de/monticore/IncCheckerTest.java index 2e4c4b347a..94f7111bb1 100644 --- a/monticore-generator/gradle-plugin/src/test/java/de/monticore/IncCheckerTest.java +++ b/monticore-generator/gradle-plugin/src/test/java/de/monticore/IncCheckerTest.java @@ -7,57 +7,43 @@ import de.se_rwth.commons.Files; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.*; -import org.junit.rules.TemporaryFolder; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.Collection; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; /** * This class tests the {@link IncChecker} testing against the expected incCheck result after changing the files. */ -@RunWith(Parameterized.class) public class IncCheckerTest { - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); - - // Test for the default mc4, a short sc, and a longer file ending - @Parameterized.Parameters(name = "{0}") - public static Collection fileEndings() { - return Arrays.asList(new Object[][]{ - {"mc4"}, {"sc"}, {"longerEnding"} - }); - } + @TempDir + public File temporaryFolder; + - @Before + @BeforeEach public void initLog() { LogStub.init(); Log.enableFailQuick(false); } - - protected final String fileEnding; - - public IncCheckerTest(String fileEnding) { - this.fileEnding = fileEnding; - } - @Test - public void testIncCheck() throws IOException { - File tempDir = temporaryFolder.newFolder(); + @ParameterizedTest + @ValueSource(strings = {"mc4", "sc", "longerEnding"}) + public void testIncCheck(String fileEnding) throws IOException { + File tempDir = new File(temporaryFolder, "tempDir"); File outDir = new File(tempDir, "out"); File repDir = new File(tempDir, "reports"); - outDir.mkdirs(); - repDir.mkdirs(); + assertTrue(outDir.mkdirs()); + assertTrue(repDir.mkdirs()); String modelName = "IncCheckExample"; Logger logger = LoggerFactory.getLogger("nop"); @@ -75,8 +61,8 @@ public void testIncCheck() throws IOException { MCPath mcPath = new MCPath(tempDir.toPath()); // Test that the MCPath is behaving correctly for both HW Files - Assert.assertTrue("Existing file not found in MCPath", mcPath.find(existingHWFile.getName()).isPresent()); - Assert.assertFalse("Missing file found in MCPath", mcPath.find(missingHWFile.getName()).isPresent()); + assertTrue(mcPath.find(existingHWFile.getName()).isPresent(), "Existing file not found in MCPath"); + assertFalse(mcPath.find(missingHWFile.getName()).isPresent(), "Missing file found in MCPath"); // Create the IncGenGradleCheck file and fill its content File modelRepDir = new File(repDir, modelName.replaceAll("\\.", "/").toLowerCase()); @@ -85,42 +71,49 @@ public void testIncCheck() throws IOException { modelRepDir.mkdirs(); incGenGradleCheckFile.createNewFile(); Files.writeToFile(CharSource.wrap( - calcChacheEntry(inputFile) + "\n" + + calcChacheEntry(inputFile, fileEnding) + "\n" + calcHwcEntry(existingHWFile) + "\n" + calcGenEntry(missingHWFile) + "\n" ).asByteSource(StandardCharsets.UTF_8).openStream(), incGenGradleCheckFile); // Has the IncGenGradleCheck file been created? - Assert.assertTrue("IncGenGradleCheck.txt does not exists: " + incGenGradleCheckFile.getAbsolutePath(), incGenGradleCheckFile.exists()); + assertTrue(incGenGradleCheckFile.exists(), + "IncGenGradleCheck.txt does not exists: " + incGenGradleCheckFile.getAbsolutePath()); // Next, actually test the IncCheck // First without any changes - Assert.assertTrue("IncCheck without changes failed", IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, "")); + assertTrue(IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, ""), + "IncCheck without changes failed"); // Check when a HW file has been added missingHWFile.createNewFile(); - Assert.assertFalse("IncCheck with added HW file did not fire", IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, "")); + assertFalse(IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, ""), + "IncCheck with added HW file did not fire"); missingHWFile.delete(); // Test with no changes again (after deleting the added HW file) - Assert.assertTrue("IncCheck without changes (after deleting) failed", IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, "")); + assertTrue(IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, ""), + "IncCheck without changes (after deleting) failed"); // Delete the existing HW file and test existingHWFile.delete(); - Assert.assertFalse("IncCheck with deleted HW file did not fire", IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, "")); + assertFalse(IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, ""), + "IncCheck with deleted HW file did not fire"); existingHWFile.createNewFile(); // Test with no changes again (after re-adding the deleted HW file) - Assert.assertTrue("IncCheck without changes (after re-adding) failed", IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, "")); + assertTrue(IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, ""), + "IncCheck without changes (after re-adding) failed"); // Change input model/content Files.writeToFile(CharSource.wrap("new file content").asByteSource(StandardCharsets.UTF_8).openStream(), inputFile); - Assert.assertFalse("IncCheck with changed input model did not fire", IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, "")); + assertFalse(IncChecker.incCheck(incGenGradleCheckFile, modelName, logger, fileEnding, ""), + "IncCheck with changed input model did not fire"); assertTrue(Log.getFindings().isEmpty()); } - private String calcChacheEntry(File file) throws IOException { + private String calcChacheEntry(File file, String fileEnding) throws IOException { StringBuilder cacheEntry = new StringBuilder(); cacheEntry.append(fileEnding + ":"); cacheEntry.append(file.getAbsolutePath()); diff --git a/monticore-generator/gradle-plugin/src/test/java/de/monticore/gradle/MCGenPluginTest.java b/monticore-generator/gradle-plugin/src/test/java/de/monticore/gradle/MCGenPluginTest.java index 8ffb705b7c..4fec85cf01 100644 --- a/monticore-generator/gradle-plugin/src/test/java/de/monticore/gradle/MCGenPluginTest.java +++ b/monticore-generator/gradle-plugin/src/test/java/de/monticore/gradle/MCGenPluginTest.java @@ -3,24 +3,26 @@ import de.monticore.symboltable.serialization.JsonParser; import de.monticore.symboltable.serialization.json.JsonObject; +import org.apache.commons.io.FileUtils; import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.GradleRunner; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; +import org.gradle.tooling.internal.consumer.ConnectorServices; +import org.gradle.tooling.internal.consumer.DefaultGradleConnector; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; -import org.junit.rules.TemporaryFolder; import javax.annotation.Nullable; import javax.annotation.concurrent.NotThreadSafe; import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; import java.util.*; import static org.gradle.testkit.runner.TaskOutcome.*; +import static org.junit.jupiter.api.Assertions.*; /** * Test if the plugin correctly configures a gradle project @@ -33,22 +35,54 @@ @Execution(ExecutionMode.SAME_THREAD) // Do not run in parallel, too memory hungry @NotThreadSafe // Technically thread safe, just memory hungry public class MCGenPluginTest { - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); + // TODO: Use @TempDir instead of manual creation and deletion of the temporary folder + // see: https://github.com/gradle/gradle/issues/12535 + // @TempDir + public Path temporaryFolder; File testProjectDir; File settingsFile; File propertiesFile; File buildFile; File grammarDir; + + // TODO: Remove when using TempDir + private static List workingDirs = new ArrayList<>(); - @Before + @BeforeEach public void setup() throws IOException { - testProjectDir = temporaryFolder.newFolder(); + testProjectDir = createDirectory(temporaryFolder.resolve("projectDir")); settingsFile = new File(testProjectDir, "settings.gradle"); buildFile = new File(testProjectDir, "build.gradle"); propertiesFile = new File(testProjectDir, "gradle.properties"); grammarDir = new File(testProjectDir, "src/main/grammars"); } + + // TODO: Remove when using TempDir + @BeforeEach + void createWorkspace() throws IOException{ + this.temporaryFolder = Files.createTempDirectory(getClass().getSimpleName()); + workingDirs.add(this.temporaryFolder); + } + + // TODO: Remove when using TempDir + @AfterEach + void resetGradleConnector() { + ConnectorServices.reset(); + } + + // TODO: Remove when using TempDir + @AfterAll + static void deleteWorkspace() throws IOException, InterruptedException { + DefaultGradleConnector.close(); + Thread.sleep(100); + for (Path workingDir : workingDirs) { + FileUtils.forceDelete(workingDir.toFile()); + } + } + + File createDirectory(Path path) throws IOException{ + return Files.createDirectory(path).toFile(); + } @Test public void testCanApplyPlugin_v7_4_2() throws IOException { @@ -87,8 +121,8 @@ void testCanApplyPlugin(String version) throws IOException { .build(); // A generateMCGrammars task was added - Assert.assertTrue(result.getOutput().contains("generateMCGrammars")); - Assert.assertEquals(SUCCESS, result.task(":tasks").getOutcome()); + assertTrue(result.getOutput().contains("generateMCGrammars")); + assertEquals(SUCCESS, result.task(":tasks").getOutcome()); } @@ -133,7 +167,7 @@ void testGenerateGrammar(String version) throws IOException { "grammar MyTestGrammarS extends MyTestGrammar { Monti = \"Core\"; }"); // use a custom gradle home directory to ensure fresh caches - File gradleHome = temporaryFolder.newFolder("gradleHome"); + File gradleHome = createDirectory(temporaryFolder.resolve("gradleHome")); BuildResult result = GradleRunner.create() .withPluginClasspath() @@ -143,19 +177,19 @@ void testGenerateGrammar(String version) throws IOException { .build(); // file MyTestGrammar is worked on -// Assert.assertTrue(result.getOutput(), result.getOutput().contains("[MyTestGrammar.mc4]")); // The Log-Prefix is unreliable - Assert.assertTrue(result.getOutput(), result.getOutput().contains("/src/main/grammars/MyTestGrammar.mc4")); +// assertTrue(result.getOutput(), result.getOutput().contains("[MyTestGrammar.mc4]")); // The Log-Prefix is unreliable + assertTrue(result.getOutput().contains("/src/main/grammars/MyTestGrammar.mc4"), result.getOutput()); // file MyTestGrammarS is worked on -// Assert.assertTrue(result.getOutput(), result.getOutput().contains("[MyTestGrammarS.mc4]")); // The Log-Prefix is unreliable - Assert.assertTrue(result.getOutput(), result.getOutput().contains("/src/main/grammars/MyTestGrammarS.mc4")); +// assertTrue(result.getOutput(), result.getOutput().contains("[MyTestGrammarS.mc4]")); // The Log-Prefix is unreliable + assertTrue(result.getOutput().contains("/src/main/grammars/MyTestGrammarS.mc4"), result.getOutput()); // and the task was successful - Assert.assertEquals(SUCCESS, result.task(":generateMCGrammars").getOutcome()); + assertEquals(SUCCESS, result.task(":generateMCGrammars").getOutcome()); JsonObject taskStats = checkAndGetStats(result.getOutput(), ":generateMCGrammars"); - Assert.assertFalse(taskStats.getBooleanMember("UpToDate")); - Assert.assertFalse(taskStats.getBooleanMember("Cached")); - Assert.assertFalse(taskStats.getBooleanMember("hasError")); - Assert.assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); + assertFalse(taskStats.getBooleanMember("UpToDate")); + assertFalse(taskStats.getBooleanMember("Cached")); + assertFalse(taskStats.getBooleanMember("hasError")); + assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); // Test build-cache, by first deleting the build dir de.se_rwth.commons.Files.deleteFiles(new File(testProjectDir, "build")); @@ -167,14 +201,14 @@ void testGenerateGrammar(String version) throws IOException { .withArguments(withProperties("generateMCGrammars", "--build-cache", "--info", "-g", gradleHome.getAbsolutePath())) .build(); // and then check, that the build cache was used - Assert.assertEquals("generateMCGrammars was not cached", - FROM_CACHE, result.task(":generateMCGrammars").getOutcome()); + assertEquals(FROM_CACHE, result.task(":generateMCGrammars").getOutcome(), + "generateMCGrammars was not cached"); taskStats = checkAndGetStats(result.getOutput(), ":generateMCGrammars"); - Assert.assertTrue(taskStats.getBooleanMember("UpToDate")); - Assert.assertTrue(taskStats.getBooleanMember("Cached")); - Assert.assertFalse(taskStats.getBooleanMember("hasError")); - Assert.assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); + assertTrue(taskStats.getBooleanMember("UpToDate")); + assertTrue(taskStats.getBooleanMember("Cached")); + assertFalse(taskStats.getBooleanMember("hasError")); + assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); // Next, test up-to-date checks: @@ -189,16 +223,18 @@ void testGenerateGrammar(String version) throws IOException { .withArguments(withProperties("generateMCGrammars", "--build-cache", "--info", "-g", gradleHome.getAbsolutePath())) .build(); // and the task was successful - Assert.assertEquals(SUCCESS, result.task(":generateMCGrammars").getOutcome()); + assertEquals(SUCCESS, result.task(":generateMCGrammars").getOutcome()); // Only MyTestGrammarS SHOULD not be up-to-date - Assert.assertTrue(result.getOutput(), result.getOutput().contains("MyTestGrammar.mc4 is UP-TO-DATE, no action required")); - Assert.assertFalse(result.getOutput(), result.getOutput().contains("MyTestGrammarS.mc4 is UP-TO-DATE, no action required")); + assertTrue(result.getOutput().contains("MyTestGrammar.mc4 is UP-TO-DATE, no action required"), + result.getOutput()); + assertFalse(result.getOutput().contains("MyTestGrammarS.mc4 is UP-TO-DATE, no action required"), + result.getOutput()); taskStats = checkAndGetStats(result.getOutput(), ":generateMCGrammars"); - Assert.assertFalse(taskStats.getBooleanMember("UpToDate")); // Note: The task is not up-to-date, as one of its inputs has changed - Assert.assertFalse(taskStats.getBooleanMember("Cached")); - Assert.assertFalse(taskStats.getBooleanMember("hasError")); - Assert.assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); + assertFalse(taskStats.getBooleanMember("UpToDate")); // Note: The task is not up-to-date, as one of its inputs has changed + assertFalse(taskStats.getBooleanMember("Cached")); + assertFalse(taskStats.getBooleanMember("hasError")); + assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); // and change MyTestGrammar @@ -212,14 +248,14 @@ void testGenerateGrammar(String version) throws IOException { .withArguments(withProperties("generateMCGrammars", "--build-cache", "--info", "-g", gradleHome.getAbsolutePath())) .build(); // Nothing SHOULD not be up-to-date - Assert.assertFalse(result.getOutput(), result.getOutput().contains("MyTestGrammar.mc4 is UP-TO-DATE, no action required")); - Assert.assertFalse(result.getOutput(), result.getOutput().contains("MyTestGrammarS.mc4 is UP-TO-DATE, no action required")); + assertFalse(result.getOutput().contains("MyTestGrammar.mc4 is UP-TO-DATE, no action required"), result.getOutput()); + assertFalse(result.getOutput().contains("MyTestGrammarS.mc4 is UP-TO-DATE, no action required"), result.getOutput()); taskStats = checkAndGetStats(result.getOutput(), ":generateMCGrammars"); - Assert.assertFalse(taskStats.getBooleanMember("UpToDate")); - Assert.assertFalse(taskStats.getBooleanMember("Cached")); - Assert.assertFalse(taskStats.getBooleanMember("hasError")); - Assert.assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); + assertFalse(taskStats.getBooleanMember("UpToDate")); + assertFalse(taskStats.getBooleanMember("Cached")); + assertFalse(taskStats.getBooleanMember("hasError")); + assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); } @@ -287,7 +323,7 @@ void testMultiProject(String version) throws IOException { "grammar MyTestGrammarS extends MyTestGrammar { Monti = \"Core\"; }"); // use a custom gradle home directory to ensure fresh cashes - File gradleHome = temporaryFolder.newFolder("gradleHome"); + File gradleHome = createDirectory(temporaryFolder.resolve("gradleHome")); BuildResult result = GradleRunner.create() .withPluginClasspath() @@ -297,20 +333,20 @@ void testMultiProject(String version) throws IOException { .build(); // file MyTestGrammar is worked on - // Assert.assertTrue(result.getOutput(), result.getOutput().contains("[MyTestGrammar.mc4]")); // The Log-Prefix is unreliable - Assert.assertTrue(result.getOutput(), result.getOutput().contains("/src/main/grammars/MyTestGrammar.mc4")); + // assertTrue(result.getOutput(), result.getOutput().contains("[MyTestGrammar.mc4]")); // The Log-Prefix is unreliable + assertTrue(result.getOutput().contains("/src/main/grammars/MyTestGrammar.mc4"), result.getOutput()); // file MyTestGrammarS is worked on - // Assert.assertTrue(result.getOutput(), result.getOutput().contains("[MyTestGrammarS.mc4]")); // The Log-Prefix is unreliable - Assert.assertTrue(result.getOutput(), result.getOutput().contains("/src/main/grammars/MyTestGrammarS.mc4")); + // assertTrue(result.getOutput(), result.getOutput().contains("[MyTestGrammarS.mc4]")); // The Log-Prefix is unreliable + assertTrue(result.getOutput().contains("/src/main/grammars/MyTestGrammarS.mc4"), result.getOutput()); // and the task was successful - Assert.assertEquals(SUCCESS, result.task(":A:generateMCGrammars").getOutcome()); - Assert.assertEquals(SUCCESS, result.task(":B:generateMCGrammars").getOutcome()); + assertEquals(SUCCESS, result.task(":A:generateMCGrammars").getOutcome()); + assertEquals(SUCCESS, result.task(":B:generateMCGrammars").getOutcome()); JsonObject taskStats = checkAndGetStats(result.getOutput(), ":A:generateMCGrammars"); - Assert.assertFalse(taskStats.getBooleanMember("UpToDate")); - Assert.assertFalse(taskStats.getBooleanMember("Cached")); - Assert.assertFalse(taskStats.getBooleanMember("hasError")); - Assert.assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); + assertFalse(taskStats.getBooleanMember("UpToDate")); + assertFalse(taskStats.getBooleanMember("Cached")); + assertFalse(taskStats.getBooleanMember("hasError")); + assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); // Test build-cache, by first deleting the build dir de.se_rwth.commons.Files.deleteFiles(new File(testProjectDir, "build")); @@ -326,17 +362,17 @@ void testMultiProject(String version) throws IOException { .build(); // and then check, that the build cache was used - Assert.assertEquals("A:generateMCGrammars was not cached", - FROM_CACHE, result.task(":A:generateMCGrammars").getOutcome()); - Assert.assertEquals("B:generateMCGrammars was not cached", - FROM_CACHE, result.task(":B:generateMCGrammars").getOutcome()); + assertEquals(FROM_CACHE, result.task(":A:generateMCGrammars").getOutcome(), + "A:generateMCGrammars was not cached"); + assertEquals(FROM_CACHE, result.task(":B:generateMCGrammars").getOutcome(), + "B:generateMCGrammars was not cached"); taskStats = checkAndGetStats(result.getOutput(), ":B:generateMCGrammars"); - Assert.assertTrue(taskStats.getBooleanMember("UpToDate")); - Assert.assertTrue(taskStats.getBooleanMember("Cached")); - Assert.assertFalse(taskStats.getBooleanMember("hasError")); - Assert.assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); + assertTrue(taskStats.getBooleanMember("UpToDate")); + assertTrue(taskStats.getBooleanMember("Cached")); + assertFalse(taskStats.getBooleanMember("hasError")); + assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); // Next, test up-to-date checks: @@ -351,21 +387,21 @@ void testMultiProject(String version) throws IOException { .withArguments(withProperties("generateMCGrammars", "--build-cache", "--info", "-g", gradleHome.getAbsolutePath())) .build(); // and the B-task was successful - Assert.assertEquals(SUCCESS, result.task(":B:generateMCGrammars").getOutcome()); + assertEquals(SUCCESS, result.task(":B:generateMCGrammars").getOutcome()); // the A-task should be up to date (i.e., not even pulled from the cache) - Assert.assertEquals(UP_TO_DATE, result.task(":A:generateMCGrammars").getOutcome()); + assertEquals(UP_TO_DATE, result.task(":A:generateMCGrammars").getOutcome()); // and thus, MyTestGrammar should not be printed to the log - Assert.assertFalse(result.getOutput(), result.getOutput().contains("MyTestGrammar.mc4 is UP-TO-DATE, no action required")); - Assert.assertFalse(result.getOutput(), result.getOutput().contains("MyTestGrammar.mc4 is *NOT* UP-TO-DATE")); + assertFalse(result.getOutput().contains("MyTestGrammar.mc4 is UP-TO-DATE, no action required"), result.getOutput()); + assertFalse(result.getOutput().contains("MyTestGrammar.mc4 is *NOT* UP-TO-DATE"), result.getOutput()); // Only MyTestGrammarS SHOULD not be up-to-date - Assert.assertFalse(result.getOutput(), result.getOutput().contains("MyTestGrammarS.mc4 is UP-TO-DATE, no action required")); - Assert.assertTrue(result.getOutput(), result.getOutput().contains("MyTestGrammarS.mc4 is *NOT* UP-TO-DATE")); + assertFalse(result.getOutput().contains("MyTestGrammarS.mc4 is UP-TO-DATE, no action required"), result.getOutput()); + assertTrue(result.getOutput().contains("MyTestGrammarS.mc4 is *NOT* UP-TO-DATE"), result.getOutput()); taskStats = checkAndGetStats(result.getOutput(), ":B:generateMCGrammars"); - Assert.assertFalse(taskStats.getBooleanMember("UpToDate")); // Note: The task is not up-to-date, as one of its inputs has changed - Assert.assertFalse(taskStats.getBooleanMember("Cached")); - Assert.assertFalse(taskStats.getBooleanMember("hasError")); - Assert.assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); + assertFalse(taskStats.getBooleanMember("UpToDate")); // Note: The task is not up-to-date, as one of its inputs has changed + assertFalse(taskStats.getBooleanMember("Cached")); + assertFalse(taskStats.getBooleanMember("hasError")); + assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); // and change MyTestGrammar @@ -379,20 +415,20 @@ void testMultiProject(String version) throws IOException { .withArguments(withProperties("generateMCGrammars", "--build-cache", "--info", "-g", gradleHome.getAbsolutePath())) .build(); // Nothing SHOULD not be up-to-date - Assert.assertFalse(result.getOutput(), result.getOutput().contains("MyTestGrammar.mc4 is UP-TO-DATE, no action required")); - Assert.assertFalse(result.getOutput(), result.getOutput().contains("MyTestGrammarS.mc4 is UP-TO-DATE, no action required")); + assertFalse(result.getOutput().contains("MyTestGrammar.mc4 is UP-TO-DATE, no action required"), result.getOutput()); + assertFalse(result.getOutput().contains("MyTestGrammarS.mc4 is UP-TO-DATE, no action required"), result.getOutput()); taskStats = checkAndGetStats(result.getOutput(), ":A:generateMCGrammars"); - Assert.assertFalse(taskStats.getBooleanMember("UpToDate")); - Assert.assertFalse(taskStats.getBooleanMember("Cached")); - Assert.assertFalse(taskStats.getBooleanMember("hasError")); - Assert.assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); + assertFalse(taskStats.getBooleanMember("UpToDate")); + assertFalse(taskStats.getBooleanMember("Cached")); + assertFalse(taskStats.getBooleanMember("hasError")); + assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); taskStats = checkAndGetStats(result.getOutput(), ":B:generateMCGrammars"); - Assert.assertFalse(taskStats.getBooleanMember("UpToDate")); - Assert.assertFalse(taskStats.getBooleanMember("Cached")); - Assert.assertFalse(taskStats.getBooleanMember("hasError")); - Assert.assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); + assertFalse(taskStats.getBooleanMember("UpToDate")); + assertFalse(taskStats.getBooleanMember("Cached")); + assertFalse(taskStats.getBooleanMember("hasError")); + assertEquals("de.monticore.gradle.gen.MCGenTask_Decorated", taskStats.getStringMember("Type")); } @@ -414,7 +450,7 @@ JsonObject checkAndGetStats(String output, String taskPath) { } } System.err.println(output); - Assert.fail("Task " + taskPath + " was not found within the stats"); + fail("Task " + taskPath + " was not found within the stats"); return null; } diff --git a/monticore-generator/gradle.properties b/monticore-generator/gradle.properties index 461ea58bb1..a4171758b0 100644 --- a/monticore-generator/gradle.properties +++ b/monticore-generator/gradle.properties @@ -14,7 +14,8 @@ previous_mc_version =7.8.0 se_commons_version =7.8.0 antlr_version =4.12.0 -junit_version =5.10.3 +junit_version = 5.14.1 +junit_platform_version = 1.14.1 cd4a_version =7.8.0 commons_lang3_version = 3.8.1 commons_cli_version = 1.4 diff --git a/monticore-generator/src/test/java/de/monticore/MCGrammarLanguageFamilySymbolTableTest.java b/monticore-generator/src/test/java/de/monticore/MCGrammarLanguageFamilySymbolTableTest.java index 99bb72ae25..6dd3c81667 100644 --- a/monticore-generator/src/test/java/de/monticore/MCGrammarLanguageFamilySymbolTableTest.java +++ b/monticore-generator/src/test/java/de/monticore/MCGrammarLanguageFamilySymbolTableTest.java @@ -8,15 +8,14 @@ import de.monticore.io.paths.MCPath; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCGrammarLanguageFamilySymbolTableTest { @@ -37,17 +36,17 @@ public void testSymbolTableOfGrammarStatechartDSL() { final Optional oldGrammar = globalScope.resolveMCGrammar("de.monticore.statechart.Statechart"); - Assertions.assertTrue(oldGrammar.isPresent()); + assertTrue(oldGrammar.isPresent()); final Optional newGrammar = globalScope.resolveMCGrammar("de.monticore.statechart.Statechart"); - Assertions.assertTrue(newGrammar.isPresent()); + assertTrue(newGrammar.isPresent()); // 2 = Statechart grammar symbol and TestLexicals grammar symbol (super grammar of Statechart) - Assertions.assertEquals(1, globalScope.getSubScopes().size()); + assertEquals(1, globalScope.getSubScopes().size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-generator/src/test/java/de/monticore/MontiCoreScriptTest.java b/monticore-generator/src/test/java/de/monticore/MontiCoreScriptTest.java index dd85b4cd0a..1991ef3002 100644 --- a/monticore-generator/src/test/java/de/monticore/MontiCoreScriptTest.java +++ b/monticore-generator/src/test/java/de/monticore/MontiCoreScriptTest.java @@ -27,7 +27,6 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import org.apache.commons.cli.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -41,6 +40,7 @@ import static de.monticore.MontiCoreConfiguration.*; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; +import static org.junit.jupiter.api.Assertions.*; /** * Test for the {@link MontiCoreScript} class. @@ -96,7 +96,7 @@ public void init() { Optional ast = new MontiCoreScript() .parseGrammar(Paths.get(new File( "src/test/resources/de/monticore/statechart/Statechart.mc4").getAbsolutePath())); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); grammar = ast.get(); } @@ -105,18 +105,18 @@ public void init() { */ @Test public void testParseGrammar() { - Assertions.assertNotNull(grammar); - Assertions.assertEquals("Statechart", grammar.getName()); + assertNotNull(grammar); + assertEquals("Statechart", grammar.getName()); MCAssertions.assertNoFindings(); } /** - * {@link MontiCoreScript#generateParser(GlobalExtensionManagement, ASTCDCompilationUnit, ASTMCGrammar, Grammar_WithConceptsGlobalScope, MCPath, MCPath, File)} + * {@link MontiCoreScript#generateParser(GlobalExtensionManagement, ASTCDCompilationUnit, ASTMCGrammar, IGrammar_WithConceptsGlobalScope, MCPath, MCPath, File)} */ @Test public void testGenerateParser() { - Assertions.assertNotNull(grammar); + assertNotNull(grammar); MontiCoreScript mc = new MontiCoreScript(); IGrammar_WithConceptsGlobalScope symbolTable = TestHelper.createGlobalScope(modelPath); mc.createSymbolsFromAST(symbolTable, grammar); @@ -137,9 +137,9 @@ public void testGetOrCreateCD() { mc.createSymbolsFromAST(symbolTable, grammar); ICD4AnalysisGlobalScope cd4AGlobalScope = mc.createCD4AGlobalScope(modelPath); cdCompilationUnit = mc.getOrCreateCD(grammar, new GlobalExtensionManagement(), cd4AGlobalScope); - Assertions.assertNotNull(cdCompilationUnit); - Assertions.assertNotNull(cdCompilationUnit.getCDDefinition()); - Assertions.assertEquals("Statechart", cdCompilationUnit.getCDDefinition().getName()); + assertNotNull(cdCompilationUnit); + assertNotNull(cdCompilationUnit.getCDDefinition()); + assertEquals("Statechart", cdCompilationUnit.getCDDefinition().getName()); MCAssertions.assertNoFindings(); } @@ -151,9 +151,9 @@ public void testDeriveASTCD() { mc.createSymbolsFromAST(symbolTable, grammar); ICD4AnalysisGlobalScope cd4AGlobalScope = mc.createCD4AGlobalScope(modelPath); cdCompilationUnit = mc.deriveASTCD(grammar, new GlobalExtensionManagement(), cd4AGlobalScope); - Assertions.assertNotNull(cdCompilationUnit); - Assertions.assertNotNull(cdCompilationUnit.getCDDefinition()); - Assertions.assertEquals("Statechart", cdCompilationUnit.getCDDefinition().getName()); + assertNotNull(cdCompilationUnit); + assertNotNull(cdCompilationUnit.getCDDefinition()); + assertEquals("Statechart", cdCompilationUnit.getCDDefinition().getName()); MCAssertions.assertNoFindings(); } @@ -165,16 +165,16 @@ public void testDecorateCd() { mc.createSymbolsFromAST(symbolTable, grammar); ICD4AnalysisGlobalScope cd4AGlobalScope = mc.createCD4AGlobalScope(modelPath); cdCompilationUnit = mc.deriveASTCD(grammar, new GlobalExtensionManagement(), cd4AGlobalScope); - Assertions.assertNotNull(cdCompilationUnit); - Assertions.assertEquals("de.monticore.statechart", String.join(".", cdCompilationUnit.getCDPackageList())); - Assertions.assertNotNull(cdCompilationUnit.getCDDefinition()); + assertNotNull(cdCompilationUnit); + assertEquals("de.monticore.statechart", String.join(".", cdCompilationUnit.getCDPackageList())); + assertNotNull(cdCompilationUnit.getCDDefinition()); ASTCDDefinition cdDefinition = cdCompilationUnit.getCDDefinition(); - Assertions.assertEquals(8, cdDefinition.getCDClassesList().size()); - Assertions.assertEquals(5, cdDefinition.getCDInterfacesList().size()); + assertEquals(8, cdDefinition.getCDClassesList().size()); + assertEquals(5, cdDefinition.getCDInterfacesList().size()); ASTCDCompilationUnit astcdCompilationUnit = mc.decorateForASTPackage(glex, cd4AGlobalScope, cdCompilationUnit, hwPath); // Added Builder classes to the each not list class - Assertions.assertEquals(17, astcdCompilationUnit.getCDDefinition().getCDClassesList().size()); + assertEquals(17, astcdCompilationUnit.getCDDefinition().getCDClassesList().size()); // Check if there are all additional methods defined in the given CD class List methods = Lists.newArrayList(); @@ -186,10 +186,10 @@ public void testDecorateCd() { String withOrder = "WithOrder"; for (String additionalMethod : additionalMethods) { if (additionalMethod.endsWith(withOrder)) { - Assertions.assertTrue(methods.contains(additionalMethod.substring(0, + assertTrue(methods.contains(additionalMethod.substring(0, additionalMethod.indexOf(withOrder)))); } else { - Assertions.assertTrue(methods.contains(additionalMethod)); + assertTrue(methods.contains(additionalMethod)); } } } @@ -201,13 +201,13 @@ public void testDecorateCd() { public void testDefaultScriptSimpleArgs() { Log.getFindings().clear(); testDefaultScript(simpleArgs); - Assertions.assertEquals(0, Log.getErrorCount()); + assertEquals(0, Log.getErrorCount()); // test whether the original template is used try { List lines = Files.readAllLines(Paths.get(outputPath.getAbsolutePath() + "/de/monticore/statechart/statechart/_ast/ASTState.java")); - Assertions.assertFalse(lines.stream().filter(l -> "// Test:Replace Template".equals(l)).findAny().isPresent()); + assertFalse(lines.stream().filter(l -> "// Test:Replace Template".equals(l)).findAny().isPresent()); } catch (Exception e) { - Assertions.fail(); + fail(); } MCAssertions.assertNoFindings(); @@ -224,13 +224,13 @@ public void testDefaultScriptSimpleArgs() { public void testDefaultScriptTemplateArgs() { Log.getFindings().clear(); testDefaultScript(templateArgs); - Assertions.assertEquals(0, Log.getErrorCount()); + assertEquals(0, Log.getErrorCount()); // test whether the changed template is used try { List lines = Files.readAllLines(Paths.get(outputPath.getAbsolutePath() + "/de/monticore/statechart/statechart/_ast/ASTState.java")); - Assertions.assertTrue(lines.stream().filter(l -> "// Test:Replace Template".equals(l)).findAny().isPresent()); + assertTrue(lines.stream().filter(l -> "// Test:Replace Template".equals(l)).findAny().isPresent()); } catch (Exception e) { - Assertions.fail(); + fail(); } MCAssertions.assertNoFindings(); @@ -266,14 +266,14 @@ public void testDefaultScriptSubsubgrammarArgs_EMF() { public void testDefaultScriptSupergrammarArgs() { Log.getFindings().clear(); testDefaultScript(inheritedgrammarArgs); - Assertions.assertEquals(0, Log.getErrorCount()); + assertEquals(0, Log.getErrorCount()); } @Test public void testDefaultScriptSupergrammarArgs_EMF() { Log.getFindings().clear(); testDefaultScriptWithEmf(inheritedgrammarArgs); - Assertions.assertEquals(0, Log.getErrorCount()); + assertEquals(0, Log.getErrorCount()); } static String[] supersubgrammarArgs = {"-" + GRAMMAR, @@ -328,7 +328,7 @@ private void testDefaultScriptWithEmf(String[] args) { // Reporting is enabled in the monticore_standard.groovy script but needs to be disabled for other tests // because Reporting is static directly disable it again here Reporting.off(); - Assertions.assertTrue(!false); + assertTrue(!false); } @Test @@ -339,19 +339,19 @@ public void testDeriveSymbolCD() { ICD4AnalysisGlobalScope cd4AGlobalScope = mc.createCD4AGlobalScope(modelPath); ASTCDCompilationUnit cdCompilationUnit = mc.deriveSymbolCD(grammar, cd4AGlobalScope); // check directly created scope - Assertions.assertNotNull(cdCompilationUnit); - Assertions.assertNotNull(cdCompilationUnit.getCDDefinition()); - Assertions.assertEquals("StatechartSymbols", cdCompilationUnit.getCDDefinition().getName()); + assertNotNull(cdCompilationUnit); + assertNotNull(cdCompilationUnit.getCDDefinition()); + assertEquals("StatechartSymbols", cdCompilationUnit.getCDDefinition().getName()); // no symbol defined - Assertions.assertEquals(0, cdCompilationUnit.getCDDefinition().getCDClassesList().size()); + assertEquals(0, cdCompilationUnit.getCDDefinition().getCDClassesList().size()); // check saved cd for grammar ASTCDCompilationUnit symbolCDOfParsedGrammar = mc.getSymbolCDOfParsedGrammar(grammar); - Assertions.assertNotNull(symbolCDOfParsedGrammar); - Assertions.assertNotNull(symbolCDOfParsedGrammar.getCDDefinition()); - Assertions.assertEquals("StatechartSymbols", symbolCDOfParsedGrammar.getCDDefinition().getName()); + assertNotNull(symbolCDOfParsedGrammar); + assertNotNull(symbolCDOfParsedGrammar.getCDDefinition()); + assertEquals("StatechartSymbols", symbolCDOfParsedGrammar.getCDDefinition().getName()); // no symbol defined - Assertions.assertEquals(0, symbolCDOfParsedGrammar.getCDDefinition().getCDClassesList().size()); + assertEquals(0, symbolCDOfParsedGrammar.getCDDefinition().getCDClassesList().size()); MCAssertions.assertNoFindings(); } @@ -364,19 +364,19 @@ public void testDeriveScopeCD() { ICD4AnalysisGlobalScope cd4AGlobalScope = mc.createCD4AGlobalScope(modelPath); ASTCDCompilationUnit cdCompilationUnit = mc.deriveScopeCD(grammar, cd4AGlobalScope); // test normal created scope cd - Assertions.assertNotNull(cdCompilationUnit); - Assertions.assertNotNull(cdCompilationUnit.getCDDefinition()); - Assertions.assertEquals("StatechartScope", cdCompilationUnit.getCDDefinition().getName()); - Assertions.assertEquals(1, cdCompilationUnit.getCDDefinition().getCDClassesList().size()); - Assertions.assertEquals("Statechart", cdCompilationUnit.getCDDefinition().getCDClassesList().get(0).getName()); + assertNotNull(cdCompilationUnit); + assertNotNull(cdCompilationUnit.getCDDefinition()); + assertEquals("StatechartScope", cdCompilationUnit.getCDDefinition().getName()); + assertEquals(1, cdCompilationUnit.getCDDefinition().getCDClassesList().size()); + assertEquals("Statechart", cdCompilationUnit.getCDDefinition().getCDClassesList().get(0).getName()); // test correct saved scope cd ASTCDCompilationUnit scopeCDOfParsedGrammar = mc.getScopeCDOfParsedGrammar(grammar); - Assertions.assertNotNull(scopeCDOfParsedGrammar); - Assertions.assertNotNull(scopeCDOfParsedGrammar.getCDDefinition()); - Assertions.assertEquals("StatechartScope", scopeCDOfParsedGrammar.getCDDefinition().getName()); - Assertions.assertEquals(1, scopeCDOfParsedGrammar.getCDDefinition().getCDClassesList().size()); - Assertions.assertEquals("Statechart", scopeCDOfParsedGrammar.getCDDefinition().getCDClassesList().get(0).getName()); + assertNotNull(scopeCDOfParsedGrammar); + assertNotNull(scopeCDOfParsedGrammar.getCDDefinition()); + assertEquals("StatechartScope", scopeCDOfParsedGrammar.getCDDefinition().getName()); + assertEquals(1, scopeCDOfParsedGrammar.getCDDefinition().getCDClassesList().size()); + assertEquals("Statechart", scopeCDOfParsedGrammar.getCDDefinition().getCDClassesList().get(0).getName()); MCAssertions.assertNoFindings(); } @@ -389,24 +389,24 @@ public void testAddListSuffixToAttributeName() { ICD4AnalysisGlobalScope cd4AGlobalScope = mc.createCD4AGlobalScope(modelPath); ASTCDCompilationUnit cdCompilationUnit = mc.deriveASTCD(grammar, new GlobalExtensionManagement(), cd4AGlobalScope); - Assertions.assertNotNull(cdCompilationUnit); - Assertions.assertNotNull(cdCompilationUnit.getCDDefinition()); - Assertions.assertEquals("Statechart", cdCompilationUnit.getCDDefinition().getName()); + assertNotNull(cdCompilationUnit); + assertNotNull(cdCompilationUnit.getCDDefinition()); + assertEquals("Statechart", cdCompilationUnit.getCDDefinition().getName()); ASTCDClass stateChartClass = cdCompilationUnit.getCDDefinition().getCDClassesList().get(0); - Assertions.assertEquals("ASTStatechart", stateChartClass.getName()); - Assertions.assertEquals("state", stateChartClass.getCDAttributeList().get(1).getName()); + assertEquals("ASTStatechart", stateChartClass.getName()); + assertEquals("state", stateChartClass.getCDAttributeList().get(1).getName()); // add list suffix ASTCDCompilationUnit listSuffixCD = mc.addListSuffixToAttributeName(cdCompilationUnit); - Assertions.assertNotNull(listSuffixCD); - Assertions.assertNotNull(listSuffixCD.getCDDefinition()); - Assertions.assertEquals("Statechart", listSuffixCD.getCDDefinition().getName()); + assertNotNull(listSuffixCD); + assertNotNull(listSuffixCD.getCDDefinition()); + assertEquals("Statechart", listSuffixCD.getCDDefinition().getName()); ASTCDClass listSuffixStateChartClass = listSuffixCD.getCDDefinition().getCDClassesList().get(0); - Assertions.assertEquals("ASTStatechart", listSuffixStateChartClass.getName()); + assertEquals("ASTStatechart", listSuffixStateChartClass.getName()); assertDeepEquals("java.util.List", listSuffixStateChartClass.getCDAttributeList().get(1).getMCType()); // attribute with 's' at the end now - Assertions.assertEquals("states", listSuffixStateChartClass.getCDAttributeList().get(1).getName()); + assertEquals("states", listSuffixStateChartClass.getCDAttributeList().get(1).getName()); MCAssertions.assertNoFindings(); } @@ -428,26 +428,26 @@ public void testDecorateForSymbolTablePackage() { MCPath handcodedPath = new MCPath("src/test/resources"); mc.decorateForSymbolTablePackage(glex, cd4AGlobalScope, cd, symbolCD, scopeCD, symbolPackageCD, handcodedPath); - Assertions.assertNotNull(symbolPackageCD); - Assertions.assertNotNull(symbolPackageCD.getCDDefinition()); - Assertions.assertEquals("Statechart", symbolPackageCD.getCDDefinition().getName()); + assertNotNull(symbolPackageCD); + assertNotNull(symbolPackageCD.getCDDefinition()); + assertEquals("Statechart", symbolPackageCD.getCDDefinition().getName()); int index = 0; - Assertions.assertEquals(7, symbolPackageCD.getCDDefinition().getCDClassesList().size()); - Assertions.assertEquals("StatechartScope", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); - Assertions.assertEquals("StatechartSymbols2Json", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); - Assertions.assertEquals("StatechartScopesGenitorDelegator", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); - Assertions.assertEquals("StatechartArtifactScope", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); - Assertions.assertEquals("StatechartDeSer", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); - Assertions.assertEquals("StatechartGlobalScope", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); - Assertions.assertEquals("StatechartScopesGenitor", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); + assertEquals(7, symbolPackageCD.getCDDefinition().getCDClassesList().size()); + assertEquals("StatechartScope", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); + assertEquals("StatechartSymbols2Json", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); + assertEquals("StatechartScopesGenitorDelegator", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); + assertEquals("StatechartArtifactScope", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); + assertEquals("StatechartDeSer", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); + assertEquals("StatechartGlobalScope", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); + assertEquals("StatechartScopesGenitor", symbolPackageCD.getCDDefinition().getCDClassesList().get(index++).getName()); index = 0; - Assertions.assertEquals(4, symbolPackageCD.getCDDefinition().getCDInterfacesList().size()); - Assertions.assertEquals("IStatechartScope", symbolPackageCD.getCDDefinition().getCDInterfacesList().get(index++).getName()); - Assertions.assertEquals("ICommonStatechartSymbol", symbolPackageCD.getCDDefinition().getCDInterfacesList().get(index++).getName()); - Assertions.assertEquals("IStatechartGlobalScope", symbolPackageCD.getCDDefinition().getCDInterfacesList().get(index++).getName()); - Assertions.assertEquals("IStatechartArtifactScope", symbolPackageCD.getCDDefinition().getCDInterfacesList().get(index++).getName()); + assertEquals(4, symbolPackageCD.getCDDefinition().getCDInterfacesList().size()); + assertEquals("IStatechartScope", symbolPackageCD.getCDDefinition().getCDInterfacesList().get(index++).getName()); + assertEquals("ICommonStatechartSymbol", symbolPackageCD.getCDDefinition().getCDInterfacesList().get(index++).getName()); + assertEquals("IStatechartGlobalScope", symbolPackageCD.getCDDefinition().getCDInterfacesList().get(index++).getName()); + assertEquals("IStatechartArtifactScope", symbolPackageCD.getCDDefinition().getCDInterfacesList().get(index++).getName()); MCAssertions.assertNoFindings(); } @@ -466,16 +466,16 @@ public void testDecorateForVisitorPackage() { mc.configureGenerator(glex,visitorPackageCD, templatePath); mc.decorateTraverserForVisitorPackage(glex, cd4AGlobalScope, cd, visitorPackageCD, handcodedPath); - Assertions.assertNotNull(visitorPackageCD); - Assertions.assertNotNull(visitorPackageCD.getCDDefinition()); - Assertions.assertEquals("Statechart", visitorPackageCD.getCDDefinition().getName()); - Assertions.assertEquals(2, visitorPackageCD.getCDDefinition().getCDClassesList().size()); - Assertions.assertEquals("StatechartTraverserImplementation", visitorPackageCD.getCDDefinition().getCDClassesList().get(0).getName()); - Assertions.assertEquals("StatechartInheritanceHandler", visitorPackageCD.getCDDefinition().getCDClassesList().get(1).getName()); - Assertions.assertEquals(3, visitorPackageCD.getCDDefinition().getCDInterfacesList().size()); - Assertions.assertEquals("StatechartTraverser", visitorPackageCD.getCDDefinition().getCDInterfacesList().get(0).getName()); - Assertions.assertEquals("StatechartVisitor2", visitorPackageCD.getCDDefinition().getCDInterfacesList().get(1).getName()); - Assertions.assertEquals("StatechartHandler", visitorPackageCD.getCDDefinition().getCDInterfacesList().get(2).getName()); + assertNotNull(visitorPackageCD); + assertNotNull(visitorPackageCD.getCDDefinition()); + assertEquals("Statechart", visitorPackageCD.getCDDefinition().getName()); + assertEquals(2, visitorPackageCD.getCDDefinition().getCDClassesList().size()); + assertEquals("StatechartTraverserImplementation", visitorPackageCD.getCDDefinition().getCDClassesList().get(0).getName()); + assertEquals("StatechartInheritanceHandler", visitorPackageCD.getCDDefinition().getCDClassesList().get(1).getName()); + assertEquals(3, visitorPackageCD.getCDDefinition().getCDInterfacesList().size()); + assertEquals("StatechartTraverser", visitorPackageCD.getCDDefinition().getCDInterfacesList().get(0).getName()); + assertEquals("StatechartVisitor2", visitorPackageCD.getCDDefinition().getCDInterfacesList().get(1).getName()); + assertEquals("StatechartHandler", visitorPackageCD.getCDDefinition().getCDInterfacesList().get(2).getName()); MCAssertions.assertNoFindings(); } @@ -493,25 +493,25 @@ public void testDecorateForCoCoPackage() { ASTCDCompilationUnit cocoPackageCD = createEmptyCompilationUnit(cd); mc.decorateForCoCoPackage(glex, cd4AGlobalScope, cd, cocoPackageCD, handcodedPath); - Assertions.assertNotNull(cocoPackageCD); - Assertions.assertNotNull(cocoPackageCD.getCDDefinition()); - Assertions.assertEquals("Statechart", cocoPackageCD.getCDDefinition().getName()); - Assertions.assertEquals(1, cocoPackageCD.getCDDefinition().getCDClassesList().size()); - Assertions.assertEquals("StatechartCoCoChecker", cocoPackageCD.getCDDefinition().getCDClassesList().get(0).getName()); - Assertions.assertEquals(13, cocoPackageCD.getCDDefinition().getCDInterfacesList().size()); - Assertions.assertEquals("StatechartASTStatechartCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(0).getName()); - Assertions.assertEquals("StatechartASTEntryActionCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(1).getName()); - Assertions.assertEquals("StatechartASTExitActionCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(2).getName()); - Assertions.assertEquals("StatechartASTStateCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(3).getName()); - Assertions.assertEquals("StatechartASTTransitionCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(4).getName()); - Assertions.assertEquals("StatechartASTArgumentCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(5).getName()); - Assertions.assertEquals("StatechartASTCodeCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(6).getName()); - Assertions.assertEquals("StatechartASTAbstractAnythingCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(7).getName()); - Assertions.assertEquals("StatechartASTSCStructureCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(8).getName()); - Assertions.assertEquals("StatechartASTBlockStatementExtCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(9).getName()); - Assertions.assertEquals("StatechartASTExpressionExtCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(10).getName()); - Assertions.assertEquals("StatechartASTClassbodyExtCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(11).getName()); - Assertions.assertEquals("StatechartASTStatechartNodeCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(12).getName()); + assertNotNull(cocoPackageCD); + assertNotNull(cocoPackageCD.getCDDefinition()); + assertEquals("Statechart", cocoPackageCD.getCDDefinition().getName()); + assertEquals(1, cocoPackageCD.getCDDefinition().getCDClassesList().size()); + assertEquals("StatechartCoCoChecker", cocoPackageCD.getCDDefinition().getCDClassesList().get(0).getName()); + assertEquals(13, cocoPackageCD.getCDDefinition().getCDInterfacesList().size()); + assertEquals("StatechartASTStatechartCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(0).getName()); + assertEquals("StatechartASTEntryActionCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(1).getName()); + assertEquals("StatechartASTExitActionCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(2).getName()); + assertEquals("StatechartASTStateCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(3).getName()); + assertEquals("StatechartASTTransitionCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(4).getName()); + assertEquals("StatechartASTArgumentCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(5).getName()); + assertEquals("StatechartASTCodeCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(6).getName()); + assertEquals("StatechartASTAbstractAnythingCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(7).getName()); + assertEquals("StatechartASTSCStructureCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(8).getName()); + assertEquals("StatechartASTBlockStatementExtCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(9).getName()); + assertEquals("StatechartASTExpressionExtCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(10).getName()); + assertEquals("StatechartASTClassbodyExtCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(11).getName()); + assertEquals("StatechartASTStatechartNodeCoCo", cocoPackageCD.getCDDefinition().getCDInterfacesList().get(12).getName()); MCAssertions.assertNoFindings(); } @@ -529,36 +529,36 @@ public void testDecorateForASTPackage() { ASTCDCompilationUnit astPackageCD = mc.decorateForASTPackage(glex, cd4AGlobalScope, cd, handcodedPath); mc.configureGenerator(glex,astPackageCD, templatePath); - Assertions.assertNotNull(astPackageCD); - Assertions.assertNotNull(astPackageCD.getCDDefinition()); - Assertions.assertEquals("Statechart", astPackageCD.getCDDefinition().getName()); - Assertions.assertEquals(17, astPackageCD.getCDDefinition().getCDClassesList().size()); - Assertions.assertEquals("ASTStatechart", astPackageCD.getCDDefinition().getCDClassesList().get(0).getName()); - Assertions.assertEquals("ASTEntryAction", astPackageCD.getCDDefinition().getCDClassesList().get(1).getName()); - Assertions.assertEquals("ASTExitAction", astPackageCD.getCDDefinition().getCDClassesList().get(2).getName()); - Assertions.assertEquals("ASTState", astPackageCD.getCDDefinition().getCDClassesList().get(3).getName()); - Assertions.assertEquals("ASTTransition", astPackageCD.getCDDefinition().getCDClassesList().get(4).getName()); - Assertions.assertEquals("ASTArgument", astPackageCD.getCDDefinition().getCDClassesList().get(5).getName()); - Assertions.assertEquals("ASTCode", astPackageCD.getCDDefinition().getCDClassesList().get(6).getName()); - Assertions.assertEquals("ASTAbstractAnything", astPackageCD.getCDDefinition().getCDClassesList().get(7).getName()); - Assertions.assertEquals("ASTStatechartBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(8).getName()); - Assertions.assertEquals("ASTEntryActionBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(9).getName()); - Assertions.assertEquals("ASTExitActionBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(10).getName()); - Assertions.assertEquals("ASTStateBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(11).getName()); - Assertions.assertEquals("ASTTransitionBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(12).getName()); - Assertions.assertEquals("ASTArgumentBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(13).getName()); - Assertions.assertEquals("ASTCodeBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(14).getName()); - Assertions.assertEquals("ASTAbstractAnythingBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(15).getName()); - Assertions.assertEquals("ASTConstantsStatechart", astPackageCD.getCDDefinition().getCDClassesList().get(16).getName()); - - Assertions.assertEquals(5, astPackageCD.getCDDefinition().getCDInterfacesList().size()); - Assertions.assertEquals("ASTSCStructure", astPackageCD.getCDDefinition().getCDInterfacesList().get(0).getName()); - Assertions.assertEquals("ASTBlockStatementExt", astPackageCD.getCDDefinition().getCDInterfacesList().get(1).getName()); - Assertions.assertEquals("ASTExpressionExt", astPackageCD.getCDDefinition().getCDInterfacesList().get(2).getName()); - Assertions.assertEquals("ASTClassbodyExt", astPackageCD.getCDDefinition().getCDInterfacesList().get(3).getName()); - Assertions.assertEquals("ASTStatechartNode", astPackageCD.getCDDefinition().getCDInterfacesList().get(4).getName()); - Assertions.assertEquals(1, astPackageCD.getCDDefinition().getCDEnumsList().size()); - Assertions.assertEquals("StatechartLiterals", astPackageCD.getCDDefinition().getCDEnumsList().get(0).getName()); + assertNotNull(astPackageCD); + assertNotNull(astPackageCD.getCDDefinition()); + assertEquals("Statechart", astPackageCD.getCDDefinition().getName()); + assertEquals(17, astPackageCD.getCDDefinition().getCDClassesList().size()); + assertEquals("ASTStatechart", astPackageCD.getCDDefinition().getCDClassesList().get(0).getName()); + assertEquals("ASTEntryAction", astPackageCD.getCDDefinition().getCDClassesList().get(1).getName()); + assertEquals("ASTExitAction", astPackageCD.getCDDefinition().getCDClassesList().get(2).getName()); + assertEquals("ASTState", astPackageCD.getCDDefinition().getCDClassesList().get(3).getName()); + assertEquals("ASTTransition", astPackageCD.getCDDefinition().getCDClassesList().get(4).getName()); + assertEquals("ASTArgument", astPackageCD.getCDDefinition().getCDClassesList().get(5).getName()); + assertEquals("ASTCode", astPackageCD.getCDDefinition().getCDClassesList().get(6).getName()); + assertEquals("ASTAbstractAnything", astPackageCD.getCDDefinition().getCDClassesList().get(7).getName()); + assertEquals("ASTStatechartBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(8).getName()); + assertEquals("ASTEntryActionBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(9).getName()); + assertEquals("ASTExitActionBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(10).getName()); + assertEquals("ASTStateBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(11).getName()); + assertEquals("ASTTransitionBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(12).getName()); + assertEquals("ASTArgumentBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(13).getName()); + assertEquals("ASTCodeBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(14).getName()); + assertEquals("ASTAbstractAnythingBuilder", astPackageCD.getCDDefinition().getCDClassesList().get(15).getName()); + assertEquals("ASTConstantsStatechart", astPackageCD.getCDDefinition().getCDClassesList().get(16).getName()); + + assertEquals(5, astPackageCD.getCDDefinition().getCDInterfacesList().size()); + assertEquals("ASTSCStructure", astPackageCD.getCDDefinition().getCDInterfacesList().get(0).getName()); + assertEquals("ASTBlockStatementExt", astPackageCD.getCDDefinition().getCDInterfacesList().get(1).getName()); + assertEquals("ASTExpressionExt", astPackageCD.getCDDefinition().getCDInterfacesList().get(2).getName()); + assertEquals("ASTClassbodyExt", astPackageCD.getCDDefinition().getCDInterfacesList().get(3).getName()); + assertEquals("ASTStatechartNode", astPackageCD.getCDDefinition().getCDInterfacesList().get(4).getName()); + assertEquals(1, astPackageCD.getCDDefinition().getCDEnumsList().size()); + assertEquals("StatechartLiterals", astPackageCD.getCDDefinition().getCDEnumsList().get(0).getName()); MCAssertions.assertNoFindings(); } @@ -575,39 +575,39 @@ public void testDecorateForEmfASTPackage() { ASTCDCompilationUnit astEmfPackageCD = mc.decorateEmfForASTPackage(glex, cd4AGlobalScope, cd, handcodedPath); - Assertions.assertNotNull(astEmfPackageCD); - Assertions.assertNotNull(astEmfPackageCD.getCDDefinition()); - Assertions.assertEquals("Statechart", astEmfPackageCD.getCDDefinition().getName()); - Assertions.assertEquals(18, astEmfPackageCD.getCDDefinition().getCDClassesList().size()); - Assertions.assertEquals("ASTStatechart", astEmfPackageCD.getCDDefinition().getCDClassesList().get(0).getName()); - Assertions.assertEquals("ASTEntryAction", astEmfPackageCD.getCDDefinition().getCDClassesList().get(1).getName()); - Assertions.assertEquals("ASTExitAction", astEmfPackageCD.getCDDefinition().getCDClassesList().get(2).getName()); - Assertions.assertEquals("ASTState", astEmfPackageCD.getCDDefinition().getCDClassesList().get(3).getName()); - Assertions.assertEquals("ASTTransition", astEmfPackageCD.getCDDefinition().getCDClassesList().get(4).getName()); - Assertions.assertEquals("ASTArgument", astEmfPackageCD.getCDDefinition().getCDClassesList().get(5).getName()); - Assertions.assertEquals("ASTCode", astEmfPackageCD.getCDDefinition().getCDClassesList().get(6).getName()); - Assertions.assertEquals("ASTAbstractAnything", astEmfPackageCD.getCDDefinition().getCDClassesList().get(7).getName()); - Assertions.assertEquals("ASTStatechartBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(8).getName()); - Assertions.assertEquals("ASTEntryActionBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(9).getName()); - Assertions.assertEquals("ASTExitActionBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(10).getName()); - Assertions.assertEquals("ASTStateBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(11).getName()); - Assertions.assertEquals("ASTTransitionBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(12).getName()); - Assertions.assertEquals("ASTArgumentBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(13).getName()); - Assertions.assertEquals("ASTCodeBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(14).getName()); - Assertions.assertEquals("ASTAbstractAnythingBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(15).getName()); - Assertions.assertEquals("ASTConstantsStatechart", astEmfPackageCD.getCDDefinition().getCDClassesList().get(16).getName()); - Assertions.assertEquals("StatechartPackageImpl", astEmfPackageCD.getCDDefinition().getCDClassesList().get(17).getName()); - - Assertions.assertEquals(6, astEmfPackageCD.getCDDefinition().getCDInterfacesList().size()); - Assertions.assertEquals("ASTSCStructure", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(0).getName()); - Assertions.assertEquals("ASTBlockStatementExt", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(1).getName()); - Assertions.assertEquals("ASTExpressionExt", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(2).getName()); - Assertions.assertEquals("ASTClassbodyExt", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(3).getName()); - Assertions.assertEquals("ASTStatechartNode", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(4).getName()); - Assertions.assertEquals("StatechartPackage", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(5).getName()); - - Assertions.assertEquals(1, astEmfPackageCD.getCDDefinition().getCDEnumsList().size()); - Assertions.assertEquals("StatechartLiterals", astEmfPackageCD.getCDDefinition().getCDEnumsList().get(0).getName()); + assertNotNull(astEmfPackageCD); + assertNotNull(astEmfPackageCD.getCDDefinition()); + assertEquals("Statechart", astEmfPackageCD.getCDDefinition().getName()); + assertEquals(18, astEmfPackageCD.getCDDefinition().getCDClassesList().size()); + assertEquals("ASTStatechart", astEmfPackageCD.getCDDefinition().getCDClassesList().get(0).getName()); + assertEquals("ASTEntryAction", astEmfPackageCD.getCDDefinition().getCDClassesList().get(1).getName()); + assertEquals("ASTExitAction", astEmfPackageCD.getCDDefinition().getCDClassesList().get(2).getName()); + assertEquals("ASTState", astEmfPackageCD.getCDDefinition().getCDClassesList().get(3).getName()); + assertEquals("ASTTransition", astEmfPackageCD.getCDDefinition().getCDClassesList().get(4).getName()); + assertEquals("ASTArgument", astEmfPackageCD.getCDDefinition().getCDClassesList().get(5).getName()); + assertEquals("ASTCode", astEmfPackageCD.getCDDefinition().getCDClassesList().get(6).getName()); + assertEquals("ASTAbstractAnything", astEmfPackageCD.getCDDefinition().getCDClassesList().get(7).getName()); + assertEquals("ASTStatechartBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(8).getName()); + assertEquals("ASTEntryActionBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(9).getName()); + assertEquals("ASTExitActionBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(10).getName()); + assertEquals("ASTStateBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(11).getName()); + assertEquals("ASTTransitionBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(12).getName()); + assertEquals("ASTArgumentBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(13).getName()); + assertEquals("ASTCodeBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(14).getName()); + assertEquals("ASTAbstractAnythingBuilder", astEmfPackageCD.getCDDefinition().getCDClassesList().get(15).getName()); + assertEquals("ASTConstantsStatechart", astEmfPackageCD.getCDDefinition().getCDClassesList().get(16).getName()); + assertEquals("StatechartPackageImpl", astEmfPackageCD.getCDDefinition().getCDClassesList().get(17).getName()); + + assertEquals(6, astEmfPackageCD.getCDDefinition().getCDInterfacesList().size()); + assertEquals("ASTSCStructure", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(0).getName()); + assertEquals("ASTBlockStatementExt", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(1).getName()); + assertEquals("ASTExpressionExt", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(2).getName()); + assertEquals("ASTClassbodyExt", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(3).getName()); + assertEquals("ASTStatechartNode", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(4).getName()); + assertEquals("StatechartPackage", astEmfPackageCD.getCDDefinition().getCDInterfacesList().get(5).getName()); + + assertEquals(1, astEmfPackageCD.getCDDefinition().getCDEnumsList().size()); + assertEquals("StatechartLiterals", astEmfPackageCD.getCDDefinition().getCDEnumsList().get(0).getName()); MCAssertions.assertNoFindings(); } @@ -626,13 +626,13 @@ public void testDecorateForODPackage() { ASTCDCompilationUnit odPackage = createEmptyCompilationUnit(cd); mc.decorateForODPackage(glex, cd4AGlobalScope, cd, odPackage, handcodedPath); - Assertions.assertNotNull(odPackage); - Assertions.assertNotNull(odPackage.getCDDefinition()); - Assertions.assertEquals("Statechart", odPackage.getCDDefinition().getName()); - Assertions.assertEquals(1, odPackage.getCDDefinition().getCDClassesList().size()); - Assertions.assertEquals("Statechart2OD", odPackage.getCDDefinition().getCDClassesList().get(0).getName()); - Assertions.assertTrue(odPackage.getCDDefinition().getCDInterfacesList().isEmpty()); - Assertions.assertTrue(odPackage.getCDDefinition().getCDEnumsList().isEmpty()); + assertNotNull(odPackage); + assertNotNull(odPackage.getCDDefinition()); + assertEquals("Statechart", odPackage.getCDDefinition().getName()); + assertEquals(1, odPackage.getCDDefinition().getCDClassesList().size()); + assertEquals("Statechart2OD", odPackage.getCDDefinition().getCDClassesList().get(0).getName()); + assertTrue(odPackage.getCDDefinition().getCDInterfacesList().isEmpty()); + assertTrue(odPackage.getCDDefinition().getCDEnumsList().isEmpty()); MCAssertions.assertNoFindings(); } @@ -655,12 +655,12 @@ public void testDecorateForMill() { mc.decorateMill(glex, cd4AGlobalScope, cd, decoratedCompilationUnit, handcodedPath); - Assertions.assertNotNull(decoratedCompilationUnit); - Assertions.assertNotNull(decoratedCompilationUnit.getCDDefinition()); + assertNotNull(decoratedCompilationUnit); + assertNotNull(decoratedCompilationUnit.getCDDefinition()); Optional millPackage = decoratedCompilationUnit.getCDDefinition().getPackageWithName("de.monticore.statechart.statechart"); - Assertions.assertTrue(millPackage.isPresent()); - Assertions.assertEquals("Statechart", decoratedCompilationUnit.getCDDefinition().getName()); - Assertions.assertEquals(1, millPackage.get().getCDElementList().size()); + assertTrue(millPackage.isPresent()); + assertEquals("Statechart", decoratedCompilationUnit.getCDDefinition().getName()); + assertEquals(1, millPackage.get().getCDElementList().size()); MCAssertions.assertNoFindings(); } @@ -679,13 +679,13 @@ public void testDecorateForAuxiliaryPackage(){ mc.decorateAuxiliary(glex, cd4AGlobalScope, cd, decoratedCd, handcodedPath); - Assertions.assertNotNull(decoratedCd); - Assertions.assertNotNull(decoratedCd.getCDDefinition()); + assertNotNull(decoratedCd); + assertNotNull(decoratedCd.getCDDefinition()); Optional pp = decoratedCd.getCDDefinition().getPackageWithName("de.monticore.statechart.statechart._auxiliary"); - Assertions.assertEquals("Statechart", decoratedCd.getCDDefinition().getName()); - Assertions.assertEquals(1, pp.get().getCDElementList().size()); - Assertions.assertTrue(decoratedCd.getCDDefinition().getCDInterfacesList().isEmpty()); - Assertions.assertTrue(decoratedCd.getCDDefinition().getCDEnumsList().isEmpty()); + assertEquals("Statechart", decoratedCd.getCDDefinition().getName()); + assertEquals(1, pp.get().getCDElementList().size()); + assertTrue(decoratedCd.getCDDefinition().getCDInterfacesList().isEmpty()); + assertTrue(decoratedCd.getCDDefinition().getCDEnumsList().isEmpty()); MCAssertions.assertNoFindings(); } diff --git a/monticore-generator/src/test/java/de/monticore/cli/MontiCoreToolTest.java b/monticore-generator/src/test/java/de/monticore/cli/MontiCoreToolTest.java index 75fd1745a2..5291b15522 100644 --- a/monticore-generator/src/test/java/de/monticore/cli/MontiCoreToolTest.java +++ b/monticore-generator/src/test/java/de/monticore/cli/MontiCoreToolTest.java @@ -9,7 +9,6 @@ import de.se_rwth.commons.logging.LogStub; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -24,7 +23,8 @@ import java.util.Set; import static de.monticore.MontiCoreConfiguration.*; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * A collection of exemplary use cases for the CLI arguments. These unit tests @@ -122,63 +122,63 @@ public void setup() { public void testMontiCoreCLI() { new MontiCoreTool().run(simpleArgs); - Assertions.assertTrue(!false); + assertFalse(false); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMontiCoreDevLogCLI() { new MontiCoreTool().run(devLogArgs); - Assertions.assertTrue(!false); + assertFalse(false); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMontiCoreCustomLogCLI() { new MontiCoreTool().run(customLogArgs); - Assertions.assertTrue(!false); + assertFalse(false); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMontiCoreCustomScriptCLI() { new MontiCoreTool().run(customScriptArgs); - Assertions.assertTrue(!false); + assertFalse(false); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMontiCoreCustomEmfScriptCLI() { new MontiCoreTool().run(customEmfScriptArgs); - Assertions.assertTrue(!false); + assertFalse(false); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testHelp() { new MontiCoreTool().run(help); - - Assertions.assertTrue(!false); + + assertFalse(false); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Disabled // It's not possible to switch off fail quick (Logger in CLI) @Test public void testArgsWithNoGrammars() { new MontiCoreTool().run(argsWithNoGrammars); - Assertions.assertTrue(!false); + assertFalse(false); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -234,7 +234,7 @@ public void generateGrammarAndCheckFiles(Path path, String grammar) throws IOExc diff.add(relPath1.toString()); } - Assertions.assertTrue(f2.isFile(), "File does not exist \n\t" + f2.getAbsolutePath()); + assertTrue(f2.isFile(), "File does not exist \n\t" + f2.getAbsolutePath()); /*assertTrue("Different output generating twice! \n" + "\t" + f1.getAbsolutePath() + "\n" + "\t" + f2.getAbsolutePath() + "\n", @@ -243,9 +243,9 @@ public void generateGrammarAndCheckFiles(Path path, String grammar) throws IOExc } } diff.forEach(s -> System.err.println("\t " + s)); - Assertions.assertTrue(diff.isEmpty()); + assertTrue(diff.isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @AfterEach diff --git a/monticore-generator/src/test/java/de/monticore/cli/UpdateCheckerRunnableTest.java b/monticore-generator/src/test/java/de/monticore/cli/UpdateCheckerRunnableTest.java index c94607db3e..32ea3c66ce 100644 --- a/monticore-generator/src/test/java/de/monticore/cli/UpdateCheckerRunnableTest.java +++ b/monticore-generator/src/test/java/de/monticore/cli/UpdateCheckerRunnableTest.java @@ -5,11 +5,10 @@ import de.monticore.cli.updateChecker.UpdateCheckerRunnable; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -43,9 +42,9 @@ public void init() { @Test public void testFindLocalPropertiesFile() { - Assertions.assertNotNull(updateCheckerRunnable.getLocalVersion()); + assertNotNull(updateCheckerRunnable.getLocalVersion()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -53,28 +52,28 @@ public void testFindLocalPropertiesFile() { public void testNewVersionAvailable() { when(httpGetter.getResponse()).thenReturn(NEW_VERSION_AVAILABLE); - Assertions.assertTrue(updateCheckerRunnable.newVersionAvailable()); - Assertions.assertEquals(NEW_VERSION, updateCheckerRunnable.getNewVersion()); + assertTrue(updateCheckerRunnable.newVersionAvailable()); + assertEquals(NEW_VERSION, updateCheckerRunnable.getNewVersion()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testNoNewVersionAvailable() { when(httpGetter.getResponse()).thenReturn(NO_NEW_VERSION_AVAILABLE); - Assertions.assertFalse(updateCheckerRunnable.newVersionAvailable()); + assertFalse(updateCheckerRunnable.newVersionAvailable()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testNoResponse() { when(httpGetter.getResponse()).thenReturn(NO_RESPONSE); - Assertions.assertFalse(updateCheckerRunnable.newVersionAvailable()); + assertFalse(updateCheckerRunnable.newVersionAvailable()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -83,8 +82,8 @@ public void testRun() { updateCheckerRunnable.run(); - Assertions.assertEquals(NEW_VERSION, updateCheckerRunnable.getNewVersion()); + assertEquals(NEW_VERSION, updateCheckerRunnable.getNewVersion()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorAssert.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorAssert.java index 0f4303285e..693883ccf6 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorAssert.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorAssert.java @@ -9,8 +9,7 @@ import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.monticore.umlmodifier._ast.ASTModifier; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public final class DecoratorAssert { @@ -22,7 +21,8 @@ private DecoratorAssert() { } public static void assertDeepEquals(ASTNode expected, ASTNode actual) { - assertTrue(String.format("Expected: [%s], Actual: [%s]", getAsString(expected), getAsString(actual)), expected.deepEquals(actual)); + assertTrue(expected.deepEquals(actual), + String.format("Expected: [%s], Actual: [%s]", getAsString(expected), getAsString(actual))); } public static void assertDeepEquals(ASTMCType expected, ASTMCType actual) { @@ -34,7 +34,7 @@ private static String getAsString(ASTNode node) { } public static void assertDeepEquals(CDModifier expected, ASTNode actual) { - assertTrue(actual instanceof ASTModifier); + assertInstanceOf(ASTModifier.class, actual); ASTModifier actualMod = (ASTModifier) actual; ASTModifier expectedMod = expected.build(); assertEquals(expectedMod.isAbstract(), actualMod.isAbstract()); @@ -48,27 +48,27 @@ public static void assertDeepEquals(CDModifier expected, ASTNode actual) { } public static void assertDeepEquals(Class expected, ASTNode actual) { - assertTrue(actual instanceof ASTMCType); + assertInstanceOf(ASTMCType.class, actual); assertEquals(expected.getSimpleName(), CD4CodeMill.prettyPrint(actual, false)); } public static void assertDeepEquals(String name, ASTNode actual) { - assertTrue(actual instanceof ASTMCType); + assertInstanceOf(ASTMCType.class, actual); assertEquals(name, CD4CodeMill.prettyPrint(actual, false)); } public static void assertBoolean(ASTNode actual) { - assertTrue(actual instanceof ASTMCPrimitiveType); + assertInstanceOf(ASTMCPrimitiveType.class, actual); assertTrue(((ASTMCPrimitiveType) actual).isBoolean()); } public static void assertInt(ASTNode actual) { - assertTrue(actual instanceof ASTMCPrimitiveType); + assertInstanceOf(ASTMCPrimitiveType.class, actual); assertTrue(((ASTMCPrimitiveType) actual).isInt()); } public static void assertFloat(ASTNode actual){ - assertTrue(actual instanceof ASTMCPrimitiveType); + assertInstanceOf(ASTMCPrimitiveType.class, actual); assertTrue(((ASTMCPrimitiveType) actual).isFloat()); } @@ -78,19 +78,19 @@ public static void assertVoid(ASTNode acutal) { public static void assertOptionalOf(Class clazz, ASTNode actual) { String type = "Optional<" + clazz.getSimpleName() + ">"; - assertTrue(actual instanceof ASTMCType); + assertInstanceOf(ASTMCType.class, actual); assertEquals(type,CD4CodeMill.prettyPrint(actual, false)); } public static void assertOptionalOf(String name, ASTNode actual) { String type = "Optional<" + name + ">"; - assertTrue(actual instanceof ASTMCType); + assertInstanceOf(ASTMCType.class, actual); assertEquals(type,CD4CodeMill.prettyPrint(actual, false)); } public static void assertListOf(Class clazz, ASTNode actual) { String type = "List<" + clazz.getSimpleName() + ">"; - assertTrue(actual instanceof ASTMCType); + assertInstanceOf(ASTMCType.class, actual); assertEquals(type,CD4CodeMill.prettyPrint(actual, false)); } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorTestCase.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorTestCase.java index 9ee6ea8db4..9ef88ae7e8 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorTestCase.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorTestCase.java @@ -20,13 +20,13 @@ import de.se_rwth.commons.Joiners; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import java.io.IOException; import java.util.List; import java.util.Optional; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public abstract class DecoratorTestCase { @@ -35,13 +35,13 @@ public abstract class DecoratorTestCase { protected GlobalExtensionManagement glex; - @Before + @BeforeEach public void initLog() { LogStub.init(); Log.enableFailQuick(false); } - @Before + @BeforeEach public void setUpDecoratorTestCase() { CD4CodeMill.reset(); CD4CodeMill.init(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorTestUtil.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorTestUtil.java index 61e0d2373f..eeece230fd 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorTestUtil.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DecoratorTestUtil.java @@ -14,7 +14,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public final class DecoratorTestUtil { @@ -24,7 +24,8 @@ public static ASTCDClass getClassBy(String name, ASTCDCompilationUnit ast) { List filtered = ast.getCDDefinition().getCDClassesList().stream() .filter(c -> name.equals(c.getName())) .collect(Collectors.toList()); - assertEquals(String.format("Expected to find 1 class, but found '%s'", filtered.size()), 1, filtered.size()); + assertEquals(1, filtered.size(), + String.format("Expected to find 1 class, but found '%s'", filtered.size())); return filtered.get(0); } @@ -32,7 +33,8 @@ public static ASTCDInterface getInterfaceBy(String name, ASTCDCompilationUnit as List filtered = ast.getCDDefinition().getCDInterfacesList().stream() .filter(c -> name.equals(c.getName())) .collect(Collectors.toList()); - assertEquals(String.format("Expected to find 1 interface, but found '%s'", filtered.size()), 1, filtered.size()); + assertEquals(1, filtered.size(), + String.format("Expected to find 1 interface, but found '%s'", filtered.size())); return filtered.get(0); } @@ -40,7 +42,8 @@ public static ASTCDEnum getEnumBy(String name, ASTCDCompilationUnit ast) { List filtered = ast.getCDDefinition().getCDEnumsList().stream() .filter(c -> name.equals(c.getName())) .collect(Collectors.toList()); - assertEquals(String.format("Expected to find 1 enum, but found '%s'", filtered.size()), 1, filtered.size()); + assertEquals(1, filtered.size(), + String.format("Expected to find 1 enum, but found '%s'", filtered.size())); return filtered.get(0); } @@ -100,7 +103,8 @@ public static ASTCDMethod getMethodBy(String name, int parameterSize, List methods, List> predicates) { List filtered = filterMethods(methods, predicates); - assertEquals(String.format("Expected find 1 method, but found '%s'", filtered.size()), 1, filtered.size()); + assertEquals(1, filtered.size(), + String.format("Expected find 1 method, but found '%s'", filtered.size())); return filtered.get(0); } @@ -116,7 +120,8 @@ public static ASTCDAttribute getAttributeBy(String name, ASTCDClass clazz) { List filtered = clazz.getCDAttributeList().stream() .filter(attribute -> name.equals(attribute.getName())) .collect(Collectors.toList()); - assertEquals(String.format("Expected find 1 attribute, but found '%s'", filtered.size()), 1, filtered.size()); + assertEquals(1, filtered.size(), + String.format("Expected find 1 attribute, but found '%s'", filtered.size())); return filtered.get(0); } @@ -125,7 +130,8 @@ public static ASTCDAttribute getAttributeBy(String name, ASTCDInterface clazz) { List filtered = clazz.getCDAttributeList().stream() .filter(attribute -> name.equals(attribute.getName())) .collect(Collectors.toList()); - assertEquals(String.format("Expected find 1 attribute, but found '%s'", filtered.size()), 1, filtered.size()); + assertEquals(1, filtered.size(), + String.format("Expected find 1 attribute, but found '%s'", filtered.size())); return filtered.get(0); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DeprecatedTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DeprecatedTest.java index abea234589..dd0a8c5eb4 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DeprecatedTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/DeprecatedTest.java @@ -28,8 +28,8 @@ import de.monticore.codegen.cd2java.methods.MethodDecorator; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Optional; @@ -37,9 +37,7 @@ 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; +import static org.junit.jupiter.api.Assertions.*; public class DeprecatedTest extends DecoratorTestCase { @@ -63,7 +61,7 @@ private ASTCDCompilationUnit compilationUnit; - @Before + @BeforeEach public void setup() { compilationUnit = this.parse("de", "monticore", "codegen", "deprecated", "DeprecatedProds"); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/GeneratedErrorCodeTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/GeneratedErrorCodeTest.java index 5ac85eb9a8..448edafa8f 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/GeneratedErrorCodeTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/GeneratedErrorCodeTest.java @@ -4,10 +4,10 @@ import de.monticore.cdbasis._ast.ASTCDCompilationUnit; import de.monticore.codegen.cd2java._ast.ast_class.ASTService; import de.se_rwth.commons.logging.Log; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * test that error codes are generated deterministic diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_constants/ASTConstantsDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_constants/ASTConstantsDecoratorTest.java index b614b11ceb..8697d22971 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_constants/ASTConstantsDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_constants/ASTConstantsDecoratorTest.java @@ -17,16 +17,14 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; 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.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTConstantsDecoratorTest extends DecoratorTestCase { @@ -35,7 +33,7 @@ public class ASTConstantsDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit originalCompilationUnit; - @Before + @BeforeEach public void setUp() { decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); originalCompilationUnit = decoratedCompilationUnit.deepClone(); @@ -139,7 +137,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/ASTInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/ASTInterfaceDecoratorTest.java index 28a569ae25..7449908f9e 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/ASTInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/ASTInterfaceDecoratorTest.java @@ -26,8 +26,8 @@ import de.monticore.generating.templateengine.GlobalExtensionManagement; import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import static de.monticore.cd.facade.CDModifier.PUBLIC_ABSTRACT; @@ -35,14 +35,14 @@ 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.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ASTInterfaceDecoratorTest extends DecoratorTestCase { private ASTCDInterface dataInterface; - @Before + @BeforeEach public void setUp() { ASTCDCompilationUnit astcdCompilationUnit = this.parse("de", "monticore", "codegen", "data", "DataInterface"); this.glex.setGlobalValue("service", new AbstractService(astcdCompilationUnit)); @@ -178,7 +178,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/ASTLanguageInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/ASTLanguageInterfaceDecoratorTest.java index ec1c0ae071..b7076b78b6 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/ASTLanguageInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/ASTLanguageInterfaceDecoratorTest.java @@ -17,13 +17,13 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ASTLanguageInterfaceDecoratorTest extends DecoratorTestCase { @@ -35,11 +35,11 @@ public class ASTLanguageInterfaceDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedCompilationUnit; - @Before + @BeforeEach 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("service", new AbstractService<>(originalCompilationUnit)); ASTService astService = new ASTService(originalCompilationUnit); VisitorService visitorService = new VisitorService(originalCompilationUnit); @@ -102,7 +102,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/FullASTInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/FullASTInterfaceDecoratorTest.java index 3637db4586..3e12b0bac8 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/FullASTInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_interface/FullASTInterfaceDecoratorTest.java @@ -26,17 +26,15 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PUBLIC_ABSTRACT; import static de.monticore.codegen.cd2java.DecoratorAssert.assertBoolean; 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.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class FullASTInterfaceDecoratorTest extends DecoratorTestCase { @@ -46,7 +44,7 @@ public class FullASTInterfaceDecoratorTest extends DecoratorTestCase { private static final String NAME_SYMBOL = "de.monticore.codegen.ast.referencedsymbol._symboltable.FooSymbol"; - @Before + @BeforeEach public void setUp() { ASTCDCompilationUnit astcdCompilationUnit = this.parse("de", "monticore", "codegen", "data", "DataInterface"); this.glex.setGlobalValue("service", new AbstractService(astcdCompilationUnit)); @@ -368,7 +366,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTCDDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTCDDecoratorTest.java index 7813dd8587..717c00726d 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTCDDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTCDDecoratorTest.java @@ -35,13 +35,12 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; - +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ASTCDDecoratorTest extends DecoratorTestCase { @@ -49,7 +48,7 @@ public class ASTCDDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit originalCompilationUnit; - @Before + @BeforeEach public void setup() { this.originalCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "AST"); this.glex.setGlobalValue("service", new AbstractService(originalCompilationUnit)); @@ -123,7 +122,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTDecoratorTest.java index 7b63400bdc..dff8cc57b0 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTDecoratorTest.java @@ -25,8 +25,8 @@ import de.monticore.types.MCTypeFacade; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.Collectors; @@ -39,9 +39,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTDecoratorTest extends DecoratorTestCase { @@ -53,7 +51,7 @@ public class ASTDecoratorTest extends DecoratorTestCase { private static final String AST_SYMBOL = "de.monticore.codegen.ast.ast._symboltable.ASymbol"; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "ast", "AST"); @@ -204,7 +202,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTFullDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTFullDecoratorTest.java index 1913fb1f2a..38fdede07a 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTFullDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTFullDecoratorTest.java @@ -17,14 +17,11 @@ import de.monticore.codegen.cd2java.data.DataDecoratorUtil; import de.monticore.codegen.cd2java.methods.MethodDecorator; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTFullDecoratorTest extends DecoratorTestCase { @@ -35,7 +32,7 @@ public class ASTFullDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit originalCompilationUnit; - @Before + @BeforeEach public void setup() { decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "AST"); originalCompilationUnit = decoratedCompilationUnit.deepClone(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTScopeDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTScopeDecoratorTest.java index a1f5c8b3d2..97c5458432 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTScopeDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTScopeDecoratorTest.java @@ -12,8 +12,8 @@ import de.monticore.codegen.mc2cd.TransformationHelper; import de.monticore.umlmodifier._ast.ASTModifier; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Optional; @@ -22,9 +22,7 @@ import static de.monticore.cd.facade.CDModifier.PROTECTED; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTScopeDecoratorTest extends DecoratorTestCase { @@ -34,7 +32,7 @@ public class ASTScopeDecoratorTest extends DecoratorTestCase { private static final String SUPER_I_SCOPE= "de.monticore.codegen.ast.supercd._symboltable.ISuperCDScope"; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "ast", "AST"); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTServiceTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTServiceTest.java index 3034032021..2697f6c3d7 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTServiceTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTServiceTest.java @@ -9,16 +9,14 @@ import de.monticore.codegen.cd2java.DecoratorTestCase; import de.monticore.codegen.cd2java._ast.ast_class.ASTService; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.Collectors; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTServiceTest extends DecoratorTestCase { @@ -30,7 +28,7 @@ public class ASTServiceTest extends DecoratorTestCase { private ASTCDClass astAutomaton; - @Before + @BeforeEach public void setup() { astcdCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); astAutomaton = astcdCompilationUnit.getCDDefinition().getCDClassesList().get(0); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTSymbolDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTSymbolDecoratorTest.java index 4bd2b0fa1e..1c685c3b53 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTSymbolDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/ASTSymbolDecoratorTest.java @@ -9,8 +9,8 @@ import de.monticore.codegen.cd2java._ast.ast_class.ASTSymbolDecorator; import de.monticore.codegen.cd2java._symboltable.SymbolTableService; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Optional; @@ -19,15 +19,13 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorAssert.assertOptionalOf; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTSymbolDecoratorTest extends DecoratorTestCase { private List attributes; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "ast", "AST"); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/ASTReferenceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/ASTReferenceDecoratorTest.java index 0e577243db..07fb76e00b 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/ASTReferenceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/ASTReferenceDecoratorTest.java @@ -9,15 +9,13 @@ import de.monticore.codegen.cd2java._ast.ast_class.reference.ASTReferenceDecorator; import de.monticore.codegen.cd2java._symboltable.SymbolTableService; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTReferenceDecoratorTest extends DecoratorTestCase { @@ -30,7 +28,7 @@ public class ASTReferenceDecoratorTest extends DecoratorTestCase { private ASTReferenceDecorator referenceDecorator; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "ast", "ReferencedSymbol"); this.referenceDecorator = new ASTReferenceDecorator(this.glex, new SymbolTableService(ast)); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorListTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorListTest.java index 95d610b739..c2f7a59ce4 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorListTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorListTest.java @@ -17,18 +17,18 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ASTReferencedDefinitionDecoratorListTest extends DecoratorTestCase { private ASTCDClass astClass; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "ast", "ReferencedSymbol"); @@ -74,7 +74,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorMandatoryTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorMandatoryTest.java index 7aba85de30..6e9618a462 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorMandatoryTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorMandatoryTest.java @@ -18,16 +18,16 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PUBLIC; import static de.monticore.codegen.cd2java.DecoratorAssert.assertBoolean; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ASTReferencedDefinitionDecoratorMandatoryTest extends DecoratorTestCase { @@ -35,7 +35,7 @@ public class ASTReferencedDefinitionDecoratorMandatoryTest extends DecoratorTest private static final String NAME_DEFINITION = "de.monticore.codegen.ast.referencedsymbol._ast.ASTFoo"; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "ast", "ReferencedSymbol"); this.glex.setGlobalValue("service", new AbstractService(ast)); @@ -102,7 +102,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorOptionalTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorOptionalTest.java index 5798ab64b4..d9cc162fd9 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorOptionalTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedDefinition/ASTReferencedDefinitionDecoratorOptionalTest.java @@ -18,16 +18,16 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PUBLIC; import static de.monticore.codegen.cd2java.DecoratorAssert.assertBoolean; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ASTReferencedDefinitionDecoratorOptionalTest extends DecoratorTestCase { @@ -35,7 +35,7 @@ public class ASTReferencedDefinitionDecoratorOptionalTest extends DecoratorTestC private static final String NAME_DEFINITION = "de.monticore.codegen.ast.referencedsymbol._ast.ASTFoo"; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "ast", "ReferencedSymbol"); this.glex.setGlobalValue("service", new AbstractService(ast)); @@ -102,7 +102,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorListTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorListTest.java index 1f84c0897e..0ab8d75308 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorListTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorListTest.java @@ -19,17 +19,15 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.umlstereotype._ast.ASTStereotype; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PROTECTED; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTReferencedSymbolDecoratorListTest extends DecoratorTestCase { @@ -39,7 +37,7 @@ public class ASTReferencedSymbolDecoratorListTest extends DecoratorTestCase { private static final String NAME_SYMBOL_MAP = "Map"; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "ast", "ReferencedSymbol"); this.glex.setGlobalValue("service", new AbstractService(ast)); @@ -118,7 +116,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorMandatoryTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorMandatoryTest.java index 074d5f42b9..e9f9f3b874 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorMandatoryTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorMandatoryTest.java @@ -20,8 +20,8 @@ import de.monticore.types.MCTypeFacade; import de.monticore.umlstereotype._ast.ASTStereotype; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PROTECTED; import static de.monticore.cd.facade.CDModifier.PUBLIC; @@ -30,9 +30,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTReferencedSymbolDecoratorMandatoryTest extends DecoratorTestCase { @@ -46,7 +44,7 @@ public class ASTReferencedSymbolDecoratorMandatoryTest extends DecoratorTestCase private static final String NAME_SYMBOL = "de.monticore.codegen.ast.referencedsymbol._symboltable.FooSymbol"; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "ast", "ReferencedSymbol"); this.glex.setGlobalValue("service", new AbstractService(ast)); @@ -147,7 +145,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorOptionalTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorOptionalTest.java index fcf17f51b4..5b3fa5edf5 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorOptionalTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/ast_new/reference/referencedSymbol/ASTReferencedSymbolDecoratorOptionalTest.java @@ -19,8 +19,8 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.umlstereotype._ast.ASTStereotype; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PROTECTED; import static de.monticore.cd.facade.CDModifier.PUBLIC; @@ -29,9 +29,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTReferencedSymbolDecoratorOptionalTest extends DecoratorTestCase { @@ -45,7 +43,7 @@ public class ASTReferencedSymbolDecoratorOptionalTest extends DecoratorTestCase private static final String NAME_SYMBOL = "de.monticore.codegen.ast.referencedsymbol._symboltable.FooSymbol"; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "ast", "ReferencedSymbol"); this.glex.setGlobalValue("service", new AbstractService(ast)); @@ -146,7 +144,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); @@ -228,7 +226,7 @@ public void testGeneratedCodeMand() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/builder/ASTBuilderDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/builder/ASTBuilderDecoratorTest.java index fd5cf19fb4..0043a4d4c4 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/builder/ASTBuilderDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/builder/ASTBuilderDecoratorTest.java @@ -15,13 +15,13 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ASTBuilderDecoratorTest extends DecoratorTestCase { @@ -31,7 +31,7 @@ public class ASTBuilderDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit originalCompilationUnit; - @Before + @BeforeEach public void setup() { decoratedCompilationUnit = parse("de", "monticore", "codegen", "ast", "Builder"); originalCompilationUnit = decoratedCompilationUnit.deepClone(); @@ -83,7 +83,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/builder/BuilderDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/builder/BuilderDecoratorTest.java index 4b8f57ca96..f0d5bfdb28 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/builder/BuilderDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/builder/BuilderDecoratorTest.java @@ -16,8 +16,8 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -26,7 +26,7 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.*; import static de.monticore.codegen.cd2java.DecoratorTestUtil.*; import static de.monticore.codegen.cd2java._ast.builder.BuilderConstants.*; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class BuilderDecoratorTest extends DecoratorTestCase { @@ -34,7 +34,7 @@ public class BuilderDecoratorTest extends DecoratorTestCase { private ASTCDClass builderClass; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = parse("de", "monticore", "codegen", "builder", "Builder"); this.glex.setGlobalValue("service", new AbstractService(ast)); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/enums/LiteralsEnumDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/enums/LiteralsEnumDecoratorTest.java index 7c11f755d3..31ee58be3a 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/enums/LiteralsEnumDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast/enums/LiteralsEnumDecoratorTest.java @@ -20,14 +20,14 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorAssert.assertInt; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getEnumBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class LiteralsEnumDecoratorTest extends DecoratorTestCase { @@ -37,7 +37,7 @@ public class LiteralsEnumDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit originalCompilationUnit; - @Before + @BeforeEach public void setUp() { decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); originalCompilationUnit = decoratedCompilationUnit.deepClone(); @@ -127,7 +127,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ASTEmfCDDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ASTEmfCDDecoratorTest.java index afb4ecfe30..998adeea13 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ASTEmfCDDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ASTEmfCDDecoratorTest.java @@ -37,11 +37,11 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ASTEmfCDDecoratorTest extends DecoratorTestCase { @@ -49,7 +49,7 @@ public class ASTEmfCDDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit originalCompilationUnit; - @Before + @BeforeEach public void setup() { this.decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "AST"); this.originalCompilationUnit = decoratedCompilationUnit.deepClone(); @@ -117,7 +117,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/ASTEmfDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/ASTEmfDecoratorTest.java index e7404077b6..b2d4ab86e1 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/ASTEmfDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/ASTEmfDecoratorTest.java @@ -21,8 +21,8 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PROTECTED; import static de.monticore.cd.facade.CDModifier.PUBLIC; @@ -32,9 +32,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTEmfDecoratorTest extends DecoratorTestCase { @@ -42,7 +40,7 @@ public class ASTEmfDecoratorTest extends DecoratorTestCase { private ASTCDClass emfTransitionClass; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "_ast_emf", "Automata"); @@ -216,9 +214,9 @@ public void testEStaticClassMethod() { * ASTTransitionWithAction already has a toString method in the classdiagramm * tests that no toString method is separately generated */ - @Test (expected = AssertionError.class) + @Test public void testToStringASTTransitionWithAction() { - getMethodBy("toString", emfTransitionClass); + assertThrows(AssertionError.class, () -> getMethodBy("toString", emfTransitionClass)); assertTrue(Log.getFindings().isEmpty()); } @@ -243,7 +241,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/ASTFullEmfDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/ASTFullEmfDecoratorTest.java index a995c93fab..7469bb9c22 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/ASTFullEmfDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/ASTFullEmfDecoratorTest.java @@ -16,14 +16,11 @@ import de.monticore.codegen.cd2java.data.DataDecoratorUtil; import de.monticore.codegen.cd2java.methods.MethodDecorator; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ASTFullEmfDecoratorTest extends DecoratorTestCase { @@ -34,7 +31,7 @@ public class ASTFullEmfDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit originalCompilationUnit; - @Before + @BeforeEach public void setup() { decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); originalCompilationUnit = decoratedCompilationUnit.deepClone(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/DataEmfDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/DataEmfDecoratorTest.java index 9ecbda9400..651c7ad616 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/DataEmfDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/ast_class/DataEmfDecoratorTest.java @@ -18,18 +18,18 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DataEmfDecoratorTest extends DecoratorTestCase { private ASTCDClass emfClass; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit compilationUnit = this.parse("de", "monticore", "codegen", "_ast_emf", "Automata"); @@ -73,7 +73,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/emf_package/PackageImplDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/emf_package/PackageImplDecoratorTest.java index 350e8ac39f..0714a40958 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/emf_package/PackageImplDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/emf_package/PackageImplDecoratorTest.java @@ -19,8 +19,8 @@ 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 org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PRIVATE; import static de.monticore.cd.facade.CDModifier.PROTECTED; @@ -31,15 +31,13 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class PackageImplDecoratorTest extends DecoratorTestCase { private ASTCDClass packageClass; - @Before + @BeforeEach public void setup() { LogStub.init(); // replace log by a sideffect free variant // LogStub.initPlusLog(); // for manual testing purpose only @@ -332,7 +330,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/emf_package/PackageInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/emf_package/PackageInterfaceDecoratorTest.java index 6d471e4415..ee09f5c201 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/emf_package/PackageInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_ast_emf/emf_package/PackageInterfaceDecoratorTest.java @@ -16,8 +16,8 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PACKAGE_PRIVATE; import static de.monticore.cd.facade.CDModifier.PACKAGE_PRIVATE_ABSTRACT; @@ -25,9 +25,7 @@ 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.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class PackageInterfaceDecoratorTest extends DecoratorTestCase { @@ -35,7 +33,7 @@ public class PackageInterfaceDecoratorTest extends DecoratorTestCase { private ASTCDDefinition astcdDefinition; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "_ast_emf", "Automata"); @@ -398,7 +396,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoCheckerDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoCheckerDecoratorTest.java index 89a87c27f1..ed257243e3 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoCheckerDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoCheckerDecoratorTest.java @@ -22,9 +22,8 @@ import de.monticore.types.MCTypeFacade; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -34,9 +33,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.*; public class CoCoCheckerDecoratorTest extends DecoratorTestCase { @@ -64,7 +61,7 @@ public class CoCoCheckerDecoratorTest extends DecoratorTestCase { private static final String LEXICALS_NODE = "de.monticore.codegen.ast.lexicals._ast.ASTLexicalsNode"; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = parse("de", "monticore", "codegen", "ast", "Automaton"); ICD4CodeGlobalScope gs = CD4CodeMill.globalScope(); @@ -85,7 +82,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); @@ -203,7 +200,7 @@ public void testAddCoCoAutomatonMethod() { assertEquals("coco", method.getCDParameter(0).getName()); assertTrue(method.getMCReturnType().isPresentMCVoidType()); - Assert.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoDecoratorTest.java index 2c46b978fe..1b35fd7bde 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoDecoratorTest.java @@ -18,17 +18,17 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.io.paths.MCPath; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CoCoDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedAst; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = this.parse("de", "monticore", "codegen", "cocos", "CoCos"); decoratedAst = createEmptyCompilationUnit(ast); @@ -64,7 +64,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); } for (ASTCDInterface astcdInterface : decoratedAst.getCDDefinition().getCDInterfacesList()) { @@ -72,7 +72,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoInterfaceDecoratorTest.java index 1c10fb018d..6ea5aee32b 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoInterfaceDecoratorTest.java @@ -16,22 +16,22 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import static de.monticore.cd.facade.CDModifier.PUBLIC; import static de.monticore.cd.facade.CDModifier.PUBLIC_ABSTRACT; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CoCoInterfaceDecoratorTest extends DecoratorTestCase { private List interfaces; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = parse("de", "monticore", "codegen", "cocos", "CoCos"); this.glex.setGlobalValue("service", new AbstractService(ast)); @@ -154,7 +154,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoServiceTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoServiceTest.java index f60e4908a6..9f6b652704 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoServiceTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_cocos/CoCoServiceTest.java @@ -5,12 +5,12 @@ import de.monticore.cdbasis._ast.ASTCDCompilationUnit; import de.monticore.codegen.cd2java.DecoratorTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CoCoServiceTest extends DecoratorTestCase { @@ -22,7 +22,7 @@ public class CoCoServiceTest extends DecoratorTestCase { private ASTCDClass astAutomaton; - @Before + @BeforeEach public void setup() { astcdCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); astAutomaton = astcdCompilationUnit.getCDDefinition().getCDClassesList().get(0); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_od/ODDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_od/ODDecoratorTest.java index da0753a795..c85c1c1984 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_od/ODDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_od/ODDecoratorTest.java @@ -18,8 +18,8 @@ import de.monticore.types.MCTypeFacade; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -30,9 +30,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ODDecoratorTest extends DecoratorTestCase { @@ -64,7 +62,7 @@ public class ODDecoratorTest extends DecoratorTestCase { private MCTypeFacade mcTypeFacade; - @Before + @BeforeEach public void setup() { this.mcTypeFacade = MCTypeFacade.getInstance(); @@ -88,7 +86,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserCDDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserCDDecoratorTest.java index 4fb398054a..33fd4d08db 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserCDDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserCDDecoratorTest.java @@ -8,14 +8,14 @@ import de.monticore.codegen.cd2java.DecoratorTestCase; import de.monticore.umlmodifier._ast.ASTModifier; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ParserCDDecoratorTest extends DecoratorTestCase { @@ -27,7 +27,7 @@ public class ParserCDDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit parserCDComponent; - @Before + @BeforeEach public void setUp() { decoratedASTCompilationUnit = this.parse("de", "monticore", "codegen", "symboltable", "Automaton"); originalASTCompilationUnit = decoratedASTCompilationUnit.deepClone(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserClassDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserClassDecoratorTest.java index 057acf7a11..972e4757d2 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserClassDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserClassDecoratorTest.java @@ -19,8 +19,8 @@ import de.monticore.types.mcbasictypes.MCBasicTypesMill; import de.monticore.types.mcbasictypes._ast.ASTMCQualifiedName; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Optional; @@ -29,8 +29,8 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertOptionalOf; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ParserClassDecoratorTest extends DecoratorTestCase { @@ -50,7 +50,7 @@ public class ParserClassDecoratorTest extends DecoratorTestCase { private final String AUTOMATON_ANTLR_PARSER = "AutomatonAntlrParser"; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); @@ -288,7 +288,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserForSuperDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserForSuperDecoratorTest.java index 1cbb6f0d64..d2cd64671a 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserForSuperDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserForSuperDecoratorTest.java @@ -18,16 +18,16 @@ import de.monticore.types.mcbasictypes.MCBasicTypesMill; import de.monticore.types.mcbasictypes._ast.ASTMCQualifiedName; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorAssert.assertOptionalOf; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ParserForSuperDecoratorTest extends DecoratorTestCase { @@ -37,7 +37,7 @@ public class ParserForSuperDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedCompilationUnit; - @Before + @BeforeEach public void setUp() { decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "parser", "SubAutomaton"); originalCompilationUnit = decoratedCompilationUnit.deepClone(); @@ -167,7 +167,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserServiceTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserServiceTest.java index 0bc2c1c286..b922931bbb 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserServiceTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_parser/ParserServiceTest.java @@ -7,12 +7,12 @@ import de.monticore.codegen.cd2java.DecoratorTestCase; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ParserServiceTest extends DecoratorTestCase { @@ -24,7 +24,7 @@ public class ParserServiceTest extends DecoratorTestCase { private ASTCDClass astAutomaton; - @Before + @BeforeEach public void setup() { this.mcTypeFacade = MCTypeFacade.getInstance(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/SymbolTableCDDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/SymbolTableCDDecoratorTest.java index ef0458e704..c2654553a0 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/SymbolTableCDDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/SymbolTableCDDecoratorTest.java @@ -32,15 +32,15 @@ import de.monticore.io.paths.MCPath; import de.monticore.umlmodifier._ast.ASTModifier; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getInterfaceBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SymbolTableCDDecoratorTest extends DecoratorTestCase { @@ -62,7 +62,7 @@ public class SymbolTableCDDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit symTabCDComponent; - @Before + @BeforeEach public void setUp() { MCPath targetPath = Mockito.mock(MCPath.class); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/SymbolTableServiceTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/SymbolTableServiceTest.java index 834536c43a..d14dd0837f 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/SymbolTableServiceTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/SymbolTableServiceTest.java @@ -14,16 +14,14 @@ import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.monticore.umlmodifier._ast.ASTModifier; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class SymbolTableServiceTest extends DecoratorTestCase { @@ -35,7 +33,7 @@ public class SymbolTableServiceTest extends DecoratorTestCase { private MCTypeFacade mcTypeFacade; - @Before + @BeforeEach public void setup() { this.mcTypeFacade = MCTypeFacade.getInstance(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/Symbols2JsonTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/Symbols2JsonTest.java index 5413774563..2922943df3 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/Symbols2JsonTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/Symbols2JsonTest.java @@ -14,16 +14,16 @@ import de.monticore.types.MCTypeFacade; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import static de.monticore.cd.facade.CDModifier.PUBLIC; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class Symbols2JsonTest extends DecoratorTestCase { @@ -40,7 +40,7 @@ public class Symbols2JsonTest extends DecoratorTestCase { private static final String AUTOMATON_SYMBOL = "de.monticore.codegen.symboltable.automaton._symboltable.AutomatonSymbol"; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ArtifactScopeClassDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ArtifactScopeClassDecoratorTest.java index bd178326db..27559658e9 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ArtifactScopeClassDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ArtifactScopeClassDecoratorTest.java @@ -21,8 +21,8 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -33,9 +33,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ArtifactScopeClassDecoratorTest extends DecoratorTestCase { @@ -53,7 +51,7 @@ public class ArtifactScopeClassDecoratorTest extends DecoratorTestCase { private static final String IMPORT_STATEMENT = "de.monticore.symboltable.ImportStatement"; - @Before + @BeforeEach public void setUp() { this.MCTypeFacade = MCTypeFacade.getInstance(); @@ -295,7 +293,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ArtifactScopeInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ArtifactScopeInterfaceDecoratorTest.java index 5636826072..be8ce9b4bb 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ArtifactScopeInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ArtifactScopeInterfaceDecoratorTest.java @@ -17,8 +17,8 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -31,7 +31,7 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertVoid; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class ArtifactScopeInterfaceDecoratorTest extends DecoratorTestCase { @@ -55,7 +55,7 @@ public class ArtifactScopeInterfaceDecoratorTest extends DecoratorTestCase { private static final String PREDICATE_QUALIFIED_NAME = "java.util.function.Predicate"; - @Before + @BeforeEach public void setUp() { this.MCTypeFacade = MCTypeFacade.getInstance(); @@ -81,7 +81,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/GlobalScopeClassDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/GlobalScopeClassDecoratorTest.java index a2d8bc48aa..f5485fb126 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/GlobalScopeClassDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/GlobalScopeClassDecoratorTest.java @@ -20,8 +20,8 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -29,7 +29,7 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorAssert.assertVoid; import static de.monticore.codegen.cd2java.DecoratorTestUtil.*; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class GlobalScopeClassDecoratorTest extends DecoratorTestCase { @@ -45,7 +45,7 @@ public class GlobalScopeClassDecoratorTest extends DecoratorTestCase { private static final String AUTOMATON_SCOPE = "de.monticore.codegen.ast.automaton._symboltable.AutomatonScope"; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); @@ -332,7 +332,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/GlobalScopeInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/GlobalScopeInterfaceDecoratorTest.java index 2978e200b7..6091b39713 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/GlobalScopeInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/GlobalScopeInterfaceDecoratorTest.java @@ -11,8 +11,8 @@ import de.monticore.codegen.cd2java.methods.MethodDecorator; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -24,8 +24,8 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertVoid; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class GlobalScopeInterfaceDecoratorTest extends DecoratorTestCase { @@ -49,7 +49,7 @@ public class GlobalScopeInterfaceDecoratorTest extends DecoratorTestCase { private static final String PREDICATE_QUALIFIED_NAME = "java.util.function.Predicate"; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ScopeClassDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ScopeClassDecoratorTest.java index 9f720941f6..4e9b928a16 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ScopeClassDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ScopeClassDecoratorTest.java @@ -20,8 +20,8 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.LinkedHashMap; import java.util.List; @@ -38,9 +38,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ScopeClassDecoratorTest extends DecoratorTestCase { @@ -82,7 +80,7 @@ public class ScopeClassDecoratorTest extends DecoratorTestCase { private static final String I_LEXICAS_SCOPE = "de.monticore.codegen.ast.lexicals._symboltable.ILexicalsScope"; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = mcTypeFacade.getInstance(); @@ -815,7 +813,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ScopeInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ScopeInterfaceDecoratorTest.java index b040cc9e06..4693d22ae8 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ScopeInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scope/ScopeInterfaceDecoratorTest.java @@ -17,8 +17,8 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -31,8 +31,8 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertVoid; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ScopeInterfaceDecoratorTest extends DecoratorTestCase { private ASTCDInterface scopeInterface; @@ -54,7 +54,7 @@ public class ScopeInterfaceDecoratorTest extends DecoratorTestCase { private static final String PREDICATE = "java.util.function.Predicate"; - @Before + @BeforeEach public void setUp() { this.MCTypeFacade = MCTypeFacade.getInstance(); ASTCDCompilationUnit astcdCompilationUnit = this.parse("de", "monticore", "codegen", "symboltable", "Automaton"); @@ -809,7 +809,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scopesgenitor/ScopesGenitorDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scopesgenitor/ScopesGenitorDecoratorTest.java index 13cee735b2..ddd0afac5f 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scopesgenitor/ScopesGenitorDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scopesgenitor/ScopesGenitorDecoratorTest.java @@ -26,8 +26,8 @@ import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.List; @@ -41,9 +41,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ScopesGenitorDecoratorTest extends DecoratorTestCase { @@ -83,7 +81,7 @@ public class ScopesGenitorDecoratorTest extends DecoratorTestCase { private static final String AST_SCOPE = "de.monticore.codegen.symboltable.automaton._ast.ASTScope"; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); @@ -535,7 +533,7 @@ public void testGeneratedCodeState() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scopesgenitor/ScopesGenitorDelegatorDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scopesgenitor/ScopesGenitorDelegatorDecoratorTest.java index 32adf75dd0..88f0731786 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scopesgenitor/ScopesGenitorDelegatorDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/scopesgenitor/ScopesGenitorDelegatorDecoratorTest.java @@ -23,8 +23,8 @@ import de.monticore.generating.templateengine.GlobalExtensionManagement; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.Optional; @@ -35,9 +35,7 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ScopesGenitorDelegatorDecoratorTest extends DecoratorTestCase { @@ -59,7 +57,7 @@ public class ScopesGenitorDelegatorDecoratorTest extends DecoratorTestCase { private static final String AST_AUTOMATON = "de.monticore.codegen.symboltable.automaton._ast.ASTAutomaton"; - @Before + @BeforeEach public void setUp() { this.MCTypeFacade = MCTypeFacade.getInstance(); @@ -219,7 +217,7 @@ public void testGeneratedCodeState() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/ScopeDeSerDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/ScopeDeSerDecoratorTest.java index 2a0ed57d30..d96af7df98 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/ScopeDeSerDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/ScopeDeSerDecoratorTest.java @@ -26,8 +26,8 @@ import de.monticore.prettyprint.IndentPrinter; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -37,10 +37,7 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertOptionalOf; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; public class ScopeDeSerDecoratorTest extends DecoratorTestCase { @@ -62,7 +59,7 @@ public class ScopeDeSerDecoratorTest extends DecoratorTestCase { public static final String I_SCOPE = "de.monticore.symboltable.IScope"; - @Before + @BeforeEach public void setUp() { this.glex = new GlobalExtensionManagement(); @@ -360,7 +357,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); @@ -372,6 +369,7 @@ public static void assertOneOf(ASTMCType actualType, String... expected) { for (String exp : expected) { if (actual.equals(exp)) { result = true; + break; } } if (!result) { diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/SymbolDeSerDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/SymbolDeSerDecoratorTest.java index f4ae2b932c..bf271c91d1 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/SymbolDeSerDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/SymbolDeSerDecoratorTest.java @@ -20,8 +20,8 @@ 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 org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -32,9 +32,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class SymbolDeSerDecoratorTest extends DecoratorTestCase { @@ -58,7 +56,7 @@ public class SymbolDeSerDecoratorTest extends DecoratorTestCase { private static final String IAUTOMATON_SCOPE = "de.monticore.codegen.symboltable.automatonsymbolcd._symboltable.IAutomatonSymbolCDScope"; - @Before + @BeforeEach public void setUp() { LogStub.init(); Log.enableFailQuick(false); @@ -404,7 +402,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); @@ -421,7 +419,7 @@ public void testGeneratedCodeFoo() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/Symbols2JsonDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/Symbols2JsonDecoratorTest.java index f192bb9922..eca7b34793 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/Symbols2JsonDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/serialization/Symbols2JsonDecoratorTest.java @@ -25,8 +25,8 @@ import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.monticore.types.mcbasictypes.MCBasicTypesMill; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -34,10 +34,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; public class Symbols2JsonDecoratorTest extends DecoratorTestCase { @@ -67,7 +64,7 @@ public class Symbols2JsonDecoratorTest extends DecoratorTestCase { private static final String FOO_SYMBOL = "de.monticore.codegen.symboltable.automaton._symboltable.FooSymbol"; - @Before + @BeforeEach public void setUp(){ ASTCDCompilationUnit astcdCompilationUnit = this.parse("de", "monticore", "codegen", "symboltable", "Automaton"); decoratedSymbolCompilationUnit = this.parse("de", "monticore", "codegen", "symboltable", "AutomatonSymbolCD"); @@ -353,6 +350,7 @@ public static void assertOneOf(ASTMCType actualType, String... expected) { for (String exp : expected) { if (actual.equals(exp)) { result = true; + break; } } if (!result) { @@ -375,8 +373,8 @@ public void testGeneratedCode() { // Then ParseResult parseResult = new JavaParser(new ParserConfiguration()).parse(generate.toString()); - assertTrue("Parsing of the generated code failed. The generated code is: \n" - + generate, parseResult.isSuccessful()); + assertTrue(parseResult.isSuccessful(), + "Parsing of the generated code failed. The generated code is: \n" + generate); assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/CommonSymbolInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/CommonSymbolInterfaceDecoratorTest.java index 78d697f482..87ca957b81 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/CommonSymbolInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/CommonSymbolInterfaceDecoratorTest.java @@ -18,15 +18,15 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PUBLIC_ABSTRACT; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CommonSymbolInterfaceDecoratorTest extends DecoratorTestCase { @@ -42,7 +42,7 @@ public class CommonSymbolInterfaceDecoratorTest extends DecoratorTestCase { private static final String AUTOMATON_TRAVERSER = "de.monticore.codegen.ast.automaton._visitor.AutomatonTraverser"; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); @@ -141,7 +141,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolBuilderDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolBuilderDecoratorTest.java index e670afbe3d..9fb5b8f90d 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolBuilderDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolBuilderDecoratorTest.java @@ -21,8 +21,8 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PUBLIC; import static de.monticore.codegen.cd2java.DecoratorAssert.assertBoolean; @@ -30,9 +30,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class SymbolBuilderDecoratorTest extends DecoratorTestCase { @@ -52,7 +50,7 @@ public class SymbolBuilderDecoratorTest extends DecoratorTestCase { private static final String VALUE = "de.monticore.interpreter.Value"; - @Before + @BeforeEach public void setup() { this.mcTypeFacade = MCTypeFacade.getInstance(); @@ -474,7 +472,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolDecoratorTest.java index fea3ecfa0f..0ef717575e 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolDecoratorTest.java @@ -22,8 +22,8 @@ import de.monticore.types.MCTypeFacade; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.List; @@ -39,9 +39,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class SymbolDecoratorTest extends DecoratorTestCase { @@ -73,7 +71,7 @@ public class SymbolDecoratorTest extends DecoratorTestCase { private static final String AUTOMATON_TRAVERSER = "de.monticore.codegen.symboltable.automatonsymbolcd._visitor.AutomatonSymbolCDTraverser"; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); @@ -572,7 +570,7 @@ public void testGeneratedCodeAutomaton() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); @@ -608,9 +606,9 @@ public void testAttributeCountStateSymbol() { assertTrue(Log.getFindings().isEmpty()); } - @Test(expected = AssertionError.class) + @Test public void testSpannedScopeAttributeStateSymbol() { - getAttributeBy("spannedScope", symbolClassState); + assertThrows(AssertionError.class, () -> getAttributeBy("spannedScope", symbolClassState)); assertTrue(Log.getFindings().isEmpty()); } @@ -622,16 +620,16 @@ public void testMethodsStateSymbol() { assertTrue(Log.getFindings().isEmpty()); } - @Test(expected = AssertionError.class) + @Test public void testGetSpannedScopeMethodStateSymbol() { - getMethodBy("getSpannedScope", symbolClassState); + assertThrows(AssertionError.class, () -> getMethodBy("getSpannedScope", symbolClassState)); assertTrue(Log.getFindings().isEmpty()); } - @Test(expected = AssertionError.class) + @Test public void testSetSpannedScopeMethodStateSymbol() { - getMethodBy("setSpannedScope", symbolClassState); + assertThrows(AssertionError.class, () -> getMethodBy("setSpannedScope", symbolClassState)); assertTrue(Log.getFindings().isEmpty()); } @@ -727,7 +725,7 @@ public void testGeneratedCodeState() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolResolverInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolResolverInterfaceDecoratorTest.java index 0bb5ffdaa9..6c36187ef1 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolResolverInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolResolverInterfaceDecoratorTest.java @@ -10,17 +10,15 @@ import de.monticore.codegen.cd2java._symboltable.SymbolTableService; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PUBLIC_ABSTRACT; import static de.monticore.codegen.cd2java.DecoratorAssert.assertBoolean; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class SymbolResolverInterfaceDecoratorTest extends DecoratorTestCase { @@ -38,7 +36,7 @@ public class SymbolResolverInterfaceDecoratorTest extends DecoratorTestCase { private static final String ACCESS_MODIFIER = "de.monticore.symboltable.modifiers.AccessModifier"; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolSurrogateBuilderDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolSurrogateBuilderDecoratorTest.java index c240f344cb..8f54255ab6 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolSurrogateBuilderDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolSurrogateBuilderDecoratorTest.java @@ -19,8 +19,8 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PROTECTED; import static de.monticore.cd.facade.CDModifier.PUBLIC; @@ -28,9 +28,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class SymbolSurrogateBuilderDecoratorTest extends DecoratorTestCase { @@ -48,7 +46,7 @@ public class SymbolSurrogateBuilderDecoratorTest extends DecoratorTestCase { private static final String VALUE = "de.monticore.interpreter.Value"; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); @@ -272,7 +270,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolSurrogateDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolSurrogateDecoratorTest.java index bc93fbdfdd..d381157c19 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolSurrogateDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_symboltable/symbol/SymbolSurrogateDecoratorTest.java @@ -21,8 +21,8 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -34,9 +34,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class SymbolSurrogateDecoratorTest extends DecoratorTestCase { @@ -58,7 +56,7 @@ public class SymbolSurrogateDecoratorTest extends DecoratorTestCase { private static final String AUTOMATON_SYMBOL = "de.monticore.codegen.symboltable.automatonsymbolcd._symboltable.AutomatonSymbol"; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "symboltable", "AutomatonSymbolCD"); @@ -296,7 +294,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); @@ -312,7 +310,7 @@ public void testGeneratedCodeFoo() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/CDTraverserDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/CDTraverserDecoratorTest.java index 3571845f61..4df02add37 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/CDTraverserDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/CDTraverserDecoratorTest.java @@ -13,14 +13,14 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.io.paths.MCPath; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getInterfaceBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CDTraverserDecoratorTest extends DecoratorTestCase { @@ -28,7 +28,7 @@ public class CDTraverserDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedCompilationUnit; - @Before + @BeforeEach public void setUp() { originalCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/HandlerDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/HandlerDecoratorTest.java index 3a1de28831..0360925cbc 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/HandlerDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/HandlerDecoratorTest.java @@ -17,8 +17,8 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.Collectors; @@ -27,8 +27,8 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class HandlerDecoratorTest extends DecoratorTestCase { @@ -51,7 +51,7 @@ public class HandlerDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedCompilationUnit; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); @@ -261,7 +261,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/InheritanceHandlerDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/InheritanceHandlerDecoratorTest.java index 446f0e7cc7..8f37cbbb89 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/InheritanceHandlerDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/InheritanceHandlerDecoratorTest.java @@ -21,8 +21,8 @@ import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -31,8 +31,8 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class InheritanceHandlerDecoratorTest extends DecoratorTestCase { @@ -58,7 +58,7 @@ public class InheritanceHandlerDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedCompilationUnit; - @Before + @BeforeEach public void setUp() { this.glex = new GlobalExtensionManagement(); this.mcTypeFacade = MCTypeFacade.getInstance(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/TraverserClassDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/TraverserClassDecoratorTest.java index 8dd3efefd5..55f0e71549 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/TraverserClassDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/TraverserClassDecoratorTest.java @@ -17,8 +17,8 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PROTECTED; import static de.monticore.cd.facade.CDModifier.PUBLIC; @@ -27,8 +27,8 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertOptionalOf; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TraverserClassDecoratorTest extends DecoratorTestCase { @@ -48,7 +48,7 @@ public class TraverserClassDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedCompilationUnit; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); @@ -160,7 +160,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/TraverserInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/TraverserInterfaceDecoratorTest.java index b30e5e9573..24e5ff8ad0 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/TraverserInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/TraverserInterfaceDecoratorTest.java @@ -17,8 +17,8 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.Collectors; @@ -27,8 +27,8 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.*; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TraverserInterfaceDecoratorTest extends DecoratorTestCase { @@ -51,7 +51,7 @@ public class TraverserInterfaceDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedCompilationUnit; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/Visitor2DecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/Visitor2DecoratorTest.java index f71c52730a..efd29ddd40 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/Visitor2DecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/Visitor2DecoratorTest.java @@ -16,16 +16,16 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.types.MCTypeFacade; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.Collectors; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class Visitor2DecoratorTest extends DecoratorTestCase { @@ -55,7 +55,7 @@ public class Visitor2DecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedCompilationUnit; - @Before + @BeforeEach public void setUp() { this.mcTypeFacade = MCTypeFacade.getInstance(); @@ -255,7 +255,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/VisitorServiceTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/VisitorServiceTest.java index 7fa18f67b3..01056ebb93 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/VisitorServiceTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/_visitor/VisitorServiceTest.java @@ -8,14 +8,14 @@ import de.monticore.types.MCTypeFacade; import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class VisitorServiceTest extends DecoratorTestCase { @@ -29,7 +29,7 @@ public class VisitorServiceTest extends DecoratorTestCase { private MCTypeFacade mcTypeFacade; - @Before + @BeforeEach public void setup() { this.mcTypeFacade = MCTypeFacade.getInstance(); astcdCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/cli/CDCLIDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/cli/CDCLIDecoratorTest.java index 032f6ad111..079c7a66df 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/cli/CDCLIDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/cli/CDCLIDecoratorTest.java @@ -15,13 +15,13 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CDCLIDecoratorTest extends DecoratorTestCase { @@ -32,7 +32,7 @@ public class CDCLIDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit clonedCD; - @Before + @BeforeEach public void setup() { originalCD = parse("de", "monticore", "codegen", "ast", "Automaton"); clonedCD = originalCD.deepClone(); @@ -104,7 +104,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/cli/CLIDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/cli/CLIDecoratorTest.java index b1a98efd8c..700240bd26 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/cli/CLIDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/cli/CLIDecoratorTest.java @@ -16,16 +16,14 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PUBLIC; import static de.monticore.cd.facade.CDModifier.PUBLIC_STATIC; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.*; public class CLIDecoratorTest extends DecoratorTestCase { private static final String AST_AUTOMATON = "de.monticore.codegen.ast.automaton._ast.ASTAutomaton"; @@ -33,7 +31,7 @@ public class CLIDecoratorTest extends DecoratorTestCase { private static final String CLI_OPTIONS = "org.apache.commons.cli.Options"; private ASTCDClass cliClass; - @Before + @BeforeEach public void setup() { ASTCDCompilationUnit ast = parse("de", "monticore", "codegen", "ast", "Automaton"); this.glex.setGlobalValue("service", new AbstractService(ast)); @@ -284,7 +282,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/DataDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/DataDecoratorTest.java index 5bbfb29ead..64a0cfe3c3 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/DataDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/DataDecoratorTest.java @@ -21,8 +21,8 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PROTECTED; import static de.monticore.cd.facade.CDModifier.PUBLIC; @@ -34,15 +34,13 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.*; public class DataDecoratorTest extends DecoratorTestCase { private ASTCDClass dataClass; - @Before + @BeforeEach public void setUp() { ASTCDCompilationUnit cd = this.parse("de", "monticore", "codegen", "data", "Data"); ASTCDClass clazz = getClassBy("A", cd); @@ -288,7 +286,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); @@ -317,7 +315,7 @@ public void testGeneratedAutomatonCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/DataInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/DataInterfaceDecoratorTest.java index d1f756103e..328b9389e6 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/DataInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/DataInterfaceDecoratorTest.java @@ -18,22 +18,20 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PUBLIC_ABSTRACT; import static de.monticore.codegen.cd2java.DecoratorAssert.assertBoolean; 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 junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.*; public class DataInterfaceDecoratorTest extends DecoratorTestCase { private ASTCDInterface dataInterface; - @Before + @BeforeEach public void setUp() { ASTCDCompilationUnit cd = this.parse("de", "monticore", "codegen", "data", "DataInterface"); ASTCDInterface clazz = getInterfaceBy("ASTA", cd); @@ -199,7 +197,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/FullConstructorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/FullConstructorTest.java index 3f933e2729..a6532defcf 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/FullConstructorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/FullConstructorTest.java @@ -20,16 +20,16 @@ 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 org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PROTECTED; import static de.monticore.codegen.cd2java.DecoratorAssert.assertBoolean; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class FullConstructorTest extends DecoratorTestCase { @@ -39,7 +39,7 @@ public class FullConstructorTest extends DecoratorTestCase { private ASTCDClass subAClass; - @Before + @BeforeEach public void setup() { this.glex.setGlobalValue("astHelper", DecorationHelper.getInstance()); this.glex.setGlobalValue("cdPrinter", new CdUtilsPrinter()); @@ -128,7 +128,7 @@ public void testGeneratedCodeSubA() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); @@ -145,7 +145,7 @@ public void testGeneratedCodeSubB() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/ListSuffixDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/ListSuffixDecoratorTest.java index 72a287272e..333af42971 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/ListSuffixDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/data/ListSuffixDecoratorTest.java @@ -7,13 +7,14 @@ import de.monticore.codegen.cd2java.AbstractService; import de.monticore.codegen.cd2java.DecoratorTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ListSuffixDecoratorTest extends DecoratorTestCase { @@ -21,7 +22,7 @@ public class ListSuffixDecoratorTest extends DecoratorTestCase { private ASTCDClass originalClass; - @Before + @BeforeEach public void setUp() { ASTCDCompilationUnit cd = this.parse("de", "monticore", "codegen", "data", "Data"); @@ -43,9 +44,9 @@ public void testNoSBefore() { assertTrue(Log.getFindings().isEmpty()); } - @Test(expected = AssertionError.class) + @Test public void testWithSSBefore() { - getAttributeBy("lists", originalClass); + assertThrows(AssertionError.class, () -> getAttributeBy("lists", originalClass)); assertTrue(Log.getFindings().isEmpty()); } @@ -59,9 +60,9 @@ public void testWithSAfter() { assertTrue(Log.getFindings().isEmpty()); } - @Test(expected = AssertionError.class) + @Test public void testNoSAfter() { - getAttributeBy("list", classWithS); + assertThrows(AssertionError.class, () -> getAttributeBy("list", classWithS)); assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/interpreter/InterpreterDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/interpreter/InterpreterDecoratorTest.java index ec65a918c4..70e02545fc 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/interpreter/InterpreterDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/interpreter/InterpreterDecoratorTest.java @@ -12,17 +12,16 @@ import de.monticore.types.mcbasictypes._ast.ASTMCQualifiedType; import de.monticore.types.mccollectiontypes._ast.ASTMCMapType; import de.se_rwth.commons.logging.Log; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class InterpreterDecoratorTest extends DecoratorTestCase { @@ -31,7 +30,7 @@ public class InterpreterDecoratorTest extends DecoratorTestCase { protected ASTCDClass decoratedClass; - @Before + @BeforeEach public void before() { originalCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); VisitorService visitorService = new VisitorService(originalCompilationUnit); @@ -98,7 +97,7 @@ public void testClassAttributes() { assertEquals( "contextMap", attributes.get(2).getName()); - assertTrue(attributes.get(2).getMCType() instanceof ASTMCMapType); + assertInstanceOf(ASTMCMapType.class, attributes.get(2).getMCType()); assertEquals( InterpreterConstants.SYMBOL_FULLNAME, ((ASTMCMapType) attributes.get(2).getMCType()).getMCTypeArgument(0).printType()); @@ -189,7 +188,7 @@ public void testContextMethods() { ASTCDMethod getMapMethod = optGetMap.get(); assertTrue(getMapMethod.getCDParameterList().isEmpty()); - assertTrue(getMapMethod.getMCReturnType().getMCType() instanceof ASTMCMapType); + assertInstanceOf(ASTMCMapType.class, getMapMethod.getMCReturnType().getMCType()); assertEquals( InterpreterConstants.SYMBOL_FULLNAME, ((ASTMCMapType) getMapMethod.getMCReturnType().getMCType()).getMCTypeArgument(0).printType()); @@ -199,7 +198,7 @@ public void testContextMethods() { } @Test - @Ignore + @Disabled public void testInterpretMethods() { List interpretMethods = decoratedClass.getCDMethodList() .stream() @@ -214,7 +213,7 @@ public void testInterpretMethods() { assertEquals(InterpreterConstants.VALUE_FULLNAME, method.getMCReturnType().printType()); } - @After + @AfterEach public void after() { assertTrue(Log.getFindings().isEmpty()); Log.getFindings().clear(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/interpreter/InterpreterInterfaceDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/interpreter/InterpreterInterfaceDecoratorTest.java index f60ccf371e..f313da9e7a 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/interpreter/InterpreterInterfaceDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/interpreter/InterpreterInterfaceDecoratorTest.java @@ -9,16 +9,16 @@ import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import de.monticore.types.mcbasictypes._ast.ASTMCQualifiedType; import de.se_rwth.commons.logging.Log; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class InterpreterInterfaceDecoratorTest extends DecoratorTestCase { @@ -27,7 +27,7 @@ public class InterpreterInterfaceDecoratorTest extends DecoratorTestCase { protected ASTCDInterface decoratedInterface; - @Before + @BeforeEach public void before() { originalCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "Automaton"); VisitorService visitorService = new VisitorService(originalCompilationUnit); @@ -55,7 +55,7 @@ public void testSuperInterfaces() { } @Test - @Ignore + @Disabled public void testInterpretMethods() { List interpretMethods = decoratedInterface.getCDMethodList() .stream() @@ -72,7 +72,7 @@ public void testInterpretMethods() { assertTrue(method.getModifier().isAbstract()); } - @After + @AfterEach public void after() { assertTrue(Log.getFindings().isEmpty()); Log.getFindings().clear(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/ListAccessorDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/ListAccessorDecoratorTest.java index 7162860d4d..26fdba79f2 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/ListAccessorDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/ListAccessorDecoratorTest.java @@ -11,8 +11,8 @@ import de.monticore.types.MCTypeFacade; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -20,15 +20,15 @@ import static de.monticore.cd.facade.CDModifier.PUBLIC; import static de.monticore.codegen.cd2java.DecoratorAssert.*; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ListAccessorDecoratorTest extends DecoratorTestCase { private List methods; - @Before + @BeforeEach public void setup() { ASTMCType listType = MCTypeFacade.getInstance().createListTypeOf(String.class); ASTCDAttribute attribute = CDAttributeFacade.getInstance().createAttribute(PROTECTED.build(), listType, "a"); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/MandatoryAccessorDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/MandatoryAccessorDecoratorTest.java index 3d8ce6b681..b5283986ed 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/MandatoryAccessorDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/MandatoryAccessorDecoratorTest.java @@ -7,7 +7,7 @@ import de.monticore.codegen.cd2java.DecoratorTestCase; import de.monticore.codegen.cd2java.methods.accessor.MandatoryAccessorDecorator; import de.se_rwth.commons.logging.Log; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; @@ -15,8 +15,8 @@ import static de.monticore.cd.facade.CDModifier.PUBLIC; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MandatoryAccessorDecoratorTest extends DecoratorTestCase { diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/OptionalAccessorDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/OptionalAccessorDecoratorTest.java index 3ff866fca3..239c899ff8 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/OptionalAccessorDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/accessor/OptionalAccessorDecoratorTest.java @@ -11,9 +11,8 @@ import de.monticore.types.MCTypeFacade; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -22,14 +21,14 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertBoolean; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class OptionalAccessorDecoratorTest extends DecoratorTestCase { private List methods; - @Before + @BeforeEach public void setup() { // dummy cd needed for a good generated error Code ASTCDCompilationUnit cd = this.parse("de", "monticore", "codegen", "symboltable", "Automaton"); @@ -51,7 +50,7 @@ public void testMethods() { public void testGetMethod() { ASTCDMethod method = getMethodBy("getA", this.methods); assertTrue(method.getCDParameterList().isEmpty()); - Assert.assertTrue(method.getMCReturnType().isPresentMCType()); + assertTrue(method.getMCReturnType().isPresentMCType()); assertDeepEquals(String.class, method.getMCReturnType().getMCType()); assertDeepEquals(PUBLIC, method.getModifier()); @@ -61,7 +60,7 @@ public void testGetMethod() { @Test public void testIsPresentMethod() { ASTCDMethod method = getMethodBy("isPresentA", this.methods); - Assert.assertTrue(method.getMCReturnType().isPresentMCType()); + assertTrue(method.getMCReturnType().isPresentMCType()); assertBoolean(method.getMCReturnType().getMCType()); assertDeepEquals(PUBLIC, method.getModifier()); assertTrue(method.getCDParameterList().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/ListMutatorDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/ListMutatorDecoratorTest.java index 4a1f60ab63..2ca3a2192a 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/ListMutatorDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/ListMutatorDecoratorTest.java @@ -10,8 +10,8 @@ import de.monticore.types.MCTypeFacade; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.Collectors; @@ -24,15 +24,15 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertListOf; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodsBy; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ListMutatorDecoratorTest extends DecoratorTestCase { private List methods; - @Before + @BeforeEach public void setup() { ASTMCType listType = MCTypeFacade.getInstance().createListTypeOf(String.class); ASTCDAttribute attribute = CDAttributeFacade.getInstance().createAttribute(PROTECTED.build(), listType, "a"); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/MandatoryMutatorDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/MandatoryMutatorDecoratorTest.java index 339cd967c5..af7bad7181 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/MandatoryMutatorDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/MandatoryMutatorDecoratorTest.java @@ -8,8 +8,8 @@ import de.monticore.codegen.cd2java.DecoratorTestCase; import de.monticore.codegen.cd2java.methods.mutator.MandatoryMutatorDecorator; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -17,14 +17,14 @@ import static de.monticore.cd.facade.CDModifier.PUBLIC; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MandatoryMutatorDecoratorTest extends DecoratorTestCase { private List methods; - @Before + @BeforeEach public void setup() { ASTCDAttribute attribute = CDAttributeFacade.getInstance().createAttribute(PROTECTED.build(), String.class, "a"); MandatoryMutatorDecorator mandatoryMutatorDecorator = new MandatoryMutatorDecorator(glex); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/OptionalMutatorDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/OptionalMutatorDecoratorTest.java index e7fa870f40..aa64f1b909 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/OptionalMutatorDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/method/mutator/OptionalMutatorDecoratorTest.java @@ -10,8 +10,8 @@ import de.monticore.types.MCTypeFacade; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; @@ -19,14 +19,14 @@ import static de.monticore.cd.facade.CDModifier.PUBLIC; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class OptionalMutatorDecoratorTest extends DecoratorTestCase { private List methods; - @Before + @BeforeEach public void setup() { ASTMCType optionalType = MCTypeFacade.getInstance().createOptionalTypeOf(String.class); ASTCDAttribute attribute = CDAttributeFacade.getInstance().createAttribute(PROTECTED.build(), optionalType, "a"); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/CDAuxiliaryDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/CDAuxiliaryDecoratorTest.java index 08aab95ad4..814c0fe8a6 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/CDAuxiliaryDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/CDAuxiliaryDecoratorTest.java @@ -29,15 +29,14 @@ import de.monticore.codegen.cd2java.methods.AccessorDecorator; import de.monticore.codegen.cd2java.methods.MethodDecorator; import de.se_rwth.commons.logging.Log; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.Optional; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CDAuxiliaryDecoratorTest extends DecoratorTestCase { @@ -45,7 +44,7 @@ public class CDAuxiliaryDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedCompilationUnit; - @Before + @BeforeEach public void setUp() { originalCompilationUnit = this.parse("de", "monticore", "codegen", "symboltable", "Automaton"); @@ -90,7 +89,7 @@ protected ASTCDCompilationUnit getASTCD() { @Test public void testPackageName() { - Assert.assertTrue (decoratedCompilationUnit.getCDDefinition().getPackageWithName("de.monticore.codegen.symboltable.automaton._auxiliary").isPresent()); + assertTrue (decoratedCompilationUnit.getCDDefinition().getPackageWithName("de.monticore.codegen.symboltable.automaton._auxiliary").isPresent()); assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/CDMillDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/CDMillDecoratorTest.java index ce377069d2..a614478ab4 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/CDMillDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/CDMillDecoratorTest.java @@ -49,17 +49,16 @@ import de.monticore.codegen.cd2java.methods.MethodDecorator; import de.monticore.io.paths.MCPath; import de.se_rwth.commons.logging.Log; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.Optional; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CDMillDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit originalCompilationUnit; @@ -72,7 +71,7 @@ public class CDMillDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit clonedCD; - @Before + @BeforeEach public void setUp() { originalCompilationUnit = this.parse("de", "monticore", "codegen", "symboltable", "Automaton"); scopeCompilationUnit = this.parse("de", "monticore", "codegen", "symboltable", "AutomatonScopeCD"); @@ -168,7 +167,7 @@ public void testCompilationUnitNotChanged() { @Test public void testPackageName() { - Assert.assertTrue (decoratedCompilationUnit.getCDDefinition().getPackageWithName("de.monticore.codegen.symboltable.automaton").isPresent()); + assertTrue (decoratedCompilationUnit.getCDDefinition().getPackageWithName("de.monticore.codegen.symboltable.automaton").isPresent()); assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillDecoratorTest.java index f472606286..9305f5f5b9 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillDecoratorTest.java @@ -66,8 +66,8 @@ import de.monticore.io.paths.MCPath; import de.monticore.umlmodifier._ast.ASTModifier; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.util.ArrayList; @@ -82,8 +82,8 @@ import static de.monticore.codegen.cd2java._ast.ast_class.ASTConstants.AST_PACKAGE; import static de.monticore.codegen.cd2java._symboltable.SymbolTableConstants.SYMBOL_TABLE_PACKAGE; import static de.monticore.codegen.cd2java._visitor.VisitorConstants.VISITOR_PACKAGE; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MillDecoratorTest extends DecoratorTestCase { @@ -99,7 +99,7 @@ public class MillDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit clonedCD; - @Before + @BeforeEach public void setUp() { originalCompilationUnit = this.parse("de", "monticore", "codegen", "symboltable", "Automaton"); originalScopeCompilationUnit = this.parse("de", "monticore", "codegen", "symboltable", "AutomatonScopeCD"); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillForSuperDecoratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillForSuperDecoratorTest.java index 9a1e123a01..14e1934c8a 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillForSuperDecoratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillForSuperDecoratorTest.java @@ -11,16 +11,16 @@ import de.monticore.codegen.cd2java._parser.ParserService; import de.monticore.codegen.cd2java._visitor.VisitorService; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.Collectors; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MillForSuperDecoratorTest extends DecoratorTestCase { @@ -30,7 +30,7 @@ public class MillForSuperDecoratorTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedCompilationUnit; - @Before + @BeforeEach public void setUp() { decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "ast", "ExtAutomaton"); originalCompilationUnit = decoratedCompilationUnit.deepClone(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillWithInheritanceTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillWithInheritanceTest.java index a83dc52ecb..7d0c7fc090 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillWithInheritanceTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/mill/MillWithInheritanceTest.java @@ -40,16 +40,16 @@ import de.monticore.generating.GeneratorEngine; import de.monticore.generating.GeneratorSetup; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static de.monticore.cd.facade.CDModifier.PROTECTED; import static de.monticore.cd.facade.CDModifier.PROTECTED_STATIC; import static de.monticore.cd.facade.CDModifier.PUBLIC_STATIC; import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getMethodBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MillWithInheritanceTest extends DecoratorTestCase { @@ -59,7 +59,7 @@ public class MillWithInheritanceTest extends DecoratorTestCase { private ASTCDCompilationUnit decoratedCompilationUnit; - @Before + @BeforeEach public void setUp() { decoratedCompilationUnit = this.parse("de", "monticore", "codegen", "factory", "CGrammar"); ICD4CodeGlobalScope gs = CD4CodeMill.globalScope(); @@ -255,7 +255,7 @@ public void testGeneratedCode() { // test parsing ParserConfiguration configuration = new ParserConfiguration(); JavaParser parser = new JavaParser(configuration); - ParseResult parseResult = parser.parse(sb.toString()); + ParseResult parseResult = parser.parse(sb.toString()); assertTrue(parseResult.isSuccessful()); assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/typecd2java/TypeCD2JavaTest.java b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/typecd2java/TypeCD2JavaTest.java index 3d79b467fc..7a0f28c11c 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/cd2java/typecd2java/TypeCD2JavaTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/cd2java/typecd2java/TypeCD2JavaTest.java @@ -8,18 +8,16 @@ import de.monticore.types.mcbasictypes._ast.ASTMCQualifiedType; import de.monticore.types.mccollectiontypes._ast.ASTMCGenericType; import de.se_rwth.commons.logging.Log; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class TypeCD2JavaTest extends DecoratorTestCase { private ASTCDCompilationUnit cdCompilationUnit; - @Before + @BeforeEach public void setUp() { ICD4AnalysisGlobalScope globalScope = CD4AnalysisMill.globalScope(); cdCompilationUnit = parse("de", "monticore", "codegen", "ast", "Automaton"); @@ -32,7 +30,9 @@ public void setUp() { @Test public void testTypeJavaConformList() { - assertTrue(cdCompilationUnit.getCDDefinition().getCDClassesList().get(0).getCDAttributeList().get(1).getMCType() instanceof ASTMCGenericType); + assertInstanceOf(ASTMCGenericType.class, + cdCompilationUnit.getCDDefinition().getCDClassesList().get(0).getCDAttributeList().get(1) + .getMCType()); ASTMCGenericType simpleReferenceType = (ASTMCGenericType) cdCompilationUnit.getCDDefinition().getCDClassesList().get(0).getCDAttributeList().get(1).getMCType(); assertFalse(simpleReferenceType.getNameList().isEmpty()); assertEquals(3, simpleReferenceType.getNameList().size()); @@ -46,11 +46,14 @@ public void testTypeJavaConformList() { @Test public void testTypeJavaConformASTPackage() { //test that for AST classes the package is now java conform - assertTrue(cdCompilationUnit.getCDDefinition().getCDClassesList().get(0).getCDAttributeList().get(1).getMCType() instanceof ASTMCGenericType); + assertInstanceOf(ASTMCGenericType.class, + cdCompilationUnit.getCDDefinition().getCDClassesList().get(0).getCDAttributeList().get(1) + .getMCType()); ASTMCGenericType listType = (ASTMCGenericType) cdCompilationUnit.getCDDefinition().getCDClassesList().get(0).getCDAttributeList().get(1).getMCType(); assertEquals(1, listType.getMCTypeArgumentList().size()); assertTrue(listType.getMCTypeArgumentList().get(0).getMCTypeOpt().isPresent()); - assertTrue(listType.getMCTypeArgumentList().get(0).getMCTypeOpt().get() instanceof ASTMCQualifiedType); + assertInstanceOf(ASTMCQualifiedType.class, + listType.getMCTypeArgumentList().get(0).getMCTypeOpt().get()); ASTMCQualifiedType typeArgument = (ASTMCQualifiedType) listType.getMCTypeArgumentList().get(0).getMCTypeOpt().get(); assertEquals(7, typeArgument.getNameList().size()); assertEquals("de", typeArgument.getNameList().get(0)); @@ -67,7 +70,9 @@ public void testTypeJavaConformASTPackage() { @Test public void testStringType() { //test that types like String are not changed - assertTrue(cdCompilationUnit.getCDDefinition().getCDClassesList().get(0).getCDAttributeList().get(0).getMCType() instanceof ASTMCQualifiedType); + assertInstanceOf(ASTMCQualifiedType.class, + cdCompilationUnit.getCDDefinition().getCDClassesList().get(0).getCDAttributeList().get(0) + .getMCType()); ASTMCQualifiedType simpleReferenceType = (ASTMCQualifiedType) cdCompilationUnit.getCDDefinition().getCDClassesList().get(0).getCDAttributeList().get(0).getMCType(); assertFalse(simpleReferenceType.getNameList().isEmpty()); assertEquals(1, simpleReferenceType.getNameList().size()); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/manipul/RemoveRedundantReferencesManipulationTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/manipul/RemoveRedundantReferencesManipulationTest.java index 8b5bf2a9cc..a6a4da37c3 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/manipul/RemoveRedundantReferencesManipulationTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/manipul/RemoveRedundantReferencesManipulationTest.java @@ -9,11 +9,10 @@ import de.monticore.codegen.mc2cd.TranslationTestCase; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class RemoveRedundantReferencesManipulationTest extends TranslationTestCase { @@ -23,14 +22,14 @@ public void testGenericList() { TransformationHelper.createType("ASTReference"), "name", TransformationHelper.createType("java.util.List", "ASTReference")); - Assertions.assertEquals(2, cdClass.getCDAttributeList().size()); + assertEquals(2, cdClass.getCDAttributeList().size()); cdClass.setCDAttributeList(new RemoveRedundantAttributesManipulation() .removeRedundantAttributes(cdClass.getCDAttributeList())); - Assertions.assertEquals(1, cdClass.getCDAttributeList().size()); + assertEquals(1, cdClass.getCDAttributeList().size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private ASTCDClass setupCDClass(String firstReferenceName, ASTMCType firstReferenceType, diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/scopeTransl/CDScopeTranslationTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/scopeTransl/CDScopeTranslationTest.java index f74e8bab38..b24d302f67 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/scopeTransl/CDScopeTranslationTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/scopeTransl/CDScopeTranslationTest.java @@ -10,7 +10,6 @@ import de.monticore.codegen.mc2cd.TranslationTestCase; import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,8 +17,8 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CDScopeTranslationTest extends TranslationTestCase { @@ -33,50 +32,50 @@ public void setUp() { @Test public void testDefinitionName() { - Assertions.assertEquals("ScopeRuleScope", compilationUnit.getCDDefinition().getName()); + assertEquals("ScopeRuleScope", compilationUnit.getCDDefinition().getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPackage() { - Assertions.assertEquals(2, compilationUnit.getCDPackageList().size()); - Assertions.assertEquals("mc2cdtransformation", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(0)); - Assertions.assertEquals("scopeTransl", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(1)); + assertEquals(2, compilationUnit.getCDPackageList().size()); + assertEquals("mc2cdtransformation", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(0)); + assertEquals("scopeTransl", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(1)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testClassCount() { - Assertions.assertEquals(1, compilationUnit.getCDDefinition().getCDClassesList().size()); + assertEquals(1, compilationUnit.getCDDefinition().getCDClassesList().size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testClassSymbol() { ASTCDClass scopeClass = getClassBy("ScopeRule", compilationUnit); - Assertions.assertEquals(1, scopeClass.getCDAttributeList().size()); - Assertions.assertEquals(1, scopeClass.getCDMethodList().size()); - Assertions.assertEquals(1, scopeClass.getInterfaceList().size()); + assertEquals(1, scopeClass.getCDAttributeList().size()); + assertEquals(1, scopeClass.getCDMethodList().size()); + assertEquals(1, scopeClass.getInterfaceList().size()); - Assertions.assertTrue(scopeClass.getCDConstructorList().isEmpty()); - Assertions.assertTrue(scopeClass.isPresentCDExtendUsage()); + assertTrue(scopeClass.getCDConstructorList().isEmpty()); + assertTrue(scopeClass.isPresentCDExtendUsage()); ASTCDAttribute cdAttribute = scopeClass.getCDAttributeList().get(0); - Assertions.assertEquals("extraAttr", cdAttribute.getName()); + assertEquals("extraAttr", cdAttribute.getName()); assertDeepEquals(String.class, cdAttribute.getMCType()); assertDeepEquals(CDModifier.PROTECTED, cdAttribute.getModifier()); ASTCDMethod cdMethod = scopeClass.getCDMethodList().get(0); - Assertions.assertEquals("toString", cdMethod.getName()); - Assertions.assertTrue(cdMethod.getMCReturnType().isPresentMCType()); + assertEquals("toString", cdMethod.getName()); + assertTrue(cdMethod.getMCReturnType().isPresentMCType()); assertDeepEquals(String.class, cdMethod.getMCReturnType().getMCType()); - Assertions.assertTrue(cdMethod.getModifier().isPublic()); - Assertions.assertTrue(cdMethod.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, cdMethod.getModifier().getStereotype().sizeValues()); - Assertions.assertEquals("methodBody", cdMethod.getModifier().getStereotype().getValues(0).getName()); + assertTrue(cdMethod.getModifier().isPublic()); + assertTrue(cdMethod.getModifier().isPresentStereotype()); + assertEquals(1, cdMethod.getModifier().getStereotype().sizeValues()); + assertEquals("methodBody", cdMethod.getModifier().getStereotype().getValues(0).getName()); ASTMCObjectType cdInterface = scopeClass.getCDInterfaceUsage().getInterface(0); assertDeepEquals("de.monticore.symboltable.IScope", cdInterface); @@ -84,7 +83,7 @@ public void testClassSymbol() { ASTMCObjectType superclass = scopeClass.getCDExtendUsage().getSuperclass(0); assertDeepEquals("de.monticore.mcbasics._symboltable.IMCBasicsScope", superclass); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/symbolTransl/CDSymbolTranslationTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/symbolTransl/CDSymbolTranslationTest.java index 8a057a5b9b..e712143380 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/symbolTransl/CDSymbolTranslationTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/symbolTransl/CDSymbolTranslationTest.java @@ -10,7 +10,6 @@ import de.monticore.codegen.mc2cd.TranslationTestCase; import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,6 +17,7 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; +import static org.junit.jupiter.api.Assertions.*; public class CDSymbolTranslationTest extends TranslationTestCase { @@ -31,49 +31,49 @@ public void setUp() { @Test public void testDefinitionName() { - Assertions.assertEquals("SymbolRuleSymbols", compilationUnit.getCDDefinition().getName()); + assertEquals("SymbolRuleSymbols", compilationUnit.getCDDefinition().getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPackage() { - Assertions.assertEquals(2, compilationUnit.getCDPackageList().size()); - Assertions.assertEquals("mc2cdtransformation", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(0)); - Assertions.assertEquals("symbolTransl", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(1)); + assertEquals(2, compilationUnit.getCDPackageList().size()); + assertEquals("mc2cdtransformation", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(0)); + assertEquals("symbolTransl", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(1)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testClassCount() { - Assertions.assertEquals(4, compilationUnit.getCDDefinition().getCDClassesList().size()); + assertEquals(4, compilationUnit.getCDDefinition().getCDClassesList().size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testClassSymbol() { ASTCDClass symbolClassSymbol = getClassBy("SymbolClass", compilationUnit); - Assertions.assertEquals(1, symbolClassSymbol.getCDAttributeList().size()); - Assertions.assertEquals(1, symbolClassSymbol.getInterfaceList().size()); - Assertions.assertEquals(1, symbolClassSymbol.getCDMethodList().size()); - Assertions.assertTrue(symbolClassSymbol.getCDConstructorList().isEmpty()); - Assertions.assertTrue(symbolClassSymbol.isPresentCDExtendUsage()); + assertEquals(1, symbolClassSymbol.getCDAttributeList().size()); + assertEquals(1, symbolClassSymbol.getInterfaceList().size()); + assertEquals(1, symbolClassSymbol.getCDMethodList().size()); + assertTrue(symbolClassSymbol.getCDConstructorList().isEmpty()); + assertTrue(symbolClassSymbol.isPresentCDExtendUsage()); ASTCDAttribute cdAttribute = symbolClassSymbol.getCDAttributeList().get(0); - Assertions.assertEquals("extraString", cdAttribute.getName()); + assertEquals("extraString", cdAttribute.getName()); assertDeepEquals(String.class, cdAttribute.getMCType()); assertDeepEquals(CDModifier.PROTECTED, cdAttribute.getModifier()); ASTCDMethod cdMethod = symbolClassSymbol.getCDMethodList().get(0); - Assertions.assertEquals("toString", cdMethod.getName()); - Assertions.assertTrue(cdMethod.getMCReturnType().isPresentMCType()); + assertEquals("toString", cdMethod.getName()); + assertTrue(cdMethod.getMCReturnType().isPresentMCType()); assertDeepEquals(String.class, cdMethod.getMCReturnType().getMCType()); - Assertions.assertTrue(cdMethod.getModifier().isPublic()); - Assertions.assertTrue(cdMethod.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, cdMethod.getModifier().getStereotype().sizeValues()); - Assertions.assertEquals("methodBody", cdMethod.getModifier().getStereotype().getValues(0).getName()); + assertTrue(cdMethod.getModifier().isPublic()); + assertTrue(cdMethod.getModifier().isPresentStereotype()); + assertEquals(1, cdMethod.getModifier().getStereotype().sizeValues()); + assertEquals("methodBody", cdMethod.getModifier().getStereotype().getValues(0).getName()); ASTMCObjectType cdInterface = symbolClassSymbol.getInterfaceList().get(0); assertDeepEquals("de.monticore.symboltable.ISymbol", cdInterface); @@ -81,62 +81,62 @@ public void testClassSymbol() { ASTMCObjectType superclass = symbolClassSymbol.getCDExtendUsage().getSuperclass(0); assertDeepEquals("de.monticore.symboltable.Symbol", superclass); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testAbstractClassSymbol() { ASTCDClass symbolClassSymbol = getClassBy("SymbolAbstractClass", compilationUnit); - Assertions.assertEquals(1, symbolClassSymbol.getCDAttributeList().size()); - Assertions.assertTrue(symbolClassSymbol.getInterfaceList().isEmpty()); - Assertions.assertTrue(symbolClassSymbol.getCDMethodList().isEmpty()); - Assertions.assertTrue(symbolClassSymbol.getCDConstructorList().isEmpty()); - Assertions.assertFalse(symbolClassSymbol.isPresentCDExtendUsage()); + assertEquals(1, symbolClassSymbol.getCDAttributeList().size()); + assertTrue(symbolClassSymbol.getInterfaceList().isEmpty()); + assertTrue(symbolClassSymbol.getCDMethodList().isEmpty()); + assertTrue(symbolClassSymbol.getCDConstructorList().isEmpty()); + assertFalse(symbolClassSymbol.isPresentCDExtendUsage()); ASTCDAttribute cdAttribute = symbolClassSymbol.getCDAttributeList().get(0); - Assertions.assertEquals("extraString", cdAttribute.getName()); + assertEquals("extraString", cdAttribute.getName()); assertDeepEquals(String.class, cdAttribute.getMCType()); assertDeepEquals(CDModifier.PROTECTED, cdAttribute.getModifier()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInterfaceCount() { - Assertions.assertTrue(compilationUnit.getCDDefinition().getCDInterfacesList().isEmpty()); + assertTrue(compilationUnit.getCDDefinition().getCDInterfacesList().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInterfaceSymbol() { ASTCDClass symbolClassSymbol = getClassBy("SymbolInterface", compilationUnit); - Assertions.assertEquals(1, symbolClassSymbol.getCDAttributeList().size()); - Assertions.assertTrue(symbolClassSymbol.getInterfaceList().isEmpty()); - Assertions.assertTrue(symbolClassSymbol.getCDMethodList().isEmpty()); + assertEquals(1, symbolClassSymbol.getCDAttributeList().size()); + assertTrue(symbolClassSymbol.getInterfaceList().isEmpty()); + assertTrue(symbolClassSymbol.getCDMethodList().isEmpty()); ASTCDAttribute cdAttribute = symbolClassSymbol.getCDAttributeList().get(0); - Assertions.assertEquals("extraString", cdAttribute.getName()); + assertEquals("extraString", cdAttribute.getName()); assertDeepEquals(String.class, cdAttribute.getMCType()); assertDeepEquals(CDModifier.PROTECTED, cdAttribute.getModifier()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExternalSymbol() { ASTCDClass symbolClassSymbol = getClassBy("SymbolExternal", compilationUnit); - Assertions.assertEquals(1, symbolClassSymbol.getCDAttributeList().size()); - Assertions.assertTrue(symbolClassSymbol.getInterfaceList().isEmpty()); - Assertions.assertTrue(symbolClassSymbol.getCDMethodList().isEmpty()); + assertEquals(1, symbolClassSymbol.getCDAttributeList().size()); + assertTrue(symbolClassSymbol.getInterfaceList().isEmpty()); + assertTrue(symbolClassSymbol.getCDMethodList().isEmpty()); ASTCDAttribute cdAttribute = symbolClassSymbol.getCDAttributeList().get(0); - Assertions.assertEquals("extraString", cdAttribute.getName()); + assertEquals("extraString", cdAttribute.getName()); assertDeepEquals(String.class, cdAttribute.getMCType()); assertDeepEquals(CDModifier.PROTECTED, cdAttribute.getModifier()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/symbolTransl/SpanningScopeTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/symbolTransl/SpanningScopeTest.java index 2fe4f89a7a..da9544d8ae 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/symbolTransl/SpanningScopeTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/symbolTransl/SpanningScopeTest.java @@ -8,13 +8,13 @@ import de.monticore.umlstereotype._ast.ASTStereoValue; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; +import static org.junit.jupiter.api.Assertions.*; public class SpanningScopeTest extends TranslationTestCase { @@ -32,64 +32,64 @@ public void setUp() { @Test public void testDefinitionName() { - Assertions.assertEquals("ScopeSpanningSymbols", compilationUnit.getCDDefinition().getName()); + assertEquals("ScopeSpanningSymbols", compilationUnit.getCDDefinition().getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPackage() { - Assertions.assertEquals(2, compilationUnit.getCDPackageList().size()); - Assertions.assertEquals("mc2cdtransformation", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(0)); - Assertions.assertEquals("symbolTransl", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(1)); + assertEquals(2, compilationUnit.getCDPackageList().size()); + assertEquals("mc2cdtransformation", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(0)); + assertEquals("symbolTransl", compilationUnit.getMCPackageDeclaration().getMCQualifiedName().getParts(1)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testClassCount() { - Assertions.assertEquals(2, compilationUnit.getCDDefinition().getCDClassesList().size()); + assertEquals(2, compilationUnit.getCDDefinition().getCDClassesList().size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testScopeSpanningSymbol() { ASTCDClass symbolClassSymbol = getClassBy("ScopeSpanning", compilationUnit); - Assertions.assertTrue(symbolClassSymbol.getInterfaceList().isEmpty()); - Assertions.assertTrue(symbolClassSymbol.getCDMethodList().isEmpty()); - Assertions.assertTrue(symbolClassSymbol.getCDConstructorList().isEmpty()); - Assertions.assertFalse(symbolClassSymbol.isPresentCDExtendUsage()); - Assertions.assertTrue(symbolClassSymbol.getCDAttributeList().isEmpty()); + assertTrue(symbolClassSymbol.getInterfaceList().isEmpty()); + assertTrue(symbolClassSymbol.getCDMethodList().isEmpty()); + assertTrue(symbolClassSymbol.getCDConstructorList().isEmpty()); + assertFalse(symbolClassSymbol.isPresentCDExtendUsage()); + assertTrue(symbolClassSymbol.getCDAttributeList().isEmpty()); - Assertions.assertTrue(symbolClassSymbol.getModifier().isPresentStereotype()); - Assertions.assertFalse(symbolClassSymbol.getModifier().getStereotype().isEmptyValues()); - Assertions.assertEquals(2, symbolClassSymbol.getModifier().getStereotype().sizeValues()); + assertTrue(symbolClassSymbol.getModifier().isPresentStereotype()); + assertFalse(symbolClassSymbol.getModifier().getStereotype().isEmptyValues()); + assertEquals(2, symbolClassSymbol.getModifier().getStereotype().sizeValues()); ASTStereoValue symbolStereotype = symbolClassSymbol.getModifier().getStereotype().getValues(0); - Assertions.assertEquals("symbol", symbolStereotype.getName()); + assertEquals("symbol", symbolStereotype.getName()); ASTStereoValue scopeStereotype = symbolClassSymbol.getModifier().getStereotype().getValues(1); - Assertions.assertEquals("scope", scopeStereotype.getName()); + assertEquals("scope", scopeStereotype.getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testOnlySymbol() { ASTCDClass symbolClassSymbol = getClassBy("OnlySymbol", compilationUnit); - Assertions.assertTrue(symbolClassSymbol.getInterfaceList().isEmpty()); - Assertions.assertTrue(symbolClassSymbol.getCDMethodList().isEmpty()); - Assertions.assertTrue(symbolClassSymbol.getCDConstructorList().isEmpty()); - Assertions.assertFalse(symbolClassSymbol.isPresentCDExtendUsage()); - Assertions.assertTrue(symbolClassSymbol.getCDAttributeList().isEmpty()); + assertTrue(symbolClassSymbol.getInterfaceList().isEmpty()); + assertTrue(symbolClassSymbol.getCDMethodList().isEmpty()); + assertTrue(symbolClassSymbol.getCDConstructorList().isEmpty()); + assertFalse(symbolClassSymbol.isPresentCDExtendUsage()); + assertTrue(symbolClassSymbol.getCDAttributeList().isEmpty()); - Assertions.assertTrue(symbolClassSymbol.getModifier().isPresentStereotype()); - Assertions.assertFalse(symbolClassSymbol.getModifier().getStereotype().isEmptyValues()); - Assertions.assertEquals(2, symbolClassSymbol.getModifier().getStereotype().sizeValues()); + assertTrue(symbolClassSymbol.getModifier().isPresentStereotype()); + assertFalse(symbolClassSymbol.getModifier().getStereotype().isEmptyValues()); + assertEquals(2, symbolClassSymbol.getModifier().getStereotype().sizeValues()); ASTStereoValue symbolStereotype = symbolClassSymbol.getModifier().getStereotype().getValues(0); - Assertions.assertEquals("symbol", symbolStereotype.getName()); + assertEquals("symbol", symbolStereotype.getName()); ASTStereoValue startProdStereotype = symbolClassSymbol.getModifier().getStereotype().getValues(1); - Assertions.assertEquals("startProd", startProdStereotype.getName()); + assertEquals("startProd", startProdStereotype.getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AbstractProdTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AbstractProdTest.java index ecc24b651a..4f1e6a2be9 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AbstractProdTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AbstractProdTest.java @@ -8,7 +8,6 @@ import de.monticore.codegen.mc2cd.TranslationTestCase; import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,8 +15,8 @@ import java.util.List; import static de.monticore.codegen.mc2cd.TransformationHelper.typeToString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test for the proper transformation of ASTAbstractProds to corresponding @@ -53,12 +52,12 @@ public void setupAbstractProdTest() { @Test public void testAbstract() { - Assertions.assertTrue(astA.getModifier().isAbstract()); - Assertions.assertTrue(astB.getModifier().isAbstract()); - Assertions.assertTrue(astC.getModifier().isAbstract()); - Assertions.assertTrue(astD.getModifier().isAbstract()); + assertTrue(astA.getModifier().isAbstract()); + assertTrue(astB.getModifier().isAbstract()); + assertTrue(astC.getModifier().isAbstract()); + assertTrue(astD.getModifier().isAbstract()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -67,11 +66,11 @@ public void testAbstract() { */ @Test public void testExtends() { - Assertions.assertTrue(astA.isPresentCDExtendUsage()); + assertTrue(astA.isPresentCDExtendUsage()); String name = typeToString(astA.getCDExtendUsage().getSuperclass(0)); - Assertions.assertEquals("mc2cdtransformation.AbstractProd.ASTextendedProd", name); + assertEquals("mc2cdtransformation.AbstractProd.ASTextendedProd", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -81,11 +80,11 @@ public void testExtends() { @Test public void testImplements() { List superInterfaces = astB.getInterfaceList(); - Assertions.assertEquals(1, superInterfaces.size()); + assertEquals(1, superInterfaces.size()); String name = typeToString(superInterfaces.get(0)); - Assertions.assertEquals("mc2cdtransformation.AbstractProd.ASTimplementedProd", name); + assertEquals("mc2cdtransformation.AbstractProd.ASTimplementedProd", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -94,11 +93,11 @@ public void testImplements() { */ @Test public void testAstextends() { - Assertions.assertTrue(astC.isPresentCDExtendUsage()); + assertTrue(astC.isPresentCDExtendUsage()); String name = typeToString(astC.getCDExtendUsage().getSuperclass(0)); - Assertions.assertEquals("AstExtendedType", name); + assertEquals("AstExtendedType", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -108,11 +107,11 @@ public void testAstextends() { @Test public void testAstimplements() { List superInterfaces = astD.getInterfaceList(); - Assertions.assertEquals(1, superInterfaces.size()); + assertEquals(1, superInterfaces.size()); String name = typeToString(superInterfaces.get(0)); - Assertions.assertEquals("AstImplementedType", name); + assertEquals("AstImplementedType", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -121,11 +120,11 @@ public void testAstimplements() { */ @Test public void testAstextendsQualified() { - Assertions.assertTrue(astE.isPresentCDExtendUsage()); + assertTrue(astE.isPresentCDExtendUsage()); String name = typeToString(astE.getCDExtendUsage().getSuperclass(0)); - Assertions.assertEquals("java.util.Observable", name); + assertEquals("java.util.Observable", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -135,10 +134,10 @@ public void testAstextendsQualified() { @Test public void testAstimplementsQualified() { List superInterfaces = astF.getInterfaceList(); - Assertions.assertEquals(1, superInterfaces.size()); + assertEquals(1, superInterfaces.size()); String name = typeToString(superInterfaces.get(0)); - Assertions.assertEquals("java.io.Serializable", name); + assertEquals("java.io.Serializable", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AstRuleInheritanceTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AstRuleInheritanceTest.java index 811bc0520b..dc70aea89a 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AstRuleInheritanceTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AstRuleInheritanceTest.java @@ -10,7 +10,6 @@ import de.monticore.codegen.mc2cd.TranslationTestCase; import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -19,6 +18,7 @@ import java.util.Optional; import static de.monticore.codegen.mc2cd.TransformationHelper.typeToString; +import static org.junit.jupiter.api.Assertions.*; /** * tests astextends and astimplements functionality at astrules @@ -49,12 +49,12 @@ public void setUp() { Optional asteOpt = TestHelper.getCDInterface(cdCompilationUnit, "ASTE"); Optional astfOpt = TestHelper.getCDClass(cdCompilationUnit, "ASTF"); - Assertions.assertTrue(astaOpt.isPresent()); - Assertions.assertTrue(astbOpt.isPresent()); - Assertions.assertTrue(astcOpt.isPresent()); - Assertions.assertTrue(astdOpt.isPresent()); - Assertions.assertTrue(asteOpt.isPresent()); - Assertions.assertTrue(astfOpt.isPresent()); + assertTrue(astaOpt.isPresent()); + assertTrue(astbOpt.isPresent()); + assertTrue(astcOpt.isPresent()); + assertTrue(astdOpt.isPresent()); + assertTrue(asteOpt.isPresent()); + assertTrue(astfOpt.isPresent()); astA = astaOpt.get(); astB = astbOpt.get(); @@ -69,23 +69,23 @@ public void setUp() { */ @Test public void testAstSuperClass() { - Assertions.assertTrue(astA.isPresentCDExtendUsage()); + assertTrue(astA.isPresentCDExtendUsage()); String name = typeToString(astA.getCDExtendUsage().getSuperclass(0)); - Assertions.assertEquals("ASTExternalProd", name); + assertEquals("ASTExternalProd", name); - Assertions.assertTrue(astC.isPresentCDExtendUsage()); + assertTrue(astC.isPresentCDExtendUsage()); name = typeToString(astC.getCDExtendUsage().getSuperclass(0)); - Assertions.assertEquals("mc2cdtransformation.AstRuleInheritance.ASTA", name); + assertEquals("mc2cdtransformation.AstRuleInheritance.ASTA", name); - Assertions.assertTrue(astD.isPresentCDExtendUsage()); + assertTrue(astD.isPresentCDExtendUsage()); name = typeToString(astD.getCDExtendUsage().getSuperclass(0)); - Assertions.assertEquals("mc2cdtransformation.Supergrammar.ASTSuperProd", name); + assertEquals("mc2cdtransformation.Supergrammar.ASTSuperProd", name); - Assertions.assertTrue(astF.isPresentCDExtendUsage()); + assertTrue(astF.isPresentCDExtendUsage()); name = typeToString(astF.getCDExtendUsage().getSuperclass(0)); - Assertions.assertEquals("java.util.Observable", name); + assertEquals("java.util.Observable", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -94,26 +94,29 @@ public void testAstSuperClass() { */ @Test public void testStereotypesForAstSuperclass() { - Assertions.assertTrue(astA.getModifier().isPresentStereotype()); + assertTrue(astA.getModifier().isPresentStereotype()); // one stereotype for the startProd flag and one for the checked external type - Assertions.assertEquals(2, astA.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals(astA.getModifier().getStereotype().getValuesList().get(0).getName(), MC2CDStereotypes.EXTERNAL_TYPE.toString()); - Assertions.assertFalse(astA.getModifier().getStereotype().getValuesList().get(0).getValue().isEmpty()); - Assertions.assertEquals(astA.getModifier().getStereotype().getValuesList().get(0).getValue(), "ASTExternalProd"); - - Assertions.assertTrue(astF.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, astF.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals(astF.getModifier().getStereotype().getValuesList().get(0).getName(), MC2CDStereotypes.EXTERNAL_TYPE.toString()); - Assertions.assertFalse(astF.getModifier().getStereotype().getValuesList().get(0).getValue().isEmpty()); - Assertions.assertEquals(astF.getModifier().getStereotype().getValuesList().get(0).getValue(), "java.util.Observable"); - - Assertions.assertTrue(astD.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, astD.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals(astD.getModifier().getStereotype().getValuesList().get(0).getName(), MC2CDStereotypes.EXTERNAL_TYPE.toString()); - Assertions.assertFalse(astD.getModifier().getStereotype().getValuesList().get(0).getValue().isEmpty()); - Assertions.assertEquals(astD.getModifier().getStereotype().getValuesList().get(0).getValue(), "java.io.Serializable"); + assertEquals(2, astA.getModifier().getStereotype().getValuesList().size()); + assertEquals(astA.getModifier().getStereotype().getValuesList().get(0).getName(), MC2CDStereotypes.EXTERNAL_TYPE.toString()); + assertFalse(astA.getModifier().getStereotype().getValuesList().get(0).getValue().isEmpty()); + assertEquals("ASTExternalProd", + astA.getModifier().getStereotype().getValuesList().get(0).getValue()); + + assertTrue(astF.getModifier().isPresentStereotype()); + assertEquals(1, astF.getModifier().getStereotype().getValuesList().size()); + assertEquals(astF.getModifier().getStereotype().getValuesList().get(0).getName(), MC2CDStereotypes.EXTERNAL_TYPE.toString()); + assertFalse(astF.getModifier().getStereotype().getValuesList().get(0).getValue().isEmpty()); + assertEquals("java.util.Observable", + astF.getModifier().getStereotype().getValuesList().get(0).getValue()); + + assertTrue(astD.getModifier().isPresentStereotype()); + assertEquals(1, astD.getModifier().getStereotype().getValuesList().size()); + assertEquals(astD.getModifier().getStereotype().getValuesList().get(0).getName(), MC2CDStereotypes.EXTERNAL_TYPE.toString()); + assertFalse(astD.getModifier().getStereotype().getValuesList().get(0).getValue().isEmpty()); + assertEquals("java.io.Serializable", + astD.getModifier().getStereotype().getValuesList().get(0).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -122,16 +125,18 @@ public void testStereotypesForAstSuperclass() { */ @Test public void testStereotypesForAstInterfaces() { - Assertions.assertTrue(astE.getModifier().isPresentStereotype()); - Assertions.assertEquals(2, astE.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals(astE.getModifier().getStereotype().getValuesList().get(0).getName(), MC2CDStereotypes.EXTERNAL_TYPE.toString()); - Assertions.assertFalse(astE.getModifier().getStereotype().getValuesList().get(0).getValue().isEmpty()); - Assertions.assertEquals(astE.getModifier().getStereotype().getValuesList().get(0).getValue(), "ASTExternalInterface"); - Assertions.assertEquals(astE.getModifier().getStereotype().getValuesList().get(1).getName(), MC2CDStereotypes.EXTERNAL_TYPE.toString()); - Assertions.assertFalse(astE.getModifier().getStereotype().getValuesList().get(1).getValue().isEmpty()); - Assertions.assertEquals(astE.getModifier().getStereotype().getValuesList().get(1).getValue(), "java.io.Serializable"); + assertTrue(astE.getModifier().isPresentStereotype()); + assertEquals(2, astE.getModifier().getStereotype().getValuesList().size()); + assertEquals(astE.getModifier().getStereotype().getValuesList().get(0).getName(), MC2CDStereotypes.EXTERNAL_TYPE.toString()); + assertFalse(astE.getModifier().getStereotype().getValuesList().get(0).getValue().isEmpty()); + assertEquals("ASTExternalInterface", + astE.getModifier().getStereotype().getValuesList().get(0).getValue()); + assertEquals(astE.getModifier().getStereotype().getValuesList().get(1).getName(), MC2CDStereotypes.EXTERNAL_TYPE.toString()); + assertFalse(astE.getModifier().getStereotype().getValuesList().get(1).getValue().isEmpty()); + assertEquals("java.io.Serializable", + astE.getModifier().getStereotype().getValuesList().get(1).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -141,15 +146,15 @@ public void testStereotypesForAstInterfaces() { @Test public void testASTExtendsAndImplements() { List superInterfaces = astD.getInterfaceList(); - Assertions.assertEquals(3, superInterfaces.size()); + assertEquals(3, superInterfaces.size()); String name = typeToString(superInterfaces.get(0)); - Assertions.assertEquals("mc2cdtransformation.AstRuleInheritance.ASTB", name); + assertEquals("mc2cdtransformation.AstRuleInheritance.ASTB", name); name = typeToString(superInterfaces.get(1)); - Assertions.assertEquals("mc2cdtransformation.Supergrammar.ASTSuperInterface", name); + assertEquals("mc2cdtransformation.Supergrammar.ASTSuperInterface", name); name = typeToString(superInterfaces.get(2)); - Assertions.assertEquals("java.io.Serializable", name); + assertEquals("java.io.Serializable", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -159,17 +164,17 @@ public void testASTExtendsAndImplements() { @Test public void testAstInterfaces() { List superInterfaces = astE.getInterfaceList(); - Assertions.assertEquals(4, superInterfaces.size()); + assertEquals(4, superInterfaces.size()); String name = typeToString(superInterfaces.get(0)); - Assertions.assertEquals("mc2cdtransformation.AstRuleInheritance.ASTB", name); + assertEquals("mc2cdtransformation.AstRuleInheritance.ASTB", name); name = typeToString(superInterfaces.get(1)); - Assertions.assertEquals("mc2cdtransformation.Supergrammar.ASTSuperInterface", name); + assertEquals("mc2cdtransformation.Supergrammar.ASTSuperInterface", name); name = typeToString(superInterfaces.get(2)); - Assertions.assertEquals("ASTExternalInterface", name); + assertEquals("ASTExternalInterface", name); name = typeToString(superInterfaces.get(3)); - Assertions.assertEquals("java.io.Serializable", name); + assertEquals("java.io.Serializable", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AstRuleTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AstRuleTest.java index 9ca5a8db06..248e73a98e 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AstRuleTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AstRuleTest.java @@ -8,7 +8,6 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -17,8 +16,8 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorAssert.assertInt; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getAttributeBy; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * this test checks the addition of attributes with astrules @@ -39,17 +38,17 @@ public void setUpASTRuleTest() { @Test public void testAstRuleAddedAttribute() { - Assertions.assertEquals(1, astC.getCDAttributeList().size()); - Assertions.assertEquals("dimensions", astC.getCDAttributeList().get(0).getName()); + assertEquals(1, astC.getCDAttributeList().size()); + assertEquals("dimensions", astC.getCDAttributeList().get(0).getName()); assertInt(astC.getCDAttributeList().get(0).getMCType()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testAstRuleDoubleInheritance() { // attributes from super interfaces are inherited - Assertions.assertEquals(2, impl.getCDAttributeList().size()); + assertEquals(2, impl.getCDAttributeList().size()); ASTCDAttribute varName = getAttributeBy("varName", impl); assertDeepEquals("varType", varName.getMCType()); @@ -57,7 +56,7 @@ public void testAstRuleDoubleInheritance() { ASTCDAttribute varName2 = getAttributeBy("varName2", impl); assertDeepEquals("varType2", varName2.getMCType()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTMultiplicityTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTMultiplicityTest.java index fe9cea2189..84b64d0885 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTMultiplicityTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTMultiplicityTest.java @@ -8,7 +8,6 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,8 +15,8 @@ import java.util.List; import static de.monticore.codegen.mc2cd.TransformationHelper.typeToString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test for the proper transformation of AttributeInASTs to corresponding @@ -48,10 +47,10 @@ public void setupAttributeInASTMultiplicityTest() { @Test public void testStarMultiplicity() { List attributes = astA.getCDAttributeList(); - Assertions.assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), + assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), "mc2cdtransformation.AttributeInASTMultiplicityGrammar.ASTX")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -62,17 +61,17 @@ public void testStarMultiplicity() { public void testOptionalCardinality() { List attributes = astB.getCDAttributeList(); String name = typeToString(attributes.get(0).getMCType()); - Assertions.assertEquals("Optional", name); + assertEquals("Optional", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testOneCardinality() { List attributes = astC.getCDAttributeList(); String name = typeToString(attributes.get(0).getMCType()); - Assertions.assertEquals("mc2cdtransformation.AttributeInASTMultiplicityGrammar.ASTZ", name); + assertEquals("mc2cdtransformation.AttributeInASTMultiplicityGrammar.ASTZ", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTOverridingTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTOverridingTest.java index 6e45e4f186..53f4a457dd 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTOverridingTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTOverridingTest.java @@ -9,15 +9,14 @@ import de.monticore.codegen.mc2cd.TransformationHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests that attributes that are redefined in ASTRules correctly override their counterparts in the @@ -36,23 +35,23 @@ public void setupAttributeInASTOverridingTest() { astA = TestHelper.getCDClass(cdCompilationUnit, "ASTA").get(); astB = TestHelper.getCDClass(cdCompilationUnit, "ASTB").get(); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testAttributeOverridden() { List attributes = astA.getCDAttributeList(); - Assertions.assertEquals(1, attributes.size()); - Assertions.assertEquals("mc2cdtransformation.AttributeInASTOverridingGrammar.ASTY", TransformationHelper.typeToString(attributes.get(0).getMCType())); + assertEquals(1, attributes.size()); + assertEquals("mc2cdtransformation.AttributeInASTOverridingGrammar.ASTY", TransformationHelper.typeToString(attributes.get(0).getMCType())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testAttributeNotOverridden() { List attributes = astB.getCDAttributeList(); - Assertions.assertEquals(2, attributes.size()); + assertEquals(2, attributes.size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTTypeTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTTypeTest.java index a6c00c94a2..ab8f566ae0 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTTypeTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/AttributeInASTTypeTest.java @@ -9,14 +9,13 @@ import de.monticore.codegen.mc2cd.TranslationTestCase; import de.monticore.types.mcbasictypes._ast.ASTMCPrimitiveType; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class AttributeInASTTypeTest extends TranslationTestCase { @@ -34,9 +33,9 @@ public void testType() { astA.getCDAttributeList().stream() .map(ASTCDAttribute::getMCType) .map(Object::getClass) - .forEach(type -> Assertions.assertEquals(ASTMCPrimitiveType.class, type)); + .forEach(type -> assertEquals(ASTMCPrimitiveType.class, type)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ComponetTranslationTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ComponetTranslationTest.java index a2d4548df3..295bcdedab 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ComponetTranslationTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ComponetTranslationTest.java @@ -5,12 +5,13 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; +import static org.junit.jupiter.api.Assertions.*; + public class ComponetTranslationTest extends TranslationTestCase { private ASTCDCompilationUnit componentCD; @@ -27,19 +28,19 @@ public void setUp() { @Test public void testIsComponent() { - Assertions.assertTrue(componentCD.getCDDefinition().getModifier().isPresentStereotype()); - Assertions.assertEquals(1, componentCD.getCDDefinition().getModifier().getStereotype().sizeValues()); - Assertions.assertEquals("component", componentCD.getCDDefinition().getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(componentCD.getCDDefinition().getModifier().getStereotype().getValues(0).isPresentText()); + assertTrue(componentCD.getCDDefinition().getModifier().isPresentStereotype()); + assertEquals(1, componentCD.getCDDefinition().getModifier().getStereotype().sizeValues()); + assertEquals("component", componentCD.getCDDefinition().getModifier().getStereotype().getValues(0).getName()); + assertFalse(componentCD.getCDDefinition().getModifier().getStereotype().getValues(0).isPresentText()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testIsNotComponent() { - Assertions.assertFalse(nonComponentCD.getCDDefinition().getModifier().isPresentStereotype()); + assertFalse(nonComponentCD.getCDDefinition().getModifier().isPresentStereotype()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/DerivedAttributeNameTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/DerivedAttributeNameTest.java index 2aab1eedeb..1bc006a7b5 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/DerivedAttributeNameTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/DerivedAttributeNameTest.java @@ -8,13 +8,14 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class DerivedAttributeNameTest extends TranslationTestCase { private ASTCDCompilationUnit compilationUnit; @@ -36,58 +37,58 @@ protected boolean hasDerivedAttributeName(ASTCDAttribute astcdAttribute) { @Test public void testFoo() { Optional fooClass = TestHelper.getCDClass(compilationUnit, "ASTFoo"); - Assertions.assertTrue(fooClass.isPresent()); - Assertions.assertEquals(1, fooClass.get().getCDAttributeList().size()); - Assertions.assertEquals("foo", fooClass.get().getCDAttributeList().get(0).getName()); - Assertions.assertFalse(hasDerivedAttributeName(fooClass.get().getCDAttributeList().get(0))); + assertTrue(fooClass.isPresent()); + assertEquals(1, fooClass.get().getCDAttributeList().size()); + assertEquals("foo", fooClass.get().getCDAttributeList().get(0).getName()); + assertFalse(hasDerivedAttributeName(fooClass.get().getCDAttributeList().get(0))); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBar() { Optional bar = TestHelper.getCDClass(compilationUnit, "ASTBar"); - Assertions.assertTrue(bar.isPresent()); - Assertions.assertEquals(2, bar.get().getCDAttributeList().size()); - Assertions.assertEquals("abc", bar.get().getCDAttributeList().get(0).getName()); - Assertions.assertFalse(hasDerivedAttributeName(bar.get().getCDAttributeList().get(0))); - Assertions.assertEquals("d", bar.get().getCDAttributeList().get(1).getName()); - Assertions.assertTrue(hasDerivedAttributeName(bar.get().getCDAttributeList().get(1))); + assertTrue(bar.isPresent()); + assertEquals(2, bar.get().getCDAttributeList().size()); + assertEquals("abc", bar.get().getCDAttributeList().get(0).getName()); + assertFalse(hasDerivedAttributeName(bar.get().getCDAttributeList().get(0))); + assertEquals("d", bar.get().getCDAttributeList().get(1).getName()); + assertTrue(hasDerivedAttributeName(bar.get().getCDAttributeList().get(1))); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBlub() { Optional blub = TestHelper.getCDClass(compilationUnit, "ASTBlub"); - Assertions.assertTrue(blub.isPresent()); - Assertions.assertEquals(4, blub.get().getCDAttributeList().size()); - Assertions.assertEquals("foo", blub.get().getCDAttributeList().get(0).getName()); - Assertions.assertTrue(hasDerivedAttributeName(blub.get().getCDAttributeList().get(0))); - Assertions.assertEquals("bar2", blub.get().getCDAttributeList().get(1).getName()); - Assertions.assertFalse(hasDerivedAttributeName(blub.get().getCDAttributeList().get(1))); - Assertions.assertEquals("fooOpt", blub.get().getCDAttributeList().get(2).getName()); - Assertions.assertFalse(hasDerivedAttributeName(blub.get().getCDAttributeList().get(2))); - Assertions.assertEquals("efg", blub.get().getCDAttributeList().get(3).getName()); - Assertions.assertFalse(hasDerivedAttributeName(blub.get().getCDAttributeList().get(3))); + assertTrue(blub.isPresent()); + assertEquals(4, blub.get().getCDAttributeList().size()); + assertEquals("foo", blub.get().getCDAttributeList().get(0).getName()); + assertTrue(hasDerivedAttributeName(blub.get().getCDAttributeList().get(0))); + assertEquals("bar2", blub.get().getCDAttributeList().get(1).getName()); + assertFalse(hasDerivedAttributeName(blub.get().getCDAttributeList().get(1))); + assertEquals("fooOpt", blub.get().getCDAttributeList().get(2).getName()); + assertFalse(hasDerivedAttributeName(blub.get().getCDAttributeList().get(2))); + assertEquals("efg", blub.get().getCDAttributeList().get(3).getName()); + assertFalse(hasDerivedAttributeName(blub.get().getCDAttributeList().get(3))); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testTest() { Optional test = TestHelper.getCDClass(compilationUnit, "ASTTest"); - Assertions.assertTrue(test.isPresent()); - Assertions.assertEquals(4, test.get().getCDAttributeList().size()); - Assertions.assertEquals("blub", test.get().getCDAttributeList().get(0).getName()); - Assertions.assertTrue(hasDerivedAttributeName(test.get().getCDAttributeList().get(0))); - Assertions.assertEquals("faa", test.get().getCDAttributeList().get(1).getName()); - Assertions.assertFalse(hasDerivedAttributeName(test.get().getCDAttributeList().get(1))); - Assertions.assertEquals("bar", test.get().getCDAttributeList().get(2).getName()); - Assertions.assertTrue(hasDerivedAttributeName(test.get().getCDAttributeList().get(2))); - Assertions.assertEquals("k", test.get().getCDAttributeList().get(3).getName()); - Assertions.assertFalse(hasDerivedAttributeName(test.get().getCDAttributeList().get(3))); + assertTrue(test.isPresent()); + assertEquals(4, test.get().getCDAttributeList().size()); + assertEquals("blub", test.get().getCDAttributeList().get(0).getName()); + assertTrue(hasDerivedAttributeName(test.get().getCDAttributeList().get(0))); + assertEquals("faa", test.get().getCDAttributeList().get(1).getName()); + assertFalse(hasDerivedAttributeName(test.get().getCDAttributeList().get(1))); + assertEquals("bar", test.get().getCDAttributeList().get(2).getName()); + assertTrue(hasDerivedAttributeName(test.get().getCDAttributeList().get(2))); + assertEquals("k", test.get().getCDAttributeList().get(3).getName()); + assertFalse(hasDerivedAttributeName(test.get().getCDAttributeList().get(3))); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/DirectLeftRecursionDetectorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/DirectLeftRecursionDetectorTest.java index 5f94929a17..54000306ac 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/DirectLeftRecursionDetectorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/DirectLeftRecursionDetectorTest.java @@ -8,7 +8,6 @@ import de.monticore.grammar.grammar._ast.ASTMCGrammar; import de.monticore.grammar.grammar_withconcepts.Grammar_WithConceptsMill; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,7 +17,8 @@ import java.util.List; import java.util.Optional; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests the helper class on a concrete grammar containing left recursive and normal rules. @@ -34,7 +34,7 @@ public class DirectLeftRecursionDetectorTest extends TranslationTestCase { public void setup() throws IOException { final Path modelPath = Paths.get("src/test/resources/mc2cdtransformation/DirectLeftRecursionDetector.mc4"); astMCGrammarOptional =Grammar_WithConceptsMill.parser().parse(modelPath.toString());; - Assertions.assertTrue(astMCGrammarOptional.isPresent()); + assertTrue(astMCGrammarOptional.isPresent()); } @Test @@ -44,17 +44,17 @@ public void testRecursiveRule() { final ASTClassProd exprProduction = productions.get(0); boolean isLeftRecursive = directLeftRecursionDetector.isAlternativeLeftRecursive(exprProduction.getAlt(0), exprProduction.getName()); - Assertions.assertTrue(isLeftRecursive); + assertTrue(isLeftRecursive); final ASTClassProd nonRecursiveProudction1 = productions.get(1); isLeftRecursive = directLeftRecursionDetector.isAlternativeLeftRecursive(nonRecursiveProudction1.getAlt(0), nonRecursiveProudction1.getName()); - Assertions.assertFalse(isLeftRecursive); + assertFalse(isLeftRecursive); final ASTClassProd nonRecursiveProudction2 = productions.get(2); isLeftRecursive = directLeftRecursionDetector.isAlternativeLeftRecursive(nonRecursiveProudction2.getAlt(0), nonRecursiveProudction2.getName()); - Assertions.assertFalse(isLeftRecursive); + assertFalse(isLeftRecursive); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/EnumProdTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/EnumProdTest.java index 3e1f6cd38f..e2667de1d8 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/EnumProdTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/EnumProdTest.java @@ -6,15 +6,14 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class EnumProdTest extends TranslationTestCase { @@ -29,8 +28,8 @@ public void setupEnumProdTest() { @Test public void testExist() { - Assertions.assertEquals(4, cdCompilationUnit.getCDDefinition().getCDEnumsList().size()); + assertEquals(4, cdCompilationUnit.getCDDefinition().getCDEnumsList().size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ExternalImplementationTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ExternalImplementationTest.java index 3d1c9f088b..38f74cac6b 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ExternalImplementationTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ExternalImplementationTest.java @@ -9,14 +9,12 @@ import de.monticore.codegen.mc2cd.TranslationTestCase; import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ExternalImplementationTest extends TranslationTestCase { @@ -32,10 +30,10 @@ public void setupExternalImplementationTest() { @Test public void testExternalImplementation() { ASTMCObjectType cdInterface = astZ.getInterfaceList().get(0); - Assertions.assertTrue(cdInterface != null); + assertNotNull(cdInterface); String name = TransformationHelper.typeToString(cdInterface); - Assertions.assertEquals("mc2cdtransformation.Supergrammar.ASTZExt", name); + assertEquals("mc2cdtransformation.Supergrammar.ASTZExt", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ExternalInterfaceTranslationTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ExternalInterfaceTranslationTest.java index cef24665d8..c6f92a7086 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ExternalInterfaceTranslationTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/ExternalInterfaceTranslationTest.java @@ -6,13 +6,13 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getInterfaceBy; +import static org.junit.jupiter.api.Assertions.*; public class ExternalInterfaceTranslationTest extends TranslationTestCase { @@ -27,11 +27,11 @@ public void setUp() { @Test public void testExternalInterface(){ ASTCDInterface a = getInterfaceBy("ASTAExt", externalInterface); - Assertions.assertTrue(a.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, a.getModifier().getStereotype().sizeValues()); - Assertions.assertEquals("externalInterface", a.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(a.getModifier().getStereotype().getValues(0).isPresentText()); + assertTrue(a.getModifier().isPresentStereotype()); + assertEquals(1, a.getModifier().getStereotype().sizeValues()); + assertEquals("externalInterface", a.getModifier().getStereotype().getValues(0).getName()); + assertFalse(a.getModifier().getStereotype().getValues(0).isPresentText()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InheritanceTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InheritanceTest.java index bdc7a05b1a..2aeb0ee0c6 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InheritanceTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InheritanceTest.java @@ -8,7 +8,6 @@ import de.monticore.codegen.mc2cd.TranslationTestCase; import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,8 +15,8 @@ import java.util.List; import static de.monticore.codegen.mc2cd.TransformationHelper.typeToString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test for the proper transformation of ASTClassProds to corresponding @@ -58,11 +57,11 @@ public void setupInheritanceTest() { */ @Test public void testExtends() { - Assertions.assertTrue(astA.isPresentCDExtendUsage()); + assertTrue(astA.isPresentCDExtendUsage()); String name = typeToString(astA.getCDExtendUsage().getSuperclass(0)); - Assertions.assertEquals("mc2cdtransformation.InheritanceGrammar.ASTextendedProd", name); + assertEquals("mc2cdtransformation.InheritanceGrammar.ASTextendedProd", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -72,11 +71,11 @@ public void testExtends() { @Test public void testImplements() { List superInterfaces = astB.getInterfaceList(); - Assertions.assertEquals(1, superInterfaces.size()); + assertEquals(1, superInterfaces.size()); String name = typeToString(superInterfaces.get(0)); - Assertions.assertEquals("mc2cdtransformation.InheritanceGrammar.ASTimplementedProd", name); + assertEquals("mc2cdtransformation.InheritanceGrammar.ASTimplementedProd", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -85,11 +84,11 @@ public void testImplements() { */ @Test public void testAstextends() { - Assertions.assertTrue(astC.isPresentCDExtendUsage()); + assertTrue(astC.isPresentCDExtendUsage()); String name = typeToString(astC.getCDExtendUsage().getSuperclass(0)); - Assertions.assertEquals("AstExtendedType", name); + assertEquals("AstExtendedType", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -99,11 +98,11 @@ public void testAstextends() { @Test public void testAstimplements() { List superInterfaces = astD.getInterfaceList(); - Assertions.assertEquals(1, superInterfaces.size()); + assertEquals(1, superInterfaces.size()); String name = typeToString(superInterfaces.get(0)); - Assertions.assertEquals("AstImplementedType", name); + assertEquals("AstImplementedType", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -112,11 +111,11 @@ public void testAstimplements() { */ @Test public void testAstextendsQualified() { - Assertions.assertTrue(astE.isPresentCDExtendUsage()); + assertTrue(astE.isPresentCDExtendUsage()); String name = typeToString(astE.getCDExtendUsage().getSuperclass(0)); - Assertions.assertEquals("java.util.Observable", name); + assertEquals("java.util.Observable", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -126,10 +125,10 @@ public void testAstextendsQualified() { @Test public void testAstimplementsQualified() { List superInterfaces = astF.getInterfaceList(); - Assertions.assertEquals(1, superInterfaces.size()); + assertEquals(1, superInterfaces.size()); String name = typeToString(superInterfaces.get(0)); - Assertions.assertEquals("java.io.Serializable", name); + assertEquals("java.io.Serializable", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InheritedAttributesTranslationTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InheritedAttributesTranslationTest.java index 43294f378c..1d53400d93 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InheritedAttributesTranslationTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InheritedAttributesTranslationTest.java @@ -9,7 +9,6 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,6 +17,7 @@ import static de.monticore.codegen.cd2java.DecoratorAssert.assertDeepEquals; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; +import static org.junit.jupiter.api.Assertions.*; public class InheritedAttributesTranslationTest extends TranslationTestCase { @@ -39,7 +39,7 @@ public class InheritedAttributesTranslationTest extends TranslationTestCase { public void setupInheritedAttributesTranslationTest() { Optional cdCompilationUnitSuper = TestHelper.parseAndTransform(Paths .get("src/test/resources/mc2cdtransformation/SuperInheritedAttributesGrammar.mc4")); - Assertions.assertTrue(cdCompilationUnitSuper.isPresent()); + assertTrue(cdCompilationUnitSuper.isPresent()); //get classes from super grammar astASuper = getClassBy("ASTA", cdCompilationUnitSuper.get()); @@ -50,7 +50,7 @@ public void setupInheritedAttributesTranslationTest() { Optional cdCompilationUnitSub = TestHelper.parseAndTransform(Paths .get("src/test/resources/mc2cdtransformation/SubInheritedAttributesGrammar.mc4")); - Assertions.assertTrue(cdCompilationUnitSub.isPresent()); + assertTrue(cdCompilationUnitSub.isPresent()); //get classes from sub grammar astASub = getClassBy("ASTA", cdCompilationUnitSub.get()); @@ -59,66 +59,66 @@ public void setupInheritedAttributesTranslationTest() { @Test public void testASuper() { - Assertions.assertTrue(astASuper.getCDAttributeList().stream().noneMatch(this::hasInheritedStereotype)); + assertTrue(astASuper.getCDAttributeList().stream().noneMatch(this::hasInheritedStereotype)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testESuper() { - Assertions.assertTrue(astESuper.getCDAttributeList().stream().noneMatch(this::hasInheritedStereotype)); + assertTrue(astESuper.getCDAttributeList().stream().noneMatch(this::hasInheritedStereotype)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBSuper() { - Assertions.assertTrue(astB.getCDAttributeList().stream().allMatch(this::hasInheritedStereotype)); + assertTrue(astB.getCDAttributeList().stream().allMatch(this::hasInheritedStereotype)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCSuper() { for (ASTCDAttribute astcdAttribute : astC.getCDAttributeList()) { if (!astcdAttribute.getName().equals("name2")) { - Assertions.assertTrue(hasInheritedStereotype(astcdAttribute)); + assertTrue(hasInheritedStereotype(astcdAttribute)); } else { - Assertions.assertFalse(hasInheritedStereotype(astcdAttribute)); + assertFalse(hasInheritedStereotype(astcdAttribute)); } } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testFSuper() { for (ASTCDAttribute astcdAttribute : astF.getCDAttributeList()) { if (!astcdAttribute.getName().equals("name2")) { - Assertions.assertTrue(hasInheritedStereotype(astcdAttribute)); + assertTrue(hasInheritedStereotype(astcdAttribute)); } else { - Assertions.assertFalse(hasInheritedStereotype(astcdAttribute)); + assertFalse(hasInheritedStereotype(astcdAttribute)); } } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testASub() { - Assertions.assertTrue(astASub.getCDAttributeList().stream().allMatch(this::hasInheritedStereotype)); + assertTrue(astASub.getCDAttributeList().stream().allMatch(this::hasInheritedStereotype)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testESub() { - Assertions.assertEquals(1, astESub.getCDAttributeList().size()); + assertEquals(1, astESub.getCDAttributeList().size()); ASTCDAttribute name2Attr = astESub.getCDAttributeList().get(0); - Assertions.assertEquals("name2", name2Attr.getName()); + assertEquals("name2", name2Attr.getName()); assertDeepEquals(String.class, name2Attr.getMCType()); - Assertions.assertFalse(hasInheritedStereotype(name2Attr)); + assertFalse(hasInheritedStereotype(name2Attr)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private boolean hasInheritedStereotype(ASTCDAttribute astcdAttribute) { diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InterfaceProdTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InterfaceProdTest.java index 02c9675e47..8a0ecc80db 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InterfaceProdTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/InterfaceProdTest.java @@ -8,7 +8,6 @@ import de.monticore.codegen.mc2cd.TranslationTestCase; import de.monticore.types.mcbasictypes._ast.ASTMCObjectType; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,8 +15,8 @@ import java.util.List; import static de.monticore.codegen.mc2cd.TransformationHelper.typeToString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test for the proper transformation of ASTInterfaceProds to corresponding ASTCDInterfaces @@ -47,11 +46,11 @@ public void setupInterfaceProdTest() { @Test public void testExtends() { List superInterfaces = astA.getInterfaceList(); - Assertions.assertEquals(1, superInterfaces.size()); + assertEquals(1, superInterfaces.size()); String name = typeToString(superInterfaces.get(0)); - Assertions.assertEquals("mc2cdtransformation.InterfaceProd.ASTextendedProd", name); + assertEquals("mc2cdtransformation.InterfaceProd.ASTextendedProd", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -61,11 +60,11 @@ public void testExtends() { @Test public void testAstextends() { List superInterfaces = astB.getInterfaceList(); - Assertions.assertEquals(1, superInterfaces.size()); + assertEquals(1, superInterfaces.size()); String name = typeToString(superInterfaces.get(0)); - Assertions.assertEquals("AstExtendedType", name); + assertEquals("AstExtendedType", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -75,11 +74,11 @@ public void testAstextends() { @Test public void testAstimplementsQualified() { List superInterfaces = astC.getInterfaceList(); - Assertions.assertEquals(1, superInterfaces.size()); + assertEquals(1, superInterfaces.size()); String name = typeToString(superInterfaces.get(0)); - Assertions.assertEquals("java.io.Serializable", name); + assertEquals("java.io.Serializable", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/LeftRecursiveTranslationTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/LeftRecursiveTranslationTest.java index 9151638378..3f98bf9159 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/LeftRecursiveTranslationTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/LeftRecursiveTranslationTest.java @@ -6,13 +6,13 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; +import static org.junit.jupiter.api.Assertions.*; public class LeftRecursiveTranslationTest extends TranslationTestCase { @@ -27,12 +27,12 @@ public void setUpLeftRecursiveTranslationTest() { @Test public void testLeftRecursiveProd(){ ASTCDClass a = getClassBy("ASTA", leftRecursive); - Assertions.assertTrue(a.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, a.getModifier().getStereotype().sizeValues()); - Assertions.assertEquals("left_recursive", a.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(a.getModifier().getStereotype().getValues(0).isPresentText()); + assertTrue(a.getModifier().isPresentStereotype()); + assertEquals(1, a.getModifier().getStereotype().sizeValues()); + assertEquals("left_recursive", a.getModifier().getStereotype().getValues(0).getName()); + assertFalse(a.getModifier().getStereotype().getValues(0).isPresentText()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/NonTerminalMultiplicityTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/NonTerminalMultiplicityTest.java index 169b0c3b6a..5a9f0e45b4 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/NonTerminalMultiplicityTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/NonTerminalMultiplicityTest.java @@ -8,7 +8,6 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,8 +15,8 @@ import java.util.List; import static de.monticore.codegen.mc2cd.TransformationHelper.typeToString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test for the proper transformation of NonTerminals to corresponding ASTCDAttributes @@ -65,9 +64,9 @@ public void setupNonTerminalMultiplicityTest() { @Test public void testNonTerminalName() { List attributes = astA.getCDAttributeList(); - Assertions.assertEquals("x", attributes.get(0).getName()); + assertEquals("x", attributes.get(0).getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -77,10 +76,10 @@ public void testNonTerminalName() { @Test public void testStarMultiplicity() { List attributes = astA.getCDAttributeList(); - Assertions.assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), + assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), "mc2cdtransformation.NonTerminalMultiplicityGrammar.ASTX")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -90,10 +89,10 @@ public void testStarMultiplicity() { @Test public void testParenthesizedStarMultiplicity() { List attributes = astB.getCDAttributeList(); - Assertions.assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), + assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), "mc2cdtransformation.NonTerminalMultiplicityGrammar.ASTX")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -103,10 +102,10 @@ public void testParenthesizedStarMultiplicity() { @Test public void testPlusMultiplicity() { List attributes = astC.getCDAttributeList(); - Assertions.assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), + assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), "mc2cdtransformation.NonTerminalMultiplicityGrammar.ASTX")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -116,10 +115,10 @@ public void testPlusMultiplicity() { @Test public void testParenthesizedPlusMultiplicity() { List attributes = astD.getCDAttributeList(); - Assertions.assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), + assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), "mc2cdtransformation.NonTerminalMultiplicityGrammar.ASTX")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -130,9 +129,9 @@ public void testParenthesizedPlusMultiplicity() { public void testOptionalMultiplicity() { List attributes = astE.getCDAttributeList(); String name = typeToString(attributes.get(0).getMCType()); - Assertions.assertEquals("Optional", name); + assertEquals("Optional", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -143,9 +142,9 @@ public void testOptionalMultiplicity() { public void testParenthesizedOptionalMultiplicity() { List attributes = astF.getCDAttributeList(); String name = typeToString(attributes.get(0).getMCType()); - Assertions.assertEquals("Optional", name); + assertEquals("Optional", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -155,10 +154,10 @@ public void testParenthesizedOptionalMultiplicity() { @Test public void testDuplicateMultiplicity() { List attributes = astG.getCDAttributeList(); - Assertions.assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), + assertTrue(TestHelper.isListOfType(attributes.get(0).getMCType(), "mc2cdtransformation.NonTerminalMultiplicityGrammar.ASTX")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -170,12 +169,12 @@ public void testAlternative() { List attributes = astH.getCDAttributeList(); String xTypeName = typeToString(attributes.get(0).getMCType()); - Assertions.assertEquals("Optional", xTypeName); + assertEquals("Optional", xTypeName); String yTypeName = typeToString(attributes.get(1).getMCType()); - Assertions.assertEquals("Optional", yTypeName); + assertEquals("Optional", yTypeName); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -185,10 +184,10 @@ public void testAlternative() { @Test public void testTwinAlternative() { List attributes = astJ.getCDAttributeList(); - Assertions.assertEquals(1, attributes.size()); + assertEquals(1, attributes.size()); String xTypeName = typeToString(attributes.get(0).getMCType()); - Assertions.assertEquals("Optional", xTypeName); + assertEquals("Optional", xTypeName); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/OverridingClassProdTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/OverridingClassProdTest.java index 3ff24e980e..b60444d46d 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/OverridingClassProdTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/OverridingClassProdTest.java @@ -7,15 +7,14 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; import static de.monticore.codegen.mc2cd.TransformationHelper.typeToString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class OverridingClassProdTest extends TranslationTestCase { @@ -34,10 +33,10 @@ public void setupOverridingClassProdTest() { */ @Test public void testOverride() { - Assertions.assertTrue(astX.isPresentCDExtendUsage()); + assertTrue(astX.isPresentCDExtendUsage()); String name = typeToString(astX.getCDExtendUsage().getSuperclass(0)); - Assertions.assertEquals("mc2cdtransformation.Supergrammar.ASTX", name); + assertEquals("mc2cdtransformation.Supergrammar.ASTX", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/StarImportSuperGrammarTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/StarImportSuperGrammarTest.java index ff762b2889..873b1df4a3 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/StarImportSuperGrammarTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/StarImportSuperGrammarTest.java @@ -7,14 +7,13 @@ import de.monticore.codegen.mc2cd.TranslationTestCase; import de.monticore.types.mcbasictypes._ast.ASTMCImportStatement; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class StarImportSuperGrammarTest extends TranslationTestCase { @@ -29,9 +28,9 @@ public void setupStarImportSuperGrammarTest() { @Test public void testStarImport() { ASTMCImportStatement importStatement = cdCompilationUnit.getMCImportStatementList().get(0); - Assertions.assertTrue(importStatement.isStar()); - Assertions.assertEquals("mc2cdtransformation.Supergrammar", importStatement.getQName()); + assertTrue(importStatement.isStar()); + assertEquals("mc2cdtransformation.Supergrammar", importStatement.getQName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/StartProdTranslationTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/StartProdTranslationTest.java index 2aef15e529..a20ec60ea2 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/StartProdTranslationTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/StartProdTranslationTest.java @@ -7,7 +7,6 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -15,6 +14,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getInterfaceBy; +import static org.junit.jupiter.api.Assertions.*; public class StartProdTranslationTest extends TranslationTestCase { @@ -36,34 +36,34 @@ public void setUpStartProdTranslationTest() { @Test public void testGlobalStartProd() { - Assertions.assertTrue(globalStartProd.getCDDefinition().getModifier().isPresentStereotype()); - Assertions.assertEquals(1, globalStartProd.getCDDefinition().getModifier().getStereotype().sizeValues()); - Assertions.assertEquals("startProd", globalStartProd.getCDDefinition().getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(globalStartProd.getCDDefinition().getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("mc2cdtransformation.Supergrammar.X", globalStartProd.getCDDefinition().getModifier().getStereotype().getValues(0).getValue()); + assertTrue(globalStartProd.getCDDefinition().getModifier().isPresentStereotype()); + assertEquals(1, globalStartProd.getCDDefinition().getModifier().getStereotype().sizeValues()); + assertEquals("startProd", globalStartProd.getCDDefinition().getModifier().getStereotype().getValues(0).getName()); + assertFalse(globalStartProd.getCDDefinition().getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("mc2cdtransformation.Supergrammar.X", globalStartProd.getCDDefinition().getModifier().getStereotype().getValues(0).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testClassStartProd() { ASTCDClass xClass = getClassBy("ASTX", classStartProd); - Assertions.assertTrue(xClass.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, xClass.getModifier().getStereotype().sizeValues()); - Assertions.assertEquals("startProd", xClass.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertTrue(xClass.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertTrue(xClass.getModifier().isPresentStereotype()); + assertEquals(1, xClass.getModifier().getStereotype().sizeValues()); + assertEquals("startProd", xClass.getModifier().getStereotype().getValues(0).getName()); + assertTrue(xClass.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInterfaceStartProd() { ASTCDInterface aInterface = getInterfaceBy("ASTA", interfaceStartProd); - Assertions.assertTrue(aInterface.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, aInterface.getModifier().getStereotype().sizeValues()); - Assertions.assertEquals("startProd", aInterface.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertTrue(aInterface.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertTrue(aInterface.getModifier().isPresentStereotype()); + assertEquals(1, aInterface.getModifier().getStereotype().sizeValues()); + assertEquals("startProd", aInterface.getModifier().getStereotype().getValues(0).getName()); + assertTrue(aInterface.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/SymbolAndScopeTranslationTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/SymbolAndScopeTranslationTest.java index 87df96e3a5..cfcf51303d 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/SymbolAndScopeTranslationTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/SymbolAndScopeTranslationTest.java @@ -7,7 +7,6 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -15,6 +14,7 @@ import static de.monticore.codegen.cd2java.DecoratorTestUtil.getClassBy; import static de.monticore.codegen.cd2java.DecoratorTestUtil.getInterfaceBy; +import static org.junit.jupiter.api.Assertions.*; public class SymbolAndScopeTranslationTest extends TranslationTestCase { @@ -32,136 +32,136 @@ public void setUpSymbolAndScopeTranslationTest() { @Test public void testSimpleSymbolInterface() { ASTCDInterface astType = getInterfaceBy("ASTType", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); + assertTrue(astType.getModifier().isPresentStereotype()); // only 2 because other one is the start prod stereotype - Assertions.assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("symbol", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("startProd", astType.getModifier().getStereotype().getValues(1).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); + assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("symbol", astType.getModifier().getStereotype().getValues(0).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("startProd", astType.getModifier().getStereotype().getValues(1).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInheritedSymbolInterface_OneLevel() { ASTCDInterface astType = getInterfaceBy("ASTCDType", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); + assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("mc2cdtransformation.symbolandscopetranslation._symboltable.TypeSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); + assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); + assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("mc2cdtransformation.symbolandscopetranslation._symboltable.TypeSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInheritedSymbolInterface_TwoLevels() { ASTCDClass astType = getClassBy("ASTCDClass", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); + assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("mc2cdtransformation.symbolandscopetranslation._symboltable.TypeSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); + assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); + assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("mc2cdtransformation.symbolandscopetranslation._symboltable.TypeSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSimpleSymbolClass() { ASTCDClass astType = getClassBy("ASTSimpleSymbolClass", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("symbol", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("symbol", astType.getModifier().getStereotype().getValues(0).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSymbolClassOverwritten() { ASTCDClass astType = getClassBy("ASTSymbolClass", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("mc2cdtransformation.symboltransl.symbolrule._symboltable.SymbolClassSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); + assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("mc2cdtransformation.symboltransl.symbolrule._symboltable.SymbolClassSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); - Assertions.assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(1).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); + assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(1).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSymbolClassExtents() { ASTCDClass astType = getClassBy("ASTExtentsSymbolClass", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("mc2cdtransformation.symbolandscopetranslation._symboltable.FooSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); + assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("mc2cdtransformation.symbolandscopetranslation._symboltable.FooSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); - Assertions.assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(1).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); + assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(1).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSymbolInterfaceOverwritten() { ASTCDClass astType = getClassBy("ASTSymbolInterface", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("mc2cdtransformation.symboltransl.symbolrule._symboltable.SymbolInterfaceSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); + assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("mc2cdtransformation.symboltransl.symbolrule._symboltable.SymbolInterfaceSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSymbolInterfaceImplements() { ASTCDClass astType = getClassBy("ASTImplementsSymbolInterface", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("mc2cdtransformation.symbolandscopetranslation._symboltable.InterfaceFooSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); + assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("mc2cdtransformation.symbolandscopetranslation._symboltable.InterfaceFooSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); - Assertions.assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(1).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); + assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(1).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSymbolAbstractClassOverwritten() { ASTCDClass astType = getClassBy("ASTSymbolAbstractClass", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("mc2cdtransformation.symboltransl.symbolrule._symboltable.SymbolAbstractClassSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); + assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("mc2cdtransformation.symboltransl.symbolrule._symboltable.SymbolAbstractClassSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSymbolAbstractClassExtents() { ASTCDClass astType = getClassBy("ASTExtentsSymbolAbstractClass", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("mc2cdtransformation.symbolandscopetranslation._symboltable.AbstractFooSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("inheritedSymbol", astType.getModifier().getStereotype().getValues(0).getName()); + assertFalse(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("mc2cdtransformation.symbolandscopetranslation._symboltable.AbstractFooSymbol", astType.getModifier().getStereotype().getValues(0).getValue()); - Assertions.assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(1).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); + assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(1).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -170,85 +170,85 @@ public void testSymbolAbstractClassExtents() { @Test public void testSimpleScopeInterface() { ASTCDInterface astType = getInterfaceBy("ASTTypeScope", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("scope", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("scope", astType.getModifier().getStereotype().getValues(0).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInheritedScopeInterface_OneLevel() { ASTCDInterface astType = getInterfaceBy("ASTCDTypeScope", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); + assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(0).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInheritedScopeInterface_TwoLevels() { ASTCDClass astType = getClassBy("ASTCDClassScope", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); + assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("inheritedScope", astType.getModifier().getStereotype().getValues(0).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSimpleScopeClass() { ASTCDClass astType = getClassBy("ASTSimpleScopeClass", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("scope", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(1, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("scope", astType.getModifier().getStereotype().getValues(0).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testNoShadowingScopeClass() { ASTCDClass astType = getClassBy("ASTScopeShadowing", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("scope", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("shadowing", astType.getModifier().getStereotype().getValues(1).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("scope", astType.getModifier().getStereotype().getValues(0).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("shadowing", astType.getModifier().getStereotype().getValues(1).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testNoExportingScopeClass() { ASTCDClass astType = getClassBy("ASTScopeNonExporting", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("scope", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("non_exporting", astType.getModifier().getStereotype().getValues(1).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("scope", astType.getModifier().getStereotype().getValues(0).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("non_exporting", astType.getModifier().getStereotype().getValues(1).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testOrderedScopeClass() { ASTCDClass astType = getClassBy("ASTScopeOrdered", symbolCD); - Assertions.assertTrue(astType.getModifier().isPresentStereotype()); - Assertions.assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); - Assertions.assertEquals("scope", astType.getModifier().getStereotype().getValues(0).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); - Assertions.assertEquals("ordered", astType.getModifier().getStereotype().getValues(1).getName()); - Assertions.assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); - - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(astType.getModifier().isPresentStereotype()); + assertEquals(2, astType.getModifier().getStereotype().getValuesList().size()); + assertEquals("scope", astType.getModifier().getStereotype().getValues(0).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(0).getValue().isEmpty()); + assertEquals("ordered", astType.getModifier().getStereotype().getValues(1).getName()); + assertTrue(astType.getModifier().getStereotype().getValues(1).getValue().isEmpty()); + + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TerminalWithUsageNameTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TerminalWithUsageNameTest.java index 903246a31d..cedd6f9f10 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TerminalWithUsageNameTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TerminalWithUsageNameTest.java @@ -10,14 +10,13 @@ import de.monticore.codegen.mc2cd.TransformationHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TerminalWithUsageNameTest extends TranslationTestCase { @@ -38,9 +37,9 @@ public void setupTerminalWithUsageNameTest() { public void testTerminalUsageName() { ASTCDAttribute cdAttribute = Iterables.getOnlyElement(astA.getCDAttributeList()); - Assertions.assertEquals("testname", cdAttribute.getName()); - Assertions.assertEquals("String", TransformationHelper.typeToString(cdAttribute.getMCType())); + assertEquals("testname", cdAttribute.getName()); + assertEquals("String", TransformationHelper.typeToString(cdAttribute.getMCType())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TokenMultiplicityTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TokenMultiplicityTest.java index 874326cade..d3fbe7f20f 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TokenMultiplicityTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TokenMultiplicityTest.java @@ -8,7 +8,6 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -17,8 +16,8 @@ import java.util.Optional; import static de.monticore.codegen.mc2cd.TransformationHelper.typeToString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TokenMultiplicityTest extends TranslationTestCase { @@ -35,8 +34,8 @@ public void setupTokenMultiplicityTest() { public void testTokenStar() { List attributes = testListClass.getCDAttributeList(); String name = typeToString(attributes.get(0).getMCType()); - Assertions.assertEquals("java.util.List", name); + assertEquals("java.util.List", name); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TokenTypeTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TokenTypeTest.java index 15b3aa4832..8d9dbc9173 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TokenTypeTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/TokenTypeTest.java @@ -9,13 +9,15 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class TokenTypeTest extends TranslationTestCase { private ASTCDClass astTest; @@ -36,88 +38,88 @@ private Optional getCDAttributeByName(String name) { @Test public void testNumber() { ASTCDAttribute cdAttribute = getCDAttributeByName("a").get(); - Assertions.assertEquals("int", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); + assertEquals("int", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBoolean() { ASTCDAttribute cdAttribute = getCDAttributeByName("b").get(); - Assertions.assertEquals("boolean", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); + assertEquals("boolean", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testChar() { ASTCDAttribute cdAttribute = getCDAttributeByName("c").get(); - Assertions.assertEquals("char", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); + assertEquals("char", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInt() { ASTCDAttribute cdAttribute = getCDAttributeByName("d").get(); - Assertions.assertEquals("int", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); + assertEquals("int", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testFloat() { ASTCDAttribute cdAttribute = getCDAttributeByName("e").get(); - Assertions.assertEquals("float", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); + assertEquals("float", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDouble() { ASTCDAttribute cdAttribute = getCDAttributeByName("f").get(); - Assertions.assertEquals("double", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); + assertEquals("double", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLong() { ASTCDAttribute cdAttribute = getCDAttributeByName("g").get(); - Assertions.assertEquals("long", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); + assertEquals("long", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCard() { ASTCDAttribute cdAttribute = getCDAttributeByName("h").get(); - Assertions.assertEquals("int", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); + assertEquals("int", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testShort() { ASTCDAttribute cdAttribute = getCDAttributeByName("i").get(); - Assertions.assertEquals("short", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); + assertEquals("short", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testByte() { ASTCDAttribute cdAttribute = getCDAttributeByName("j").get(); - Assertions.assertEquals("byte", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); + assertEquals("byte", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testByte2() { ASTCDAttribute cdAttribute = getCDAttributeByName("k").get(); - Assertions.assertEquals("byte", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); + assertEquals("byte", CD4CodeMill.prettyPrint(cdAttribute.getMCType(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/UsageNameTest.java b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/UsageNameTest.java index b1a38951e5..b2f7153c01 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/UsageNameTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/mc2cd/transl/UsageNameTest.java @@ -9,14 +9,13 @@ import de.monticore.codegen.mc2cd.TestHelper; import de.monticore.codegen.mc2cd.TranslationTestCase; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class UsageNameTest extends TranslationTestCase { @@ -35,16 +34,16 @@ public void setupUsageNameTest() { @Test public void testNonTerminal() { ASTCDAttribute cdAttribute = Iterables.getOnlyElement(astA.getCDAttributeList()); - Assertions.assertEquals("nonTerminalUsageName", cdAttribute.getName()); + assertEquals("nonTerminalUsageName", cdAttribute.getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testConstant() { ASTCDAttribute cdAttribute = Iterables.getOnlyElement(astB.getCDAttributeList()); - Assertions.assertEquals("constantUsageName", cdAttribute.getName()); + assertEquals("constantUsageName", cdAttribute.getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-generator/src/test/java/de/monticore/codegen/parser/MCGrammarParserTest.java b/monticore-generator/src/test/java/de/monticore/codegen/parser/MCGrammarParserTest.java index 0ebed23a33..215a79331c 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/parser/MCGrammarParserTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/parser/MCGrammarParserTest.java @@ -8,7 +8,6 @@ import de.monticore.grammar.grammar_withconcepts._parser.Grammar_WithConceptsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,6 +15,8 @@ import java.io.StringReader; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCGrammarParserTest { @BeforeEach @@ -32,16 +33,16 @@ public void testParse() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); - Assertions.assertEquals("Statechart", grammar.getName()); - Assertions.assertEquals(7, grammar.getClassProdList().size()); - Assertions.assertEquals(3, grammar.getExternalProdList().size()); - Assertions.assertEquals(1, grammar.getInterfaceProdList().size()); + assertEquals("Statechart", grammar.getName()); + assertEquals(7, grammar.getClassProdList().size()); + assertEquals(3, grammar.getExternalProdList().size()); + assertEquals(1, grammar.getInterfaceProdList().size()); GrammarTransformer.transform(grammar); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -51,15 +52,15 @@ public void testASTRule() throws IOException { str = "astrule MCGrammar = GrammarOption max=1 ;"; Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parseASTRule(new StringReader(str)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); str = " astrule State = method public String getName(){ return \"\";};"; result = parser.parseASTRule(new StringReader(str)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -69,10 +70,10 @@ public void testSematicPred() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parseSemanticpredicateOrAction(new StringReader(str)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -81,10 +82,10 @@ public void testScript() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -93,10 +94,10 @@ public void testAutomatonV1() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -105,10 +106,10 @@ public void testAutomatonV2() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -117,8 +118,8 @@ public void testAutomatonV3() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); } @Test @@ -127,10 +128,10 @@ public void testHierarchicalAutomaton() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -139,11 +140,11 @@ public void testAutomatonWithInvsComp() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertEquals(1, Log.getFindings().size()); - Assertions.assertEquals("0xA4003 The grammar name InvAutomaton must be identical to the file name" + + assertEquals(1, Log.getFindings().size()); + assertEquals("0xA4003 The grammar name InvAutomaton must be identical to the file name" + " AutomatonWithInvsComp of the grammar (without its file extension).", Log.getFindings().get(0).getMsg()); Log.getFindings().clear(); @@ -155,8 +156,8 @@ public void testAutomatonWithInvs() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); } @Test @@ -165,8 +166,8 @@ public void testAutomatonWithInvsAndStartRule() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); } @Test @@ -175,22 +176,22 @@ public void testGrammarSymbolTableInfo() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); - Assertions.assertEquals(4, grammar.getClassProdList().size()); + assertEquals(4, grammar.getClassProdList().size()); ASTClassProd transition = grammar.getClassProdList().get(2); ASTNonTerminal fromState = (ASTNonTerminal) transition.getAltList().get(0).getComponentList().get(0); - Assertions.assertTrue(fromState.isPresentReferencedSymbol()); - Assertions.assertEquals("State", fromState.getReferencedSymbol()); + assertTrue(fromState.isPresentReferencedSymbol()); + assertEquals("State", fromState.getReferencedSymbol()); ASTNonTerminal toState = (ASTNonTerminal) transition.getAltList().get(0).getComponentList().get(0); - Assertions.assertTrue(toState.isPresentReferencedSymbol()); - Assertions.assertEquals("State", toState.getReferencedSymbol()); + assertTrue(toState.isPresentReferencedSymbol()); + assertEquals("State", toState.getReferencedSymbol()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -199,8 +200,8 @@ public void testPackageNameWithPointsDefined() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); parser.parse(model); - Assertions.assertEquals(1, Log.getFindings().size()); - Assertions.assertEquals("0xA4004 The package declaration point.in.packagename of the grammar must not differ from " + + assertEquals(1, Log.getFindings().size()); + assertEquals("0xA4004 The package declaration point.in.packagename of the grammar must not differ from " + "the package of the grammar file.", Log.getFindings().get(0).getMsg()); Log.getFindings().clear(); @@ -212,8 +213,8 @@ public void testPackageWrongPackageDefined() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); parser.parse(model); - Assertions.assertEquals(1, Log.getFindings().size()); - Assertions.assertEquals("0xA4004 The package declaration de.ronticore of the grammar " + + assertEquals(1, Log.getFindings().size()); + assertEquals("0xA4004 The package declaration de.ronticore of the grammar " + "must not differ from the package of the grammar file.", Log.getFindings().get(0).getMsg()); Log.getFindings().clear(); diff --git a/monticore-generator/src/test/java/de/monticore/codegen/parser/ParserGeneratorTest.java b/monticore-generator/src/test/java/de/monticore/codegen/parser/ParserGeneratorTest.java index 7358e57faa..a1a7161e48 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/parser/ParserGeneratorTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/parser/ParserGeneratorTest.java @@ -18,7 +18,6 @@ import de.se_rwth.commons.Names; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -29,8 +28,8 @@ import java.util.Optional; import static de.monticore.codegen.mc2cd.TestHelper.createGlobalScope; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test for the MontiCore parser generator. @@ -70,15 +69,15 @@ public void testAutomatonSTParserGeneration() { Optional ast = new MontiCoreScript() .parseGrammar(Paths.get(new File( "src/test/resources/de/monticore/AutomatonST.mc4").getAbsolutePath())); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); ASTMCGrammar grammar = ast.get(); createSymbolsFromAST(Grammar_WithConceptsMill.globalScope(), ast.get()); ParserGenerator.generateParser(glex, grammar, Grammar_WithConceptsMill.globalScope(), new MCPath(), new MCPath(), new File("target/generated-test-sources/parsertest")); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -86,15 +85,15 @@ public void testExpressionParserGeneration() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional ast = parser .parse("src/test/resources/de/monticore/expression/Expression.mc4"); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); ASTMCGrammar grammar = ast.get(); createSymbolsFromAST(Grammar_WithConceptsMill.globalScope(), ast.get()); ParserGenerator.generateParser(glex, grammar, Grammar_WithConceptsMill.globalScope(), new MCPath(), new MCPath(), new File("target/generated-test-sources/parsertest")); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -102,15 +101,15 @@ public void testCdAttributesParserGeneration() { Optional ast = new MontiCoreScript() .parseGrammar(Paths.get(new File( "src/test/resources/de/monticore/CdAttributes.mc4").getAbsolutePath())); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); ASTMCGrammar grammar = ast.get(); createSymbolsFromAST(Grammar_WithConceptsMill.globalScope(), ast.get()); ParserGenerator.generateParser(glex, grammar, Grammar_WithConceptsMill.globalScope(), new MCPath(), new MCPath(), new File("target/generated-test-sources/parsertest")); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -118,15 +117,15 @@ public void testSubsubgrammarParserGeneration() { Optional ast = new MontiCoreScript() .parseGrammar(Paths.get(new File( "src/test/resources/de/monticore/inherited/subsub/Subsubgrammar.mc4").getAbsolutePath())); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); ASTMCGrammar grammar = ast.get(); createSymbolsFromAST(Grammar_WithConceptsMill.globalScope(), ast.get()); ParserGenerator.generateParser(glex, grammar, Grammar_WithConceptsMill.globalScope(), new MCPath(), new MCPath(), new File("target/generated-test-sources/parsertest")); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -134,15 +133,15 @@ public void testSubgrammarParserGeneration() { Optional ast = new MontiCoreScript() .parseGrammar(Paths.get(new File( "src/test/resources/de/monticore/inherited/sub/Subgrammar.mc4").getAbsolutePath())); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); ASTMCGrammar grammar = ast.get(); createSymbolsFromAST(Grammar_WithConceptsMill.globalScope(), ast.get()); ParserGenerator.generateParser(glex, grammar, Grammar_WithConceptsMill.globalScope(), new MCPath(), new MCPath(), new File("target/generated-test-sources/parsertest")); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -151,15 +150,15 @@ public void testActionParserGeneration() { Optional ast = new MontiCoreScript() .parseGrammar(Paths.get(new File( "src/test/resources/de/monticore/Action.mc4").getAbsolutePath())); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); ASTMCGrammar grammar = ast.get(); createSymbolsFromAST(Grammar_WithConceptsMill.globalScope(), ast.get()); ParserGenerator.generateParser(glex, grammar, Grammar_WithConceptsMill.globalScope(), new MCPath(), new MCPath(), new File("target/generated-test-sources/parsertest")); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private ASTMCGrammar createSymbolsFromAST(IGrammar_WithConceptsGlobalScope globalScope, ASTMCGrammar ast) { diff --git a/monticore-generator/src/test/java/de/monticore/codegen/prettyprint/MCGrammarPrettyPrinterTest.java b/monticore-generator/src/test/java/de/monticore/codegen/prettyprint/MCGrammarPrettyPrinterTest.java index 472dbb11f4..d30fc399f1 100644 --- a/monticore-generator/src/test/java/de/monticore/codegen/prettyprint/MCGrammarPrettyPrinterTest.java +++ b/monticore-generator/src/test/java/de/monticore/codegen/prettyprint/MCGrammarPrettyPrinterTest.java @@ -7,7 +7,6 @@ import de.monticore.grammar.grammar_withconcepts._parser.Grammar_WithConceptsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -15,8 +14,8 @@ import java.io.StringReader; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCGrammarPrettyPrinterTest { @@ -36,8 +35,8 @@ public void testStatechart() throws IOException { // Parsing input Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parseMCGrammar(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); // Prettyprinting input @@ -45,12 +44,12 @@ public void testStatechart() throws IOException { // Parsing printed input result = parser.parseMCGrammar(new StringReader (output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(grammar.deepEquals(result.get())); + assertTrue(grammar.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -61,8 +60,8 @@ public void testAutomaton() throws IOException { // Parsing input Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parseMCGrammar(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); // Prettyprinting input @@ -70,12 +69,12 @@ public void testAutomaton() throws IOException { // Parsing printed input result = parser.parseMCGrammar(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(grammar.deepEquals(result.get())); + assertTrue(grammar.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -86,8 +85,8 @@ public void testGrammar() throws IOException { // Parsing input Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parseMCGrammar(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); // Prettyprinting input @@ -95,12 +94,12 @@ public void testGrammar() throws IOException { // Parsing printed input result = parser.parseMCGrammar(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(grammar.deepEquals(result.get())); + assertTrue(grammar.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -111,8 +110,8 @@ public void testLexicals() throws IOException { // Parsing input Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parseMCGrammar(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); // Prettyprinting input @@ -120,12 +119,12 @@ public void testLexicals() throws IOException { // Parsing printed input result = parser.parseMCGrammar(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(grammar.deepEquals(result.get())); + assertTrue(grammar.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -136,8 +135,8 @@ public void testAnnotations() throws IOException { // Parsing input Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parseMCGrammar(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); // Prettyprinting input @@ -145,12 +144,12 @@ public void testAnnotations() throws IOException { // Parsing printed input result = parser.parseMCGrammar(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(grammar.deepEquals(result.get())); + assertTrue(grammar.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar-emf/build.gradle b/monticore-grammar-emf/build.gradle index 2fd13f6b0f..eb551b83bb 100644 --- a/monticore-grammar-emf/build.gradle +++ b/monticore-grammar-emf/build.gradle @@ -21,8 +21,8 @@ dependencies { implementation 'org.eclipse.emf:org.eclipse.emf.common:2.15.0' testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version" - testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" testImplementation 'org.apache.groovy:groovy:4.0.2' testImplementation testFixtures(project(':monticore-runtime')) } @@ -81,6 +81,7 @@ generateTestMCGrammars { } test { + useJUnitPlatform() exclude '**/CommentsOnASTTest.class' exclude '**/SwitchStatementValidTest.class' exclude '**/GrammarInheritanceCycleTest.class' diff --git a/monticore-grammar/build.gradle b/monticore-grammar/build.gradle index 14957b38ea..dfdeb04519 100644 --- a/monticore-grammar/build.gradle +++ b/monticore-grammar/build.gradle @@ -78,8 +78,8 @@ dependencies { implementation "org.apache.commons:commons-lang3:$commons_lang3_version" testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version" - testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" // grammar test fixtures includes runtime test dependencies testFixturesApi testFixtures(project(":monticore-runtime")) if (("true").equals(getProperty('genTagging'))) { @@ -88,6 +88,10 @@ dependencies { } } +test { + useJUnitPlatform() +} + tasks.named('generateMCGrammars') { outputDir = file grammarOutDir diff --git a/monticore-grammar/src/test/java/de/monticore/MCCommonUnitTest.java b/monticore-grammar/src/test/java/de/monticore/MCCommonUnitTest.java index c70bf822b3..528f582fdf 100644 --- a/monticore-grammar/src/test/java/de/monticore/MCCommonUnitTest.java +++ b/monticore-grammar/src/test/java/de/monticore/MCCommonUnitTest.java @@ -12,7 +12,6 @@ import de.monticore.umlstereotype._ast.ASTStereotype; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -20,6 +19,8 @@ import java.util.List; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCCommonUnitTest { // setup the language infrastructure @@ -42,19 +43,19 @@ public void init() { @Test public void testNat1() throws IOException { ASTNatLiteral ast = parser.parse_StringNatLiteral( " 9" ).get(); - Assertions.assertEquals("9", ast.getSource()); - Assertions.assertEquals(9, ast.getValue()); + assertEquals("9", ast.getSource()); + assertEquals(9, ast.getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testNat4() throws IOException { ASTNatLiteral ast = parser.parse_StringNatLiteral( " 42 " ).get(); - Assertions.assertEquals("42", ast.getSource()); - Assertions.assertEquals(42, ast.getValue()); + assertEquals("42", ast.getSource()); + assertEquals(42, ast.getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @@ -65,11 +66,11 @@ public void testNat4() throws IOException { @Test public void testModifier() throws IOException { ASTModifier ast = parser.parse_StringModifier( "# final" ).get(); - Assertions.assertEquals(true, ast.isProtected()); - Assertions.assertEquals(true, ast.isFinal()); - Assertions.assertEquals(false, ast.isLocal()); + assertTrue(ast.isProtected()); + assertTrue(ast.isFinal()); + assertFalse(ast.isLocal()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -77,15 +78,15 @@ public void testModifier() throws IOException { @Test public void testModifierStereo() throws IOException { ASTModifier ast = parser.parse_StringModifier( "<>#+?" ).get(); - Assertions.assertEquals(true, ast.isProtected()); - Assertions.assertEquals(true, ast.isPublic()); - Assertions.assertEquals(true, ast.isReadonly()); - Assertions.assertEquals(false, ast.isFinal()); - Assertions.assertEquals(true, ast.isPresentStereotype()); + assertTrue(ast.isProtected()); + assertTrue(ast.isPublic()); + assertTrue(ast.isReadonly()); + assertFalse(ast.isFinal()); + assertTrue(ast.isPresentStereotype()); ASTStereotype sty = ast.getStereotype(); - Assertions.assertEquals("x1", sty.getValue("bla")); + assertEquals("x1", sty.getValue("bla")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -98,12 +99,12 @@ public void testModifierStereo() throws IOException { @Test public void testStereoValue() throws IOException { ASTStereoValue ast = parser.parse_StringStereoValue( "bla=\"17\"" ).get(); - Assertions.assertEquals("bla", ast.getName()); - Assertions.assertEquals(true, ast.isPresentText()); - Assertions.assertEquals("17", ast.getText().getValue()); - Assertions.assertEquals("17", ast.getValue()); + assertEquals("bla", ast.getName()); + assertTrue(ast.isPresentText()); + assertEquals("17", ast.getText().getValue()); + assertEquals("17", ast.getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -111,11 +112,11 @@ public void testStereoValue() throws IOException { @Test public void testStereoValue2() throws IOException { ASTStereoValue ast = parser.parse_StringStereoValue( "cc" ).get(); - Assertions.assertEquals("cc", ast.getName()); - Assertions.assertEquals(false, ast.isPresentText()); - Assertions.assertEquals("", ast.getValue()); + assertEquals("cc", ast.getName()); + assertFalse(ast.isPresentText()); + assertEquals("", ast.getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -123,12 +124,12 @@ public void testStereoValue2() throws IOException { @Test public void testStereoValueExpr() throws IOException { ASTStereoValue ast = parser.parse_StringStereoValue( "bla=name1" ).get(); - Assertions.assertEquals("bla", ast.getName()); - Assertions.assertEquals(false, ast.isPresentText()); - Assertions.assertEquals(true, ast.getExpression() instanceof ASTNameExpression); - Assertions.assertEquals(true, ((ASTNameExpression) ast.getExpression()).getName().equals("name1")); + assertEquals("bla", ast.getName()); + assertFalse(ast.isPresentText()); + assertTrue(ast.getExpression() instanceof ASTNameExpression); + assertTrue(((ASTNameExpression) ast.getExpression()).getName().equals("name1")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @@ -136,13 +137,13 @@ public void testStereoValueExpr() throws IOException { public void testStereotype() throws IOException { ASTStereotype ast = parser.parse_StringStereotype( "<< a1 >>" ).get(); List svl = ast.getValuesList(); - Assertions.assertEquals(1, svl.size()); - Assertions.assertEquals(true, ast.contains("a1")); - Assertions.assertEquals(false, ast.contains("bla")); - Assertions.assertEquals(true, ast.contains("a1","")); - Assertions.assertEquals(false, ast.contains("a1","wert1")); + assertEquals(1, svl.size()); + assertTrue(ast.contains("a1")); + assertFalse(ast.contains("bla")); + assertTrue(ast.contains("a1", "")); + assertFalse(ast.contains("a1", "wert1")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -152,12 +153,12 @@ public void testStereotype2() throws IOException { ASTStereotype ast = parser.parse_StringStereotype( "<< bla, a1=\"wert1\" >>" ).get(); List svl = ast.getValuesList(); - Assertions.assertEquals(2, svl.size()); - Assertions.assertEquals(true, ast.contains("a1")); - Assertions.assertEquals(false, ast.contains("a1","")); - Assertions.assertEquals(true, ast.contains("a1","wert1")); + assertEquals(2, svl.size()); + assertTrue(ast.contains("a1")); + assertFalse(ast.contains("a1", "")); + assertTrue(ast.contains("a1", "wert1")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -166,15 +167,15 @@ public void testStereotype2() throws IOException { public void testStereotype3() throws IOException { ASTStereotype ast = parser.parse_StringStereotype( "<< a1=name1 >>" ).get(); List svl = ast.getValuesList(); - Assertions.assertEquals(1, svl.size()); - Assertions.assertEquals(true, ast.contains("a1")); - Assertions.assertEquals(false, ast.contains("bla")); - Assertions.assertEquals(true, ast.contains("a1","")); - Assertions.assertEquals(false, ast.contains("a1","name1")); - Assertions.assertEquals(true, ast.getValues(0).getExpression() instanceof ASTNameExpression); - Assertions.assertEquals(true, ((ASTNameExpression) ast.getValues(0).getExpression()).getName().equals("name1")); - - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(1, svl.size()); + assertTrue(ast.contains("a1")); + assertFalse(ast.contains("bla")); + assertTrue(ast.contains("a1", "")); + assertFalse(ast.contains("a1", "name1")); + assertInstanceOf(ASTNameExpression.class, ast.getValues(0).getExpression()); + assertEquals("name1", ((ASTNameExpression) ast.getValues(0).getExpression()).getName()); + + assertTrue(Log.getFindings().isEmpty()); } @@ -183,14 +184,14 @@ public void testStereotype3() throws IOException { public void testGetValue() throws IOException { ASTStereotype ast = parser.parse_StringStereotype( "<< bla, a1=\"wert1\" >>" ).get(); - Assertions.assertEquals("wert1", ast.getValue("a1")); + assertEquals("wert1", ast.getValue("a1")); try { - Assertions.assertEquals("", ast.getValue("foo")); - Assertions.fail("Expected an Exception to be thrown"); + assertEquals("", ast.getValue("foo")); + fail("Expected an Exception to be thrown"); } catch (java.util.NoSuchElementException ex) { } - Assertions.assertEquals("", ast.getValue("bla")); + assertEquals("", ast.getValue("bla")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -198,7 +199,7 @@ public void testGetValue() throws IOException { public void testEnding() throws IOException { Optional oast = parser.parse_StringStereotype( "<< bla, a1=\"wert1\" > >" ); - Assertions.assertEquals(false, oast.isPresent()); + assertFalse(oast.isPresent()); } @@ -211,10 +212,10 @@ public void testEnding() throws IOException { @Test public void testBasics() throws IOException { ASTCompleteness ast = parser.parse_StringCompleteness( "(c)" ).get(); - Assertions.assertEquals(true, ast.isComplete()); - Assertions.assertEquals(false, ast.isIncomplete()); + assertTrue(ast.isComplete()); + assertFalse(ast.isIncomplete()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -222,12 +223,12 @@ public void testBasics() throws IOException { @Test public void testBasics2() throws IOException { ASTCompleteness ast = parser.parse_StringCompleteness( "(...)" ).get(); - Assertions.assertEquals(false, ast.isComplete()); - Assertions.assertEquals(true, ast.isIncomplete()); - Assertions.assertEquals(false, ast.isRightComplete()); - Assertions.assertEquals(false, ast.isLeftComplete()); + assertFalse(ast.isComplete()); + assertTrue(ast.isIncomplete()); + assertFalse(ast.isRightComplete()); + assertFalse(ast.isLeftComplete()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -235,12 +236,12 @@ public void testBasics2() throws IOException { @Test public void testBasics3() throws IOException { ASTCompleteness ast = parser.parse_StringCompleteness( "(...,c)" ).get(); - Assertions.assertEquals(false, ast.isComplete()); - Assertions.assertEquals(false, ast.isIncomplete()); - Assertions.assertEquals(true, ast.isRightComplete()); - Assertions.assertEquals(false, ast.isLeftComplete()); + assertFalse(ast.isComplete()); + assertFalse(ast.isIncomplete()); + assertTrue(ast.isRightComplete()); + assertFalse(ast.isLeftComplete()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -249,7 +250,7 @@ public void testBasics3() throws IOException { public void testIllegalComplete() throws IOException { Optional ast = parser.parse_StringCompleteness( "(...,d)" ); - Assertions.assertEquals(false, ast.isPresent()); + assertFalse(ast.isPresent()); } // -------------------------------------------------------------------- @@ -260,11 +261,11 @@ public void testIllegalComplete() throws IOException { @Test public void testMany() throws IOException { ASTCardinality ast = parser.parse_StringCardinality("[*]").get(); - Assertions.assertEquals(true, ast.isMany()); - Assertions.assertEquals(0, ast.getLowerBound()); - Assertions.assertEquals(0, ast.getUpperBound()); + assertTrue(ast.isMany()); + assertEquals(0, ast.getLowerBound()); + assertEquals(0, ast.getUpperBound()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -272,12 +273,12 @@ public void testMany() throws IOException { @Test public void testLowAndStar() throws IOException { ASTCardinality ast = parser.parse_StringCardinality("[7..*]").get(); - Assertions.assertEquals(false, ast.isMany()); - Assertions.assertEquals(true, ast.isNoUpperLimit()); - Assertions.assertEquals(7, ast.getLowerBound()); - Assertions.assertEquals(0, ast.getUpperBound()); + assertFalse(ast.isMany()); + assertTrue(ast.isNoUpperLimit()); + assertEquals(7, ast.getLowerBound()); + assertEquals(0, ast.getUpperBound()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -285,11 +286,11 @@ public void testLowAndStar() throws IOException { @Test public void testLowAndUp() throws IOException { ASTCardinality ast = parser.parse_StringCardinality("[17..235]").get(); - Assertions.assertEquals(false, ast.isMany()); - Assertions.assertEquals(17, ast.getLowerBound()); - Assertions.assertEquals(235, ast.getUpperBound()); + assertFalse(ast.isMany()); + assertEquals(17, ast.getLowerBound()); + assertEquals(235, ast.getUpperBound()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -297,11 +298,11 @@ public void testLowAndUp() throws IOException { @Test public void testSpace() throws IOException { ASTCardinality ast = parser.parse_StringCardinality(" [ 34 .. 15 ] ").get(); - Assertions.assertEquals(false, ast.isMany()); - Assertions.assertEquals(34, ast.getLowerBound()); - Assertions.assertEquals(15, ast.getUpperBound()); + assertFalse(ast.isMany()); + assertEquals(34, ast.getLowerBound()); + assertEquals(15, ast.getUpperBound()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -312,7 +313,7 @@ public void testSpace() throws IOException { public void testHex() throws IOException { Optional oast = parser.parse_StringCardinality( "[0x34..0x15]"); - Assertions.assertEquals(false, oast.isPresent()); + assertFalse(oast.isPresent()); } diff --git a/monticore-grammar/src/test/java/de/monticore/SymbolImportTest.java b/monticore-grammar/src/test/java/de/monticore/SymbolImportTest.java index c47fc74581..8e49bbd04a 100644 --- a/monticore-grammar/src/test/java/de/monticore/SymbolImportTest.java +++ b/monticore-grammar/src/test/java/de/monticore/SymbolImportTest.java @@ -9,7 +9,6 @@ import de.monticore.symbols.basicsymbols.BasicSymbolsMill; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,6 +17,8 @@ import java.util.Optional; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class SymbolImportTest { @BeforeEach @@ -68,24 +69,24 @@ public void testTestStarImportGrammar() throws IOException { protected void test(String filename) throws IOException { Optional grammarOpt = Grammar_WithConceptsMill.parser().parse(filename); - Assertions.assertTrue(grammarOpt.isPresent()); + assertTrue(grammarOpt.isPresent()); Grammar_WithConceptsMill.scopesGenitorDelegator().createFromAST(grammarOpt.get()); MCGrammarSymbol symbol = grammarOpt.get().getSymbol(); for (MCGrammarSymbolSurrogate surrogate : symbol.getSuperGrammars()) { - Assertions.assertTrue(surrogate.checkLazyLoadDelegate(), "Unable to lazy load delegate " + surrogate.getName() + " of " + surrogate.getEnclosingScope()); + assertTrue(surrogate.checkLazyLoadDelegate(), "Unable to lazy load delegate " + surrogate.getName() + " of " + surrogate.getEnclosingScope()); } String allSuperGrammars = symbol.getSuperGrammars().stream().map(MCGrammarSymbol::getFullName).collect(Collectors.joining(", ")); String allSuperGrammarsLazy = symbol.getSuperGrammars().stream().map(MCGrammarSymbolSurrogate::lazyLoadDelegate).map(MCGrammarSymbol::getFullName).collect(Collectors.joining(", ")); // check if the surrogate is returning the correct symbol - Assertions.assertTrue(symbol.getSuperGrammars().stream().anyMatch(x -> x.lazyLoadDelegate().getFullName().equals("de.monticore.grammar.SamePackage")), "SamePackage import failed: " + allSuperGrammars); - Assertions.assertTrue(symbol.getSuperGrammars().stream().anyMatch(x -> x.lazyLoadDelegate().getFullName().equals("de.monticore.grammar.pack.DifferentPackage")), "DifferentPackage import failed: " + allSuperGrammars); + assertTrue(symbol.getSuperGrammars().stream().anyMatch(x -> x.lazyLoadDelegate().getFullName().equals("de.monticore.grammar.SamePackage")), "SamePackage import failed: " + allSuperGrammars); + assertTrue(symbol.getSuperGrammars().stream().anyMatch(x -> x.lazyLoadDelegate().getFullName().equals("de.monticore.grammar.pack.DifferentPackage")), "DifferentPackage import failed: " + allSuperGrammars); // check if the surrogate is returning the correct fullname - Assertions.assertTrue(symbol.getSuperGrammars().stream().anyMatch(x -> x.getFullName().equals("de.monticore.grammar.SamePackage")), "SamePackage lazy import failed: " + allSuperGrammarsLazy); - Assertions.assertTrue(symbol.getSuperGrammars().stream().anyMatch(x -> x.getFullName().equals("de.monticore.grammar.pack.DifferentPackage")), "DifferentPackage lazy import failed: " + allSuperGrammarsLazy); + assertTrue(symbol.getSuperGrammars().stream().anyMatch(x -> x.getFullName().equals("de.monticore.grammar.SamePackage")), "SamePackage lazy import failed: " + allSuperGrammarsLazy); + assertTrue(symbol.getSuperGrammars().stream().anyMatch(x -> x.getFullName().equals("de.monticore.grammar.pack.DifferentPackage")), "DifferentPackage lazy import failed: " + allSuperGrammarsLazy); } } diff --git a/monticore-grammar/src/test/java/de/monticore/aggregation/AggregationTest.java b/monticore-grammar/src/test/java/de/monticore/aggregation/AggregationTest.java index 7e891ae658..97197e5024 100644 --- a/monticore-grammar/src/test/java/de/monticore/aggregation/AggregationTest.java +++ b/monticore-grammar/src/test/java/de/monticore/aggregation/AggregationTest.java @@ -18,14 +18,13 @@ import de.monticore.runtime.junit.AbstractMCTest; import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static junit.framework.TestCase.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class AggregationTest extends AbstractMCTest { @@ -78,14 +77,14 @@ public void test() throws IOException { // check dummy symbol is present in local scope Optional blubSymbol1 = blahSymbolTable.resolveDummy("blahmodel.blubScope1.blubSymbol1"); - Assertions.assertTrue(blubSymbol1.isPresent()); + assertTrue(blubSymbol1.isPresent()); // // // check dummy symbol is present in global scope Optional barSymbol = globalScope.resolveBar("blahmodel.blubScope1.blubSymbol1"); - Assertions.assertTrue(barSymbol.isPresent()); + assertTrue(barSymbol.isPresent()); /* *************************************************************************************************************** @@ -99,7 +98,7 @@ public void test() throws IOException { Optional fooModel = fooParser.parse_String("bar { blubSymbol1() } name"); // Check foo model is parsed - Assertions.assertTrue(fooModel.isPresent()); + assertTrue(fooModel.isPresent()); // create symbol table for "foo" FooScopesGenitorDelegator fooSymbolTableCreator = FooMill.scopesGenitorDelegator(); @@ -107,9 +106,9 @@ public void test() throws IOException { // check symbol is resolvable Optional k = fooScope.resolveBar("name"); - Assertions.assertTrue(k.isPresent()); + assertTrue(k.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @AfterEach diff --git a/monticore-grammar/src/test/java/de/monticore/comments/CommentsOnASTTest.java b/monticore-grammar/src/test/java/de/monticore/comments/CommentsOnASTTest.java index 75d30dbb9e..eaa788ae46 100644 --- a/monticore-grammar/src/test/java/de/monticore/comments/CommentsOnASTTest.java +++ b/monticore-grammar/src/test/java/de/monticore/comments/CommentsOnASTTest.java @@ -13,6 +13,8 @@ import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + /** * This test should document the current comment behavior * Note: The location of comments has changed as of MC 7.7.0 @@ -38,57 +40,57 @@ public void before() { @Test public void testComments() throws IOException { Optional ast = parser.parse("src/test/resources/de/monticore/comments/CommentsTest.jlight"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMethodDeclaration m = (ASTMethodDeclaration) ast.get(); - Assertions.assertEquals(1, m.get_PreCommentList().size()); - Assertions.assertEquals("// (c) https://github.com/MontiCore/monticore", m.get_PreComment(0).getText()); - Assertions.assertEquals(1, m.get_PreCommentList().size()); - Assertions.assertEquals("// After doStuff", m.get_PostComment(0).getText()); + assertEquals(1, m.get_PreCommentList().size()); + assertEquals("// (c) https://github.com/MontiCore/monticore", m.get_PreComment(0).getText()); + assertEquals(1, m.get_PreCommentList().size()); + assertEquals("// After doStuff", m.get_PostComment(0).getText()); - Assertions.assertEquals(1, m.sizeMCModifiers()); - Assertions.assertEquals(0, m.getMCModifier(0).get_PostCommentList().size()); - Assertions.assertEquals(0, m.getMCModifier(0).get_PostCommentList().size()); + assertEquals(1, m.sizeMCModifiers()); + assertEquals(0, m.getMCModifier(0).get_PostCommentList().size()); + assertEquals(0, m.getMCModifier(0).get_PostCommentList().size()); - Assertions.assertEquals(1, m.getMCReturnType().get_PreCommentList().size()); - Assertions.assertEquals("/* t2 */", m.getMCReturnType().get_PreComment(0).getText()); - Assertions.assertEquals(0, m.getMCReturnType().get_PostCommentList().size()); + assertEquals(1, m.getMCReturnType().get_PreCommentList().size()); + assertEquals("/* t2 */", m.getMCReturnType().get_PreComment(0).getText()); + assertEquals(0, m.getMCReturnType().get_PostCommentList().size()); - Assertions.assertEquals(1, m.getFormalParameters().get_PreCommentList().size()); - Assertions.assertEquals("/* t4 */", m.getFormalParameters().get_PreComment(0).getText()); - Assertions.assertEquals(0, m.getFormalParameters().get_PostCommentList().size()); + assertEquals(1, m.getFormalParameters().get_PreCommentList().size()); + assertEquals("/* t4 */", m.getFormalParameters().get_PreComment(0).getText()); + assertEquals(0, m.getFormalParameters().get_PostCommentList().size()); - Assertions.assertEquals(1, m.getMCJavaBlock().get_PreCommentList().size()); - Assertions.assertEquals("/* t6 */", m.getMCJavaBlock().get_PreComment(0).getText()); - Assertions.assertEquals(1, m.getMCJavaBlock().get_PostCommentList().size()); - Assertions.assertEquals("// Final doStuff", m.getMCJavaBlock().get_PostComment(0).getText()); + assertEquals(1, m.getMCJavaBlock().get_PreCommentList().size()); + assertEquals("/* t6 */", m.getMCJavaBlock().get_PreComment(0).getText()); + assertEquals(1, m.getMCJavaBlock().get_PostCommentList().size()); + assertEquals("// Final doStuff", m.getMCJavaBlock().get_PostComment(0).getText()); ASTConstDeclaration c = (ASTConstDeclaration) m.getMCJavaBlock().getMCBlockStatement(0); - Assertions.assertEquals(1, c.get_PreCommentList().size()); - Assertions.assertEquals("// First doStuff", c.get_PreComment(0).getText()); - Assertions.assertEquals(2, c.get_PostCommentList().size()); + assertEquals(1, c.get_PreCommentList().size()); + assertEquals("// First doStuff", c.get_PreComment(0).getText()); + assertEquals(2, c.get_PostCommentList().size()); // Note: When pretty-printing /*A*/;//B , // the result will look like ; /*A*/ //B - Assertions.assertEquals("/* after value */", c.get_PostComment(0).getText()); - Assertions.assertEquals("// after line", c.get_PostComment(1).getText()); + assertEquals("/* after value */", c.get_PostComment(0).getText()); + assertEquals("// after line", c.get_PostComment(1).getText()); - Assertions.assertEquals(0, c.getLocalVariableDeclaration().sizeMCModifiers()); + assertEquals(0, c.getLocalVariableDeclaration().sizeMCModifiers()); - Assertions.assertEquals(0, c.getLocalVariableDeclaration().getMCType().get_PreCommentList().size()); - Assertions.assertEquals(0, c.getLocalVariableDeclaration().getMCType().get_PostCommentList().size()); + assertEquals(0, c.getLocalVariableDeclaration().getMCType().get_PreCommentList().size()); + assertEquals(0, c.getLocalVariableDeclaration().getMCType().get_PostCommentList().size()); - Assertions.assertEquals(1, c.getLocalVariableDeclaration().getVariableDeclarator(0).get_PreCommentList().size()); - Assertions.assertEquals("/* pre name */", c.getLocalVariableDeclaration().getVariableDeclarator(0).get_PreComment(0).getText()); + assertEquals(1, c.getLocalVariableDeclaration().getVariableDeclarator(0).get_PreCommentList().size()); + assertEquals("/* pre name */", c.getLocalVariableDeclaration().getVariableDeclarator(0).get_PreComment(0).getText()); - Assertions.assertEquals(2, c.getLocalVariableDeclaration().getVariableDeclarator(0) + assertEquals(2, c.getLocalVariableDeclaration().getVariableDeclarator(0) .getVariableInit().get_PreCommentList().size()); - Assertions.assertEquals("/* pre op */", c.getLocalVariableDeclaration().getVariableDeclarator(0) + assertEquals("/* pre op */", c.getLocalVariableDeclaration().getVariableDeclarator(0) .getVariableInit().get_PreComment(0).getText()); - Assertions.assertEquals("/* pre value */", c.getLocalVariableDeclaration().getVariableDeclarator(0) + assertEquals("/* pre value */", c.getLocalVariableDeclaration().getVariableDeclarator(0) .getVariableInit().get_PreComment(1).getText()); } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/AbstractInterpreterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/AbstractInterpreterTest.java index e7561ebabf..bf6067edec 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/AbstractInterpreterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/AbstractInterpreterTest.java @@ -17,8 +17,7 @@ import java.io.IOException; import java.util.Optional; -import static junit.framework.TestCase.*; -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public abstract class AbstractInterpreterTest { @@ -249,7 +248,7 @@ protected void testInvalidExpression(String expr) { } assertNotNull(interpretationResult); assertEquals(Log.getFindings().size(), 1); - assertTrue(interpretationResult instanceof NotAValue); + assertInstanceOf(NotAValue.class, interpretationResult); } protected Value parseExpressionAndInterpret(String expr) throws IOException { diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/assignmentexpressions/cocos/AssignmentExpressionsOnlyAssignToLValuesCoCoTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/assignmentexpressions/cocos/AssignmentExpressionsOnlyAssignToLValuesCoCoTest.java index 2a2b900e2a..2920b583a7 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/assignmentexpressions/cocos/AssignmentExpressionsOnlyAssignToLValuesCoCoTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/assignmentexpressions/cocos/AssignmentExpressionsOnlyAssignToLValuesCoCoTest.java @@ -8,14 +8,14 @@ import de.monticore.types3.util.CombineExpressionsWithLiteralsTypeTraverserFactory; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class AssignmentExpressionsOnlyAssignToLValuesCoCoTest { @@ -187,14 +187,14 @@ public void testFurtherInvalidAssignments() throws IOException { protected void testValid(String exprStr) throws IOException { check(exprStr); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); Log.clearFindings(); } protected void testInvalid(String exprStr) throws IOException { check(exprStr); - Assertions.assertTrue(!Log.getFindings().isEmpty()); - Assertions.assertTrue(Log.getFindings().stream().anyMatch( + assertFalse(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().stream().anyMatch( f -> f.getMsg().contains("0xFDD47") )); Log.clearFindings(); @@ -203,8 +203,8 @@ protected void testInvalid(String exprStr) throws IOException { protected void check(String exprStr) throws IOException { Optional exprOpt = CombineExpressionsWithLiteralsMill .parser().parse_StringExpression(exprStr); - Assertions.assertTrue(exprOpt.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(exprOpt.isPresent()); + assertTrue(Log.getFindings().isEmpty()); getChecker().checkAll(exprOpt.get()); } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/assignmentexpressions/cocos/LiteralAssignmentMatchesRegExExpressionCoCoTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/assignmentexpressions/cocos/LiteralAssignmentMatchesRegExExpressionCoCoTest.java index dd8704bd9d..c850ed917a 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/assignmentexpressions/cocos/LiteralAssignmentMatchesRegExExpressionCoCoTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/assignmentexpressions/cocos/LiteralAssignmentMatchesRegExExpressionCoCoTest.java @@ -13,14 +13,13 @@ import de.monticore.types3.util.CombineExpressionsWithLiteralsTypeTraverserFactory; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.*; public class LiteralAssignmentMatchesRegExExpressionCoCoTest { @@ -86,14 +85,14 @@ public void testIncorrectAssignments() throws IOException { protected void testValid(String type, String exprStr) throws IOException { check(type, exprStr); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); Log.clearFindings(); } protected void testInvalid(String type, String exprStr) throws IOException { check(type, exprStr); - Assertions.assertEquals(1, Log.getFindings().size()); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith("0xFD724")); + assertEquals(1, Log.getFindings().size()); + assertTrue(Log.getFindings().get(0).getMsg().startsWith("0xFD724")); Log.clearFindings(); } @@ -107,7 +106,7 @@ protected void check(String type, String exprStr) throws IOException { Optional optType = CombineExpressionsWithLiteralsMill .parser() .parse_StringMCType(type); - Assertions.assertTrue(optType.isPresent()); + assertTrue(optType.isPresent()); SymTypeExpression typeExpression = TypeCheck3.symTypeFromAST(optType.get()); assertFalse(typeExpression.isObscureType()); @@ -121,11 +120,11 @@ protected void check(String type, String exprStr) throws IOException { Optional exprOpt = CombineExpressionsWithLiteralsMill .parser().parse_StringExpression(exprStr); - Assertions.assertTrue(exprOpt.isPresent()); + assertTrue(exprOpt.isPresent()); generateScopes(exprOpt.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); getChecker().checkAll(exprOpt.get()); } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/cocos/ExpressionValidTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/cocos/ExpressionValidTest.java index 4c61c1dafa..f61dc0e5b9 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/cocos/ExpressionValidTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/cocos/ExpressionValidTest.java @@ -10,13 +10,15 @@ import de.monticore.types.check.FullDeriveFromCombineExpressionsWithLiterals; import de.monticore.types.check.TypeCalculator; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class ExpressionValidTest extends CocoTest { protected ExpressionsBasisCoCoChecker checker; @@ -35,19 +37,19 @@ public void init() { public void checkValid(String expressionString) throws IOException { CombineExpressionsWithLiteralsParser parser = new CombineExpressionsWithLiteralsParser(); Optional optAST = parser.parse_StringExpression(expressionString); - Assertions.assertTrue(optAST.isPresent()); + assertTrue(optAST.isPresent()); Log.getFindings().clear(); checker.checkAll(optAST.get()); - Assertions.assertTrue(Log.getFindings().isEmpty(), Log.getFindings().toString()); + assertTrue(Log.getFindings().isEmpty(), Log.getFindings().toString()); } public void checkInvalid(String expressionString) throws IOException { CombineExpressionsWithLiteralsParser parser = new CombineExpressionsWithLiteralsParser(); Optional optAST = parser.parse_StringExpression(expressionString); - Assertions.assertTrue(optAST.isPresent()); + assertTrue(optAST.isPresent()); Log.getFindings().clear(); checker.checkAll(optAST.get()); - Assertions.assertFalse(Log.getFindings().isEmpty()); + assertFalse(Log.getFindings().isEmpty()); } @Test diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/combineexpressionswithliterals/ParserTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/combineexpressionswithliterals/ParserTest.java index 56c5f014a3..1edee256e1 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/combineexpressionswithliterals/ParserTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/combineexpressionswithliterals/ParserTest.java @@ -5,14 +5,13 @@ import de.monticore.expressions.expressionsbasis._ast.ASTExpression; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; class ParserTest { @@ -35,7 +34,7 @@ void parseBigExpr() throws IOException { "|| !(x2 && x15)) "; Optional ast = CombineExpressionsWithLiteralsMill.parser().parse_StringExpression(expr); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); } @Test @@ -48,7 +47,7 @@ void parseBigExpr2() throws IOException { Optional ast = CombineExpressionsWithLiteralsMill.parser().parse_StringExpression(expr); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); } @Test diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/combineexpressionswithliterals/_cocos/TestNoClassExpressionForGenerics.java b/monticore-grammar/src/test/java/de/monticore/expressions/combineexpressionswithliterals/_cocos/TestNoClassExpressionForGenerics.java index 1d5bb88549..12c8787156 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/combineexpressionswithliterals/_cocos/TestNoClassExpressionForGenerics.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/combineexpressionswithliterals/_cocos/TestNoClassExpressionForGenerics.java @@ -6,13 +6,15 @@ import de.monticore.expressions.javaclassexpressions._ast.ASTJavaClassExpressionsNode; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class TestNoClassExpressionForGenerics { CombineExpressionsWithLiteralsParser p = new CombineExpressionsWithLiteralsParser(); @@ -27,22 +29,22 @@ public void setup(){ public void testValid() throws IOException { Optional optClass = p.parse_StringClassExpression("Integer.class"); - Assertions.assertTrue(optClass.isPresent()); + assertTrue(optClass.isPresent()); CombineExpressionsWithLiteralsCoCoChecker coCoChecker = new CombineExpressionsWithLiteralsCoCoChecker().getCombineExpressionsWithLiteralsCoCoChecker(); coCoChecker.checkAll((ASTJavaClassExpressionsNode) optClass.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testValid2() throws IOException{ Optional optClass = p.parse_StringClassExpression("int.class"); - Assertions.assertTrue(optClass.isPresent()); + assertTrue(optClass.isPresent()); CombineExpressionsWithLiteralsCoCoChecker coCoChecker = new CombineExpressionsWithLiteralsCoCoChecker().getCombineExpressionsWithLiteralsCoCoChecker(); coCoChecker.checkAll((ASTJavaClassExpressionsNode) optClass.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -50,12 +52,12 @@ public void testInvalidGeneric() throws IOException{ //MCListType Optional optClass = p.parse_StringClassExpression("List.class"); - Assertions.assertTrue(optClass.isPresent()); + assertTrue(optClass.isPresent()); CombineExpressionsWithLiteralsCoCoChecker coCoChecker = new CombineExpressionsWithLiteralsCoCoChecker().getCombineExpressionsWithLiteralsCoCoChecker(); coCoChecker.checkAll((ASTJavaClassExpressionsNode) optClass.get()); - Assertions.assertFalse(Log.getFindings().isEmpty()); - Assertions.assertTrue(Log.getFindings().get(Log.getFindings().size()-1).getMsg().startsWith(NoClassExpressionForGenerics.ERROR_CODE)); + assertFalse(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().get(Log.getFindings().size()-1).getMsg().startsWith(NoClassExpressionForGenerics.ERROR_CODE)); } @Test @@ -63,12 +65,12 @@ public void testInvalidGeneric2() throws IOException{ //MCBasicGenericType Optional optClass = p.parse_StringClassExpression("a.b.List.class"); - Assertions.assertTrue(optClass.isPresent()); + assertTrue(optClass.isPresent()); CombineExpressionsWithLiteralsCoCoChecker coCoChecker = new CombineExpressionsWithLiteralsCoCoChecker().getCombineExpressionsWithLiteralsCoCoChecker(); coCoChecker.checkAll((ASTJavaClassExpressionsNode) optClass.get()); - Assertions.assertFalse(Log.getFindings().isEmpty()); - Assertions.assertTrue(Log.getFindings().get(Log.getFindings().size()-1).getMsg().startsWith(NoClassExpressionForGenerics.ERROR_CODE)); + assertFalse(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().get(Log.getFindings().size()-1).getMsg().startsWith(NoClassExpressionForGenerics.ERROR_CODE)); } } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/commonexpressions/CommonExpressionsBuilderTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/commonexpressions/CommonExpressionsBuilderTest.java index 65d77b6241..7906087a37 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/commonexpressions/CommonExpressionsBuilderTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/commonexpressions/CommonExpressionsBuilderTest.java @@ -3,9 +3,10 @@ package de.monticore.expressions.commonexpressions; import de.monticore.runtime.junit.TestWithMCLanguage; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + @TestWithMCLanguage(CommonExpressionsMill.class) public class CommonExpressionsBuilderTest { @Test @@ -16,6 +17,6 @@ public void testBooleanAndOpExpression() { .setRight(CommonExpressionsMill.nameExpressionBuilder().setName("r").build()) .build(); // And that the actual operator is "&&" (instead of "" from the infix operator) - Assertions.assertEquals("&&", elem.getOperator()); + assertEquals("&&", elem.getOperator()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/commonexpressions/cocos/FunctionCallArgumentsMatchesRegExCoCoTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/commonexpressions/cocos/FunctionCallArgumentsMatchesRegExCoCoTest.java index b0391bb087..a05e5831ad 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/commonexpressions/cocos/FunctionCallArgumentsMatchesRegExCoCoTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/commonexpressions/cocos/FunctionCallArgumentsMatchesRegExCoCoTest.java @@ -18,7 +18,6 @@ import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -28,6 +27,8 @@ import java.util.Optional; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class FunctionCallArgumentsMatchesRegExCoCoTest { @BeforeEach @@ -141,7 +142,7 @@ public void testIncorrectFunctionCalls() throws IOException { protected void testValid(String expression, List> functions, boolean varArgs) throws IOException { check(expression, functions, varArgs); - Assertions.assertTrue(Log.getFindings().isEmpty(), Log.getFindings().stream() + assertTrue(Log.getFindings().isEmpty(), Log.getFindings().stream() .map(Finding::buildMsg) .collect(Collectors.joining(System.lineSeparator()))); Log.clearFindings(); @@ -149,7 +150,7 @@ protected void testValid(String expression, List> functions, boolea protected void testInvalid(String expression, List> functions, boolean varArgs) throws IOException { check(expression, functions, varArgs); - Assertions.assertTrue(Log.getFindings().stream().anyMatch( + assertTrue(Log.getFindings().stream().anyMatch( f -> f.getMsg().startsWith("0xFD725") )); Log.clearFindings(); @@ -179,11 +180,11 @@ protected void check(String expression, List> functions, boolean va Optional optExpr = CombineExpressionsWithLiteralsMill .parser().parse_StringExpression(expression); - Assertions.assertTrue(optExpr.isPresent()); + assertTrue(optExpr.isPresent()); ASTExpression expr = optExpr.get(); generateScopes(expr); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); getChecker(derive).checkAll(expr); } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/AssignmentExpressionsJavaPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/AssignmentExpressionsJavaPrinterTest.java index d96a01f534..897942eadf 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/AssignmentExpressionsJavaPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/AssignmentExpressionsJavaPrinterTest.java @@ -10,7 +10,6 @@ import de.monticore.prettyprint.IndentPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,6 +17,7 @@ import java.util.Optional; import static de.monticore.expressions.assignmentexpressions._ast.ASTConstantsAssignmentExpressions.*; +import static org.junit.jupiter.api.Assertions.*; public class AssignmentExpressionsJavaPrinterTest { @@ -38,78 +38,78 @@ public void init() { @Test public void testIncPrefixExpression() throws IOException { Optional result = parser.parse_StringIncPrefixExpression("++a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTIncPrefixExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringIncPrefixExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDecPrefixExpression() throws IOException { Optional result = parser.parse_StringDecPrefixExpression("--a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTDecPrefixExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringDecPrefixExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testIncSuffixExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); ASTIncSuffixExpression result = AssignmentExpressionsMill.incSuffixExpressionBuilder() .setExpression(a.get()) .build(); String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a++", output); + assertEquals("a++", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDecSuffixExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); ASTDecSuffixExpression result = AssignmentExpressionsMill.decSuffixExpressionBuilder() .setExpression(a.get()) .build(); String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a--", output); + assertEquals("a--", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -118,18 +118,18 @@ public void testRegularAssignmentEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a=b", output); + assertEquals("a=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentPlusEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -138,18 +138,18 @@ public void testRegularAssignmentPlusEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a+=b", output); + assertEquals("a+=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentMinusExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -158,18 +158,18 @@ public void testRegularAssignmentMinusExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a-=b", output); + assertEquals("a-=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentPercentEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -178,18 +178,18 @@ public void testRegularAssignmentPercentEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a%=b", output); + assertEquals("a%=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentAndEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -198,18 +198,18 @@ public void testRegularAssignmentAndEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a&=b", output); + assertEquals("a&=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentRoofEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -218,18 +218,18 @@ public void testRegularAssignmentRoofEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a^=b", output); + assertEquals("a^=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentSlashEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -238,18 +238,18 @@ public void testRegularAssignmentSlashEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a/=b", output); + assertEquals("a/=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentStarEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -258,18 +258,18 @@ public void testRegularAssignmentStarEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a*=b", output); + assertEquals("a*=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentPipeEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -278,18 +278,18 @@ public void testRegularAssignmentPipeEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a|=b", output); + assertEquals("a|=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentLTLTEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -298,18 +298,18 @@ public void testRegularAssignmentLTLTEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a<<=b", output); + assertEquals("a<<=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentGTGTEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -318,18 +318,18 @@ public void testRegularAssignmentGTGTEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a>>=b", output); + assertEquals("a>>=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentGTGTGTEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -338,8 +338,8 @@ public void testRegularAssignmentGTGTGTEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a>>>=b", output); + assertEquals("a>>>=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/BitExpressionsJavaPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/BitExpressionsJavaPrinterTest.java index ef7c955f62..77488488b3 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/BitExpressionsJavaPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/BitExpressionsJavaPrinterTest.java @@ -8,15 +8,14 @@ import de.monticore.prettyprint.IndentPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BitExpressionsJavaPrinterTest { @@ -37,115 +36,115 @@ public void init() { @Test public void testLeftShiftExpression() throws IOException { Optional result = parser.parse_StringExpression("a< result = parser.parse_StringExpression("a>>b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLogicalRightShiftExpression() throws IOException { Optional result = parser.parse_StringExpression("a>>>b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBinaryOrOpExpression() throws IOException { Optional result = parser.parse_StringExpression("a|b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBinaryXorExpression() throws IOException { Optional result = parser.parse_StringExpression("a^b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBinaryAndExpression() throws IOException { Optional result = parser.parse_StringExpression("a&b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/CommonExpressionsJavaPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/CommonExpressionsJavaPrinterTest.java index d626879315..9565c018a5 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/CommonExpressionsJavaPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/CommonExpressionsJavaPrinterTest.java @@ -11,14 +11,13 @@ import de.monticore.prettyprint.IndentPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class CommonExpressionsJavaPrinterTest { @@ -46,119 +45,119 @@ public void init() { @Test public void testMinusPrefixExpression() throws IOException { Optional result = parser.parse_StringMinusPrefixExpression("-a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMinusPrefixExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringMinusPrefixExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPlusPrefixExpression() throws IOException { Optional result = parser.parse_StringPlusPrefixExpression("+a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTPlusPrefixExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringPlusPrefixExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBooleanNotExpression() throws IOException { Optional result = parser.parse_StringBooleanNotExpression("~a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTBooleanNotExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringBooleanNotExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLogicalNotExpression() throws IOException { Optional result = parser.parse_StringLogicalNotExpression("!a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTLogicalNotExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringLogicalNotExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBracketExpression() throws IOException { Optional result = parser.parse_StringBracketExpression("(a == b)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTBracketExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringBracketExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testArguments() throws IOException { Optional result = parser.parse_StringArguments("(a , b , c)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTArguments ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringArguments(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCallExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional arguments = parser.parse_StringArguments("(b, c)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(arguments.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(arguments.isPresent()); ASTCallExpression result = CommonExpressionsMill.callExpressionBuilder() .setExpression(a.get()) .setArguments(arguments.get()) @@ -166,16 +165,16 @@ public void testCallExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a(b,c)", output); + assertEquals("a(b,c)", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testFieldAccessExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); ASTFieldAccessExpression result = CommonExpressionsMill.fieldAccessExpressionBuilder() .setExpression(a.get()) .setName("foo") @@ -183,18 +182,18 @@ public void testFieldAccessExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a.getFoo()", output); + assertEquals("a.getFoo()", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMultExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTMultExpression result = CommonExpressionsMill.multExpressionBuilder() .setLeft(a.get()) .setOperator("*") @@ -203,18 +202,18 @@ public void testMultExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a*b", output); + assertEquals("a*b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDivideExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTDivideExpression result = CommonExpressionsMill.divideExpressionBuilder() .setLeft(a.get()) .setOperator("/") @@ -223,18 +222,18 @@ public void testDivideExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a/b", output); + assertEquals("a/b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testModuloExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTModuloExpression result = CommonExpressionsMill.moduloExpressionBuilder() .setLeft(a.get()) .setOperator("%") @@ -243,18 +242,18 @@ public void testModuloExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a%b", output); + assertEquals("a%b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPlusExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTPlusExpression result = CommonExpressionsMill.plusExpressionBuilder() .setLeft(a.get()) .setOperator("+") @@ -263,18 +262,18 @@ public void testPlusExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a+b", output); + assertEquals("a+b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMinusExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTMinusExpression result = CommonExpressionsMill.minusExpressionBuilder() .setLeft(a.get()) .setOperator("-") @@ -283,18 +282,18 @@ public void testMinusExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a-b", output); + assertEquals("a-b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLessEqualExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTLessEqualExpression result = CommonExpressionsMill.lessEqualExpressionBuilder() .setLeft(a.get()) .setOperator("<=") @@ -303,18 +302,18 @@ public void testLessEqualExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a<=b", output); + assertEquals("a<=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testGreaterEqualExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTGreaterEqualExpression result = CommonExpressionsMill.greaterEqualExpressionBuilder() .setLeft(a.get()) .setOperator(">=") @@ -323,18 +322,18 @@ public void testGreaterEqualExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a>=b", output); + assertEquals("a>=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLessThanExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTLessThanExpression result = CommonExpressionsMill.lessThanExpressionBuilder() .setLeft(a.get()) .setOperator("<") @@ -343,18 +342,18 @@ public void testLessThanExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTGreaterThanExpression result = CommonExpressionsMill.greaterThanExpressionBuilder() .setLeft(a.get()) .setOperator(">") @@ -363,18 +362,18 @@ public void testGreaterThanExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a>b", output); + assertEquals("a>b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTEqualsExpression result = CommonExpressionsMill.equalsExpressionBuilder() .setLeft(a.get()) .setOperator("==") @@ -383,18 +382,18 @@ public void testEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a==b", output); + assertEquals("a==b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testNotEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTNotEqualsExpression result = CommonExpressionsMill.notEqualsExpressionBuilder() .setLeft(a.get()) .setOperator("!=") @@ -403,18 +402,18 @@ public void testNotEqualsExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a!=b", output); + assertEquals("a!=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBooleanAndOpExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTBooleanAndOpExpression result = CommonExpressionsMill.booleanAndOpExpressionBuilder() .setLeft(a.get()) .setOperator("&&") @@ -423,18 +422,18 @@ public void testBooleanAndOpExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a&&b", output); + assertEquals("a&&b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBooleanOrOpExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTBooleanOrOpExpression result = CommonExpressionsMill.booleanOrOpExpressionBuilder() .setLeft(a.get()) .setOperator("||") @@ -443,9 +442,9 @@ public void testBooleanOrOpExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a||b", output); + assertEquals("a||b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -453,10 +452,10 @@ public void testConditionalExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); Optional c = parser.parse_StringExpression("c"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); - Assertions.assertTrue(c.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); + assertTrue(c.isPresent()); ASTConditionalExpression result = CommonExpressionsMill.conditionalExpressionBuilder() .setCondition(a.get()) .setTrueExpression(b.get()) @@ -465,18 +464,18 @@ public void testConditionalExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a ? b:c", output); + assertEquals("a ? b:c", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testArrayExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTArrayAccessExpression result = CommonExpressionsMill.arrayAccessExpressionBuilder() .setExpression(a.get()) @@ -485,9 +484,9 @@ public void testArrayExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a[b]", output); + assertEquals("a[b]", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/JavaClassExpressionsJavaPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/JavaClassExpressionsJavaPrinterTest.java index 59f55f89b0..99d617fe7d 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/JavaClassExpressionsJavaPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/JavaClassExpressionsJavaPrinterTest.java @@ -10,13 +10,14 @@ import de.monticore.prettyprint.IndentPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class JavaClassExpressionsJavaPrinterTest { protected TestJavaClassExpressionsParser parser; @@ -36,62 +37,62 @@ public void init() { @Test public void testPrimaryThisExpression() throws IOException { Optional result = parser.parse_StringPrimaryThisExpression("this"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTPrimaryThisExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringPrimaryThisExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPrimarySuperExpression() throws IOException { Optional result = parser.parse_StringPrimarySuperExpression("super"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTPrimarySuperExpression ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringPrimarySuperExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testThisExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); ASTThisExpression result = JavaClassExpressionsMill.thisExpressionBuilder() .setExpression(a.get()) .build(); String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a.this", output); + assertEquals("a.this", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSuperExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringSuperSuffix("(b)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTSuperExpression result = JavaClassExpressionsMill.superExpressionBuilder() .setExpression(a.get()) .setSuperSuffix(b.get()) @@ -99,81 +100,81 @@ public void testSuperExpression() throws IOException { String output = javaPrinter.prettyprint(result); - Assertions.assertEquals("a.super(b)", output); + assertEquals("a.super(b)", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testGenericInvocationSuffixThis() throws IOException { Optional result = parser.parse_StringGenericInvocationSuffix("this(a)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTGenericInvocationSuffix ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringGenericInvocationSuffix(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testGenericInvocationSuffixSuper() throws IOException { Optional result = parser.parse_StringGenericInvocationSuffix("super(b)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTGenericInvocationSuffix ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringGenericInvocationSuffix(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testGenericInvocationSuffixSimple() throws IOException { Optional result = parser.parse_StringGenericInvocationSuffix("a(b)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTGenericInvocationSuffix ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringGenericInvocationSuffix(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testTypePattern() throws IOException { Optional result = parser.parse_StringTypePattern("String s"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTTypePattern ast = result.get(); String output = javaPrinter.prettyprint(ast); result = parser.parse_StringTypePattern(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/UglyExpressionsJavaPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/UglyExpressionsJavaPrinterTest.java index 644e2fb6c4..9da703508b 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/UglyExpressionsJavaPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/exptojava/UglyExpressionsJavaPrinterTest.java @@ -1,31 +1,7 @@ /* (c) https://github.com/MontiCore/monticore */ package de.monticore.expressions.exptojava; -import de.monticore.expressions.expressionsbasis._ast.ASTExpression; -import de.monticore.expressions.javaclassexpressions.JavaClassExpressionsMill; -import de.monticore.expressions.javaclassexpressions._ast.ASTGenericInvocationSuffix; -import de.monticore.expressions.javaclassexpressions._ast.ASTPrimarySuperExpression; -import de.monticore.expressions.javaclassexpressions._ast.ASTPrimaryThisExpression; -import de.monticore.expressions.javaclassexpressions._ast.ASTSuperExpression; -import de.monticore.expressions.javaclassexpressions._ast.ASTSuperSuffix; -import de.monticore.expressions.javaclassexpressions._ast.ASTThisExpression; -import de.monticore.expressions.javaclassexpressions._ast.ASTTypePattern; -import de.monticore.expressions.javaclassexpressions._prettyprint.JavaClassExpressionsFullPrettyPrinter; -import de.monticore.expressions.testjavaclassexpressions.TestJavaClassExpressionsMill; -import de.monticore.expressions.testjavaclassexpressions._parser.TestJavaClassExpressionsParser; import de.monticore.expressions.uglyexpressions._prettyprint.UglyExpressionsFullPrettyPrinter; -import de.monticore.prettyprint.IndentPrinter; -import de.se_rwth.commons.logging.Log; -import de.se_rwth.commons.logging.LogStub; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.util.Optional; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; public class UglyExpressionsJavaPrinterTest { diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/AssignmentExpressionsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/AssignmentExpressionsPrettyPrinterTest.java index 52ba69fb30..645c9d65e1 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/AssignmentExpressionsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/AssignmentExpressionsPrettyPrinterTest.java @@ -10,7 +10,6 @@ import de.monticore.prettyprint.IndentPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,6 +17,7 @@ import java.util.Optional; import static de.monticore.expressions.assignmentexpressions._ast.ASTConstantsAssignmentExpressions.*; +import static org.junit.jupiter.api.Assertions.*; public class AssignmentExpressionsPrettyPrinterTest { @@ -38,78 +38,78 @@ public void init() { @Test public void testIncPrefixExpression() throws IOException { Optional result = parser.parse_StringIncPrefixExpression("++a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTIncPrefixExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringIncPrefixExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDecPrefixExpression() throws IOException { Optional result = parser.parse_StringDecPrefixExpression("--a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTDecPrefixExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringDecPrefixExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testIncSuffixExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); ASTIncSuffixExpression result = AssignmentExpressionsMill.incSuffixExpressionBuilder() .setExpression(a.get()) .build(); String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a++", output); + assertEquals("a++", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDecSuffixExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); ASTDecSuffixExpression result = AssignmentExpressionsMill.decSuffixExpressionBuilder() .setExpression(a.get()) .build(); String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a--", output); + assertEquals("a--", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -118,18 +118,18 @@ public void testRegularAssignmentEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a=b", output); + assertEquals("a=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentPlusEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -138,18 +138,18 @@ public void testRegularAssignmentPlusEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a+=b", output); + assertEquals("a+=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentMinusExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -158,18 +158,18 @@ public void testRegularAssignmentMinusExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a-=b", output); + assertEquals("a-=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentPercentEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -178,18 +178,18 @@ public void testRegularAssignmentPercentEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a%=b", output); + assertEquals("a%=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentAndEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -198,18 +198,18 @@ public void testRegularAssignmentAndEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a&=b", output); + assertEquals("a&=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentRoofEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -218,18 +218,18 @@ public void testRegularAssignmentRoofEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a^=b", output); + assertEquals("a^=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentSlashEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -238,18 +238,18 @@ public void testRegularAssignmentSlashEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a/=b", output); + assertEquals("a/=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentStarEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -258,18 +258,18 @@ public void testRegularAssignmentStarEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a*=b", output); + assertEquals("a*=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentPipeEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -278,18 +278,18 @@ public void testRegularAssignmentPipeEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a|=b", output); + assertEquals("a|=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentLTLTEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -298,18 +298,18 @@ public void testRegularAssignmentLTLTEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a<<=b", output); + assertEquals("a<<=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentGTGTEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -318,18 +318,18 @@ public void testRegularAssignmentGTGTEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a>>=b", output); + assertEquals("a>>=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRegularAssignmentGTGTGTEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTAssignmentExpression result = AssignmentExpressionsMill.assignmentExpressionBuilder() .setLeft(a.get()) .setRight(b.get()) @@ -338,8 +338,8 @@ public void testRegularAssignmentGTGTGTEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result).trim(); - Assertions.assertEquals("a>>>=b", output); + assertEquals("a>>>=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/BitExpressionsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/BitExpressionsPrettyPrinterTest.java index 957c4d4ea1..3097709eb4 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/BitExpressionsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/BitExpressionsPrettyPrinterTest.java @@ -8,13 +8,15 @@ import de.monticore.prettyprint.IndentPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class BitExpressionsPrettyPrinterTest { protected TestBitExpressionsParser parser; protected BitExpressionsFullPrettyPrinter prettyPrinter; @@ -33,120 +35,114 @@ public void init() { @Test public void testLeftShiftExpression() throws IOException { Optional result = parser.parse_StringExpression("a< result = parser.parse_StringExpression("a>>b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLogicalRightShiftExpression() throws IOException { Optional result = parser.parse_StringExpression("a>>>b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBinaryOrOpExpression() throws IOException { Optional result = parser.parse_StringExpression("a|b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBinaryXorExpression() throws IOException { Optional result = parser.parse_StringExpression("a^b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBinaryAndExpression() throws IOException { Optional result = parser.parse_StringExpression("a&b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/CommonExpressionsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/CommonExpressionsPrettyPrinterTest.java index 8b8e526108..3c878cb812 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/CommonExpressionsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/CommonExpressionsPrettyPrinterTest.java @@ -11,13 +11,14 @@ import de.monticore.prettyprint.IndentPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class CommonExpressionsPrettyPrinterTest { protected TestCommonExpressionsParser parser; @@ -37,119 +38,119 @@ public void init() { @Test public void testMinusPrefixExpression() throws IOException { Optional result = parser.parse_StringMinusPrefixExpression("-a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMinusPrefixExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringMinusPrefixExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPlusPrefixExpression() throws IOException { Optional result = parser.parse_StringPlusPrefixExpression("+a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTPlusPrefixExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringPlusPrefixExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBooleanNotExpression() throws IOException { Optional result = parser.parse_StringBooleanNotExpression("~a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTBooleanNotExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringBooleanNotExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLogicalNotExpression() throws IOException { Optional result = parser.parse_StringLogicalNotExpression("!a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTLogicalNotExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringLogicalNotExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBracketExpression() throws IOException { Optional result = parser.parse_StringBracketExpression("(a == b)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTBracketExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringBracketExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testArguments() throws IOException { Optional result = parser.parse_StringArguments("(a , b , c)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTArguments ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringArguments(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCallExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional arguments = parser.parse_StringArguments("(b, c)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(arguments.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(arguments.isPresent()); ASTCallExpression result = CommonExpressionsMill.callExpressionBuilder() .setExpression(a.get()) .setArguments(arguments.get()) @@ -157,16 +158,16 @@ public void testCallExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a(b,c)", output); + assertEquals("a(b,c)", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testFieldAccessExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); ASTFieldAccessExpression result = CommonExpressionsMill.fieldAccessExpressionBuilder() .setExpression(a.get()) .setName("foo") @@ -174,18 +175,18 @@ public void testFieldAccessExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a.foo", output); + assertEquals("a.foo", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMultExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTMultExpression result = CommonExpressionsMill.multExpressionBuilder() .setLeft(a.get()) .setOperator("*") @@ -194,18 +195,18 @@ public void testMultExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a*b", output); + assertEquals("a*b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDivideExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTDivideExpression result = CommonExpressionsMill.divideExpressionBuilder() .setLeft(a.get()) .setOperator("/") @@ -214,18 +215,18 @@ public void testDivideExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a/b", output); + assertEquals("a/b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testModuloExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTModuloExpression result = CommonExpressionsMill.moduloExpressionBuilder() .setLeft(a.get()) .setOperator("%") @@ -234,18 +235,18 @@ public void testModuloExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a%b", output); + assertEquals("a%b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPlusExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTPlusExpression result = CommonExpressionsMill.plusExpressionBuilder() .setLeft(a.get()) .setOperator("+") @@ -254,18 +255,18 @@ public void testPlusExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a+b", output); + assertEquals("a+b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMinusExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTMinusExpression result = CommonExpressionsMill.minusExpressionBuilder() .setLeft(a.get()) .setOperator("-") @@ -274,18 +275,18 @@ public void testMinusExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a-b", output); + assertEquals("a-b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLessEqualExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTLessEqualExpression result = CommonExpressionsMill.lessEqualExpressionBuilder() .setLeft(a.get()) .setOperator("<=") @@ -294,18 +295,18 @@ public void testLessEqualExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a<=b", output); + assertEquals("a<=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testGreaterEqualExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTGreaterEqualExpression result = CommonExpressionsMill.greaterEqualExpressionBuilder() .setLeft(a.get()) .setOperator(">=") @@ -314,18 +315,18 @@ public void testGreaterEqualExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a>=b", output); + assertEquals("a>=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLessThanExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTLessThanExpression result = CommonExpressionsMill.lessThanExpressionBuilder() .setLeft(a.get()) .setOperator("<") @@ -334,18 +335,18 @@ public void testLessThanExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTGreaterThanExpression result = CommonExpressionsMill.greaterThanExpressionBuilder() .setLeft(a.get()) .setOperator(">") @@ -354,18 +355,18 @@ public void testGreaterThanExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a>b", output); + assertEquals("a>b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTEqualsExpression result = CommonExpressionsMill.equalsExpressionBuilder() .setLeft(a.get()) .setOperator("==") @@ -374,18 +375,18 @@ public void testEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a==b", output); + assertEquals("a==b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testNotEqualsExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTNotEqualsExpression result = CommonExpressionsMill.notEqualsExpressionBuilder() .setLeft(a.get()) .setOperator("!=") @@ -394,18 +395,18 @@ public void testNotEqualsExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a!=b", output); + assertEquals("a!=b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBooleanAndOpExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTBooleanAndOpExpression result = CommonExpressionsMill.booleanAndOpExpressionBuilder() .setLeft(a.get()) .setOperator("&&") @@ -414,18 +415,18 @@ public void testBooleanAndOpExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a&&b", output); + assertEquals("a&&b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBooleanOrOpExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTBooleanOrOpExpression result = CommonExpressionsMill.booleanOrOpExpressionBuilder() .setLeft(a.get()) .setOperator("||") @@ -434,9 +435,9 @@ public void testBooleanOrOpExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a||b", output); + assertEquals("a||b", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -444,10 +445,10 @@ public void testConditionalExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); Optional c = parser.parse_StringExpression("c"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); - Assertions.assertTrue(c.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); + assertTrue(c.isPresent()); ASTConditionalExpression result = CommonExpressionsMill.conditionalExpressionBuilder() .setCondition(a.get()) .setTrueExpression(b.get()) @@ -456,8 +457,8 @@ public void testConditionalExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a ? b:c", output); + assertEquals("a ? b:c", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/JavaClassExpressionsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/JavaClassExpressionsPrettyPrinterTest.java index 07b2a165e8..d189fa9f5f 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/JavaClassExpressionsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/JavaClassExpressionsPrettyPrinterTest.java @@ -14,13 +14,14 @@ import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class JavaClassExpressionsPrettyPrinterTest { private TestJavaClassExpressionsParser parser = new TestJavaClassExpressionsParser(); @@ -41,44 +42,44 @@ public void init() { @Test public void testPrimaryThisExpression() throws IOException { Optional result = parser.parse_StringPrimaryThisExpression("this"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTPrimaryThisExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringPrimaryThisExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPrimarySuperExpression() throws IOException { Optional result = parser.parse_StringPrimarySuperExpression("super"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTPrimarySuperExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringPrimarySuperExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testTypeCaseExpression() throws IOException { Optional result = parser.parse_StringTypeCastExpression("(Integer) a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTTypeCastExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); @@ -87,72 +88,72 @@ public void testTypeCaseExpression() throws IOException { // prettyprinter of langauge that fills the external String pattern = "^\\(.*\\)a$"; boolean matches = output.matches(pattern); - Assertions.assertEquals(matches, true); + assertEquals(matches, true); } @Test public void testClassExpression() throws IOException { Optional result = parser.parse_StringClassExpression("Integer.class"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTClassExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); - Assertions.assertEquals("Integer.class", output); + assertEquals("Integer.class", output); } @Test public void testPrimaryGenericInvocationExpressionExpression() throws IOException { Optional result = parser.parse_StringPrimaryGenericInvocationExpression(" super(a)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTPrimaryGenericInvocationExpression ast = result.get(); String output = prettyPrinter.prettyprint(ast); - Assertions.assertEquals("super(a)", output); + assertEquals("super(a)", output); } @Test public void testInstanceofExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional type = parser.parse_StringMCType("Integer"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(type.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(type.isPresent()); ASTInstanceofExpression result = JavaClassExpressionsMill.instanceofExpressionBuilder() .setExpression(a.get()) .setMCType(type.get()) .build(); String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a instanceof Integer", output); + assertEquals("a instanceof Integer", output); } @Test public void testThisExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); ASTThisExpression result = JavaClassExpressionsMill.thisExpressionBuilder() .setExpression(a.get()) .build(); String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a.this", output); + assertEquals("a.this", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testArrayExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringExpression("b"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTArrayAccessExpression result = JavaClassExpressionsMill.arrayAccessExpressionBuilder() .setExpression(a.get()) .setIndexExpression(b.get()) @@ -160,18 +161,18 @@ public void testArrayExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a[b]", output); + assertEquals("a[b]", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSuperExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringSuperSuffix("(b)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTSuperExpression result = JavaClassExpressionsMill.superExpressionBuilder() .setExpression(a.get()) .setSuperSuffix(b.get()) @@ -179,17 +180,17 @@ public void testSuperExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a.super(b)", output); + assertEquals("a.super(b)", output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testGenericInvocationExpressionExpression() throws IOException { Optional a = parser.parse_StringExpression("a"); Optional b = parser.parse_StringPrimaryGenericInvocationExpression(" c(b)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ASTGenericInvocationExpression result = JavaClassExpressionsMill.genericInvocationExpressionBuilder() .setExpression(a.get()) .setPrimaryGenericInvocationExpression(b.get()) @@ -197,60 +198,60 @@ public void testGenericInvocationExpressionExpression() throws IOException { String output = prettyPrinter.prettyprint(result); - Assertions.assertEquals("a.c(b)", output); + assertEquals("a.c(b)", output); } @Test public void testGenericInvocationSuffixThis() throws IOException { Optional result = parser.parse_StringGenericInvocationSuffix("this(a)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTGenericInvocationSuffix ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringGenericInvocationSuffix(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testGenericInvocationSuffixSuper() throws IOException { Optional result = parser.parse_StringGenericInvocationSuffix("super(b)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTGenericInvocationSuffix ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringGenericInvocationSuffix(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testGenericInvocationSuffixSimple() throws IOException { Optional result = parser.parse_StringGenericInvocationSuffix("a(b)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTGenericInvocationSuffix ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringGenericInvocationSuffix(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/LambdaExpressionsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/LambdaExpressionsPrettyPrinterTest.java index 86c042c8bb..557effc273 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/LambdaExpressionsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/LambdaExpressionsPrettyPrinterTest.java @@ -8,7 +8,6 @@ import de.monticore.prettyprint.IndentPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,8 +15,8 @@ import java.util.Optional; import java.util.regex.Pattern; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class LambdaExpressionsPrettyPrinterTest { @@ -40,21 +39,21 @@ public void init() { public void testLambdaWithoutParameter() throws IOException { testLambdaExpression("() -> a"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLambdaWithoutTypeWithoutParenthesis() throws IOException { testLambdaExpression("a -> a"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLambdaWithoutTypeWithParenthesis() throws IOException { testLambdaExpression("(a) -> a"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -78,16 +77,16 @@ public void testLambdaWithType() throws IOException { // "a" + "a" ); - Assertions.assertTrue(pattern.asPredicate().test(output)); + assertTrue(pattern.asPredicate().test(output)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLambdaMultipeParametersWithoutType() throws IOException { testLambdaExpression("(a, b) -> a"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -117,24 +116,24 @@ public void testLambdaMultipeParametersWithType() throws IOException { // "a" + "a" ); - Assertions.assertTrue(pattern.asPredicate().test(output)); + assertTrue(pattern.asPredicate().test(output)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } public void testLambdaExpression(String exp) throws IOException { ASTLambdaExpression ast = parseLambdaExpression(exp); String output = prettyPrinter.prettyprint(ast); ASTLambdaExpression ast2 = parseLambdaExpression(output); - Assertions.assertTrue(ast.deepEquals(ast2), "Parse equals: " + exp + " vs " + output); + assertTrue(ast.deepEquals(ast2), "Parse equals: " + exp + " vs " + output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } public ASTLambdaExpression parseLambdaExpression(String exp) throws IOException { Optional result = parser.parse_StringLambdaExpression(exp); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); return result.get(); } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/StreamExpressionsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/StreamExpressionsPrettyPrinterTest.java index 52406247ea..82073264fe 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/StreamExpressionsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/prettyprint/StreamExpressionsPrettyPrinterTest.java @@ -6,7 +6,6 @@ import de.monticore.expressions.teststreamexpressions._parser.TestStreamExpressionsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -14,6 +13,9 @@ import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class StreamExpressionsPrettyPrinterTest { protected TestStreamExpressionsParser parser; @@ -44,18 +46,18 @@ public void init() { }) public void testPrettyPrint(String input) throws IOException { Optional result = parser.parse_StringExpression(input); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpression ast = result.get(); String output = TestStreamExpressionsMill.prettyPrint(ast, true); result = parser.parse_StringExpression(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/expressions/streamexpressions/parser/CombinedStreamsExpressionsParserTest.java b/monticore-grammar/src/test/java/de/monticore/expressions/streamexpressions/parser/CombinedStreamsExpressionsParserTest.java index 79fd763da5..caa31e1bea 100644 --- a/monticore-grammar/src/test/java/de/monticore/expressions/streamexpressions/parser/CombinedStreamsExpressionsParserTest.java +++ b/monticore-grammar/src/test/java/de/monticore/expressions/streamexpressions/parser/CombinedStreamsExpressionsParserTest.java @@ -19,7 +19,6 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -31,9 +30,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * This test checks for parser clashes of stream expressions with the expression universe. Additionally, it checks if @@ -248,7 +245,7 @@ public static void cleanUp() { // Helpers, could in part be generalized? protected static void assertNoFindings() { - Assertions.assertTrue(Log.getFindings().isEmpty(), "Expected no Log findings, but got:" + assertTrue(Log.getFindings().isEmpty(), "Expected no Log findings, but got:" + System.lineSeparator() + getAllFindingsAsString()); } diff --git a/monticore-grammar/src/test/java/de/monticore/grammar/MCGrammarParserTest.java b/monticore-grammar/src/test/java/de/monticore/grammar/MCGrammarParserTest.java index b337367c00..c1e76e8384 100644 --- a/monticore-grammar/src/test/java/de/monticore/grammar/MCGrammarParserTest.java +++ b/monticore-grammar/src/test/java/de/monticore/grammar/MCGrammarParserTest.java @@ -8,7 +8,6 @@ import de.monticore.grammar.grammar_withconcepts._parser.Grammar_WithConceptsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,6 +15,8 @@ import java.io.StringReader; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCGrammarParserTest { @BeforeEach @@ -33,16 +34,16 @@ public void testParse() throws IOException { Grammar_WithConceptsParser parser = Grammar_WithConceptsMill.parser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); - Assertions.assertEquals("Statechart", grammar.getName()); - Assertions.assertEquals(7, grammar.getClassProdList().size()); - Assertions.assertEquals(3, grammar.getExternalProdList().size()); - Assertions.assertEquals(1, grammar.getInterfaceProdList().size()); + assertEquals("Statechart", grammar.getName()); + assertEquals(7, grammar.getClassProdList().size()); + assertEquals(3, grammar.getExternalProdList().size()); + assertEquals(1, grammar.getInterfaceProdList().size()); GrammarTransformer.transform(grammar); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -52,15 +53,15 @@ public void testASTRule() throws IOException { str = "astrule MCGrammar = GrammarOption max=1 ;"; Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parseASTRule(new StringReader(str)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); str = " astrule State = method public String getName(){ return \"\";};"; result = parser.parseASTRule(new StringReader(str)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -70,10 +71,10 @@ public void testSematicPred() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parseSemanticpredicateOrAction(new StringReader(str)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -82,10 +83,10 @@ public void testScript() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -94,10 +95,10 @@ public void testAutomatonV1() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -106,10 +107,10 @@ public void testAutomatonV2() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -118,8 +119,8 @@ public void testAutomatonV3() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); } @Test @@ -128,10 +129,10 @@ public void testHierarchicalAutomaton() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -140,11 +141,11 @@ public void testAutomatonWithInvsComp() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertEquals(1, Log.getFindings().size()); - Assertions.assertEquals("0xA4003 The grammar name InvAutomaton must be identical to the file name" + + assertEquals(1, Log.getFindings().size()); + assertEquals("0xA4003 The grammar name InvAutomaton must be identical to the file name" + " AutomatonWithInvsComp of the grammar (without its file extension).", Log.getFindings().get(0).getMsg()); Log.getFindings().clear(); @@ -156,8 +157,8 @@ public void testAutomatonWithInvs() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); } @Test @@ -166,8 +167,8 @@ public void testAutomatonWithInvsAndStartRule() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); } @Test @@ -176,22 +177,22 @@ public void testGrammarSymbolTableInfo() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); - Assertions.assertEquals(4, grammar.getClassProdList().size()); + assertEquals(4, grammar.getClassProdList().size()); ASTClassProd transition = grammar.getClassProdList().get(2); ASTNonTerminal fromState = (ASTNonTerminal) transition.getAltList().get(0).getComponentList().get(0); - Assertions.assertTrue(fromState.isPresentReferencedSymbol()); - Assertions.assertEquals("State", fromState.getReferencedSymbol()); + assertTrue(fromState.isPresentReferencedSymbol()); + assertEquals("State", fromState.getReferencedSymbol()); ASTNonTerminal toState = (ASTNonTerminal) transition.getAltList().get(0).getComponentList().get(0); - Assertions.assertTrue(toState.isPresentReferencedSymbol()); - Assertions.assertEquals("State", toState.getReferencedSymbol()); + assertTrue(toState.isPresentReferencedSymbol()); + assertEquals("State", toState.getReferencedSymbol()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -200,8 +201,8 @@ public void testPackageNameWithPointsDefined() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); parser.parse(model); - Assertions.assertEquals(1, Log.getFindings().size()); - Assertions.assertEquals("0xA4004 The package declaration point.in.packagename of the grammar must not differ from " + + assertEquals(1, Log.getFindings().size()); + assertEquals("0xA4004 The package declaration point.in.packagename of the grammar must not differ from " + "the package of the grammar file.", Log.getFindings().get(0).getMsg()); Log.getFindings().clear(); @@ -213,8 +214,8 @@ public void testPackageWrongPackageDefined() throws IOException { Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); parser.parse(model); - Assertions.assertEquals(1, Log.getFindings().size()); - Assertions.assertEquals("0xA4004 The package declaration de.ronticore of the grammar " + + assertEquals(1, Log.getFindings().size()); + assertEquals("0xA4004 The package declaration de.ronticore of the grammar " + "must not differ from the package of the grammar file.", Log.getFindings().get(0).getMsg()); Log.getFindings().clear(); diff --git a/monticore-grammar/src/test/java/de/monticore/grammar/MCGrammarPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/grammar/MCGrammarPrettyPrinterTest.java index 09b73bd833..a8576fb251 100644 --- a/monticore-grammar/src/test/java/de/monticore/grammar/MCGrammarPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/grammar/MCGrammarPrettyPrinterTest.java @@ -9,7 +9,6 @@ import de.monticore.prettyprint.IndentPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -17,8 +16,8 @@ import java.io.StringReader; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCGrammarPrettyPrinterTest { @@ -38,8 +37,8 @@ public void testStatechart() throws IOException { // Parsing input Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parseMCGrammar(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); // Prettyprinting input @@ -48,12 +47,12 @@ public void testStatechart() throws IOException { // Parsing printed input result = parser.parseMCGrammar(new StringReader (output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(grammar.deepEquals(result.get()), "Failed to deep equals: \n" + output); + assertTrue(grammar.deepEquals(result.get()), "Failed to deep equals: \n" + output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -64,8 +63,8 @@ public void testAutomaton() throws IOException { // Parsing input Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parseMCGrammar(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); // Prettyprinting input @@ -74,12 +73,12 @@ public void testAutomaton() throws IOException { // Parsing printed input result = parser.parseMCGrammar(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(grammar.deepEquals(result.get()), "Failed to deep equals: \n" + output); + assertTrue(grammar.deepEquals(result.get()), "Failed to deep equals: \n" + output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -90,8 +89,8 @@ public void testGrammar() throws IOException { // Parsing input Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parseMCGrammar(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); // Prettyprinting input @@ -100,12 +99,12 @@ public void testGrammar() throws IOException { // Parsing printed input result = parser.parseMCGrammar(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(grammar.deepEquals(result.get()), "Failed to deep equals: \n" + output); + assertTrue(grammar.deepEquals(result.get()), "Failed to deep equals: \n" + output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -116,8 +115,8 @@ public void testLexicals() throws IOException { // Parsing input Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parseMCGrammar(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); // Prettyprinting input @@ -126,12 +125,12 @@ public void testLexicals() throws IOException { // Parsing printed input result = parser.parseMCGrammar(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(grammar.deepEquals(result.get())); + assertTrue(grammar.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -142,8 +141,8 @@ public void testAnnotations() throws IOException { // Parsing input Grammar_WithConceptsParser parser = new Grammar_WithConceptsParser(); Optional result = parser.parseMCGrammar(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCGrammar grammar = result.get(); // Prettyprinting input @@ -152,12 +151,12 @@ public void testAnnotations() throws IOException { // Parsing printed input result = parser.parseMCGrammar(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(grammar.deepEquals(result.get()), "Failed to deep equals: \n" + output); + assertTrue(grammar.deepEquals(result.get()), "Failed to deep equals: \n" + output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/CocoTest.java b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/CocoTest.java index f64f278c11..5da803bd1e 100644 --- a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/CocoTest.java +++ b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/CocoTest.java @@ -10,9 +10,10 @@ import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; +import static org.junit.jupiter.api.Assertions.*; + public abstract class CocoTest { protected Grammar_WithConceptsCoCoChecker checker; @@ -32,13 +33,13 @@ protected void testValidGrammar(String grammar, Grammar_WithConceptsCoCoChecker final MCGrammarSymbol grammarSymbol = globalScope .resolveMCGrammar(grammar) .orElse(null); - Assertions.assertNotNull(grammarSymbol); - Assertions.assertTrue(grammarSymbol.getAstGrammar().isPresent()); + assertNotNull(grammarSymbol); + assertTrue(grammarSymbol.getAstGrammar().isPresent()); Log.getFindings().clear(); checker.checkAll(grammarSymbol.getAstGrammar().get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } protected void testInvalidGrammar(String grammar, String code, String message, @@ -54,16 +55,16 @@ protected void testInvalidGrammar(String grammar, String code, String message, final MCGrammarSymbol grammarSymbol = globalScope .resolveMCGrammar(grammar) .orElse(null); - Assertions.assertNotNull(grammarSymbol); - Assertions.assertTrue(grammarSymbol.getAstGrammar().isPresent()); + assertNotNull(grammarSymbol); + assertTrue(grammarSymbol.getAstGrammar().isPresent()); Log.getFindings().clear(); checker.checkAll(grammarSymbol.getAstGrammar().get()); - Assertions.assertFalse(Log.getFindings().isEmpty()); - Assertions.assertEquals(numberOfFindings, Log.getFindings().size()); + assertFalse(Log.getFindings().isEmpty()); + assertEquals(numberOfFindings, Log.getFindings().size()); for (Finding f : Log.getFindings()) { - Assertions.assertEquals(code + message, f.getMsg()); + assertEquals(code + message, f.getMsg()); } } @@ -75,13 +76,13 @@ protected void testInvalidGrammarKeepFindings(String grammar, String code, Strin final MCGrammarSymbol grammarSymbol = globalScope .resolveMCGrammar(grammar) .orElse(null); - Assertions.assertNotNull(grammarSymbol); - Assertions.assertTrue(grammarSymbol.getAstGrammar().isPresent()); + assertNotNull(grammarSymbol); + assertTrue(grammarSymbol.getAstGrammar().isPresent()); checker.checkAll(grammarSymbol.getAstGrammar().get()); - Assertions.assertFalse(Log.getFindings().isEmpty()); - Assertions.assertEquals(1, Log.getFindings().size()); + assertFalse(Log.getFindings().isEmpty()); + assertEquals(1, Log.getFindings().size()); for (Finding f : Log.getFindings()) { - Assertions.assertEquals(code + message, f.getMsg()); + assertEquals(code + message, f.getMsg()); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/GrammarInheritanceCycleTest.java b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/GrammarInheritanceCycleTest.java index 150741ded7..071b996fbb 100644 --- a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/GrammarInheritanceCycleTest.java +++ b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/GrammarInheritanceCycleTest.java @@ -6,7 +6,6 @@ import de.monticore.grammar.grammar_withconcepts._cocos.Grammar_WithConceptsCoCoChecker; import de.monticore.grammar.grammar_withconcepts._parser.Grammar_WithConceptsParser; import de.se_rwth.commons.logging.Finding; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,8 +15,8 @@ import static de.monticore.grammar.cocos.GrammarInheritanceCycle.ERROR_CODE; import static de.se_rwth.commons.logging.Log.getFindings; import static java.lang.String.format; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; public class GrammarInheritanceCycleTest extends CocoTest { @@ -36,10 +35,10 @@ public void testInvalid() throws IOException { getFindings().clear(); checker.checkAll(grammar.get()); - Assertions.assertFalse(getFindings().isEmpty()); - Assertions.assertEquals(1, getFindings().size()); + assertFalse(getFindings().isEmpty()); + assertEquals(1, getFindings().size()); for (Finding f : getFindings()) { - Assertions.assertEquals(format(ERROR_CODE + MESSAGE, ""), f.getMsg()); + assertEquals(format(ERROR_CODE + MESSAGE, ""), f.getMsg()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/GrammarNameEqualsFileNameTest.java b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/GrammarNameEqualsFileNameTest.java index 6ad0f0dbe2..1d663ed342 100644 --- a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/GrammarNameEqualsFileNameTest.java +++ b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/GrammarNameEqualsFileNameTest.java @@ -5,14 +5,13 @@ import de.monticore.grammar.grammar_withconcepts._parser.Grammar_WithConceptsParser; import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; public class GrammarNameEqualsFileNameTest extends CocoTest { @@ -26,9 +25,9 @@ public void testInvalidFilename() throws IOException { Log.getFindings().clear(); parser.parse("src/test/resources/de/monticore/grammar/cocos/invalid/A4003/A4003.mc4"); - Assertions.assertFalse(Log.getFindings().isEmpty()); + assertFalse(Log.getFindings().isEmpty()); for(Finding f : Log.getFindings()){ - Assertions.assertEquals("0"+"xA4003 The grammar name A4002 must be identical to the file name" + assertEquals("0"+"xA4003 The grammar name A4002 must be identical to the file name" + " A4003 of the grammar (without its file extension).", f.getMsg()); } } @@ -38,9 +37,9 @@ public void testInvalidPackage() throws IOException { Log.getFindings().clear(); parser.parse("src/test/resources/de/monticore/grammar/cocos/invalid/A4004/A4004.mc4"); - Assertions.assertFalse(Log.getFindings().isEmpty()); + assertFalse(Log.getFindings().isEmpty()); for(Finding f : Log.getFindings()){ - Assertions.assertEquals("0"+"xA4004 The package declaration de.monticore.grammar.cocos.invalid.A4003 of the grammar must not" + assertEquals("0"+"xA4004 The package declaration de.monticore.grammar.cocos.invalid.A4003 of the grammar must not" + " differ from the package of the grammar file.", f.getMsg()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/KeywordAlternativeNameTest.java b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/KeywordAlternativeNameTest.java index d804674acc..273ac69424 100644 --- a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/KeywordAlternativeNameTest.java +++ b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/KeywordAlternativeNameTest.java @@ -7,12 +7,11 @@ import de.monticore.grammar.grammar_withconcepts._symboltable.Grammar_WithConceptsGlobalScope; import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; public class KeywordAlternativeNameTest extends CocoTest { private final String MESSAGE = " The name of the constant group could't be ascertained"; @@ -33,10 +32,10 @@ public void testKeywordAlternativeWithoutName() throws IllegalArgumentException // test grammar symbol globalScope.resolveMCGrammar(grammar).orElse(null); - Assertions.assertFalse(Log.getFindings().isEmpty()); - Assertions.assertEquals(1, Log.getFindings().size()); + assertFalse(Log.getFindings().isEmpty()); + assertEquals(1, Log.getFindings().size()); for (Finding f : Log.getFindings()) { - Assertions.assertEquals("0xA2345" + MESSAGE, f.getMsg()); + assertEquals("0xA2345" + MESSAGE, f.getMsg()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/NTUniqueIgnoreCaseTest.java b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/NTUniqueIgnoreCaseTest.java index 352bbbe0f5..2841190561 100644 --- a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/NTUniqueIgnoreCaseTest.java +++ b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/NTUniqueIgnoreCaseTest.java @@ -5,12 +5,11 @@ import de.monticore.grammar.grammar_withconcepts._cocos.Grammar_WithConceptsCoCoChecker; import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; public class NTUniqueIgnoreCaseTest extends CocoTest { @@ -28,10 +27,10 @@ public void init() { public void testInvalid() { Log.getFindings().clear(); testInvalidGrammar(grammar, NTUniqueIgnoreCase.ERROR_CODE, MESSAGE, checker); - Assertions.assertFalse(Log.getFindings().isEmpty()); - Assertions.assertEquals(1, Log.getFindings().size()); + assertFalse(Log.getFindings().isEmpty()); + assertEquals(1, Log.getFindings().size()); for (Finding f : Log.getFindings()) { - Assertions.assertEquals(NTUniqueIgnoreCase.ERROR_CODE + MESSAGE, f.getMsg()); + assertEquals(NTUniqueIgnoreCase.ERROR_CODE + MESSAGE, f.getMsg()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/NoNTInheritanceCycleTest.java b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/NoNTInheritanceCycleTest.java index 5dd57a1a7a..ee83ad68d0 100644 --- a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/NoNTInheritanceCycleTest.java +++ b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/NoNTInheritanceCycleTest.java @@ -7,10 +7,11 @@ import de.monticore.grammar.grammar_withconcepts._cocos.Grammar_WithConceptsCoCoChecker; import de.monticore.grammar.grammar_withconcepts._symboltable.Grammar_WithConceptsGlobalScope; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class NoNTInheritanceCycleTest extends CocoTest { private final String grammar = "de.monticore.grammar.cocos.invalid.A4022.A4022"; @@ -33,15 +34,15 @@ public void testInvalid2() { // test grammar symbol final MCGrammarSymbol grammarSymbol = (MCGrammarSymbol) globalScope.resolveMCGrammar(grammar + "b").orElse(null); - Assertions.assertNotNull(grammarSymbol); - Assertions.assertTrue(grammarSymbol.getAstGrammar().isPresent()); + assertNotNull(grammarSymbol); + assertTrue(grammarSymbol.getAstGrammar().isPresent()); Log.getFindings().clear(); checker.checkAll(grammarSymbol.getAstGrammar().get()); - Assertions.assertEquals(2, Log.getFindings().size()); - Assertions.assertEquals(NoNTInheritanceCycle.ERROR_CODE + String.format(NoNTInheritanceCycle.ERROR_MSG_FORMAT, "de.monticore.grammar.cocos.invalid.A4022.A4022b.A"), Log.getFindings().get(0).getMsg()); - Assertions.assertEquals(NoNTInheritanceCycle.ERROR_CODE + String.format(NoNTInheritanceCycle.ERROR_MSG_FORMAT, "de.monticore.grammar.cocos.invalid.A4022.A4022b.B"), Log.getFindings().get(1).getMsg()); + assertEquals(2, Log.getFindings().size()); + assertEquals(NoNTInheritanceCycle.ERROR_CODE + String.format(NoNTInheritanceCycle.ERROR_MSG_FORMAT, "de.monticore.grammar.cocos.invalid.A4022.A4022b.A"), Log.getFindings().get(0).getMsg()); + assertEquals(NoNTInheritanceCycle.ERROR_CODE + String.format(NoNTInheritanceCycle.ERROR_MSG_FORMAT, "de.monticore.grammar.cocos.invalid.A4022.A4022b.B"), Log.getFindings().get(1).getMsg()); } diff --git a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/UsedNTNotDefinedTest.java b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/UsedNTNotDefinedTest.java index 6e885a8d6e..38cee0641f 100644 --- a/monticore-grammar/src/test/java/de/monticore/grammar/cocos/UsedNTNotDefinedTest.java +++ b/monticore-grammar/src/test/java/de/monticore/grammar/cocos/UsedNTNotDefinedTest.java @@ -5,10 +5,11 @@ import de.monticore.grammar.grammar_withconcepts._cocos.Grammar_WithConceptsCoCoChecker; import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class UsedNTNotDefinedTest extends CocoTest { private final String MESSAGE =" The production A must not use the nonterminal " + @@ -24,13 +25,13 @@ public void init() { @Test public void testInvalid() { testInvalidGrammar(grammar, UsedNTNotDefined.ERROR_CODE, MESSAGE, checker); - Assertions.assertFalse(Log.getFindings().isEmpty()); - Assertions.assertEquals(1, Log.getFindings().size()); + assertFalse(Log.getFindings().isEmpty()); + assertEquals(1, Log.getFindings().size()); boolean found = false; for (Finding f : Log.getFindings()) { found |= f.getMsg().equals(UsedNTNotDefined.ERROR_CODE + MESSAGE); } - Assertions.assertTrue(found); + assertTrue(found); } @Test diff --git a/monticore-grammar/src/test/java/de/monticore/grammar/symboltable/IGrammarScopeTest.java b/monticore-grammar/src/test/java/de/monticore/grammar/symboltable/IGrammarScopeTest.java index 07c9f93efc..934af00d9f 100644 --- a/monticore-grammar/src/test/java/de/monticore/grammar/symboltable/IGrammarScopeTest.java +++ b/monticore-grammar/src/test/java/de/monticore/grammar/symboltable/IGrammarScopeTest.java @@ -10,15 +10,14 @@ import de.monticore.symboltable.modifiers.AccessModifier; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class IGrammarScopeTest { @@ -35,34 +34,34 @@ public void testCombiningGrammarSymbolTable() throws IOException { final Grammar_WithConceptsGlobalScope globalScope = GrammarGlobalScopeTestFactory.create(); final Optional grammar = globalScope .resolveMCGrammar("de.monticore.CombiningGrammar"); - Assertions.assertTrue(grammar.isPresent()); - Assertions.assertTrue(grammar.get().isPresentAstNode()); + assertTrue(grammar.isPresent()); + assertTrue(grammar.get().isPresentAstNode()); ASTMCGrammar ast = grammar.get().getAstNode(); IGrammarScope innerScope = ast.getClassProd(0).getEnclosingScope(); - Assertions.assertTrue(innerScope.resolveProd("NewProd").isPresent()); + assertTrue(innerScope.resolveProd("NewProd").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("Automaton").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("Transition").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("State").isPresent()); + assertTrue(innerScope.resolveProd("Automaton").isPresent()); + assertTrue(innerScope.resolveProd("Transition").isPresent()); + assertTrue(innerScope.resolveProd("State").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("X").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("Y").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("J").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("G").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("K").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("N").isPresent()); + assertTrue(innerScope.resolveProd("X").isPresent()); + assertTrue(innerScope.resolveProd("Y").isPresent()); + assertTrue(innerScope.resolveProd("J").isPresent()); + assertTrue(innerScope.resolveProd("G").isPresent()); + assertTrue(innerScope.resolveProd("K").isPresent()); + assertTrue(innerScope.resolveProd("N").isPresent()); - Assertions.assertFalse(innerScope.resolveProd("Supergrammar").isPresent()); - Assertions.assertFalse(innerScope.resolveProd("de.monticore.inherited.Supergrammar").isPresent()); - Assertions.assertFalse(innerScope.resolveProd("CombiningGrammar").isPresent()); + assertFalse(innerScope.resolveProd("Supergrammar").isPresent()); + assertFalse(innerScope.resolveProd("de.monticore.inherited.Supergrammar").isPresent()); + assertFalse(innerScope.resolveProd("CombiningGrammar").isPresent()); - Assertions.assertTrue(innerScope.resolveMCGrammar("de.monticore.inherited.Supergrammar").isPresent()); - Assertions.assertTrue(innerScope.resolveMCGrammar("CombiningGrammar").isPresent()); - Assertions.assertTrue(innerScope.resolveMCGrammar("Automaton").isPresent()); + assertTrue(innerScope.resolveMCGrammar("de.monticore.inherited.Supergrammar").isPresent()); + assertTrue(innerScope.resolveMCGrammar("CombiningGrammar").isPresent()); + assertTrue(innerScope.resolveMCGrammar("Automaton").isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -70,28 +69,28 @@ public void testCombiningGrammarResolveInSuperGrammars() throws IOException { final Grammar_WithConceptsGlobalScope globalScope = GrammarGlobalScopeTestFactory.create(); final Optional grammar = globalScope .resolveMCGrammar("de.monticore.CombiningGrammar"); - Assertions.assertTrue(grammar.isPresent()); - Assertions.assertTrue(grammar.get().isPresentAstNode()); + assertTrue(grammar.isPresent()); + assertTrue(grammar.get().isPresentAstNode()); ASTMCGrammar ast = grammar.get().getAstNode(); IGrammarScope innerScope = ast.getClassProd(0).getEnclosingScope(); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("Automaton", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("Transition", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("State", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("Automaton", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("Transition", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("State", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("X", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("Y", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("J", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("G", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("K", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("N", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("X", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("Y", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("J", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("G", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("K", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("N", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertFalse(innerScope.resolveInSuperGrammars("Supergrammar", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertFalse(innerScope.resolveInSuperGrammars("de.monticore.inherited.Supergrammar", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertFalse(innerScope.resolveInSuperGrammars("CombiningGrammar", AccessModifier.ALL_INCLUSION).isPresent()); + assertFalse(innerScope.resolveInSuperGrammars("Supergrammar", AccessModifier.ALL_INCLUSION).isPresent()); + assertFalse(innerScope.resolveInSuperGrammars("de.monticore.inherited.Supergrammar", AccessModifier.ALL_INCLUSION).isPresent()); + assertFalse(innerScope.resolveInSuperGrammars("CombiningGrammar", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -99,43 +98,43 @@ public void testSubsubgrammarSymbolTable() throws IOException { final Grammar_WithConceptsGlobalScope globalScope = GrammarGlobalScopeTestFactory.create(); final Optional grammar = globalScope .resolveMCGrammar("de.monticore.inherited.Subsubgrammar"); - Assertions.assertTrue(grammar.isPresent()); - Assertions.assertTrue(grammar.get().isPresentAstNode()); + assertTrue(grammar.isPresent()); + assertTrue(grammar.get().isPresentAstNode()); ASTMCGrammar ast = grammar.get().getAstNode(); IGrammarScope innerScope = ast.getClassProd(0).getEnclosingScope(); - Assertions.assertTrue(innerScope.resolveProd("N").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("S").isPresent()); - - Assertions.assertTrue(innerScope.resolveProd("A").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("B").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("M").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("D").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("L").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("O").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("M").isPresent()); - - Assertions.assertTrue(innerScope.resolveProd("X").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("Y").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("J").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("G").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("K").isPresent()); - Assertions.assertTrue(innerScope.resolveProd("N").isPresent()); - - Assertions.assertFalse(innerScope.resolveProd("Supergrammar").isPresent()); - Assertions.assertFalse(innerScope.resolveProd("de.monticore.inherited.Supergrammar").isPresent()); - Assertions.assertFalse(innerScope.resolveProd("Subgrammar").isPresent()); - Assertions.assertFalse(innerScope.resolveProd("de.monticore.inherited.Subgrammar").isPresent()); - Assertions.assertFalse(innerScope.resolveProd("Subsubgrammar").isPresent()); - Assertions.assertFalse(innerScope.resolveProd("de.monticore.inherited.Subsubgrammar").isPresent()); - - Assertions.assertTrue(innerScope.resolveMCGrammar("de.monticore.inherited.Supergrammar").isPresent()); - Assertions.assertTrue(innerScope.resolveMCGrammar("de.monticore.inherited.Subgrammar").isPresent()); - Assertions.assertTrue(innerScope.resolveMCGrammar("de.monticore.inherited.Subsubgrammar").isPresent()); - Assertions.assertTrue(innerScope.resolveMCGrammar("Subsubgrammar").isPresent()); + assertTrue(innerScope.resolveProd("N").isPresent()); + assertTrue(innerScope.resolveProd("S").isPresent()); + + assertTrue(innerScope.resolveProd("A").isPresent()); + assertTrue(innerScope.resolveProd("B").isPresent()); + assertTrue(innerScope.resolveProd("M").isPresent()); + assertTrue(innerScope.resolveProd("D").isPresent()); + assertTrue(innerScope.resolveProd("L").isPresent()); + assertTrue(innerScope.resolveProd("O").isPresent()); + assertTrue(innerScope.resolveProd("M").isPresent()); + + assertTrue(innerScope.resolveProd("X").isPresent()); + assertTrue(innerScope.resolveProd("Y").isPresent()); + assertTrue(innerScope.resolveProd("J").isPresent()); + assertTrue(innerScope.resolveProd("G").isPresent()); + assertTrue(innerScope.resolveProd("K").isPresent()); + assertTrue(innerScope.resolveProd("N").isPresent()); + + assertFalse(innerScope.resolveProd("Supergrammar").isPresent()); + assertFalse(innerScope.resolveProd("de.monticore.inherited.Supergrammar").isPresent()); + assertFalse(innerScope.resolveProd("Subgrammar").isPresent()); + assertFalse(innerScope.resolveProd("de.monticore.inherited.Subgrammar").isPresent()); + assertFalse(innerScope.resolveProd("Subsubgrammar").isPresent()); + assertFalse(innerScope.resolveProd("de.monticore.inherited.Subsubgrammar").isPresent()); + + assertTrue(innerScope.resolveMCGrammar("de.monticore.inherited.Supergrammar").isPresent()); + assertTrue(innerScope.resolveMCGrammar("de.monticore.inherited.Subgrammar").isPresent()); + assertTrue(innerScope.resolveMCGrammar("de.monticore.inherited.Subsubgrammar").isPresent()); + assertTrue(innerScope.resolveMCGrammar("Subsubgrammar").isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -143,35 +142,35 @@ public void testSubsubgrammarResolveInSuperGrammars() throws IOException { final Grammar_WithConceptsGlobalScope globalScope = GrammarGlobalScopeTestFactory.create(); final Optional grammar = globalScope .resolveMCGrammar("de.monticore.inherited.Subsubgrammar"); - Assertions.assertTrue(grammar.isPresent()); - Assertions.assertTrue(grammar.get().isPresentAstNode()); + assertTrue(grammar.isPresent()); + assertTrue(grammar.get().isPresentAstNode()); ASTMCGrammar ast = grammar.get().getAstNode(); IGrammarScope innerScope = ast.getClassProd(0).getEnclosingScope(); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("N", AccessModifier.ALL_INCLUSION).isPresent()); - - Assertions.assertTrue(innerScope.resolveInSuperGrammars("A", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("B", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("M", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("D", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("L", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("O", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("M", AccessModifier.ALL_INCLUSION).isPresent()); - - Assertions.assertTrue(innerScope.resolveInSuperGrammars("X", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("Y", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("J", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("G", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("K", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(innerScope.resolveInSuperGrammars("N", AccessModifier.ALL_INCLUSION).isPresent()); - - Assertions.assertFalse(innerScope.resolveInSuperGrammars("Supergrammar", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertFalse(innerScope.resolveInSuperGrammars("de.monticore.inherited.Supergrammar", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertFalse(innerScope.resolveInSuperGrammars("Subgrammar", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertFalse(innerScope.resolveInSuperGrammars("de.monticore.inherited.Subgrammar", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertFalse(innerScope.resolveInSuperGrammars("Subsubgrammar", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertFalse(innerScope.resolveInSuperGrammars("de.monticore.inherited.Subsubgrammar", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("N", AccessModifier.ALL_INCLUSION).isPresent()); + + assertTrue(innerScope.resolveInSuperGrammars("A", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("B", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("M", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("D", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("L", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("O", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("M", AccessModifier.ALL_INCLUSION).isPresent()); + + assertTrue(innerScope.resolveInSuperGrammars("X", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("Y", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("J", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("G", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("K", AccessModifier.ALL_INCLUSION).isPresent()); + assertTrue(innerScope.resolveInSuperGrammars("N", AccessModifier.ALL_INCLUSION).isPresent()); + + assertFalse(innerScope.resolveInSuperGrammars("Supergrammar", AccessModifier.ALL_INCLUSION).isPresent()); + assertFalse(innerScope.resolveInSuperGrammars("de.monticore.inherited.Supergrammar", AccessModifier.ALL_INCLUSION).isPresent()); + assertFalse(innerScope.resolveInSuperGrammars("Subgrammar", AccessModifier.ALL_INCLUSION).isPresent()); + assertFalse(innerScope.resolveInSuperGrammars("de.monticore.inherited.Subgrammar", AccessModifier.ALL_INCLUSION).isPresent()); + assertFalse(innerScope.resolveInSuperGrammars("Subsubgrammar", AccessModifier.ALL_INCLUSION).isPresent()); + assertFalse(innerScope.resolveInSuperGrammars("de.monticore.inherited.Subsubgrammar", AccessModifier.ALL_INCLUSION).isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/grammar/symboltable/MontiCoreGrammarSymbolTableCreatorTest.java b/monticore-grammar/src/test/java/de/monticore/grammar/symboltable/MontiCoreGrammarSymbolTableCreatorTest.java index 82f304f714..d8b173283e 100644 --- a/monticore-grammar/src/test/java/de/monticore/grammar/symboltable/MontiCoreGrammarSymbolTableCreatorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/grammar/symboltable/MontiCoreGrammarSymbolTableCreatorTest.java @@ -9,7 +9,6 @@ import de.monticore.grammar.grammar_withconcepts._symboltable.Grammar_WithConceptsGlobalScope; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,6 +17,8 @@ import java.util.Map; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MontiCoreGrammarSymbolTableCreatorTest { @BeforeEach @@ -35,140 +36,140 @@ public void testSymbolTableOfGrammarStatechartDSL() { final Optional grammar = globalScope .resolveMCGrammar("de.monticore.Statechart"); - Assertions.assertTrue(grammar.isPresent()); - Assertions.assertTrue(grammar.get().isPresentAstNode()); + assertTrue(grammar.isPresent()); + assertTrue(grammar.get().isPresentAstNode()); testGrammarSymbolOfStatechart(grammar.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private void testGrammarSymbolOfStatechart(MCGrammarSymbol grammar) { - Assertions.assertNotNull(grammar); - Assertions.assertEquals("de.monticore.Statechart", grammar.getFullName()); - Assertions.assertEquals("de.monticore", grammar.getPackageName()); - Assertions.assertTrue(grammar.getStartProd().isPresent()); + assertNotNull(grammar); + assertEquals("de.monticore.Statechart", grammar.getFullName()); + assertEquals("de.monticore", grammar.getPackageName()); + assertTrue(grammar.getStartProd().isPresent()); - Assertions.assertTrue(grammar.isIsComponent()); - Assertions.assertEquals(1, grammar.getSuperGrammars().size()); + assertTrue(grammar.isIsComponent()); + assertEquals(1, grammar.getSuperGrammars().size()); - Assertions.assertEquals(12, grammar.getProds().size()); + assertEquals(12, grammar.getProds().size()); // AST - Assertions.assertTrue(grammar.isPresentAstNode()); - Assertions.assertSame(grammar.getEnclosingScope(), grammar.getAstNode().getEnclosingScope()); + assertTrue(grammar.isPresentAstNode()); + assertSame(grammar.getEnclosingScope(), grammar.getAstNode().getEnclosingScope()); final ProdSymbol stateChartProd = grammar.getProd("Statechart").orElse(null); - Assertions.assertNotNull(stateChartProd); - Assertions.assertEquals("Statechart", stateChartProd.getName()); - Assertions.assertEquals("de.monticore.Statechart.Statechart", stateChartProd.getFullName()); - Assertions.assertEquals("de.monticore", stateChartProd.getPackageName()); - Assertions.assertTrue(stateChartProd.isIsStartProd()); - Assertions.assertTrue(stateChartProd.isClass()); + assertNotNull(stateChartProd); + assertEquals("Statechart", stateChartProd.getName()); + assertEquals("de.monticore.Statechart.Statechart", stateChartProd.getFullName()); + assertEquals("de.monticore", stateChartProd.getPackageName()); + assertTrue(stateChartProd.isIsStartProd()); + assertTrue(stateChartProd.isClass()); // generic vs. specific Optional resolvedStateChartProd = grammar.getSpannedScope().resolveProd("Statechart"); - Assertions.assertTrue(resolvedStateChartProd.isPresent()); - Assertions.assertSame(stateChartProd, resolvedStateChartProd.get()); + assertTrue(resolvedStateChartProd.isPresent()); + assertSame(stateChartProd, resolvedStateChartProd.get()); // AST testLinkBetweenSymbolAndAst(stateChartProd); final ProdSymbol entryActionProd = grammar.getProd("EntryAction").orElse(null); - Assertions.assertNotNull(entryActionProd); - Assertions.assertEquals("EntryAction", entryActionProd.getName()); - Assertions.assertEquals("de.monticore.Statechart.EntryAction", entryActionProd.getFullName()); - Assertions.assertFalse(entryActionProd.isIsStartProd()); + assertNotNull(entryActionProd); + assertEquals("EntryAction", entryActionProd.getName()); + assertEquals("de.monticore.Statechart.EntryAction", entryActionProd.getFullName()); + assertFalse(entryActionProd.isIsStartProd()); testLinkBetweenSymbolAndAst(entryActionProd); // test prod components Collection rcsList = entryActionProd.getProdComponents(); - Assertions.assertEquals(1, rcsList.size()); + assertEquals(1, rcsList.size()); List prodComps = entryActionProd.getSpannedScope().resolveRuleComponentDownMany("block"); - Assertions.assertFalse(prodComps.isEmpty()); - Assertions.assertEquals("block", prodComps.get(0).getName()); - Assertions.assertTrue(prodComps.get(0).isIsNonterminal()); - Assertions.assertTrue(prodComps.get(0).isPresentAstNode()); - Assertions.assertFalse(prodComps.get(0).isIsList()); - Assertions.assertFalse(prodComps.get(0).isIsOptional()); - Assertions.assertSame(entryActionProd.getSpannedScope(), prodComps.get(0).getEnclosingScope()); + assertFalse(prodComps.isEmpty()); + assertEquals("block", prodComps.get(0).getName()); + assertTrue(prodComps.get(0).isIsNonterminal()); + assertTrue(prodComps.get(0).isPresentAstNode()); + assertFalse(prodComps.get(0).isIsList()); + assertFalse(prodComps.get(0).isIsOptional()); + assertSame(entryActionProd.getSpannedScope(), prodComps.get(0).getEnclosingScope()); // reference to defining prod - Assertions.assertEquals("BlockStatement", prodComps.get(0).getReferencedProd().get().getName()); - Assertions.assertTrue(prodComps.get(0).getReferencedProd().get().isIsExternal()); + assertEquals("BlockStatement", prodComps.get(0).getReferencedProd().get().getName()); + assertTrue(prodComps.get(0).getReferencedProd().get().isIsExternal()); ProdSymbol scStructure = grammar.getProd("SCStructure").orElse(null); - Assertions.assertNotNull(scStructure); - Assertions.assertEquals("SCStructure", scStructure.getName()); - Assertions.assertTrue(scStructure.isIsInterface()); - Assertions.assertEquals(0, scStructure.getProdComponents().size()); + assertNotNull(scStructure); + assertEquals("SCStructure", scStructure.getName()); + assertTrue(scStructure.isIsInterface()); + assertEquals(0, scStructure.getProdComponents().size()); testLinkBetweenSymbolAndAst(scStructure); ProdSymbol abstractAnything = grammar.getProd("AbstractAnything").orElse(null); - Assertions.assertNotNull(abstractAnything); - Assertions.assertEquals("AbstractAnything", abstractAnything.getName()); - Assertions.assertEquals("de.monticore.Statechart.AbstractAnything", abstractAnything.getFullName()); - Assertions.assertFalse(abstractAnything.isIsInterface()); - Assertions.assertFalse(abstractAnything.isIsSymbolDefinition()); - Assertions.assertEquals(0, abstractAnything.getProdComponents().size()); + assertNotNull(abstractAnything); + assertEquals("AbstractAnything", abstractAnything.getName()); + assertEquals("de.monticore.Statechart.AbstractAnything", abstractAnything.getFullName()); + assertFalse(abstractAnything.isIsInterface()); + assertFalse(abstractAnything.isIsSymbolDefinition()); + assertEquals(0, abstractAnything.getProdComponents().size()); testLinkBetweenSymbolAndAst(abstractAnything); final ProdSymbol stateProd = grammar.getProd("State").orElse(null); - Assertions.assertNotNull(stateProd); - Assertions.assertEquals("State", stateProd.getName()); - Assertions.assertEquals("de.monticore.Statechart.State", stateProd.getFullName()); - Assertions.assertTrue(stateProd.isClass()); + assertNotNull(stateProd); + assertEquals("State", stateProd.getName()); + assertEquals("de.monticore.Statechart.State", stateProd.getFullName()); + assertTrue(stateProd.isClass()); - Assertions.assertEquals(1, stateProd.getSuperInterfaceProds().size()); + assertEquals(1, stateProd.getSuperInterfaceProds().size()); final ProdSymbolSurrogate superInterfaceScStructure = stateProd.getSuperInterfaceProds() .get(0); - Assertions.assertSame(scStructure, superInterfaceScStructure.lazyLoadDelegate()); + assertSame(scStructure, superInterfaceScStructure.lazyLoadDelegate()); // AST testLinkBetweenSymbolAndAst(stateProd); List initialComponents = stateProd.getSpannedScope().resolveRuleComponentDownMany("initial"); - Assertions.assertFalse(initialComponents.isEmpty()); + assertFalse(initialComponents.isEmpty()); RuleComponentSymbol initialComponent = initialComponents.get(0); - Assertions.assertEquals("de.monticore.Statechart.State.initial", initialComponent.getFullName()); - Assertions.assertEquals("initial", initialComponent.getName()); + assertEquals("de.monticore.Statechart.State.initial", initialComponent.getFullName()); + assertEquals("initial", initialComponent.getName()); ProdSymbol classBody = grammar.getProd("Classbody").orElse(null); - Assertions.assertNotNull(classBody); - Assertions.assertEquals("Classbody", classBody.getName()); - Assertions.assertEquals(0, classBody.getProdComponents().size()); - Assertions.assertTrue(classBody.isIsExternal()); - Assertions.assertFalse(classBody.isIsSymbolDefinition()); + assertNotNull(classBody); + assertEquals("Classbody", classBody.getName()); + assertEquals(0, classBody.getProdComponents().size()); + assertTrue(classBody.isIsExternal()); + assertFalse(classBody.isIsSymbolDefinition()); testLinkBetweenSymbolAndAst(classBody); ProdSymbol codeProd = grammar.getProd("Code").orElse(null); - Assertions.assertNotNull(codeProd); - Assertions.assertEquals("Code", codeProd.getName()); - Assertions.assertEquals(1, codeProd.getProdComponents().size()); + assertNotNull(codeProd); + assertEquals("Code", codeProd.getName()); + assertEquals(1, codeProd.getProdComponents().size()); prodComps = codeProd.getSpannedScope().resolveRuleComponentDownMany("body"); - Assertions.assertFalse((prodComps.isEmpty())); - Assertions.assertTrue(prodComps.get(0).getReferencedProd().isPresent()); - Assertions.assertSame(classBody, prodComps.get(0).getReferencedProd().get().lazyLoadDelegate()); + assertFalse((prodComps.isEmpty())); + assertTrue(prodComps.get(0).getReferencedProd().isPresent()); + assertSame(classBody, prodComps.get(0).getReferencedProd().get().lazyLoadDelegate()); testLinkBetweenSymbolAndAst(codeProd); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private void testLinkBetweenSymbolAndAst(ProdSymbol prodSymbol) { - Assertions.assertTrue(prodSymbol.isPresentAstNode()); - Assertions.assertSame(prodSymbol, prodSymbol.getAstNode().getSymbol()); - Assertions.assertSame(prodSymbol.getEnclosingScope(), prodSymbol.getAstNode().getEnclosingScope()); + assertTrue(prodSymbol.isPresentAstNode()); + assertSame(prodSymbol, prodSymbol.getAstNode().getSymbol()); + assertSame(prodSymbol.getEnclosingScope(), prodSymbol.getAstNode().getEnclosingScope()); if (prodSymbol.isClass()) { - Assertions.assertTrue(prodSymbol.getAstNode() instanceof ASTClassProd); + assertTrue(prodSymbol.getAstNode() instanceof ASTClassProd); } else if (prodSymbol.isIsInterface()) { - Assertions.assertTrue(prodSymbol.getAstNode() instanceof ASTInterfaceProd); + assertTrue(prodSymbol.getAstNode() instanceof ASTInterfaceProd); } else if (prodSymbol.isIsAbstract()) { - Assertions.assertTrue(prodSymbol.getAstNode() instanceof ASTAbstractProd); + assertTrue(prodSymbol.getAstNode() instanceof ASTAbstractProd); } else if (prodSymbol.isIsLexerProd()) { - Assertions.assertTrue(prodSymbol.getAstNode() instanceof ASTLexProd); + assertTrue(prodSymbol.getAstNode() instanceof ASTLexProd); } else if (prodSymbol.isIsExternal()) { - Assertions.assertTrue(prodSymbol.getAstNode() instanceof ASTExternalProd); + assertTrue(prodSymbol.getAstNode() instanceof ASTExternalProd); } } @@ -177,25 +178,25 @@ public void testGrammarTypeReferences() { final Grammar_WithConceptsGlobalScope globalScope = GrammarGlobalScopeTestFactory.create(); MCGrammarSymbol grammar = globalScope.resolveMCGrammar("de.monticore.TypeReferences").orElse(null); - Assertions.assertNotNull(grammar); + assertNotNull(grammar); - Assertions.assertEquals(5, grammar.getProds().size()); + assertEquals(5, grammar.getProds().size()); ProdSymbol c = grammar.getProd("C").orElse(null); - Assertions.assertNotNull(c); - Assertions.assertEquals("C", c.getName()); - Assertions.assertTrue(c.isIsInterface()); - Assertions.assertEquals(0, c.getProdComponents().size()); + assertNotNull(c); + assertEquals("C", c.getName()); + assertTrue(c.isIsInterface()); + assertEquals(0, c.getProdComponents().size()); ProdSymbol q = grammar.getProd("Q").orElse(null); - Assertions.assertNotNull(q); - Assertions.assertEquals("Q", q.getName()); - Assertions.assertTrue(q.isClass()); + assertNotNull(q); + assertEquals("Q", q.getName()); + assertTrue(q.isClass()); ProdSymbol p = grammar.getProd("P").orElse(null); - Assertions.assertNotNull(p); + assertNotNull(p); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -205,44 +206,44 @@ public void testSuperGrammar() { MCGrammarSymbol grammar = globalScope .resolveMCGrammar("de.monticore.SubStatechart") .orElse(null); - Assertions.assertNotNull(grammar); - Assertions.assertEquals("de.monticore.SubStatechart", grammar.getFullName()); - Assertions.assertTrue(grammar.getStartProd().isPresent()); + assertNotNull(grammar); + assertEquals("de.monticore.SubStatechart", grammar.getFullName()); + assertTrue(grammar.getStartProd().isPresent()); - Assertions.assertEquals(1, grammar.getSuperGrammars().size()); + assertEquals(1, grammar.getSuperGrammars().size()); MCGrammarSymbolSurrogate superGrammarRef = grammar.getSuperGrammars().get(0); - Assertions.assertEquals("Statechart", superGrammarRef.getName()); - Assertions.assertEquals("de.monticore.Statechart", superGrammarRef.getFullName()); + assertEquals("Statechart", superGrammarRef.getName()); + assertEquals("de.monticore.Statechart", superGrammarRef.getFullName()); testGrammarSymbolOfStatechart(superGrammarRef.lazyLoadDelegate()); ProdSymbol firstProd = grammar.getProd("First").orElse(null); - Assertions.assertNotNull(firstProd); - Assertions.assertTrue(firstProd.isIsStartProd()); - Assertions.assertSame(grammar.getStartProd().get(), firstProd); + assertNotNull(firstProd); + assertTrue(firstProd.isIsStartProd()); + assertSame(grammar.getStartProd().get(), firstProd); ProdSymbol secondProd = grammar.getProd("Second").orElse(null); - Assertions.assertNotNull(secondProd); - Assertions.assertFalse(secondProd.isIsStartProd()); + assertNotNull(secondProd); + assertFalse(secondProd.isIsStartProd()); - Assertions.assertEquals(2, grammar.getProdNames().size()); - Assertions.assertEquals(19, grammar.getProdsWithInherited().size()); + assertEquals(2, grammar.getProdNames().size()); + assertEquals(19, grammar.getProdsWithInherited().size()); // get prod of super grammar - Assertions.assertFalse(grammar.getProd("State").isPresent()); + assertFalse(grammar.getProd("State").isPresent()); final ProdSymbol stateProd = grammar.getProdWithInherited("State").orElse(null); - Assertions.assertNotNull(stateProd); - Assertions.assertEquals("de.monticore.Statechart.State", stateProd.getFullName()); + assertNotNull(stateProd); + assertEquals("de.monticore.Statechart.State", stateProd.getFullName()); // generic vs. specific search in super grammar Optional resolvedProd = grammar.getSpannedScope().resolveProd("State"); - Assertions.assertTrue(resolvedProd.isPresent()); - Assertions.assertSame(stateProd, resolvedProd.get()); + assertTrue(resolvedProd.isPresent()); + assertSame(stateProd, resolvedProd.get()); Optional resolvedProd2 = firstProd.getEnclosingScope().resolveProd("State"); - Assertions.assertTrue(resolvedProd2.isPresent()); - Assertions.assertSame(stateProd, resolvedProd2.get()); + assertTrue(resolvedProd2.isPresent()); + assertSame(stateProd, resolvedProd2.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -251,22 +252,22 @@ public void testMontiCoreGrammar() { final Grammar_WithConceptsGlobalScope globalScope = GrammarGlobalScopeTestFactory.create(); MCGrammarSymbol grammar = globalScope.resolveMCGrammar("de.monticore.TestGrammar").orElse(null); - Assertions.assertNotNull(grammar); - Assertions.assertEquals("de.monticore.TestGrammar", grammar.getFullName()); + assertNotNull(grammar); + assertEquals("de.monticore.TestGrammar", grammar.getFullName()); - Assertions.assertEquals(3, countExternalProd(grammar)); - Assertions.assertEquals(5, countInterfaceAndAbstractProds(grammar)); + assertEquals(3, countExternalProd(grammar)); + assertEquals(5, countInterfaceAndAbstractProds(grammar)); - Assertions.assertEquals(1, grammar.getSuperGrammars().size()); + assertEquals(1, grammar.getSuperGrammars().size()); final MCGrammarSymbolSurrogate superGrammarRef = grammar.getSuperGrammars().get(0); final String superGrammarFullName = superGrammarRef.lazyLoadDelegate().getFullName(); - Assertions.assertEquals("de.monticore.common.TestLiterals", superGrammarFullName); + assertEquals("de.monticore.common.TestLiterals", superGrammarFullName); ProdSymbol prod = grammar.getProdWithInherited("StringLiteral").orElse(null); - Assertions.assertNotNull(prod); - Assertions.assertEquals(superGrammarFullName + ".StringLiteral", prod.getFullName()); + assertNotNull(prod); + assertEquals(superGrammarFullName + ".StringLiteral", prod.getFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -275,18 +276,18 @@ public void testNonTerminalsWithSameName() { MCGrammarSymbol grammar = globalScope.resolveMCGrammar("de.monticore" + ".NonTerminalsWithSameName").orElse(null); - Assertions.assertNotNull(grammar); - Assertions.assertEquals("de.monticore.NonTerminalsWithSameName", grammar.getFullName()); + assertNotNull(grammar); + assertEquals("de.monticore.NonTerminalsWithSameName", grammar.getFullName()); - Assertions.assertEquals(2, grammar.getProds().size()); + assertEquals(2, grammar.getProds().size()); ProdSymbol transition = grammar.getProd("Transition").orElse(null); - Assertions.assertNotNull(transition); + assertNotNull(transition); List r = transition.getSpannedScope().resolveRuleComponentMany("arg"); - Assertions.assertEquals(2, r.size()); - Assertions.assertTrue(r.get(0).isIsList()); + assertEquals(2, r.size()); + assertTrue(r.get(0).isIsList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -294,16 +295,16 @@ public void testTokenModes() { final Grammar_WithConceptsGlobalScope globalScope = GrammarGlobalScopeTestFactory.create(); MCGrammarSymbol grammar = globalScope.resolveMCGrammar("de.monticore.Modes").orElse(null); - Assertions.assertNotNull(grammar); - Assertions.assertEquals("de.monticore.Modes", grammar.getFullName()); + assertNotNull(grammar); + assertEquals("de.monticore.Modes", grammar.getFullName()); Map> tokenModes = grammar.getTokenModesWithInherited(); - Assertions.assertEquals(3, tokenModes.size()); - Assertions.assertEquals(4, tokenModes.get(MCGrammarSymbol.DEFAULT_MODE).size()); - Assertions.assertEquals(1, tokenModes.get("FOO_MODE").size()); - Assertions.assertEquals(1, tokenModes.get("BLA_MODE").size()); + assertEquals(3, tokenModes.size()); + assertEquals(4, tokenModes.get(MCGrammarSymbol.DEFAULT_MODE).size()); + assertEquals(1, tokenModes.get("FOO_MODE").size()); + assertEquals(1, tokenModes.get("BLA_MODE").size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -311,14 +312,14 @@ public void testReplaceKeywords() { final Grammar_WithConceptsGlobalScope globalScope = GrammarGlobalScopeTestFactory.create(); MCGrammarSymbol grammar = globalScope.resolveMCGrammar("de.monticore.Keywords").orElse(null); - Assertions.assertNotNull(grammar); + assertNotNull(grammar); Map> keywords = grammar.getReplacedKeywordsWithInherited(); - Assertions.assertEquals(2, keywords.size()); - Assertions.assertEquals(1, keywords.get("A").size()); - Assertions.assertEquals(4, keywords.get("B").size()); + assertEquals(2, keywords.size()); + assertEquals(1, keywords.get("A").size()); + assertEquals(4, keywords.get("B").size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private int countExternalProd(MCGrammarSymbol grammar) { @@ -347,21 +348,21 @@ public void testSymbolTableOfAutomaton() { // test grammar symbol MCGrammarSymbol grammar = globalScope.resolveMCGrammar("Automaton").orElse(null); - Assertions.assertNotNull(grammar); - Assertions.assertTrue(grammar.isPresentAstNode()); + assertNotNull(grammar); + assertTrue(grammar.isPresentAstNode()); ProdSymbol autProd = grammar.getSpannedScope() .resolveProd("Automaton").orElse(null); - Assertions.assertNotNull(autProd); - Assertions.assertTrue(autProd.isIsScopeSpanning()); - Assertions.assertTrue(autProd.isIsSymbolDefinition()); + assertNotNull(autProd); + assertTrue(autProd.isIsScopeSpanning()); + assertTrue(autProd.isIsSymbolDefinition()); ProdSymbol stateProd = grammar.getSpannedScope().resolveProd("State").orElse(null); - Assertions.assertNotNull(stateProd); - Assertions.assertFalse(stateProd.isIsScopeSpanning()); - Assertions.assertTrue(stateProd.isIsSymbolDefinition()); + assertNotNull(stateProd); + assertFalse(stateProd.isIsScopeSpanning()); + assertTrue(stateProd.isIsSymbolDefinition()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -370,41 +371,41 @@ public void testRuleWithSymbolReference() { MCGrammarSymbol grammar = globalScope.resolveMCGrammar("de.monticore" + ".RuleWithSymbolReference").orElse(null); - Assertions.assertNotNull(grammar); - Assertions.assertEquals("de.monticore.RuleWithSymbolReference", grammar.getFullName()); + assertNotNull(grammar); + assertEquals("de.monticore.RuleWithSymbolReference", grammar.getFullName()); - Assertions.assertEquals(7, grammar.getProds().size()); + assertEquals(7, grammar.getProds().size()); ProdSymbol s = grammar.getProd("S").orElse(null); - Assertions.assertNotNull(s); - Assertions.assertTrue(s.isIsSymbolDefinition()); - Assertions.assertEquals("S", s.getName()); + assertNotNull(s); + assertTrue(s.isIsSymbolDefinition()); + assertEquals("S", s.getName()); ProdSymbol t = grammar.getProd("T").orElse(null); - Assertions.assertEquals("T", t.getName()); - Assertions.assertFalse(t.isIsSymbolDefinition()); + assertEquals("T", t.getName()); + assertFalse(t.isIsSymbolDefinition()); ProdSymbol a = grammar.getProd("A").orElse(null); - Assertions.assertEquals("A", a.getName()); - Assertions.assertFalse(a.isIsSymbolDefinition()); + assertEquals("A", a.getName()); + assertFalse(a.isIsSymbolDefinition()); ProdSymbol b = grammar.getProd("B").orElse(null); - Assertions.assertFalse(b.isIsSymbolDefinition()); + assertFalse(b.isIsSymbolDefinition()); List comps = b.getSpannedScope().resolveRuleComponentDownMany("an"); - Assertions.assertFalse(comps.isEmpty()); + assertFalse(comps.isEmpty()); RuleComponentSymbol aComponent = comps.get(0); - Assertions.assertEquals("Name", aComponent.getReferencedProd().get().getName()); + assertEquals("Name", aComponent.getReferencedProd().get().getName()); ProdSymbol e = grammar.getProd("E").orElse(null); - Assertions.assertTrue(e.isIsExternal()); - Assertions.assertTrue(e.isIsSymbolDefinition()); + assertTrue(e.isIsExternal()); + assertTrue(e.isIsSymbolDefinition()); ProdSymbol r = grammar.getProd("R").orElse(null); - Assertions.assertTrue(r.isIsAbstract()); - Assertions.assertFalse(r.isIsInterface()); - Assertions.assertTrue(r.isIsSymbolDefinition()); + assertTrue(r.isIsAbstract()); + assertFalse(r.isIsInterface()); + assertTrue(r.isIsSymbolDefinition()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -416,59 +417,59 @@ public void testRuleWithSymbolReference() { public void testASTKeySymbolCreation() { final Grammar_WithConceptsGlobalScope globalScope = GrammarGlobalScopeTestFactory.create(); Optional grammarOpt = globalScope.resolveMCGrammar("de.monticore.KeyAndNext"); - Assertions.assertTrue(grammarOpt.isPresent()); + assertTrue(grammarOpt.isPresent()); MCGrammarSymbol grammar = grammarOpt.get(); - Assertions.assertNotNull(grammar); - Assertions.assertTrue(grammar.isPresentAstNode()); + assertNotNull(grammar); + assertTrue(grammar.isPresentAstNode()); // no usage name Optional aProd = grammar.getSpannedScope().resolveProd("A"); - Assertions.assertTrue(aProd.isPresent()); + assertTrue(aProd.isPresent()); List comps = aProd.get().getSpannedScope().resolveRuleComponentDownMany("b"); - Assertions.assertFalse(comps.isEmpty()); + assertFalse(comps.isEmpty()); RuleComponentSymbol aBRule= comps.get(0); - Assertions.assertFalse(aBRule.isIsList()); + assertFalse(aBRule.isIsList()); // with usage name Optional bProd = grammar.getSpannedScope().resolveProd("B"); - Assertions.assertTrue(bProd.isPresent()); + assertTrue(bProd.isPresent()); List bBRules = bProd.get().getSpannedScope().resolveRuleComponentMany("b"); - Assertions.assertTrue(!bBRules.isEmpty()); - Assertions.assertTrue(bBRules.get(0).isIsList()); + assertTrue(!bBRules.isEmpty()); + assertTrue(bBRules.get(0).isIsList()); // no usage name Optional cProd = grammar.getSpannedScope().resolveProd("C"); - Assertions.assertTrue(cProd.isPresent()); + assertTrue(cProd.isPresent()); List cBRules= cProd.get().getSpannedScope().resolveRuleComponentMany("b"); - Assertions.assertFalse(cBRules.isEmpty()); - Assertions.assertFalse(cBRules.get(0).isIsList()); + assertFalse(cBRules.isEmpty()); + assertFalse(cBRules.get(0).isIsList()); // no usage name Optional dProd = grammar.getSpannedScope().resolveProd("D"); - Assertions.assertTrue(dProd.isPresent()); + assertTrue(dProd.isPresent()); List dBRules= dProd.get().getSpannedScope().resolveRuleComponentMany("b"); - Assertions.assertFalse(dBRules.isEmpty()); - Assertions.assertFalse(dBRules.get(0).isIsList()); + assertFalse(dBRules.isEmpty()); + assertFalse(dBRules.get(0).isIsList()); // with usage name Optional eProd = grammar.getSpannedScope().resolveProd("E"); - Assertions.assertTrue(eProd.isPresent()); + assertTrue(eProd.isPresent()); List eBRules = eProd.get().getSpannedScope().resolveRuleComponentMany("b"); - Assertions.assertTrue(!eBRules.isEmpty()); - Assertions.assertTrue(eBRules.get(0).isIsList()); + assertTrue(!eBRules.isEmpty()); + assertTrue(eBRules.get(0).isIsList()); // no usage name Optional fProd = grammar.getSpannedScope().resolveProd("F"); - Assertions.assertTrue(fProd.isPresent()); + assertTrue(fProd.isPresent()); List fBRules = fProd.get().getSpannedScope().resolveRuleComponentMany("b"); - Assertions.assertTrue(fBRules.isEmpty()); + assertTrue(fBRules.isEmpty()); // with usage name Optional gProd = grammar.getSpannedScope().resolveProd("G"); - Assertions.assertTrue(gProd.isPresent()); + assertTrue(gProd.isPresent()); List gBRules = gProd.get().getSpannedScope().resolveRuleComponentMany("b"); - Assertions.assertFalse(gBRules.isEmpty()); + assertFalse(gBRules.isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorFormalParametersDifferentNameTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorFormalParametersDifferentNameTest.java index c087052522..a475e8c9cc 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorFormalParametersDifferentNameTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorFormalParametersDifferentNameTest.java @@ -2,13 +2,13 @@ package de.monticore.javalight.cocos; import de.monticore.javalight._cocos.JavaLightCoCoChecker; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; -import static org.junit.Assert.assertTrue; import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class ConstructorFormalParametersDifferentNameTest extends JavaLightCocoTest{ private final String fileName = "de.monticore.javalight.cocos.invalid.A0821.A0821"; @BeforeEach @@ -33,7 +33,7 @@ public void testInvalid2() { public void testCorrect() { testValid("de.monticore.javalight.cocos.valid.A0821", "const1", checker); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorModifiersValidTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorModifiersValidTest.java index 858f00939d..43c3751947 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorModifiersValidTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorModifiersValidTest.java @@ -3,11 +3,10 @@ import de.monticore.javalight._cocos.JavaLightCoCoChecker; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ConstructorModifiersValidTest extends JavaLightCocoTest{ private final String fileName = "de.monticore.javalight.cocos.invalid.A0820.A0820"; @@ -28,7 +27,7 @@ public void testInvalid() { public void testCorrect() { testValid("de.monticore.javalight.cocos.valid.A0820", "constructor", checker); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorNoAccessModifierPairTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorNoAccessModifierPairTest.java index 393114d1a0..fa3086457a 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorNoAccessModifierPairTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorNoAccessModifierPairTest.java @@ -3,11 +3,10 @@ import de.monticore.javalight._cocos.JavaLightCoCoChecker; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ConstructorNoAccessModifierPairTest extends JavaLightCocoTest{ private final String fileName = "de.monticore.javalight.cocos.invalid.A0809.A0809"; @@ -28,7 +27,7 @@ public void testInvalid() { public void testCorrect() { testValid("de.monticore.javalight.cocos.valid.A0809", "constructor", checker); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorNoDuplicateModifierTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorNoDuplicateModifierTest.java index 4cc2f91d4b..1e90c6775d 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorNoDuplicateModifierTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ConstructorNoDuplicateModifierTest.java @@ -3,11 +3,10 @@ import de.monticore.javalight._cocos.JavaLightCoCoChecker; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ConstructorNoDuplicateModifierTest extends JavaLightCocoTest{ private final String fileName = "de.monticore.javalight.cocos.invalid.A0808.A0808"; @@ -28,6 +27,6 @@ public void testInvalid() { public void testCorrect() { testValid("de.monticore.javalight.cocos.valid.A0808", "constructor", checker); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/JavaLightCocoTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/JavaLightCocoTest.java index a5155ba1dd..8eaee288bb 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/JavaLightCocoTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/JavaLightCocoTest.java @@ -28,6 +28,8 @@ import java.nio.file.Paths; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public abstract class JavaLightCocoTest { static protected ITestJavaLightGlobalScope globalScope; @@ -57,13 +59,13 @@ protected void testValid(String fileName, String methodName, JavaLightCoCoChecke final MethodSymbol methodSymbol = artifactScope .resolveMethod(methodName) .orElse(null); - Assertions.assertNotNull(methodSymbol); - Assertions.assertTrue(methodSymbol.isPresentAstNode()); + assertNotNull(methodSymbol); + assertTrue(methodSymbol.isPresentAstNode()); Log.getFindings().clear(); checker.checkAll((ASTJavaLightNode) methodSymbol.getAstNode()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } protected void testInvalid(String fileName, String methodName, String code, String message, @@ -78,16 +80,16 @@ protected void testInvalid(String fileName, String methodName, String code, Stri final MethodSymbol methodSymbol = artifactScope .resolveMethod(methodName) .orElse(null); - Assertions.assertNotNull(methodSymbol); - Assertions.assertTrue(methodSymbol.isPresentAstNode()); + assertNotNull(methodSymbol); + assertTrue(methodSymbol.isPresentAstNode()); Log.getFindings().clear(); checker.checkAll((ASTJavaLightNode) methodSymbol.getAstNode()); - Assertions.assertFalse(Log.getFindings().isEmpty()); - Assertions.assertEquals(numberOfFindings, Log.getFindings().size()); + assertFalse(Log.getFindings().isEmpty()); + assertEquals(numberOfFindings, Log.getFindings().size()); for (Finding f : Log.getFindings()) { - Assertions.assertEquals(code + message, f.getMsg()); + assertEquals(code + message, f.getMsg()); } } @@ -105,7 +107,7 @@ protected void loadFileForModelName(String modelName) { globalScope.addSubScope(artifactScope); } } catch (IOException e) { - Assertions.fail(); + fail(); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodAbstractAndOtherModifiersTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodAbstractAndOtherModifiersTest.java index 90cd981c88..4673f59c5b 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodAbstractAndOtherModifiersTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodAbstractAndOtherModifiersTest.java @@ -3,11 +3,10 @@ import de.monticore.javalight._cocos.JavaLightCoCoChecker; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MethodAbstractAndOtherModifiersTest extends JavaLightCocoTest{ @@ -30,7 +29,7 @@ public void testCorrect() { testValid("de.monticore.javalight.cocos.valid.A0802", "a", checker); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodBodyAbsenceTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodBodyAbsenceTest.java index 3cfffc62d7..cfb6bd7aa0 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodBodyAbsenceTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodBodyAbsenceTest.java @@ -3,11 +3,10 @@ import de.monticore.javalight._cocos.JavaLightCoCoChecker; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MethodBodyAbsenceTest extends JavaLightCocoTest{ private final String fileName = "de.monticore.javalight.cocos.invalid.A0804.A0804"; @@ -32,7 +31,7 @@ public void testInvalid2(){ public void testCorrect() { testValid("de.monticore.javalight.cocos.valid.A0804", "method", checker); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodBodyPresenceTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodBodyPresenceTest.java index f4ebf1e3eb..a797380bdc 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodBodyPresenceTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodBodyPresenceTest.java @@ -3,11 +3,10 @@ import de.monticore.javalight._cocos.JavaLightCoCoChecker; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MethodBodyPresenceTest extends JavaLightCocoTest{ private final String fileName = "de.monticore.javalight.cocos.invalid.A0803.A0803"; @@ -32,7 +31,7 @@ public void testInvalid2(){ public void testCorrect() { testValid("de.monticore.javalight.cocos.valid.A0803", "method", checker); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodExceptionThrowsTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodExceptionThrowsTest.java index ca89503578..07b0a7961b 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodExceptionThrowsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodExceptionThrowsTest.java @@ -4,12 +4,12 @@ import de.monticore.javalight._cocos.JavaLightCoCoChecker; import de.monticore.types3.util.DefsTypesForTests; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static de.monticore.types3.util.DefsTypesForTests.oOtype; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; + import de.se_rwth.commons.logging.Log; import java.util.List; @@ -37,7 +37,7 @@ public void testCorrect() { testValid("de.monticore.javalight.cocos.valid.MethodDecl", "meth1", checker); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodFormalParametersDifferentNameTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodFormalParametersDifferentNameTest.java index acd69a89ea..a13bd1419b 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodFormalParametersDifferentNameTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodFormalParametersDifferentNameTest.java @@ -4,11 +4,10 @@ import de.monticore.javalight._cocos.JavaLightCoCoChecker; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MethodFormalParametersDifferentNameTest extends JavaLightCocoTest { private final String fileName = "de.monticore.javalight.cocos.invalid.A0812.A0812"; @@ -35,7 +34,7 @@ public void testInvalid2() { public void testCorrect() { testValid("de.monticore.javalight.cocos.valid.MethodDecl", "meth1", checker); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodNoNativeAndStrictfpTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodNoNativeAndStrictfpTest.java index a976962a0c..079a1187c1 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodNoNativeAndStrictfpTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/MethodNoNativeAndStrictfpTest.java @@ -3,11 +3,10 @@ import de.monticore.javalight._cocos.JavaLightCoCoChecker; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MethodNoNativeAndStrictfpTest extends JavaLightCocoTest{ private final String fileName = "de.monticore.javalight.cocos.invalid.A0819.A0819"; @@ -27,7 +26,7 @@ public void testInvalid1(){ public void testCorrect() { testValid("de.monticore.javalight.cocos.valid.A0819", "method", checker); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ReturnTypeAssignmentIsValidTest.java b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ReturnTypeAssignmentIsValidTest.java index 33cb65233d..2771c3aa5a 100644 --- a/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ReturnTypeAssignmentIsValidTest.java +++ b/monticore-grammar/src/test/java/de/monticore/javalight/cocos/ReturnTypeAssignmentIsValidTest.java @@ -2,26 +2,21 @@ package de.monticore.javalight.cocos; import de.monticore.javalight._cocos.JavaLightCoCoChecker; -import de.monticore.symbols.basicsymbols.BasicSymbolsMill; import de.monticore.symbols.basicsymbols._ast.ASTBasicSymbolsNode; import de.monticore.symbols.oosymbols._ast.ASTMethod; import de.monticore.testjavalight.TestJavaLightMill; import de.monticore.testjavalight._parser.TestJavaLightParser; import de.monticore.testjavalight._visitor.TestJavaLightTraverser; import de.monticore.types.check.FlatExpressionScopeSetter; -import de.monticore.types.check.FullDeriveFromCombineExpressionsWithLiterals; -import de.monticore.types.check.FullSynthesizeFromCombineExpressionsWithLiterals; -import de.monticore.types.check.TypeCalculator; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ReturnTypeAssignmentIsValidTest extends JavaLightCocoTest { @@ -35,12 +30,12 @@ public void checkValid(String expressionString) throws IOException { TestJavaLightParser parser = new TestJavaLightParser(); Optional optAST = parser.parse_StringMethod(expressionString); - Assertions.assertTrue(optAST.isPresent()); + assertTrue(optAST.isPresent()); Log.getFindings().clear(); TestJavaLightTraverser traverser = getFlatExpressionScopeSetter(); optAST.get().accept(traverser); checker.checkAll((ASTBasicSymbolsNode) optAST.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -48,12 +43,12 @@ public void checkInvalid(String expressionString) throws IOException { TestJavaLightParser parser = new TestJavaLightParser(); Optional optAST = parser.parse_StringMethod(expressionString); - Assertions.assertTrue(optAST.isPresent()); + assertTrue(optAST.isPresent()); Log.getFindings().clear(); TestJavaLightTraverser traverser = getFlatExpressionScopeSetter(); optAST.get().accept(traverser); checker.checkAll((ASTBasicSymbolsNode) optAST.get()); - Assertions.assertFalse(Log.getFindings().isEmpty()); + assertFalse(Log.getFindings().isEmpty()); } diff --git a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/DoubleCommonLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/DoubleCommonLiteralsTest.java index 491d868f3c..a14fb70955 100644 --- a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/DoubleCommonLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/DoubleCommonLiteralsTest.java @@ -8,7 +8,6 @@ import de.monticore.literals.testmccommonliterals._parser.TestMCCommonLiteralsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,6 +15,8 @@ import java.io.StringReader; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class DoubleCommonLiteralsTest { @BeforeEach @@ -29,15 +30,15 @@ public void init() { private void checkDoubleLiteral(double d, String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional lit = parser.parseLiteral(new StringReader(s)); - Assertions.assertTrue(lit.isPresent()); - Assertions.assertTrue(lit.get() instanceof ASTBasicDoubleLiteral); - Assertions.assertEquals(d, ((ASTBasicDoubleLiteral) lit.get()).getValue(), 0); + assertTrue(lit.isPresent()); + assertInstanceOf(ASTBasicDoubleLiteral.class, lit.get()); + assertEquals(d, ((ASTBasicDoubleLiteral) lit.get()).getValue(), 0); } private void checkFalse(String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional lit = parser.parseBasicDoubleLiteral(new StringReader(s)); - Assertions.assertTrue(!lit.isPresent()); + assertFalse(lit.isPresent()); } @Test @@ -50,10 +51,10 @@ public void testDoubleLiterals() { checkDoubleLiteral(3.0, "3.0"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -68,7 +69,7 @@ public void testFalseDoubleLiterals() { checkFalse("0.0 d"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/FloatCommonLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/FloatCommonLiteralsTest.java index 54d29098df..3bd909afde 100644 --- a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/FloatCommonLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/FloatCommonLiteralsTest.java @@ -8,7 +8,6 @@ import de.monticore.literals.testmccommonliterals._parser.TestMCCommonLiteralsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,6 +15,8 @@ import java.io.StringReader; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class FloatCommonLiteralsTest { @BeforeEach @@ -29,18 +30,18 @@ public void init() { private void checkFloatLiteral(float f, String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional lit = parser.parseLiteral(new StringReader(s)); - Assertions.assertTrue(lit.isPresent()); - Assertions.assertTrue(lit.get() instanceof ASTBasicFloatLiteral); - Assertions.assertEquals(f, ((ASTBasicFloatLiteral) lit.get()).getValue(), 0); - Assertions.assertTrue(true); + assertTrue(lit.isPresent()); + assertInstanceOf(ASTBasicFloatLiteral.class, lit.get()); + assertEquals(f, ((ASTBasicFloatLiteral) lit.get()).getValue(), 0); + assertTrue(true); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private void checkFalse(String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional lit = parser.parseBasicFloatLiteral(new StringReader(s)); - Assertions.assertTrue(!lit.isPresent()); + assertFalse(lit.isPresent()); } @Test @@ -51,7 +52,7 @@ public void testFloatLiterals() { } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } @@ -103,7 +104,7 @@ public void checkFalseLiterals() { } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/IntCommonLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/IntCommonLiteralsTest.java index 65c78775ba..b0a5bf26e2 100644 --- a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/IntCommonLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/IntCommonLiteralsTest.java @@ -9,7 +9,6 @@ import de.monticore.literals.testmccommonliterals._parser.TestMCCommonLiteralsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -17,6 +16,8 @@ import java.io.StringReader; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class IntCommonLiteralsTest { @BeforeEach @@ -30,35 +31,35 @@ public void init() { private void checkIntLiteral(int i, String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional lit = parser.parseLiteral(new StringReader(s)); - Assertions.assertTrue(lit.isPresent()); - Assertions.assertTrue(lit.get() instanceof ASTNatLiteral); - Assertions.assertEquals(i, ((ASTNatLiteral) lit.get()).getValue()); + assertTrue(lit.isPresent()); + assertInstanceOf(ASTNatLiteral.class, lit.get()); + assertEquals(i, ((ASTNatLiteral) lit.get()).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private void checkSignedIntLiteral(int i, String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional lit = parser.parseSignedNatLiteral(new StringReader(s)); - Assertions.assertTrue(lit.isPresent()); - Assertions.assertTrue(lit.get() instanceof ASTSignedNatLiteral); - Assertions.assertEquals(i, ((ASTSignedNatLiteral) lit.get()).getValue()); + assertTrue(lit.isPresent()); + assertInstanceOf(ASTSignedNatLiteral.class, lit.get()); + assertEquals(i, ((ASTSignedNatLiteral) lit.get()).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private void checkFalse(String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional lit = parser.parseNatLiteral(new StringReader(s)); - Assertions.assertTrue(!lit.isPresent()); + assertFalse(lit.isPresent()); } private void checkSignedFalse(String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional lit = parser.parseSignedNatLiteral(new StringReader(s)); - Assertions.assertTrue(!lit.isPresent()); + assertFalse(lit.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -78,7 +79,7 @@ public void testIntLiterals() { checkIntLiteral(17, "00017"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } @@ -96,7 +97,7 @@ public void testFalse() { checkFalse("0x005f"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } @@ -117,7 +118,7 @@ public void testSignedIntLiterals() { checkSignedIntLiteral(-17, "-00017"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } @@ -130,7 +131,7 @@ public void testSignedFalse() { checkFalse("- 02"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/LongCommonLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/LongCommonLiteralsTest.java index e09eea41cb..9f4fd8a009 100644 --- a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/LongCommonLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/LongCommonLiteralsTest.java @@ -8,7 +8,6 @@ import de.monticore.literals.testmccommonliterals._parser.TestMCCommonLiteralsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,6 +15,8 @@ import java.io.StringReader; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class LongCommonLiteralsTest { @BeforeEach @@ -29,17 +30,17 @@ public void init() { private void checkLongLiteral(long l, String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional lit = parser.parseLiteral(new StringReader(s)); - Assertions.assertTrue(lit.isPresent()); - Assertions.assertTrue(lit.get() instanceof ASTBasicLongLiteral); - Assertions.assertEquals(l, ((ASTBasicLongLiteral) lit.get()).getValue()); + assertTrue(lit.isPresent()); + assertInstanceOf(ASTBasicLongLiteral.class, lit.get()); + assertEquals(l, ((ASTBasicLongLiteral) lit.get()).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private void checkFalse(String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional lit = parser.parseBasicLongLiteral(new StringReader(s)); - Assertions.assertTrue(!lit.isPresent()); + assertFalse(lit.isPresent()); } @Test @@ -55,7 +56,7 @@ public void testLongLiterals() { } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } @@ -74,7 +75,7 @@ public void testFalse() { checkFalse("0 L"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/NoLineBreaksInStringLiteralTest.java b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/NoLineBreaksInStringLiteralTest.java index 6c63cb6b61..8dd6cae2b1 100644 --- a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/NoLineBreaksInStringLiteralTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/NoLineBreaksInStringLiteralTest.java @@ -9,7 +9,6 @@ import de.monticore.literals.testmccommonliterals._parser.TestMCCommonLiteralsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,6 +17,7 @@ import java.util.Optional; import static de.monticore.literals.mccommonliterals.cocos.NoLineBreaksInStringLiteralCoCo.ERROR_CODE; +import static org.junit.jupiter.api.Assertions.*; public class NoLineBreaksInStringLiteralTest { @@ -33,7 +33,7 @@ private void checkStringLiteral(String s) throws IOException { // Parsing TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional lit = parser.parseLiteral(new StringReader(s)); - Assertions.assertTrue(lit.isPresent()); + assertTrue(lit.isPresent()); // check CoCo MCCommonLiteralsCoCoChecker checker = new MCCommonLiteralsCoCoChecker(); @@ -47,9 +47,9 @@ public void testStringLiterals() { checkStringLiteral("\"okay\""); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -59,10 +59,10 @@ public void testFalseStringLiterals() { checkStringLiteral("\"okay\r or not\""); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertEquals(2, Log.getFindings().size()); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith(ERROR_CODE)); - Assertions.assertTrue(Log.getFindings().get(1).getMsg().startsWith(ERROR_CODE)); + assertEquals(2, Log.getFindings().size()); + assertTrue(Log.getFindings().get(0).getMsg().startsWith(ERROR_CODE)); + assertTrue(Log.getFindings().get(1).getMsg().startsWith(ERROR_CODE)); } } diff --git a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/RangeCoCosTest.java b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/RangeCoCosTest.java index 49608fc5c2..f074a8820d 100644 --- a/monticore-grammar/src/test/java/de/monticore/mccommonliterals/RangeCoCosTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mccommonliterals/RangeCoCosTest.java @@ -7,7 +7,6 @@ import de.monticore.literals.mcliteralsbasis._ast.ASTLiteral; import de.monticore.literals.testmccommonliterals.TestMCCommonLiteralsMill; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,6 +15,8 @@ import java.math.BigInteger; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class RangeCoCosTest { @BeforeEach @@ -29,7 +30,7 @@ public void setup(){ protected final void checkLiteral(String expression, BigInteger min, BigInteger max) throws IOException { Log.clearFindings(); Optional astex = TestMCCommonLiteralsMill.parser().parse_StringLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCCommonLiteralsCoCoChecker checker = new MCCommonLiteralsCoCoChecker(); checker.addCoCo(new BasicFloatLiteralRangeCoCo(new BigDecimal(min), new BigDecimal(max))); @@ -39,13 +40,13 @@ protected final void checkLiteral(String expression, BigInteger min, BigInteger checker.checkAll(astex.get()); - Assertions.assertFalse(Log.getErrorCount() > 0); + assertFalse(Log.getErrorCount() > 0); } protected final void checkLiteral(String expression) throws IOException { Log.clearFindings(); Optional astex = TestMCCommonLiteralsMill.parser().parse_StringLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCCommonLiteralsCoCoChecker checker = new MCCommonLiteralsCoCoChecker(); checker.addCoCo(new BasicFloatLiteralRangeCoCo()); @@ -55,13 +56,13 @@ protected final void checkLiteral(String expression) throws IOException { checker.checkAll(astex.get()); - Assertions.assertFalse(Log.getErrorCount() > 0); + assertFalse(Log.getErrorCount() > 0); } protected final void checkSignedLiteral(String expression) throws IOException { Log.clearFindings(); Optional astex = TestMCCommonLiteralsMill.parser().parse_StringSignedLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCCommonLiteralsCoCoChecker checker = new MCCommonLiteralsCoCoChecker(); checker.addCoCo(new SignedBasicFloatLiteralRangeCoCo()); @@ -71,13 +72,13 @@ protected final void checkSignedLiteral(String expression) throws IOException { checker.checkAll(astex.get()); - Assertions.assertFalse(Log.getErrorCount() > 0); + assertFalse(Log.getErrorCount() > 0); } protected final void checkErrorLiteral(String expression, BigInteger min, BigInteger max, String expectedError) throws IOException { Log.clearFindings(); Optional astex = TestMCCommonLiteralsMill.parser().parse_StringLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCCommonLiteralsCoCoChecker checker = new MCCommonLiteralsCoCoChecker(); checker.addCoCo(new BasicFloatLiteralRangeCoCo(new BigDecimal(min), new BigDecimal(max))); @@ -87,14 +88,14 @@ protected final void checkErrorLiteral(String expression, BigInteger min, BigInt checker.checkAll(astex.get()); - Assertions.assertEquals(1, Log.getErrorCount()); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); + assertEquals(1, Log.getErrorCount()); + assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); } protected final void checkErrorLiteral(String expression, String expectedError) throws IOException { Log.clearFindings(); Optional astex = TestMCCommonLiteralsMill.parser().parse_StringLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCCommonLiteralsCoCoChecker checker = new MCCommonLiteralsCoCoChecker(); checker.addCoCo(new BasicFloatLiteralRangeCoCo()); @@ -104,14 +105,14 @@ protected final void checkErrorLiteral(String expression, String expectedError) checker.checkAll(astex.get()); - Assertions.assertEquals(1, Log.getErrorCount()); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); + assertEquals(1, Log.getErrorCount()); + assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); } protected final void checkErrorSignedLiteral(String expression, BigInteger min, BigInteger max, String expectedError) throws IOException { Log.clearFindings(); Optional astex = TestMCCommonLiteralsMill.parser().parse_StringSignedLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCCommonLiteralsCoCoChecker checker = new MCCommonLiteralsCoCoChecker(); checker.addCoCo(new SignedBasicFloatLiteralRangeCoCo(new BigDecimal(min), new BigDecimal(max))); @@ -121,14 +122,14 @@ protected final void checkErrorSignedLiteral(String expression, BigInteger min, checker.checkAll(astex.get()); - Assertions.assertEquals(1, Log.getErrorCount()); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); + assertEquals(1, Log.getErrorCount()); + assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); } protected final void checkErrorSignedLiteral(String expression, String expectedError) throws IOException { Log.clearFindings(); Optional astex = TestMCCommonLiteralsMill.parser().parse_StringSignedLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCCommonLiteralsCoCoChecker checker = new MCCommonLiteralsCoCoChecker(); checker.addCoCo(new SignedBasicFloatLiteralRangeCoCo()); @@ -138,8 +139,8 @@ protected final void checkErrorSignedLiteral(String expression, String expectedE checker.checkAll(astex.get()); - Assertions.assertEquals(1, Log.getErrorCount()); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); + assertEquals(1, Log.getErrorCount()); + assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); } diff --git a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/DoubleJavaLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/DoubleJavaLiteralsTest.java index 6f24987a03..9cb2df8a20 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/DoubleJavaLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/DoubleJavaLiteralsTest.java @@ -7,12 +7,13 @@ import de.monticore.literals.testmcjavaliterals.TestMCJavaLiteralsMill; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; +import static org.junit.jupiter.api.Assertions.*; + public class DoubleJavaLiteralsTest { @BeforeEach @@ -25,10 +26,10 @@ public void init() { private void checkDoubleLiteral(double d, String s) throws IOException { ASTLiteral lit = MCJavaLiteralsTestHelper.getInstance().parseLiteral(s); - Assertions.assertTrue(lit instanceof ASTDoubleLiteral); - Assertions.assertEquals(d, ((ASTDoubleLiteral) lit).getValue(), 0); + assertInstanceOf(ASTDoubleLiteral.class, lit); + assertEquals(d, ((ASTDoubleLiteral) lit).getValue(), 0); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -83,7 +84,7 @@ public void testDoubleLiterals() { checkDoubleLiteral(1e137, "1e137"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/FloatJavaLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/FloatJavaLiteralsTest.java index 39020bb9a1..8e0fbc130e 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/FloatJavaLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/FloatJavaLiteralsTest.java @@ -7,12 +7,13 @@ import de.monticore.literals.testmcjavaliterals.TestMCJavaLiteralsMill; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; +import static org.junit.jupiter.api.Assertions.*; + public class FloatJavaLiteralsTest { @BeforeEach @@ -25,11 +26,10 @@ public void init() { private void checkFloatLiteral(float f, String s) throws IOException { ASTLiteral lit = MCJavaLiteralsTestHelper.getInstance().parseLiteral(s); - Assertions.assertTrue(lit instanceof ASTFloatLiteral); - Assertions.assertEquals(f, ((ASTFloatLiteral) lit).getValue(), 0); - Assertions.assertTrue(true); + assertInstanceOf(ASTFloatLiteral.class, lit); + assertEquals(f, ((ASTFloatLiteral) lit).getValue(), 0); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -83,7 +83,7 @@ public void testFloatLiterals() { } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/IntJavaLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/IntJavaLiteralsTest.java index 411b2d04d2..753b6d4daf 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/IntJavaLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/IntJavaLiteralsTest.java @@ -13,6 +13,8 @@ import java.io.IOException; +import static org.junit.jupiter.api.Assertions.*; + public class IntJavaLiteralsTest { @BeforeEach @@ -25,10 +27,10 @@ public void init() { private void checkIntLiteral(int i, String s) throws IOException { ASTLiteral lit = MCJavaLiteralsTestHelper.getInstance().parseLiteral(s); - Assertions.assertTrue(lit instanceof ASTIntLiteral); - Assertions.assertEquals(i, ((ASTIntLiteral) lit).getValue()); + assertInstanceOf(ASTIntLiteral.class, lit); + assertEquals(i, ((ASTIntLiteral) lit).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -58,7 +60,7 @@ public void testIntLiterals() { checkIntLiteral(00017, "00017"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/LongJavaLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/LongJavaLiteralsTest.java index b76ee07838..c9f1ba8e3c 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/LongJavaLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/LongJavaLiteralsTest.java @@ -13,6 +13,8 @@ import java.io.IOException; +import static org.junit.jupiter.api.Assertions.*; + public class LongJavaLiteralsTest { @@ -26,10 +28,10 @@ public void init() { private void checkLongLiteral(long l, String s) throws IOException { ASTLiteral lit = MCJavaLiteralsTestHelper.getInstance().parseLiteral(s); - Assertions.assertTrue(lit instanceof ASTLongLiteral); - Assertions.assertEquals(l, ((ASTLongLiteral) lit).getValue()); + assertInstanceOf(ASTLongLiteral.class, lit); + assertEquals(l, ((ASTLongLiteral) lit).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -59,7 +61,7 @@ public void testLongLiterals() { checkLongLiteral(00017L, "00017L"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/MCJavaLiteralsTestHelper.java b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/MCJavaLiteralsTestHelper.java index 0db56550cf..e7de9267ba 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/MCJavaLiteralsTestHelper.java +++ b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/MCJavaLiteralsTestHelper.java @@ -4,12 +4,13 @@ import de.monticore.literals.mcliteralsbasis._ast.ASTLiteral; import de.monticore.literals.testmcjavaliterals._parser.TestMCJavaLiteralsParser; -import junit.framework.TestCase; import java.io.IOException; import java.io.StringReader; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * This class provides two methods that allow testing type grammar. The test * parses a given input string to an AST. The AST is printed via prettyprint and @@ -48,7 +49,7 @@ public static MCJavaLiteralsTestHelper getInstance() { public ASTLiteral parseLiteral(String input) throws IOException { TestMCJavaLiteralsParser parser = new TestMCJavaLiteralsParser(); Optional res = parser.parseLiteral(new StringReader(input)); - TestCase.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); return res.get(); } diff --git a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/RangeCoCosTest.java b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/RangeCoCosTest.java index 47dbbb88ed..28f0451526 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/RangeCoCosTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mcjavaliterals/RangeCoCosTest.java @@ -9,7 +9,6 @@ import de.monticore.literals.mcjavaliterals.cocos.LongLiteralRangeCoCo; import de.monticore.literals.testmcjavaliterals.TestMCJavaLiteralsMill; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,7 +17,7 @@ import java.math.BigInteger; import java.util.Optional; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class RangeCoCosTest { @@ -34,109 +33,109 @@ public void setup(){ protected final void checkIntLiteral(String expression, BigInteger min, BigInteger max) throws IOException { Log.clearFindings(); Optional astex = TestMCJavaLiteralsMill.parser().parse_StringIntLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCJavaLiteralsCoCoChecker checker = new MCJavaLiteralsCoCoChecker(); checker.addCoCo(new IntLiteralRangeCoCo(min, max)); checker.checkAll((ASTMCJavaLiteralsNode) astex.get()); - Assertions.assertFalse(Log.getErrorCount() > 0); + assertFalse(Log.getErrorCount() > 0); } protected final void checkLongLiteral(String expression, BigInteger min, BigInteger max) throws IOException { Log.clearFindings(); Optional astex = TestMCJavaLiteralsMill.parser().parse_StringLongLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCJavaLiteralsCoCoChecker checker = new MCJavaLiteralsCoCoChecker(); checker.addCoCo(new LongLiteralRangeCoCo(min, max)); checker.checkAll((ASTMCJavaLiteralsNode) astex.get()); - Assertions.assertFalse(Log.getErrorCount() > 0); + assertFalse(Log.getErrorCount() > 0); } protected final void checkDoubleLiteral(String expression, BigDecimal min, BigDecimal max) throws IOException { Log.clearFindings(); Optional astex = TestMCJavaLiteralsMill.parser().parse_StringDoubleLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCJavaLiteralsCoCoChecker checker = new MCJavaLiteralsCoCoChecker(); checker.addCoCo(new DoubleLiteralRangeCoCo(min, max)); checker.checkAll((ASTMCJavaLiteralsNode) astex.get()); - Assertions.assertFalse(Log.getErrorCount() > 0); + assertFalse(Log.getErrorCount() > 0); } protected final void checkFloatLiteral(String expression, BigDecimal min, BigDecimal max) throws IOException { Log.clearFindings(); Optional astex = TestMCJavaLiteralsMill.parser().parse_StringFloatLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCJavaLiteralsCoCoChecker checker = new MCJavaLiteralsCoCoChecker(); checker.addCoCo(new FloatLiteralRangeCoCo(min, max)); checker.checkAll((ASTMCJavaLiteralsNode) astex.get()); - Assertions.assertFalse(Log.getErrorCount() > 0); + assertFalse(Log.getErrorCount() > 0); } protected final void checkErrorIntLiteral(String expression, BigInteger min, BigInteger max, String expectedError) throws IOException { Log.clearFindings(); Optional astex = TestMCJavaLiteralsMill.parser().parse_StringIntLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCJavaLiteralsCoCoChecker checker = new MCJavaLiteralsCoCoChecker(); checker.addCoCo(new IntLiteralRangeCoCo(min, max)); checker.checkAll((ASTMCJavaLiteralsNode) astex.get()); - Assertions.assertEquals(1, Log.getErrorCount()); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); + assertEquals(1, Log.getErrorCount()); + assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); } protected final void checkErrorLongLiteral(String expression, BigInteger min, BigInteger max, String expectedError) throws IOException { Log.clearFindings(); Optional astex = TestMCJavaLiteralsMill.parser().parse_StringLongLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCJavaLiteralsCoCoChecker checker = new MCJavaLiteralsCoCoChecker(); checker.addCoCo(new LongLiteralRangeCoCo(min, max)); checker.checkAll((ASTMCJavaLiteralsNode) astex.get()); - Assertions.assertEquals(1, Log.getErrorCount()); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); + assertEquals(1, Log.getErrorCount()); + assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); } protected final void checkErrorDoubleLiteral(String expression, BigDecimal min, BigDecimal max, String expectedError) throws IOException { Log.clearFindings(); Optional astex = TestMCJavaLiteralsMill.parser().parse_StringDoubleLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCJavaLiteralsCoCoChecker checker = new MCJavaLiteralsCoCoChecker(); checker.addCoCo(new DoubleLiteralRangeCoCo(min, max)); checker.checkAll((ASTMCJavaLiteralsNode) astex.get()); - Assertions.assertEquals(1, Log.getErrorCount()); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); + assertEquals(1, Log.getErrorCount()); + assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); } protected final void checkErrorFloatLiteral(String expression, BigDecimal min, BigDecimal max, String expectedError) throws IOException { Log.clearFindings(); Optional astex = TestMCJavaLiteralsMill.parser().parse_StringFloatLiteral(expression); - Assertions.assertTrue(astex.isPresent()); + assertTrue(astex.isPresent()); MCJavaLiteralsCoCoChecker checker = new MCJavaLiteralsCoCoChecker(); checker.addCoCo(new FloatLiteralRangeCoCo(min, max)); checker.checkAll((ASTMCJavaLiteralsNode) astex.get()); - Assertions.assertEquals(1, Log.getErrorCount()); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); + assertEquals(1, Log.getErrorCount()); + assertTrue(Log.getFindings().get(0).getMsg().startsWith(expectedError)); } @Test diff --git a/monticore-grammar/src/test/java/de/monticore/mcliterals/CharLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mcliterals/CharLiteralsTest.java index 6a4d39d7de..5ca90c32f9 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcliterals/CharLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mcliterals/CharLiteralsTest.java @@ -13,6 +13,8 @@ import java.io.IOException; +import static org.junit.jupiter.api.Assertions.*; + public class CharLiteralsTest { @BeforeEach @@ -25,10 +27,10 @@ public void init() { private void checkCharLiteral(char c, String s) throws IOException { ASTLiteral lit = MCLiteralsTestHelper.getInstance().parseLiteral(s); - Assertions.assertTrue(lit instanceof ASTCharLiteral); - Assertions.assertEquals(c, ((ASTCharLiteral) lit).getValue()); + assertInstanceOf(ASTCharLiteral.class, lit); + assertEquals(c, ((ASTCharLiteral) lit).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -55,7 +57,7 @@ public void testCharLiterals() { checkCharLiteral('\uffff', "'\\uffff'"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/mcliterals/MCLiteralsTestHelper.java b/monticore-grammar/src/test/java/de/monticore/mcliterals/MCLiteralsTestHelper.java index 4bfc3f62de..9e4442823b 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcliterals/MCLiteralsTestHelper.java +++ b/monticore-grammar/src/test/java/de/monticore/mcliterals/MCLiteralsTestHelper.java @@ -5,12 +5,13 @@ import de.monticore.literals.mccommonliterals._ast.ASTSignedLiteral; import de.monticore.literals.mcliteralsbasis._ast.ASTLiteral; import de.monticore.literals.testmccommonliterals._parser.TestMCCommonLiteralsParser; -import junit.framework.TestCase; import java.io.IOException; import java.io.StringReader; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * This class provides two methods that allow testing type grammar. The test * parses a given input string to an AST. The AST is printed via prettyprint and @@ -50,7 +51,7 @@ public static MCLiteralsTestHelper getInstance() { public ASTLiteral parseLiteral(String input) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional res = parser.parseLiteral(new StringReader(input)); - TestCase.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); return res.get(); } @@ -65,7 +66,7 @@ public ASTSignedLiteral parseSignedLiteral(String input) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional res = parser.parseSignedLiteral(new StringReader(input)); - TestCase.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); return res.get(); } diff --git a/monticore-grammar/src/test/java/de/monticore/mcliterals/MCLiteralsUnitTest.java b/monticore-grammar/src/test/java/de/monticore/mcliterals/MCLiteralsUnitTest.java index 6cfc2b14b1..1e6e0fc8b3 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcliterals/MCLiteralsUnitTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mcliterals/MCLiteralsUnitTest.java @@ -10,7 +10,6 @@ import mcnumbers._ast.ASTDecimal; import mcnumbers._ast.ASTInteger; import mcnumbers._ast.ASTNumber; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import stringliterals._ast.ASTCharLiteral; @@ -18,8 +17,8 @@ import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; // import de.monticore.mcliteralsv2._ast.*; @@ -44,18 +43,18 @@ public void init() { @Test public void testCardinalityToken() throws IOException { ASTAnyTokenList ast = parser.parse_StringAnyTokenList( ":[65..67]:" ).get(); - Assertions.assertEquals(5, ast.sizeAnyTokens()); + assertEquals(5, ast.sizeAnyTokens()); ASTAnyToken t = ast.getAnyToken(0); t = ast.getAnyToken(1); - Assertions.assertTrue(t.isPresentDecimalToken()); - Assertions.assertEquals("65", t.getDecimalToken()); + assertTrue(t.isPresentDecimalToken()); + assertEquals("65", t.getDecimalToken()); t = ast.getAnyToken(2); t = ast.getAnyToken(3); - Assertions.assertTrue(t.isPresentDecimalToken()); - Assertions.assertEquals("67", t.getDecimalToken()); + assertTrue(t.isPresentDecimalToken()); + assertEquals("67", t.getDecimalToken()); t = ast.getAnyToken(4); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @@ -66,62 +65,62 @@ public void testCardinalityToken() throws IOException { @Test public void testNat1() throws IOException { ASTDecimal ast = parser.parse_StringDecimal( " 9" ).get(); - Assertions.assertEquals("9", ast.getSource()); - Assertions.assertEquals(9, ast.getValue()); - Assertions.assertEquals(9, ast.getValueInt()); + assertEquals("9", ast.getSource()); + assertEquals(9, ast.getValue()); + assertEquals(9, ast.getValueInt()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testNat2() throws IOException { ASTDecimal ast = parser.parse_StringDecimal( " 0" ).get(); - Assertions.assertEquals("0", ast.getSource()); - Assertions.assertEquals(0, ast.getValue()); + assertEquals("0", ast.getSource()); + assertEquals(0, ast.getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testNat3() throws IOException { Optional os = parser.parse_StringDecimal( " 00 0 " ); - Assertions.assertEquals(false, os.isPresent()); + assertEquals(false, os.isPresent()); } @Test public void testNat4() throws IOException { ASTDecimal ast = parser.parse_StringDecimal( " 23 " ).get(); - Assertions.assertEquals("23", ast.getSource()); - Assertions.assertEquals(23, ast.getValue()); - Assertions.assertEquals(23, ast.getValueInt()); + assertEquals("23", ast.getSource()); + assertEquals(23, ast.getValue()); + assertEquals(23, ast.getValueInt()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testNat5() throws IOException { ASTDecimal ast = parser.parse_StringDecimal( " 463 " ).get(); - Assertions.assertEquals(463, ast.getValue()); + assertEquals(463, ast.getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @Test public void testNat6() throws IOException { Optional os = parser.parse_StringDecimal( " 0x23 " ); - Assertions.assertEquals(false, os.isPresent()); + assertEquals(false, os.isPresent()); } // -------------------------------------------------------------------- @Test public void testTokens() throws IOException { ASTAnyTokenList ast = parser.parse_StringAnyTokenList( ":463 23:" ).get(); - Assertions.assertEquals(2, ast.sizeAnyTokens()); + assertEquals(2, ast.sizeAnyTokens()); ASTAnyToken a0 = ast.getAnyToken(0); - Assertions.assertTrue(a0.isPresentDecimalToken()); - Assertions.assertEquals("463", a0.getDecimalToken()); + assertTrue(a0.isPresentDecimalToken()); + assertEquals("463", a0.getDecimalToken()); ASTAnyToken a1 = ast.getAnyToken(1); - Assertions.assertTrue(a1.isPresentDecimalToken()); - Assertions.assertEquals("23", a1.getDecimalToken()); + assertTrue(a1.isPresentDecimalToken()); + assertEquals("23", a1.getDecimalToken()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @@ -129,27 +128,27 @@ public void testTokens() throws IOException { public void testTokens2() throws IOException { ASTAnyTokenList ast = parser.parse_StringAnyTokenList( ":9 'a' 45 00 47:" ).get(); - Assertions.assertEquals(6, ast.sizeAnyTokens()); - Assertions.assertEquals("9", ast.getAnyToken(0).getDecimalToken()); - Assertions.assertEquals("a", ast.getAnyToken(1).getCharToken()); - Assertions.assertEquals("45", ast.getAnyToken(2).getDecimalToken()); + assertEquals(6, ast.sizeAnyTokens()); + assertEquals("9", ast.getAnyToken(0).getDecimalToken()); + assertEquals("a", ast.getAnyToken(1).getCharToken()); + assertEquals("45", ast.getAnyToken(2).getDecimalToken()); // Observe the separated '0's! - Assertions.assertEquals("0", ast.getAnyToken(3).getDecimalToken()); - Assertions.assertEquals("0", ast.getAnyToken(4).getDecimalToken()); - Assertions.assertEquals("47", ast.getAnyToken(5).getDecimalToken()); + assertEquals("0", ast.getAnyToken(3).getDecimalToken()); + assertEquals("0", ast.getAnyToken(4).getDecimalToken()); + assertEquals("47", ast.getAnyToken(5).getDecimalToken()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @Test public void testAbstractInterfaceFunctions() throws IOException { ASTNumber ast = parser.parse_StringDecimal( " 234 " ).get(); - Assertions.assertEquals(234, ast.getValue()); - Assertions.assertEquals(234, ast.getValueInt()); - Assertions.assertEquals("234", ast.getSource()); + assertEquals(234, ast.getValue()); + assertEquals(234, ast.getValueInt()); + assertEquals("234", ast.getSource()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @@ -160,11 +159,11 @@ public void testAbstractInterfaceFunctions() throws IOException { @Test public void testInt() throws IOException { ASTInteger ast = parser.parse_StringInteger( " -463 " ).get(); - Assertions.assertEquals(-463, ast.getValue()); - Assertions.assertEquals(-463, ast.getValueInt()); - Assertions.assertEquals("-463", ast.getSource()); + assertEquals(-463, ast.getValue()); + assertEquals(-463, ast.getValueInt()); + assertEquals("-463", ast.getSource()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @@ -172,26 +171,26 @@ public void testInt() throws IOException { public void testIntTokens2() throws IOException { ASTIntegerList ast = parser.parse_StringIntegerList( "[9, -45, -0, - 47]" ).get(); - Assertions.assertEquals(4, ast.sizeIntegers()); - Assertions.assertEquals(9, ast.getInteger(0).getValue()); - Assertions.assertEquals("9", ast.getInteger(0).getSource()); - Assertions.assertEquals(-45, ast.getInteger(1).getValue()); - Assertions.assertEquals("-45", ast.getInteger(1).getSource()); - Assertions.assertEquals(0, ast.getInteger(2).getValue()); + assertEquals(4, ast.sizeIntegers()); + assertEquals(9, ast.getInteger(0).getValue()); + assertEquals("9", ast.getInteger(0).getSource()); + assertEquals(-45, ast.getInteger(1).getValue()); + assertEquals("-45", ast.getInteger(1).getSource()); + assertEquals(0, ast.getInteger(2).getValue()); // "-" is still present - Assertions.assertEquals("-0", ast.getInteger(2).getSource()); - Assertions.assertEquals(-47, ast.getInteger(3).getValue()); + assertEquals("-0", ast.getInteger(2).getSource()); + assertEquals(-47, ast.getInteger(3).getValue()); // space between the two token is missing - Assertions.assertEquals("-47", ast.getInteger(3).getSource()); + assertEquals("-47", ast.getInteger(3).getSource()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @Test public void testIntNEG() throws IOException { Optional os = parser.parse_StringInteger( " 0x34 " ); - Assertions.assertEquals(false, os.isPresent()); + assertEquals(false, os.isPresent()); } // -------------------------------------------------------------------- @@ -202,10 +201,10 @@ public void testIntNEG() throws IOException { @Test public void testB() throws IOException { ASTBTest ast = parser.parse_StringBTest( " X2X, XFF001DX" ).get(); - Assertions.assertEquals("X2X", ast.getXHexDigit(0)); - Assertions.assertEquals("XFF001DX", ast.getXHexDigit(1)); + assertEquals("X2X", ast.getXHexDigit(0)); + assertEquals("XFF001DX", ast.getXHexDigit(1)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -218,16 +217,16 @@ public void testB() throws IOException { public void testString() throws IOException { ASTStringList ast = parser.parse_StringStringList( "[\"ZWeR\",\"4\", \"',\\b,\\\\;\", \"S\\u34F4W\", \"o\"]" ).get(); - Assertions.assertEquals("ZWeR", ast.getStringLiteral(0).getValue()); - Assertions.assertEquals("4", ast.getStringLiteral(1).getValue()); - Assertions.assertEquals("',\b,\\;", ast.getStringLiteral(2).getValue()); - Assertions.assertEquals("S\u34F4W", ast.getStringLiteral(3).getValue()); - Assertions.assertEquals("o", ast.getStringLiteral(4).getValue()); + assertEquals("ZWeR", ast.getStringLiteral(0).getValue()); + assertEquals("4", ast.getStringLiteral(1).getValue()); + assertEquals("',\b,\\;", ast.getStringLiteral(2).getValue()); + assertEquals("S\u34F4W", ast.getStringLiteral(3).getValue()); + assertEquals("o", ast.getStringLiteral(4).getValue()); // repeat wg. buffering - Assertions.assertEquals("ZWeR", ast.getStringLiteral(0).getValue()); + assertEquals("ZWeR", ast.getStringLiteral(0).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @@ -238,10 +237,10 @@ public void testString() throws IOException { @Test public void testChar() throws IOException { ASTCharLiteral ast = parser.parse_StringCharLiteral( " 'h'" ).get(); - Assertions.assertEquals("h", ast.getSource()); - Assertions.assertEquals('h', ast.getValue()); + assertEquals("h", ast.getSource()); + assertEquals('h', ast.getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @@ -249,16 +248,16 @@ public void testChar() throws IOException { public void testChar2() throws IOException { ASTCharList ast = parser.parse_StringCharList( "['Z','4','\\'', '\\b', '\\\\', '\7', '\\7', 'o']" ).get(); - Assertions.assertEquals('Z', ast.getCharLiteral(0).getValue()); - Assertions.assertEquals('4', ast.getCharLiteral(1).getValue()); - Assertions.assertEquals('\'', ast.getCharLiteral(2).getValue()); - Assertions.assertEquals('\b', ast.getCharLiteral(3).getValue()); - Assertions.assertEquals('\\', ast.getCharLiteral(4).getValue()); + assertEquals('Z', ast.getCharLiteral(0).getValue()); + assertEquals('4', ast.getCharLiteral(1).getValue()); + assertEquals('\'', ast.getCharLiteral(2).getValue()); + assertEquals('\b', ast.getCharLiteral(3).getValue()); + assertEquals('\\', ast.getCharLiteral(4).getValue()); // Encoded by Java - Assertions.assertEquals('\7', ast.getCharLiteral(5).getValue()); - Assertions.assertEquals('o', ast.getCharLiteral(7).getValue()); + assertEquals('\7', ast.getCharLiteral(5).getValue()); + assertEquals('o', ast.getCharLiteral(7).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // -------------------------------------------------------------------- @@ -267,12 +266,12 @@ public void testChar2() throws IOException { public void testCharUnicode() throws IOException { ASTCharList ast = parser.parse_StringCharList( "['\\u2345', '\\u23EF', '\\u0001', '\\uAFFA']" ).get(); - Assertions.assertEquals('\u2345', ast.getCharLiteral(0).getValue()); - Assertions.assertEquals('\u23EF', ast.getCharLiteral(1).getValue()); - Assertions.assertEquals('\u0001', ast.getCharLiteral(2).getValue()); - Assertions.assertEquals('\uAFFA', ast.getCharLiteral(3).getValue()); + assertEquals('\u2345', ast.getCharLiteral(0).getValue()); + assertEquals('\u23EF', ast.getCharLiteral(1).getValue()); + assertEquals('\u0001', ast.getCharLiteral(2).getValue()); + assertEquals('\uAFFA', ast.getCharLiteral(3).getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/mcliterals/NatLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mcliterals/NatLiteralsTest.java index 552702f640..509eff7e7a 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcliterals/NatLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mcliterals/NatLiteralsTest.java @@ -7,13 +7,14 @@ import de.monticore.literals.testmccommonliterals._parser.TestMCCommonLiteralsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class NatLiteralsTest { @BeforeEach @@ -27,16 +28,16 @@ public void init() { private void checkNatLiteral(int i, String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional ast = parser.parse_StringNatLiteral(s); - Assertions.assertTrue(!parser.hasErrors()); - Assertions.assertEquals(i, ast.get().getValue()); + assertFalse(parser.hasErrors()); + assertEquals(i, ast.get().getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private void checkFailingNatLiteral(String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); parser.parse_StringNatLiteral(s); - Assertions.assertTrue(parser.hasErrors()); + assertTrue(parser.hasErrors()); } @Test @@ -49,7 +50,7 @@ public void testNatLiterals() { checkNatLiteral(5, "5"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } @@ -60,7 +61,7 @@ public void testFailingNatLiterals() throws IOException { checkFailingNatLiteral("-5"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/mcliterals/NullAndBooleanLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mcliterals/NullAndBooleanLiteralsTest.java index f91defb234..757238104f 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcliterals/NullAndBooleanLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mcliterals/NullAndBooleanLiteralsTest.java @@ -8,12 +8,13 @@ import de.monticore.literals.testmccommonliterals.TestMCCommonLiteralsMill; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; +import static org.junit.jupiter.api.Assertions.*; + public class NullAndBooleanLiteralsTest { @BeforeEach @@ -28,13 +29,13 @@ public void initLog() { public void testNullLiteral() { try { ASTLiteral lit = MCLiteralsTestHelper.getInstance().parseLiteral("null"); - Assertions.assertTrue(lit instanceof ASTNullLiteral); + assertInstanceOf(ASTNullLiteral.class, lit); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -42,18 +43,18 @@ public void testBooleanLiterals() { try { // literal "true": ASTLiteral lit = MCLiteralsTestHelper.getInstance().parseLiteral("true"); - Assertions.assertTrue(lit instanceof ASTBooleanLiteral); - Assertions.assertTrue(((ASTBooleanLiteral) lit).getValue()); + assertInstanceOf(ASTBooleanLiteral.class, lit); + assertTrue(((ASTBooleanLiteral) lit).getValue()); // literal "false": lit = MCLiteralsTestHelper.getInstance().parseLiteral("false"); - Assertions.assertTrue(lit instanceof ASTBooleanLiteral); - Assertions.assertFalse(((ASTBooleanLiteral) lit).getValue()); + assertInstanceOf(ASTBooleanLiteral.class, lit); + assertFalse(((ASTBooleanLiteral) lit).getValue()); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/mcliterals/SignedNatLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mcliterals/SignedNatLiteralsTest.java index f55d174d60..178975869f 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcliterals/SignedNatLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mcliterals/SignedNatLiteralsTest.java @@ -7,13 +7,14 @@ import de.monticore.literals.testmccommonliterals._parser.TestMCCommonLiteralsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class SignedNatLiteralsTest { @BeforeEach @@ -27,16 +28,16 @@ public void initLog() { private void checkNatLiteral(int i, String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); Optional ast = parser.parse_StringSignedNatLiteral(s); - Assertions.assertTrue(!parser.hasErrors()); - Assertions.assertEquals(i, ast.get().getValue()); + assertFalse(parser.hasErrors()); + assertEquals(i, ast.get().getValue()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private void checkFailingNatLiteral(String s) throws IOException { TestMCCommonLiteralsParser parser = new TestMCCommonLiteralsParser(); parser.parse_StringSignedNatLiteral(s); - Assertions.assertTrue(parser.hasErrors()); + assertTrue(parser.hasErrors()); } @Test @@ -56,7 +57,7 @@ public void testNatLiterals() { } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } @@ -67,7 +68,7 @@ public void testFailingNatLiterals() throws IOException { // checkFailingNatLiteral("-5"); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/mcliterals/StringLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/mcliterals/StringLiteralsTest.java index 02e77b5d7b..064051698d 100644 --- a/monticore-grammar/src/test/java/de/monticore/mcliterals/StringLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/mcliterals/StringLiteralsTest.java @@ -8,7 +8,6 @@ import de.monticore.literals.testmccommonliterals._ast.ASTA; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -30,7 +29,7 @@ public void initLog() { private void checkStringLiteral(String expected, String actual) throws IOException { ASTLiteral lit = MCLiteralsTestHelper.getInstance().parseLiteral(actual); - assertTrue(lit instanceof ASTStringLiteral); + assertInstanceOf(ASTStringLiteral.class, lit); assertEquals(expected, ((ASTStringLiteral) lit).getValue()); assertTrue(Log.getFindings().isEmpty()); @@ -62,7 +61,7 @@ public void testStringLiterals() { checkStringLiteral("\u010000", "\"\\u010000\""); } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } } } diff --git a/monticore-grammar/src/test/java/de/monticore/prettyprint/CardinalityPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/prettyprint/CardinalityPrettyPrinterTest.java index 7c499082e7..ee550922ef 100644 --- a/monticore-grammar/src/test/java/de/monticore/prettyprint/CardinalityPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/prettyprint/CardinalityPrettyPrinterTest.java @@ -8,7 +8,6 @@ import de.monticore.cardinality._prettyprint.CardinalityFullPrettyPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,8 +15,8 @@ import java.io.StringReader; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CardinalityPrettyPrinterTest { @@ -33,59 +32,59 @@ public void init() { public void testCardinality1() throws IOException { TestCardinalityParser parser = new TestCardinalityParser(); Optional result = parser.parseCardinality(new StringReader("[*]")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCardinality cardinality = result.get(); CardinalityFullPrettyPrinter prettyPrinter = new CardinalityFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(cardinality); result = parser.parseCardinality(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(cardinality.deepEquals(result.get())); + assertTrue(cardinality.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCardinality2() throws IOException { TestCardinalityParser parser = new TestCardinalityParser(); Optional result = parser.parseCardinality(new StringReader("[5..9]")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCardinality cardinality = result.get(); CardinalityFullPrettyPrinter prettyPrinter = new CardinalityFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(cardinality); result = parser.parseCardinality(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(cardinality.deepEquals(result.get())); + assertTrue(cardinality.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCardinality3() throws IOException { TestCardinalityParser parser = new TestCardinalityParser(); Optional result = parser.parseCardinality(new StringReader("[6..*]")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCardinality cardinality = result.get(); CardinalityFullPrettyPrinter prettyPrinter = new CardinalityFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(cardinality); result = parser.parseCardinality(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(cardinality.deepEquals(result.get())); + assertTrue(cardinality.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/prettyprint/CompletenessPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/prettyprint/CompletenessPrettyPrinterTest.java index ae4488ef7c..172236ace7 100644 --- a/monticore-grammar/src/test/java/de/monticore/prettyprint/CompletenessPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/prettyprint/CompletenessPrettyPrinterTest.java @@ -2,15 +2,11 @@ package de.monticore.prettyprint; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.monticore.testcompleteness.TestCompletenessMill; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import de.monticore.completeness._ast.ASTCompleteness; @@ -19,6 +15,9 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class CompletenessPrettyPrinterTest { @BeforeEach @@ -33,79 +32,79 @@ public void init() { public void testCompleteness() throws IOException { TestCompletenessParser parser = new TestCompletenessParser(); Optional result = parser.parseCompleteness(new StringReader("(c)")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCompleteness completeness = result.get(); CompletenessFullPrettyPrinter prettyPrinter = new CompletenessFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(completeness); result = parser.parseCompleteness(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(completeness.deepEquals(result.get())); + assertTrue(completeness.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testIncompleteness() throws IOException { TestCompletenessParser parser = new TestCompletenessParser(); Optional result = parser.parseCompleteness(new StringReader("(...)")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCompleteness completeness = result.get(); CompletenessFullPrettyPrinter prettyPrinter = new CompletenessFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(completeness); result = parser.parseCompleteness(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(completeness.deepEquals(result.get())); + assertTrue(completeness.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRightCompleteness() throws IOException { TestCompletenessParser parser = new TestCompletenessParser(); Optional result = parser.parseCompleteness(new StringReader("(...,c)")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCompleteness completeness = result.get(); CompletenessFullPrettyPrinter prettyPrinter = new CompletenessFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(completeness); result = parser.parseCompleteness(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(completeness.deepEquals(result.get())); + assertTrue(completeness.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLeftCompleteness() throws IOException { TestCompletenessParser parser = new TestCompletenessParser(); Optional result = parser.parseCompleteness(new StringReader("(c,...)")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCompleteness completeness = result.get(); CompletenessFullPrettyPrinter prettyPrinter = new CompletenessFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(completeness); result = parser.parseCompleteness(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(completeness.deepEquals(result.get())); + assertTrue(completeness.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/prettyprint/GrammarPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/prettyprint/GrammarPrettyPrinterTest.java index ee2d1aab6b..4bf66abff9 100644 --- a/monticore-grammar/src/test/java/de/monticore/prettyprint/GrammarPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/prettyprint/GrammarPrettyPrinterTest.java @@ -5,7 +5,6 @@ import de.monticore.grammar.grammar_withconcepts.Grammar_WithConceptsMill; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,6 +15,8 @@ import java.util.Optional; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.*; + /** * This test checks if all (hand-written) MontiCore grammars are print-able using the generated pretty printers */ @@ -59,23 +60,23 @@ public void testPrintGrammar(Path path) throws IOException { System.err.println(path.toAbsolutePath()); Optional astOpt = Grammar_WithConceptsMill.parser().parse(path.toString()); - Assertions.assertTrue(astOpt.isPresent()); + assertTrue(astOpt.isPresent()); String pretty = Grammar_WithConceptsMill.prettyPrint(astOpt.get(), true); - Assertions.assertEquals(0, Log.getFindingsCount(), "Failed to pretty print without findings: " + path); + assertEquals(0, Log.getFindingsCount(), "Failed to pretty print without findings: " + path); Optional parsedAST = Grammar_WithConceptsMill.parser().parse_String(pretty); if (parsedAST.isEmpty()) { - Assertions.assertEquals(Files.readString(path), pretty, "Failed to parse " + path); - Assertions.fail("Failed to parse " + path); + assertEquals(Files.readString(path), pretty, "Failed to parse " + path); + fail("Failed to parse " + path); } if (!Log.getFindings().isEmpty()) { - Assertions.assertEquals(Files.readString(path), pretty, "Failed to parse " + path + " without findings"); - Assertions.fail("Failed to parse " + path + " without findings"); + assertEquals(Files.readString(path), pretty, "Failed to parse " + path + " without findings"); + fail("Failed to parse " + path + " without findings"); } if (!astOpt.get().deepEquals(parsedAST.get())) { - Assertions.assertEquals(Files.readString(path), pretty, "Failed to deep-equals " + path); - Assertions.fail("Failed to deep-equals"); + assertEquals(Files.readString(path), pretty, "Failed to deep-equals " + path); + fail("Failed to deep-equals"); } } diff --git a/monticore-grammar/src/test/java/de/monticore/prettyprint/JavaLightPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/prettyprint/JavaLightPrettyPrinterTest.java index 25b1d736e0..140581dc91 100644 --- a/monticore-grammar/src/test/java/de/monticore/prettyprint/JavaLightPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/prettyprint/JavaLightPrettyPrinterTest.java @@ -7,15 +7,14 @@ import de.monticore.javalight._prettyprint.JavaLightFullPrettyPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class JavaLightPrettyPrinterTest { @@ -35,272 +34,272 @@ public void init() { @Test public void testMethodDeclaration() throws IOException { Optional result = parser.parse_StringMethodDeclaration("private static final int foo(String s[], boolean b)[][][] throws e.Exception { private Integer foo = a; }"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMethodDeclaration ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringMethodDeclaration(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testAbstractInterfaceMethod() throws IOException { Optional result = parser.parse_StringMethodDeclaration("public void foo(String s, boolean b);"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMethodDeclaration ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringMethodDeclaration(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get()), "Parse pp output: " + output); + assertTrue(ast.deepEquals(result.get()), "Parse pp output: " + output); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDefaultMethod() throws IOException { Optional result = parser.parse_StringMethodDeclaration("default int foo(String s, boolean b)[][] throws e.Exception { return expr; }"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMethodDeclaration ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringMethodDeclaration(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testConstructorDeclaration() throws IOException { Optional result = parser.parse_StringConstructorDeclaration("public ClassName(String s, boolean b) throws e.Exception { private Integer foo = a;}"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTConstructorDeclaration ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringConstructorDeclaration(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testConstDeclaration() throws IOException { Optional result = parser.parse_StringConstDeclaration("private static Foo foo [][][] = a;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTConstDeclaration ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringConstDeclaration(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testThrows() throws IOException { Optional result = parser.parse_StringThrows("a.b.c.D, person.A "); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTThrows ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringThrows(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testFormalParameters() throws IOException { Optional result = parser.parse_StringFormalParameters("(public float f, int i, private ASTNode n, Float ... a)"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTFormalParameters ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringFormalParameters(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testFormalParameterListing() throws IOException { Optional result = parser.parse_StringFormalParameterListing("public float f, int i, private ASTNode n, Float ... a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTFormalParameterListing ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringFormalParameterListing(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLastFormalParameter() throws IOException { Optional result = parser.parse_StringLastFormalParameter("private String ... a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTLastFormalParameter ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringLastFormalParameter(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testAnnotation() throws IOException { Optional result = parser.parse_StringAnnotation("@java.util.List (a = ++a, b = {c, d})"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTAnnotation ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringAnnotation(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testAnnotationPairArguments() throws IOException { Optional result = parser.parse_StringAnnotationPairArguments("a = ++a, b = {c, d}"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTAnnotationPairArguments ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringAnnotationPairArguments(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testElementValueOrExpr() throws IOException { Optional result = parser.parse_StringElementValueOrExpr("++a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTElementValueOrExpr ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringElementValueOrExpr(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testElementValueArrayInitializer() throws IOException { Optional result = parser.parse_StringElementValueArrayInitializer("{c, d}"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTElementValueArrayInitializer ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringElementValueArrayInitializer(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testElementValuePair() throws IOException { Optional result = parser.parse_StringElementValuePair("a = ++a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTElementValuePair ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringElementValuePair(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreatorExpression2() throws IOException { Optional result = parser.parse_StringArrayDimensionByInitializer("[][]{{}}"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTArrayDimensionByInitializer ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringArrayDimensionByInitializer(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/prettyprint/MCCommonLiteralsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/prettyprint/MCCommonLiteralsPrettyPrinterTest.java index b74c299c4d..f6ed383012 100644 --- a/monticore-grammar/src/test/java/de/monticore/prettyprint/MCCommonLiteralsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/prettyprint/MCCommonLiteralsPrettyPrinterTest.java @@ -7,15 +7,14 @@ import de.monticore.literals.testmccommonliterals._parser.TestMCCommonLiteralsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCCommonLiteralsPrettyPrinterTest { @@ -35,218 +34,218 @@ public void init() { @Test public void testIntLiteral() throws IOException { Optional result = parser.parse_StringNullLiteral("null"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTNullLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringNullLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testFalseBooleanLiteral() throws IOException { Optional result = parser.parse_StringBooleanLiteral("true"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTBooleanLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringBooleanLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testTrueBooleanLiteral() throws IOException { Optional result = parser.parse_StringBooleanLiteral("false"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTBooleanLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringBooleanLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCharLiteral() throws IOException { Optional result = parser.parse_StringCharLiteral("'c'"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCharLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringCharLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testStringLiteral() throws IOException { Optional result = parser.parse_StringStringLiteral("\"something\""); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTStringLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringStringLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSignedNatLiteral() throws IOException { Optional result = parser.parse_StringSignedNatLiteral("-123456789"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTSignedNatLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringSignedNatLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBasicLongLiteral() throws IOException { Optional result = parser.parse_StringBasicLongLiteral("13745934L"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTBasicLongLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringBasicLongLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSignedBasicLongLiteral() throws IOException { Optional result = parser.parse_StringSignedBasicLongLiteral("-13745934L"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTSignedBasicLongLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringSignedBasicLongLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBasicFloatLiteral() throws IOException { Optional result = parser.parse_StringBasicFloatLiteral("13745934.73649F"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTBasicFloatLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringBasicFloatLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSignedBasicFloatLiteral() throws IOException { Optional result = parser.parse_StringSignedBasicFloatLiteral("-13745934.38462F"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTSignedBasicFloatLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringSignedBasicFloatLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBasicDoubleLiteral() throws IOException { Optional result = parser.parse_StringBasicDoubleLiteral("13745934.73649"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTBasicDoubleLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringBasicDoubleLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSignedBasicDoubleLiteral() throws IOException { Optional result = parser.parse_StringSignedBasicDoubleLiteral("-13745934.38462"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTSignedBasicDoubleLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringSignedBasicDoubleLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/prettyprint/MCHexNumbersPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/prettyprint/MCHexNumbersPrettyPrinterTest.java index a5d81ef62a..052b2ce593 100644 --- a/monticore-grammar/src/test/java/de/monticore/prettyprint/MCHexNumbersPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/prettyprint/MCHexNumbersPrettyPrinterTest.java @@ -9,7 +9,6 @@ import mchexnumbers._ast.ASTHexInteger; import mchexnumbers._ast.ASTHexadecimal; import mchexnumbers._prettyprint.MCHexNumbersFullPrettyPrinter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -17,8 +16,8 @@ import java.io.StringReader; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCHexNumbersPrettyPrinterTest { @@ -34,60 +33,60 @@ public void init() { public void testHexadecimal() throws IOException { TestMCHexNumbersParser parser = new TestMCHexNumbersParser(); Optional result = parser.parseHexadecimal(new StringReader("0X6b90A")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTHexadecimal hexadecimal = result.get(); MCHexNumbersFullPrettyPrinter prettyPrinter = new MCHexNumbersFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(hexadecimal); result = parser.parseHexadecimal(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(hexadecimal.deepEquals(result.get())); + assertTrue(hexadecimal.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testHexIntegerPositiv() throws IOException { TestMCHexNumbersParser parser = new TestMCHexNumbersParser(); Optional result = parser.parseHexInteger(new StringReader("0X6b90A")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTHexInteger hexinteger = result.get(); MCHexNumbersFullPrettyPrinter prettyPrinter = new MCHexNumbersFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(hexinteger); result = parser.parseHexInteger(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(hexinteger.deepEquals(result.get())); + assertTrue(hexinteger.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testHexIntegerNegative() throws IOException { TestMCHexNumbersParser parser = new TestMCHexNumbersParser(); Optional result = parser.parseHexInteger(new StringReader("-0xaf67")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTHexInteger hexinteger = result.get(); MCHexNumbersFullPrettyPrinter prettyPrinter = new MCHexNumbersFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(hexinteger); result = parser.parseHexInteger(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(hexinteger.deepEquals(result.get())); + assertTrue(hexinteger.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/prettyprint/MCJavaLiteralsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/prettyprint/MCJavaLiteralsPrettyPrinterTest.java index b08415bd12..5907a4e65f 100644 --- a/monticore-grammar/src/test/java/de/monticore/prettyprint/MCJavaLiteralsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/prettyprint/MCJavaLiteralsPrettyPrinterTest.java @@ -10,15 +10,14 @@ import de.monticore.literals.testmcjavaliterals._parser.TestMCJavaLiteralsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCJavaLiteralsPrettyPrinterTest { @@ -37,75 +36,75 @@ public void init() { @Test public void testIntLiteral() throws IOException { Optional result = parser.parse_StringIntLiteral("1110"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTIntLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringIntLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLongLiteral() throws IOException { Optional result = parser.parse_StringLongLiteral("109584763l"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTLongLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringLongLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testFloatLiteral() throws IOException { Optional result = parser.parse_StringFloatLiteral("93475.2434356677f"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTFloatLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringFloatLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDoubleLiteral() throws IOException { Optional result = parser.parse_StringDoubleLiteral("1110.45600233"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTDoubleLiteral ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringDoubleLiteral(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/prettyprint/MCNumbersPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/prettyprint/MCNumbersPrettyPrinterTest.java index 120853d0ba..c0302d8731 100644 --- a/monticore-grammar/src/test/java/de/monticore/prettyprint/MCNumbersPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/prettyprint/MCNumbersPrettyPrinterTest.java @@ -9,7 +9,6 @@ import mcnumbers._ast.ASTDecimal; import mcnumbers._ast.ASTInteger; import mcnumbers._prettyprint.MCNumbersFullPrettyPrinter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -17,8 +16,8 @@ import java.io.StringReader; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCNumbersPrettyPrinterTest { @@ -34,79 +33,79 @@ public void init() { public void testDecimalZero() throws IOException { TestMCNumbersParser parser = new TestMCNumbersParser(); Optional result = parser.parseDecimal(new StringReader("0")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTDecimal decimal = result.get(); MCNumbersFullPrettyPrinter prettyPrinter = new MCNumbersFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(decimal); result = parser.parseDecimal(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(decimal.deepEquals(result.get())); + assertTrue(decimal.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDecimal() throws IOException { TestMCNumbersParser parser = new TestMCNumbersParser(); Optional result = parser.parseDecimal(new StringReader("9702")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTDecimal decimal = result.get(); MCNumbersFullPrettyPrinter prettyPrinter = new MCNumbersFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(decimal); result = parser.parseDecimal(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(decimal.deepEquals(result.get())); + assertTrue(decimal.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testIntegerPositive() throws IOException { TestMCNumbersParser parser = new TestMCNumbersParser(); Optional result = parser.parseInteger(new StringReader("780530")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTInteger integer = result.get(); MCNumbersFullPrettyPrinter prettyPrinter = new MCNumbersFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(integer); result = parser.parseInteger(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(integer.deepEquals(result.get())); + assertTrue(integer.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testIntegerNegative() throws IOException { TestMCNumbersParser parser = new TestMCNumbersParser(); Optional result = parser.parseInteger(new StringReader("-9702")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTInteger integer = result.get(); MCNumbersFullPrettyPrinter prettyPrinter = new MCNumbersFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(integer); result = parser.parseInteger(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(integer.deepEquals(result.get())); + assertTrue(integer.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/prettyprint/StringLiteralsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/prettyprint/StringLiteralsPrettyPrinterTest.java index 2fb3c47e36..af3334bde4 100644 --- a/monticore-grammar/src/test/java/de/monticore/prettyprint/StringLiteralsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/prettyprint/StringLiteralsPrettyPrinterTest.java @@ -6,7 +6,6 @@ import de.monticore.teststringliterals._parser.TestStringLiteralsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import stringliterals._ast.ASTCharLiteral; @@ -17,8 +16,8 @@ import java.io.StringReader; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class StringLiteralsPrettyPrinterTest { @@ -34,8 +33,8 @@ public void init() { public void testCharLiteralEscapeSequenz() throws IOException { TestStringLiteralsParser parser = new TestStringLiteralsParser(); Optional result = parser.parseCharLiteral(new StringReader("'\"'")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCharLiteral cliteral = result.get(); StringLiteralsFullPrettyPrinter prettyPrinter = new StringLiteralsFullPrettyPrinter( @@ -43,20 +42,20 @@ public void testCharLiteralEscapeSequenz() throws IOException { String output = prettyPrinter.prettyprint(cliteral); result = parser.parseCharLiteral(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors(), output); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors(), output); + assertTrue(result.isPresent()); - Assertions.assertTrue(cliteral.deepEquals(result.get())); + assertTrue(cliteral.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCharLiteral() throws IOException { TestStringLiteralsParser parser = new TestStringLiteralsParser(); Optional result = parser.parseCharLiteral(new StringReader("'c'")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCharLiteral cliteral = result.get(); StringLiteralsFullPrettyPrinter prettyPrinter = new StringLiteralsFullPrettyPrinter( @@ -64,12 +63,12 @@ public void testCharLiteral() throws IOException { String output = prettyPrinter.prettyprint(cliteral); result = parser.parseCharLiteral(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors(), output); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors(), output); + assertTrue(result.isPresent()); - Assertions.assertTrue(cliteral.deepEquals(result.get())); + assertTrue(cliteral.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -77,20 +76,20 @@ public void testStringLiteral() throws IOException { TestStringLiteralsParser parser = new TestStringLiteralsParser(); Optional result = parser .parseStringLiteral(new StringReader("\"Text mit 893\"")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTStringLiteral sliteral = result.get(); StringLiteralsFullPrettyPrinter prettyPrinter = new StringLiteralsFullPrettyPrinter( new IndentPrinter()); String output = prettyPrinter.prettyprint(sliteral); result = parser.parseStringLiteral(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors(), output); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors(), output); + assertTrue(result.isPresent()); - Assertions.assertTrue(sliteral.deepEquals(result.get())); + assertTrue(sliteral.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/prettyprint/UMLModifierPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/prettyprint/UMLModifierPrettyPrinterTest.java index 6b27b869e6..423ed61a22 100644 --- a/monticore-grammar/src/test/java/de/monticore/prettyprint/UMLModifierPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/prettyprint/UMLModifierPrettyPrinterTest.java @@ -2,15 +2,11 @@ package de.monticore.prettyprint; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.monticore.testumlmodifier.TestUMLModifierMill; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -20,6 +16,9 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class UMLModifierPrettyPrinterTest { @BeforeEach @@ -34,39 +33,39 @@ public void init() { public void testModifierWord() throws IOException { TestUMLModifierParser parser = new TestUMLModifierParser(); Optional result = parser.parseModifier(new StringReader("private")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTModifier modifier = result.get(); UMLModifierFullPrettyPrinter prettyPrinter = new UMLModifierFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(modifier); result = parser.parseModifier(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(modifier.deepEquals(result.get())); + assertTrue(modifier.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testModifierSymbol() throws IOException { TestUMLModifierParser parser = new TestUMLModifierParser(); Optional result = parser.parseModifier(new StringReader("-")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTModifier modifier = result.get(); UMLModifierFullPrettyPrinter prettyPrinter = new UMLModifierFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(modifier); result = parser.parseModifier(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(modifier.deepEquals(result.get())); + assertTrue(modifier.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/prettyprint/UMLStereotypePrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/prettyprint/UMLStereotypePrettyPrinterTest.java index 80ca703916..d744bd7bf1 100644 --- a/monticore-grammar/src/test/java/de/monticore/prettyprint/UMLStereotypePrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/prettyprint/UMLStereotypePrettyPrinterTest.java @@ -2,14 +2,11 @@ package de.monticore.prettyprint; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.monticore.testumlstereotype.TestUMLStereotypeMill; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import de.monticore.umlstereotype._prettyprint.UMLStereotypeFullPrettyPrinter; import de.monticore.testumlstereotype._parser.TestUMLStereotypeParser; @@ -19,6 +16,9 @@ import de.se_rwth.commons.logging.LogStub; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class UMLStereotypePrettyPrinterTest { @BeforeEach @@ -38,39 +38,39 @@ public void setUp() { public void testStereotype() throws IOException { TestUMLStereotypeParser parser = new TestUMLStereotypeParser(); Optional result = parser.parseStereotype(new StringReader("<>")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTStereotype stereotype = result.get(); UMLStereotypeFullPrettyPrinter prettyPrinter = new UMLStereotypeFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(stereotype); result = parser.parseStereotype(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(stereotype.deepEquals(result.get())); + assertTrue(stereotype.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testStereoValue() throws IOException { TestUMLStereotypeParser parser = new TestUMLStereotypeParser(); Optional result = parser.parseStereoValue(new StringReader("s1=\"S1\"")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTStereoValue stereovalue = result.get(); UMLStereotypeFullPrettyPrinter prettyPrinter = new UMLStereotypeFullPrettyPrinter(new IndentPrinter()); String output = prettyPrinter.prettyprint(stereovalue); result = parser.parseStereoValue(new StringReader(output)); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(stereovalue.deepEquals(result.get())); + assertTrue(stereovalue.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/regex/regularexpressions/cocos/RangeHasLowerOrUpperBoundTest.java b/monticore-grammar/src/test/java/de/monticore/regex/regularexpressions/cocos/RangeHasLowerOrUpperBoundTest.java index 790e11d745..5106b33f26 100644 --- a/monticore-grammar/src/test/java/de/monticore/regex/regularexpressions/cocos/RangeHasLowerOrUpperBoundTest.java +++ b/monticore-grammar/src/test/java/de/monticore/regex/regularexpressions/cocos/RangeHasLowerOrUpperBoundTest.java @@ -8,7 +8,6 @@ import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,8 +15,8 @@ import java.util.Optional; import java.util.stream.Collectors; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class RangeHasLowerOrUpperBoundTest { @@ -51,10 +50,10 @@ protected void checkValid(String expressionString) throws IOException { CombineExpressionsWithLiteralsParser parser = new CombineExpressionsWithLiteralsParser(); Optional optAST = parser.parse_StringRegExLiteral(expressionString); - Assertions.assertTrue(optAST.isPresent()); + assertTrue(optAST.isPresent()); Log.getFindings().clear(); checker.checkAll(optAST.get()); - Assertions.assertTrue(Log.getFindings().isEmpty(), Log.getFindings().stream() + assertTrue(Log.getFindings().isEmpty(), Log.getFindings().stream() .map(Finding::buildMsg) .collect(Collectors.joining(System.lineSeparator()))); } @@ -63,10 +62,10 @@ protected void checkInvalid(String expressionString) throws IOException { CombineExpressionsWithLiteralsParser parser = new CombineExpressionsWithLiteralsParser(); Optional optAST = parser.parse_StringRegExLiteral(expressionString); - Assertions.assertTrue(optAST.isPresent()); + assertTrue(optAST.isPresent()); Log.getFindings().clear(); checker.checkAll(optAST.get()); - Assertions.assertFalse(Log.getFindings().isEmpty()); + assertFalse(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCArrayStatementsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCArrayStatementsPrettyPrinterTest.java index fb27b74ed9..d1c45040e5 100644 --- a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCArrayStatementsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCArrayStatementsPrettyPrinterTest.java @@ -9,13 +9,14 @@ import de.monticore.statements.testmcarraystatements._parser.TestMCArrayStatementsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCArrayStatementsPrettyPrinterTest { private TestMCArrayStatementsParser parser = new TestMCArrayStatementsParser(); @@ -36,38 +37,38 @@ public void init() { public void testArrayInit() throws IOException { String input = "{a, b, foo}"; Optional result = parser.parse_StringArrayInit(input); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTArrayInit ast = result.get(); String output = prettyPrinter.prettyprint(ast); - Assertions.assertEquals(input.replaceAll(" ", ""), output.replaceAll(" ", "").replaceAll("\n", "")); + assertEquals(input.replaceAll(" ", ""), output.replaceAll(" ", "").replaceAll("\n", "")); result = parser.parse_StringArrayInit(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testArrayDeclaratorId() throws IOException { Optional result = parser.parse_StringArrayDeclaratorId("a [] []"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTArrayDeclaratorId ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringArrayDeclaratorId(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCCommonStatementsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCCommonStatementsPrettyPrinterTest.java index 280fc5857a..c8e17e10ac 100644 --- a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCCommonStatementsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCCommonStatementsPrettyPrinterTest.java @@ -12,15 +12,14 @@ import de.monticore.statements.testmccommonstatements._parser.TestMCCommonStatementsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCCommonStatementsPrettyPrinterTest { @@ -40,379 +39,379 @@ public void init() { @Test public void testBlock() throws IOException { Optional result = parser.parse_StringMCJavaBlock("{ private Integer foo = a; }"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCJavaBlock ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringMCJavaBlock(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBlockStatement() throws IOException { Optional result = parser.parse_StringMCBlockStatement("private Integer foo = a;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTMCBlockStatement ast = result.get(); ast.accept(prettyPrinter.getTraverser()); String output = prettyPrinter.getPrinter().getContent(); result = parser.parse_StringMCBlockStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLocalVariableDeclaration() throws IOException { Optional result = parser.parse_StringLocalVariableDeclaration("private Integer foo = a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTLocalVariableDeclaration ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringLocalVariableDeclaration(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testVariableDeclaration() throws IOException { Optional result = parser.parse_StringVariableDeclarator("foo = a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTVariableDeclarator ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringVariableDeclarator(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDeclaratorId() throws IOException { Optional result = parser.parse_StringDeclaratorId("a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTDeclaratorId ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringDeclaratorId(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testIfStatement() throws IOException { Optional result = parser.parse_StringIfStatement("if(a) ; else ;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTIfStatement ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringIfStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testForStatement() throws IOException { Optional result = parser.parse_StringForStatement("for(i; i ; i) a;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTForStatement ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringForStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCommonForControl() throws IOException { Optional result = parser.parse_StringCommonForControl("i; i ; i"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCommonForControl ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringCommonForControl(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testEnhancedForControl() throws IOException { Optional result = parser.parse_StringEnhancedForControl("protected List l : a"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTEnhancedForControl ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringEnhancedForControl(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testFormalParameter() throws IOException { Optional result = parser.parse_StringFormalParameter("public float f"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTFormalParameter ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringFormalParameter(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testForInitByExpressions() throws IOException { Optional result = parser.parse_StringForInitByExpressions("i, b, c"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTForInitByExpressions ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringForInitByExpressions(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testWhileStatement() throws IOException { Optional result = parser.parse_StringWhileStatement("while (a) ;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTWhileStatement ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringWhileStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDoWhileStatement() throws IOException { Optional result = parser.parse_StringDoWhileStatement("do ; while (a);"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTDoWhileStatement ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringDoWhileStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSwitchStatement() throws IOException { Optional result = parser.parse_StringSwitchStatement("switch (a) {case b : c; default : d;}"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTSwitchStatement ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringSwitchStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testEmptyStatement() throws IOException { Optional result = parser.parse_StringEmptyStatement(";"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTEmptyStatement ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringEmptyStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpressionStatement() throws IOException { Optional result = parser.parse_StringExpressionStatement("a;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTExpressionStatement ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringExpressionStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSwitchBlockStatementGroup() throws IOException { Optional result = parser.parse_StringSwitchBlockStatementGroup("case a: foo;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTSwitchBlockStatementGroup ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringSwitchBlockStatementGroup(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testConstantExpressionSwitchLabel() throws IOException { Optional result = parser.parse_StringConstantExpressionSwitchLabel("case a :"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTConstantExpressionSwitchLabel ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringConstantExpressionSwitchLabel(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testEnumConstantSwitchLabel() throws IOException { Optional result = parser.parse_StringEnumConstantSwitchLabel("case a :"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTEnumConstantSwitchLabel ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringEnumConstantSwitchLabel(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDefaultSwitchLabel() throws IOException { Optional result = parser.parse_StringDefaultSwitchLabel("default :"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTDefaultSwitchLabel ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringDefaultSwitchLabel(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBreakStatement() throws IOException { Optional result = parser.parse_StringBreakStatement("break ;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTBreakStatement ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringBreakStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCExceptionStatementsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCExceptionStatementsPrettyPrinterTest.java index be268e44ae..1f6c394b2c 100644 --- a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCExceptionStatementsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCExceptionStatementsPrettyPrinterTest.java @@ -8,15 +8,14 @@ import de.monticore.statements.testmcexceptionstatements._parser.TestMCExceptionStatementsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCExceptionStatementsPrettyPrinterTest { @@ -36,37 +35,37 @@ public void init() { @Test public void testTryStatement2() throws IOException { Optional result = parser.parse_StringTryStatement2(" try { Integer foo = a;} finally { Integer foo = a; }"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTTryStatement2 ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringTryStatement2(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testTryStatement1() throws IOException { Optional result = parser.parse_StringTryStatement1(" try { Integer foo = a; } catch (private static a.b.c | d.e.G foo) {Integer foo = a; }"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTTryStatement1 ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringTryStatement1(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -75,94 +74,94 @@ public void testTryStatements() throws IOException { Optional result = parser.parse_StringTryStatement3("try ( public Integer a = foo; ) " + "{ public String foo = a ;} " + "catch (private static a.b.c | d.e.G foo) { public String foo = a ;}"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTTryStatement3 ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringTryStatement3(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testTryvariableDeclaration() throws IOException { Optional result = parser.parse_StringTryLocalVariableDeclaration("public Integer a = foo"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTTryLocalVariableDeclaration ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringTryLocalVariableDeclaration(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCatchClause() throws IOException { Optional result = parser.parse_StringCatchClause("catch (private static a.b.c | d.e.G foo) { public String foo = a; }"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCatchClause ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringCatchClause(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCatchType() throws IOException { Optional result = parser.parse_StringCatchTypeList(" a.b.c | d.e.G "); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTCatchTypeList ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringCatchTypeList(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testThrowStatement() throws IOException { Optional result = parser.parse_StringThrowStatement("throw Exception;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTThrowStatement ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringThrowStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCLowLevelStatementsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCLowLevelStatementsPrettyPrinterTest.java index 6e446c6502..d494e92fb0 100644 --- a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCLowLevelStatementsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCLowLevelStatementsPrettyPrinterTest.java @@ -10,15 +10,14 @@ import de.monticore.statements.testmclowlevelstatements._parser.TestMCLowLevelStatementsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCLowLevelStatementsPrettyPrinterTest { @@ -36,54 +35,54 @@ public void init() { @Test public void testBreakStatement() throws IOException { Optional result = parser.parse_StringLabelledBreakStatement("break a ;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTLabelledBreakStatement ast = result.get(); String output = TestMCLowLevelStatementsMill.prettyPrint(ast, true); result = parser.parse_StringLabelledBreakStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLabeledStatement() throws IOException { Optional result = parser.parse_StringLabel("a : break foo;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTLabel ast = result.get(); String output = TestMCLowLevelStatementsMill.prettyPrint(ast, true); result = parser.parse_StringLabel(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testContinueStatement() throws IOException { Optional result = parser.parse_StringContinueStatement("continue foo;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTContinueStatement ast = result.get(); String output = TestMCLowLevelStatementsMill.prettyPrint(ast, true); result = parser.parse_StringContinueStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCReturnStatementsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCReturnStatementsPrettyPrinterTest.java index f4aad7c28c..bc60c49fae 100644 --- a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCReturnStatementsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCReturnStatementsPrettyPrinterTest.java @@ -8,15 +8,14 @@ import de.monticore.statements.testmcreturnstatements._parser.TestMCReturnStatementsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCReturnStatementsPrettyPrinterTest { @@ -36,18 +35,18 @@ public void init() { @Test public void testReturnStatement() throws IOException { Optional result = parser.parse_StringReturnStatement("return a ;"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTReturnStatement ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringReturnStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCSynchronizedStatementsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCSynchronizedStatementsPrettyPrinterTest.java index 3cbb5071b1..ee2dfb3632 100644 --- a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCSynchronizedStatementsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCSynchronizedStatementsPrettyPrinterTest.java @@ -8,15 +8,14 @@ import de.monticore.statements.testmcsynchronizedstatements._parser.TestMCSynchronizedStatementsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCSynchronizedStatementsPrettyPrinterTest { @@ -36,19 +35,19 @@ public void init() { @Test public void testReturnStatement() throws IOException { Optional result = parser.parse_StringSynchronizedStatement("synchronized (foo) { final Integer foo = a ;}"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTSynchronizedStatement ast = result.get(); String output = prettyPrinter.prettyprint(ast); result = parser.parse_StringSynchronizedStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCVarDeclarationStatementsPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCVarDeclarationStatementsPrettyPrinterTest.java index bbf24beea1..4b2367d3e8 100644 --- a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCVarDeclarationStatementsPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/MCVarDeclarationStatementsPrettyPrinterTest.java @@ -8,15 +8,14 @@ import de.monticore.statements.testmcvardeclarationstatements._parser.TestMCVarDeclarationStatementsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCVarDeclarationStatementsPrettyPrinterTest { @@ -36,20 +35,20 @@ public void init() { @Test public void testLocalVariableDeclaration() throws IOException { Optional result = parser.parse_StringLocalVariableDeclaration("List a = b, c = d"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); ASTLocalVariableDeclaration ast = result.get(); ast.accept(prettyPrinter.getTraverser()); String output = prettyPrinter.getPrinter().getContent(); result = parser.parse_StringLocalVariableDeclaration(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(result.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(result.isPresent()); - Assertions.assertTrue(ast.deepEquals(result.get())); + assertTrue(ast.deepEquals(result.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/TrailingSpacesPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/TrailingSpacesPrettyPrinterTest.java index 2ad2c0fdc3..b29ea4336a 100644 --- a/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/TrailingSpacesPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/statements/prettyprint/TrailingSpacesPrettyPrinterTest.java @@ -9,13 +9,14 @@ import de.monticore.statements.testmccommonstatements._parser.TestMCCommonStatementsParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class TrailingSpacesPrettyPrinterTest { TestMCCommonStatementsParser parser; @@ -34,21 +35,21 @@ public void testSingleLineCommentEOL() throws IOException { // Scenario: An expression is string-concatenated into a statement as the initial value // First, we have to extract the inner AST node with the comment Optional blocks = parser.parse_StringMCJavaBlock("{int i1 = a // single line comment\n; int i2 = b; }"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(blocks.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(blocks.isPresent()); ASTLocalVariableDeclarationStatement setStatement = (ASTLocalVariableDeclarationStatement) blocks.get().getMCBlockStatementList().get(0); ASTExpression initialValueAST = ((ASTSimpleInit) setStatement.getLocalVariableDeclaration().getVariableDeclarator(0).getVariableInit()).getExpression(); - Assertions.assertEquals(1, initialValueAST.get_PostCommentList().size()); + assertEquals(1, initialValueAST.get_PostCommentList().size()); // print the initial value expression String initialValue = TestMCCommonStatementsMill.prettyPrint(initialValueAST, true); // and ensure the pretty printed string ends with a linebreak - Assertions.assertTrue(initialValue.endsWith("\n")); + assertTrue(initialValue.endsWith("\n")); // then test to parse this value inlined - in case no linebreak is present, this will fail Optional statement = parser.parse_StringMCJavaBlock("{int i = " + initialValue + "; int i2 = 0; }"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(statement.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(statement.isPresent()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/BasicSymbolsSymbols2JsonTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/BasicSymbolsSymbols2JsonTest.java index aad6a0d487..eb12f4c30b 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/BasicSymbolsSymbols2JsonTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/BasicSymbolsSymbols2JsonTest.java @@ -9,12 +9,13 @@ import de.monticore.types.check.SymTypeExpressionFactory; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class BasicSymbolsSymbols2JsonTest { private IBasicSymbolsArtifactScope scope; @@ -100,7 +101,7 @@ public void init() { public void testDeSer(){ performRoundTripSerialization(scope); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } public void performRoundTripSerialization(IBasicSymbolsArtifactScope scope){ @@ -109,59 +110,59 @@ public void performRoundTripSerialization(IBasicSymbolsArtifactScope scope){ String serialized = symbols2Json.serialize(scope); // then deserialize it IBasicSymbolsArtifactScope deserialized = symbols2Json.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); // and assert that the deserialized scope equals the one before //check that both can resolve the type "Type" Optional type = scope.resolveType("Type"); Optional deserializedType = deserialized.resolveType("Type"); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(deserializedType.isPresent()); + assertTrue(type.isPresent()); + assertTrue(deserializedType.isPresent()); //check that both can resolve the type "SubType" with the supertype "Type" Optional subtype = scope.resolveType("SubType"); Optional deserializedSubType = deserialized.resolveType("SubType"); - Assertions.assertTrue(subtype.isPresent()); - Assertions.assertTrue(deserializedSubType.isPresent()); - Assertions.assertEquals(1, subtype.get().getSuperTypesList().size()); - Assertions.assertEquals(1, deserializedSubType.get().getSuperTypesList().size()); - Assertions.assertEquals("Type", subtype.get().getSuperTypesList().get(0).print()); - Assertions.assertEquals("Type", deserializedSubType.get().getSuperTypesList().get(0).print()); + assertTrue(subtype.isPresent()); + assertTrue(deserializedSubType.isPresent()); + assertEquals(1, subtype.get().getSuperTypesList().size()); + assertEquals(1, deserializedSubType.get().getSuperTypesList().size()); + assertEquals("Type", subtype.get().getSuperTypesList().get(0).print()); + assertEquals("Type", deserializedSubType.get().getSuperTypesList().get(0).print()); IBasicSymbolsScope typeSpanned = type.get().getSpannedScope(); IBasicSymbolsScope deserTypeSpanned = deserializedType.get().getSpannedScope(); //check that both can resolve the TypeVariable "T" in their "Type" - Assertions.assertTrue(typeSpanned.resolveTypeVar("T").isPresent()); - Assertions.assertTrue(deserTypeSpanned.resolveTypeVar("T").isPresent()); + assertTrue(typeSpanned.resolveTypeVar("T").isPresent()); + assertTrue(deserTypeSpanned.resolveTypeVar("T").isPresent()); //check for Variable variable in Type Optional variable = typeSpanned.resolveVariable("variable"); Optional deserializedVariable = deserTypeSpanned.resolveVariable("variable"); - Assertions.assertTrue(variable.isPresent()); - Assertions.assertTrue(deserializedVariable.isPresent()); - Assertions.assertEquals("double", variable.get().getType().print()); - Assertions.assertEquals("double", deserializedVariable.get().getType().print()); + assertTrue(variable.isPresent()); + assertTrue(deserializedVariable.isPresent()); + assertEquals("double", variable.get().getType().print()); + assertEquals("double", deserializedVariable.get().getType().print()); //check for Variable variable2 in Type Optional variable2 = typeSpanned.resolveVariable("variable2"); Optional deserializedVariable2 = deserTypeSpanned.resolveVariable("variable2"); - Assertions.assertTrue(variable2.isPresent()); - Assertions.assertTrue(deserializedVariable2.isPresent()); - Assertions.assertEquals("T", variable2.get().getType().print()); - Assertions.assertEquals("T", deserializedVariable2.get().getType().print()); - Assertions.assertEquals("Type.T", variable2.get().getType().printFullName()); - Assertions.assertEquals("Type.T", deserializedVariable2.get().getType().printFullName()); - Assertions.assertSame(type.get().getSpannedScope(), variable2.get().getType().asTypeVariable().getTypeVarSymbol().getEnclosingScope()); - Assertions.assertSame(deserializedType.get().getSpannedScope(), deserializedVariable2.get().getType().asTypeVariable().getTypeVarSymbol().getEnclosingScope()); + assertTrue(variable2.isPresent()); + assertTrue(deserializedVariable2.isPresent()); + assertEquals("T", variable2.get().getType().print()); + assertEquals("T", deserializedVariable2.get().getType().print()); + assertEquals("Type.T", variable2.get().getType().printFullName()); + assertEquals("Type.T", deserializedVariable2.get().getType().printFullName()); + assertSame(type.get().getSpannedScope(), variable2.get().getType().asTypeVariable().getTypeVarSymbol().getEnclosingScope()); + assertSame(deserializedType.get().getSpannedScope(), deserializedVariable2.get().getType().asTypeVariable().getTypeVarSymbol().getEnclosingScope()); //check for Function function in Type Optional function = typeSpanned.resolveFunction("function"); Optional deserializedFunction = deserTypeSpanned.resolveFunction("function"); - Assertions.assertTrue(function.isPresent()); - Assertions.assertTrue(deserializedFunction.isPresent()); - Assertions.assertEquals("int", function.get().getType().print()); - Assertions.assertEquals("int", deserializedFunction.get().getType().print()); + assertTrue(function.isPresent()); + assertTrue(deserializedFunction.isPresent()); + assertEquals("int", function.get().getType().print()); + assertEquals("int", deserializedFunction.get().getType().print()); MCAssertions.assertNoFindings(); } @@ -170,7 +171,7 @@ public void performRoundTripSerialization(IBasicSymbolsArtifactScope scope){ public void testSerializedUnknownKind() { BasicSymbolsSymbols2Json symbols2Json = new BasicSymbolsSymbols2Json(); symbols2Json.deserialize("{\"symbols\": [{\"kind\":\"unknown\", \"name\":\"test\"}]}"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -181,13 +182,13 @@ public void testInvalidJsonForSerializingReturnsError(){ BasicSymbolsSymbols2Json symbols2Json = new BasicSymbolsSymbols2Json(); symbols2Json.deserialize(invalidJsonForSerializing); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith("0xA1238")); + assertTrue(Log.getFindings().get(0).getMsg().startsWith("0xA1238")); symbols2Json.deserialize(invalidJsonForSerializing2); - Assertions.assertTrue(Log.getFindings().get(1).getMsg().startsWith("0xA1233")); + assertTrue(Log.getFindings().get(1).getMsg().startsWith("0xA1233")); symbols2Json.deserialize(invalidJsonForSerializing3); - Assertions.assertTrue(Log.getFindings().get(2).getMsg().startsWith("0xA0572")); + assertTrue(Log.getFindings().get(2).getMsg().startsWith("0xA0572")); } diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/TypeSymbolSurrogateTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/TypeSymbolSurrogateTest.java index e8fb7c7047..662dcf3393 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/TypeSymbolSurrogateTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/TypeSymbolSurrogateTest.java @@ -15,7 +15,6 @@ import de.se_rwth.commons.SourcePosition; import de.se_rwth.commons.logging.LogStub; import org.checkerframework.checker.nullness.qual.NonNull; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -26,6 +25,8 @@ import java.util.function.Predicate; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.*; + /** Tests {@link TypeSymbolSurrogate} */ public class TypeSymbolSurrogateTest { @@ -48,7 +49,7 @@ public void setSpannedScopeShouldSkipSurrogate() { surrogate.setSpannedScope(scopeToSet); // Then - Assertions.assertSame(scopeToSet, type.getSpannedScope()); + assertSame(scopeToSet, type.getSpannedScope()); } @Test @@ -62,7 +63,7 @@ public void getSpannedScopeShouldSkipSurrogate() { IBasicSymbolsScope scope = surrogate.getSpannedScope(); // Then - Assertions.assertSame(type.getSpannedScope(), scope); + assertSame(type.getSpannedScope(), scope); } @Test @@ -80,7 +81,7 @@ void getSuperClassShouldSkipSurrogate() { SymTypeExpression superClassCalculated = surrogate.getSuperClass(); // Then - Assertions.assertSame(superClassExpr, superClassCalculated); + assertSame(superClassExpr, superClassCalculated); } @@ -98,7 +99,7 @@ void setSuperClassShouldSkipSurrogate() { surrogate.setSuperTypesList(Collections.singletonList(superClassExpr)); // Then - Assertions.assertSame(superClassExpr, type.getSuperClass()); + assertSame(superClassExpr, type.getSuperClass()); } @Test @@ -114,7 +115,7 @@ void getTypeParameterListShouldSkipSurrogate() { List typeParams = surrogate.getTypeParameterList(); // Then - Assertions.assertArrayEquals(new TypeVarSymbol[]{typeParam}, typeParams.toArray()); + assertArrayEquals(new TypeVarSymbol[]{typeParam}, typeParams.toArray()); } @Test @SuppressWarnings({"EqualsWithItself", "ConstantConditions"}) @@ -129,7 +130,7 @@ void equalsShouldEqualSame() { boolean result = surrogate.equals(surrogate); // Then - Assertions.assertTrue(result); + assertTrue(result); } @Test @@ -149,7 +150,7 @@ void equalsShouldNotEqualDifferent1() { boolean result = surrogate1.equals(surrogate2); // Then - Assertions.assertFalse(result); + assertFalse(result); } @Test @@ -185,7 +186,7 @@ void equalsShouldNotEqualDifferent2() { boolean result = surrogate1.equals(surrogate2); // Then - Assertions.assertFalse(result); + assertFalse(result); } @Test @@ -209,7 +210,7 @@ void equalsShouldEqualSymbol() { boolean result = surrogate.equals(symbol); // Then - Assertions.assertTrue(result); + assertTrue(result); } @Test @@ -233,13 +234,13 @@ void equalsShouldNotEqualSymbol() { boolean result = surrogate.equals(symbol); // Then - Assertions.assertFalse(result); + assertFalse(result); // When boolean resultSymmetric = symbol.equals(surrogate); // Then - Assertions.assertFalse(resultSymmetric); + assertFalse(resultSymmetric); } @Test @@ -263,7 +264,7 @@ public void equalsShouldNotEqualAdapted() { var result = surrogate1.equals(surrogate2); - Assertions.assertFalse(result); + assertFalse(result); } @Test @@ -286,7 +287,7 @@ public void equalsShouldEqualAdapted() { var result = surrogate1.equals(surrogate2); - Assertions.assertTrue(result); + assertTrue(result); } private static class SymbolMock implements ISymbol { diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/TypeSymbolTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/TypeSymbolTest.java index 60eb8a5634..81c751046b 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/TypeSymbolTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/basicsymbols/_symboltable/TypeSymbolTest.java @@ -2,10 +2,12 @@ import de.monticore.symbols.basicsymbols.BasicSymbolsMill; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class TypeSymbolTest { @BeforeEach @@ -26,7 +28,7 @@ void equalsShouldEqualSame() { boolean result = symbol.equals(symbol); // Then - Assertions.assertTrue(result); + assertTrue(result); } @Test @@ -46,7 +48,7 @@ void equalsShouldNotEqualDifferent() { boolean result = symbol1.equals(symbol2); // Then - Assertions.assertFalse(result); + assertFalse(result); } @Test @@ -70,7 +72,7 @@ void equalsShouldEqualSurrogate() { boolean result = symbol.equals(surrogate); // Then - Assertions.assertTrue(result); + assertTrue(result); } @Test @@ -94,6 +96,6 @@ void equalsShouldNotEqualSurrogate() { boolean result = symbol.equals(surrogate); // Then - Assertions.assertFalse(result); + assertFalse(result); } } diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentType2TypeSymbolAdapterTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentType2TypeSymbolAdapterTest.java index 607a30663b..67eaab7a9a 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentType2TypeSymbolAdapterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentType2TypeSymbolAdapterTest.java @@ -4,12 +4,14 @@ import de.monticore.symbols.compsymbols.CompSymbolsMill; import de.monticore.symboltable.modifiers.BasicAccessModifier; import org.checkerframework.checker.nullness.qual.NonNull; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Holds tests for {@link ComponentType2TypeSymbolAdapter}. */ @@ -22,18 +24,18 @@ void shouldAdaptFields(@NonNull ComponentTypeSymbol adaptee) { ComponentType2TypeSymbolAdapter adapter = new ComponentType2TypeSymbolAdapter(adaptee); // Then - Assertions.assertAll( - () -> Assertions.assertEquals(adaptee.getName(), adapter.getName(), + assertAll( + () -> assertEquals(adaptee.getName(), adapter.getName(), "The adapter's name should match the adaptee's name."), - () -> Assertions.assertEquals(adaptee.getFullName(), adapter.getFullName(), + () -> assertEquals(adaptee.getFullName(), adapter.getFullName(), "The adapter's full name should match the adaptee's full name."), - () -> Assertions.assertEquals(adaptee.getSpannedScope(), adapter.getSpannedScope(), + () -> assertEquals(adaptee.getSpannedScope(), adapter.getSpannedScope(), "The adapter's spanned scope should match the adaptee's enclosing scope."), - () -> Assertions.assertEquals(adaptee.getEnclosingScope(), adapter.getEnclosingScope(), + () -> assertEquals(adaptee.getEnclosingScope(), adapter.getEnclosingScope(), "The adapter's enclosing scope should match the adaptee's enclosing scope."), - () -> Assertions.assertEquals(adaptee.getSourcePosition(), adapter.getSourcePosition(), + () -> assertEquals(adaptee.getSourcePosition(), adapter.getSourcePosition(), "The adapter's source position should match the adaptee's source position."), - () -> Assertions.assertEquals(BasicAccessModifier.PUBLIC, adapter.getAccessModifier(), + () -> assertEquals(BasicAccessModifier.PUBLIC, adapter.getAccessModifier(), "The adapter should have a public access modifier as ports are the public interface of a component.") ); } diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolBuilderTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolBuilderTest.java index a2ca6d9bab..28442243e4 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolBuilderTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolBuilderTest.java @@ -6,7 +6,6 @@ import de.monticore.symbols.compsymbols.CompSymbolsMill; import de.monticore.types.check.CompKindExpression; import de.monticore.types.check.CompKindOfComponentType; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -17,6 +16,7 @@ import java.util.List; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.params.provider.Arguments.arguments; /** @@ -28,7 +28,7 @@ class ComponentTypeSymbolBuilderTest { void shouldBeValid() { ComponentTypeSymbolBuilder builder = new ComponentTypeSymbolBuilder(); builder.setName("A").setSpannedScope(CompSymbolsMill.scope()); - Assertions.assertTrue(builder.isValid()); + assertTrue(builder.isValid()); } @Test @@ -38,9 +38,9 @@ void shouldBeInvalid() { builder2.setName("Comp"); ComponentTypeSymbolBuilder builder3 = new ComponentTypeSymbolBuilder(); builder3.setSpannedScope(CompSymbolsMill.scope()); - Assertions.assertFalse(builder1.isValid()); - Assertions.assertFalse(builder2.isValid()); - Assertions.assertFalse(builder3.isValid()); + assertFalse(builder1.isValid()); + assertFalse(builder2.isValid()); + assertFalse(builder3.isValid()); } @Test @@ -49,14 +49,14 @@ void shouldHaveParent() { .setSpannedScope(CompSymbolsMill.scope()).setName("A").build(); ComponentTypeSymbol childComp = CompSymbolsMill.componentTypeSymbolBuilder().setName("B") .setSpannedScope(CompSymbolsMill.scope()).setSuperComponentsList(Collections.singletonList(new CompKindOfComponentType(parentComp))).build(); - Assertions.assertFalse(childComp.isEmptySuperComponents()); + assertFalse(childComp.isEmptySuperComponents()); } @Test void shouldNotHaveParent() { ComponentTypeSymbol symbol = CompSymbolsMill.componentTypeSymbolBuilder().setName("A") .setSpannedScope(CompSymbolsMill.scope()).build(); - Assertions.assertTrue(symbol.isEmptySuperComponents()); + assertTrue(symbol.isEmptySuperComponents()); } @Test @@ -76,8 +76,8 @@ void shouldHaveSpec() { ComponentTypeSymbol child = childBuilder.build(); // Then - Assertions.assertEquals(1, child.sizeRefinements()); - Assertions.assertEquals(parentExpr, child.getRefinements(0)); + assertEquals(1, child.sizeRefinements()); + assertEquals(parentExpr, child.getRefinements(0)); } @Test @@ -104,10 +104,10 @@ void shouldHaveSpecs() { ComponentTypeSymbol child = childBuilder.build(); // Then - Assertions.assertEquals(2, child.sizeRefinements()); - Assertions.assertAll( - () -> Assertions.assertEquals(parentExpr1, child.getRefinements(0)), - () -> Assertions.assertEquals(parentExpr2, child.getRefinements(1)) + assertEquals(2, child.sizeRefinements()); + assertAll( + () -> assertEquals(parentExpr1, child.getRefinements(0)), + () -> assertEquals(parentExpr2, child.getRefinements(1)) ); } @@ -122,7 +122,7 @@ void shouldNotHaveSpecs() { ComponentTypeSymbol child = childBuilder.build(); // Then - Assertions.assertTrue(child.isEmptyRefinements()); + assertTrue(child.isEmptyRefinements()); } @ParameterizedTest @@ -130,8 +130,8 @@ void shouldNotHaveSpecs() { void shouldBuildWithExpectedParameters(String name, List parameters) { ComponentTypeSymbol symbol = CompSymbolsMill.componentTypeSymbolBuilder().setName(name) .setSpannedScope(CompSymbolsMill.scope()).setParameterList(parameters).build(); - Assertions.assertEquals(symbol.getName(), name); - Assertions.assertIterableEquals(parameters, symbol.getParameterList()); + assertEquals(symbol.getName(), name); + assertIterableEquals(parameters, symbol.getParameterList()); } static Stream compNameAndParametersProvider() { @@ -163,7 +163,7 @@ void shouldBuildWithExpectedNumberOfOptionalParameters() { .build(); // Then - Assertions.assertEquals(2, symbol.getNumOptParams()); + assertEquals(2, symbol.getNumOptParams()); } @ParameterizedTest @@ -172,8 +172,8 @@ void shouldBuildWithExpectedTypeParameters(String name, List typeParameters) { ComponentTypeSymbol symbol = CompSymbolsMill.componentTypeSymbolBuilder().setName(name) .setSpannedScope(CompSymbolsMill.scope()).setTypeParameters(typeParameters).build(); - Assertions.assertEquals(symbol.getName(), name); - Assertions.assertIterableEquals(symbol.getTypeParameters(), typeParameters); + assertEquals(symbol.getName(), name); + assertIterableEquals(symbol.getTypeParameters(), typeParameters); } static Stream compNameAndTypeParametersProvider() { diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolDeSerTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolDeSerTest.java index ed78c7416b..d0f89ae124 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolDeSerTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolDeSerTest.java @@ -8,7 +8,6 @@ import de.monticore.types.check.CompKindExpression; import de.monticore.types.check.CompKindOfComponentType; import de.monticore.types.check.SymTypeExpressionFactory; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -17,6 +16,7 @@ import java.util.Collections; import static java.nio.file.Files.readString; +import static org.junit.jupiter.api.Assertions.*; public class ComponentTypeSymbolDeSerTest { @@ -65,7 +65,7 @@ void shouldSerializeSuperComponentType() throws IOException { String expected = readString(json).replaceAll("\\s+", ""); // Then - Assertions.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -101,7 +101,7 @@ void shouldSerializeSuperComponentType2() throws IOException { String expected = readString(json).replaceAll("\\s+", ""); // Then - Assertions.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -117,7 +117,7 @@ void shouldNotSerializeAbsent() throws IOException { String expected = readString(json).replaceAll("\\s+", ""); // Then - Assertions.assertEquals(expected, createdJson); + assertEquals(expected, createdJson); } @Test @@ -145,7 +145,7 @@ void shouldSerializeTypeParameters() throws IOException { String expected = readString(json).replaceAll("\\s+", ""); // Then - Assertions.assertEquals(expected, createdJson); + assertEquals(expected, createdJson); } @Test @@ -174,7 +174,7 @@ void shouldSerializeParameters() throws IOException { String expected = readString(json).replaceAll("\\s+", ""); // Then - Assertions.assertEquals(expected, createdJson); + assertEquals(expected, createdJson); } @Test @@ -208,7 +208,7 @@ void shouldSerializePorts() throws IOException { String expected = readString(json).replaceAll("\\s+", ""); // Then - Assertions.assertEquals(expected, createdJson); + assertEquals(expected, createdJson); } @Test @@ -219,7 +219,7 @@ void shouldNotDeserializeAbsentParent() throws IOException { ComponentTypeSymbol comp = deSer.deserialize(CompSymbolsMill.globalScope(), jsonString); // Then - Assertions.assertTrue(comp.isEmptySuperComponents(), "Parent is present"); + assertTrue(comp.isEmptySuperComponents(), "Parent is present"); } @Test @@ -230,10 +230,10 @@ void shouldDeserializeTypeParameters() throws IOException { ComponentTypeSymbol comp = deSer.deserialize(CompSymbolsMill.globalScope(), jsonString); // Then - Assertions.assertEquals(2, comp.getTypeParameters().size()); - Assertions.assertAll( - () -> Assertions.assertEquals("A", comp.getTypeParameters().get(0).getName()), - () -> Assertions.assertEquals("B", comp.getTypeParameters().get(1).getName()) + assertEquals(2, comp.getTypeParameters().size()); + assertAll( + () -> assertEquals("A", comp.getTypeParameters().get(0).getName()), + () -> assertEquals("B", comp.getTypeParameters().get(1).getName()) ); } @@ -245,15 +245,15 @@ void shouldDeserializeParameters() throws IOException { ComponentTypeSymbol comp = deSer.deserialize(CompSymbolsMill.globalScope(), jsonString); // Then - Assertions.assertEquals(2, comp.getParameterList().size()); - Assertions.assertEquals(2, comp.getSpannedScope().getLocalVariableSymbols().size()); - Assertions.assertAll( - () -> Assertions.assertEquals("a", comp.getParameterList().get(0).getName()), - () -> Assertions.assertEquals("b", comp.getParameterList().get(1).getName()), - () -> Assertions.assertTrue(comp.getSpannedScope().resolveVariable("a").isPresent()), - () -> Assertions.assertTrue(comp.getSpannedScope().resolveVariable("b").isPresent()), - () -> Assertions.assertEquals(comp.getSpannedScope().resolveVariable("a").get(), comp.getParameterList().get(0)), - () -> Assertions.assertEquals(comp.getSpannedScope().resolveVariable("b").get(), comp.getParameterList().get(1)) + assertEquals(2, comp.getParameterList().size()); + assertEquals(2, comp.getSpannedScope().getLocalVariableSymbols().size()); + assertAll( + () -> assertEquals("a", comp.getParameterList().get(0).getName()), + () -> assertEquals("b", comp.getParameterList().get(1).getName()), + () -> assertTrue(comp.getSpannedScope().resolveVariable("a").isPresent()), + () -> assertTrue(comp.getSpannedScope().resolveVariable("b").isPresent()), + () -> assertEquals(comp.getSpannedScope().resolveVariable("a").get(), comp.getParameterList().get(0)), + () -> assertEquals(comp.getSpannedScope().resolveVariable("b").get(), comp.getParameterList().get(1)) ); } @@ -265,15 +265,15 @@ void shouldDeserializePorts() throws IOException { ComponentTypeSymbol comp = deSer.deserialize(CompSymbolsMill.globalScope(), jsonString); // Then - Assertions.assertEquals(2, comp.getPorts().size()); - Assertions.assertEquals(2, comp.getSpannedScope().getLocalPortSymbols().size()); - Assertions.assertAll( - () -> Assertions.assertEquals("inc", comp.getPorts().get(0).getName()), - () -> Assertions.assertEquals("outg", comp.getPorts().get(1).getName()), - () -> Assertions.assertTrue(comp.getSpannedScope().resolvePort("inc").isPresent()), - () -> Assertions.assertTrue(comp.getSpannedScope().resolvePort("outg").isPresent()), - () -> Assertions.assertEquals(comp.getSpannedScope().resolvePort("inc").get(), comp.getPorts().get(0)), - () -> Assertions.assertEquals(comp.getSpannedScope().resolvePort("outg").get(), comp.getPorts().get(1)) + assertEquals(2, comp.getPorts().size()); + assertEquals(2, comp.getSpannedScope().getLocalPortSymbols().size()); + assertAll( + () -> assertEquals("inc", comp.getPorts().get(0).getName()), + () -> assertEquals("outg", comp.getPorts().get(1).getName()), + () -> assertTrue(comp.getSpannedScope().resolvePort("inc").isPresent()), + () -> assertTrue(comp.getSpannedScope().resolvePort("outg").isPresent()), + () -> assertEquals(comp.getSpannedScope().resolvePort("inc").get(), comp.getPorts().get(0)), + () -> assertEquals(comp.getSpannedScope().resolvePort("outg").get(), comp.getPorts().get(1)) ); } @@ -296,7 +296,7 @@ void shouldSerializeSubComponents() throws IOException { String expected = readString(json).replaceAll("\\s+", ""); // Then - Assertions.assertEquals(expected, createdJson); + assertEquals(expected, createdJson); } @Test @@ -307,12 +307,12 @@ void shouldDeserializeSubComponents() throws IOException { ComponentTypeSymbol comp = deSer.deserialize(CompSymbolsMill.globalScope(), jsonString); // Then - Assertions.assertEquals(1, comp.getSubcomponents().size()); - Assertions.assertEquals(1, comp.getSpannedScope().getLocalSubcomponentSymbols().size()); - Assertions.assertAll( - () -> Assertions.assertEquals("inst", comp.getSubcomponents().get(0).getName()), - () -> Assertions.assertTrue(comp.getSpannedScope().resolveSubcomponent("inst").isPresent()), - () -> Assertions.assertEquals(comp.getSpannedScope().resolveSubcomponent("inst").get(), comp.getSubcomponents().get(0)) + assertEquals(1, comp.getSubcomponents().size()); + assertEquals(1, comp.getSpannedScope().getLocalSubcomponentSymbols().size()); + assertAll( + () -> assertEquals("inst", comp.getSubcomponents().get(0).getName()), + () -> assertTrue(comp.getSpannedScope().resolveSubcomponent("inst").isPresent()), + () -> assertEquals(comp.getSpannedScope().resolveSubcomponent("inst").get(), comp.getSubcomponents().get(0)) ); } @@ -339,7 +339,7 @@ void shouldSerializeSpec() throws IOException { String expected = readString(json).replaceAll("\\s+", ""); // Then - Assertions.assertEquals(expected, createdJson); + assertEquals(expected, createdJson); } @Test @@ -350,8 +350,8 @@ void shouldDeserializeSpec() throws IOException { ComponentTypeSymbol comp = deSer.deserialize(CompSymbolsMill.globalScope(), jsonString); // Then - Assertions.assertFalse(comp.isEmptyRefinements(), "Refined component not present"); - Assertions.assertEquals("RefinementCType", comp.getRefinements(0).printName()); + assertFalse(comp.isEmptyRefinements(), "Refined component not present"); + assertEquals("RefinementCType", comp.getRefinements(0).printName()); } @@ -374,7 +374,7 @@ void shouldSerializeInnerComponents() throws IOException { String expected = readString(json).replaceAll("\\s+", ""); // Then - Assertions.assertEquals(expected, createdJson); + assertEquals(expected, createdJson); } @Test @@ -385,9 +385,9 @@ void shouldDeserializeInnerComponents() throws IOException { ComponentTypeSymbol comp = deSer.deserialize(CompSymbolsMill.globalScope(), jsonString); // Then - Assertions.assertEquals(1, comp.getSpannedScope().getLocalComponentTypeSymbols().size()); - Assertions.assertAll( - () -> Assertions.assertEquals("inst", comp.getSpannedScope().getLocalComponentTypeSymbols().get(0).getName()) + assertEquals(1, comp.getSpannedScope().getLocalComponentTypeSymbols().size()); + assertAll( + () -> assertEquals("inst", comp.getSpannedScope().getLocalComponentTypeSymbols().get(0).getName()) ); } @@ -410,7 +410,7 @@ void shouldSerializeFields() throws IOException { String expected = readString(json).replaceAll("\\s+", ""); // Then - Assertions.assertEquals(expected, createdJson); + assertEquals(expected, createdJson); } @Test @@ -421,9 +421,9 @@ void shouldDeserializeFields() throws IOException { ComponentTypeSymbol comp = deSer.deserialize(CompSymbolsMill.globalScope(), jsonString); // Then - Assertions.assertEquals(1, comp.getFields().size()); - Assertions.assertAll( - () -> Assertions.assertEquals("inst", comp.getFields().get(0).getName()) + assertEquals(1, comp.getFields().size()); + assertAll( + () -> assertEquals("inst", comp.getFields().get(0).getName()) ); } } diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolSurrogateTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolSurrogateTest.java index 06a6c98586..eeff2cbe28 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolSurrogateTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolSurrogateTest.java @@ -10,7 +10,6 @@ import de.monticore.types.check.CompKindOfComponentType; import de.monticore.types.check.SymTypeExpressionFactory; import org.checkerframework.checker.nullness.qual.NonNull; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -19,6 +18,8 @@ import java.util.Optional; import java.util.Set; +import static org.junit.jupiter.api.Assertions.*; + public class ComponentTypeSymbolSurrogateTest { @Test @@ -34,7 +35,7 @@ public void setSpannedScopeShouldSkipSurrogate() { surrogate.setSpannedScope(scopeToSet); // Then - Assertions.assertSame(scopeToSet, comp.getSpannedScope()); + assertSame(scopeToSet, comp.getSpannedScope()); } @Test @@ -48,7 +49,7 @@ public void getSpannedScopeShouldSkipSurrogate() { ICompSymbolsScope scope = surrogate.getSpannedScope(); // Then - Assertions.assertSame(comp.getSpannedScope(), scope); + assertSame(comp.getSpannedScope(), scope); } @Test @@ -64,7 +65,7 @@ public void getPortsShouldSkipSurrogate() { List ports = surrogate.getPorts(); // Then - Assertions.assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); + assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); } @Test @@ -80,8 +81,8 @@ public void getPortByNameShouldSkipSurrogate() { Optional portOpt = surrogate.getPort("myPort"); // Then - Assertions.assertTrue(portOpt.isPresent(), "Port is not present"); - Assertions.assertSame(port, portOpt.get()); + assertTrue(portOpt.isPresent(), "Port is not present"); + assertSame(port, portOpt.get()); } @Test @@ -103,8 +104,8 @@ public void getInheritedPortByNameShouldSkipSurrogate() { Optional portOpt = surrogate.getPort("parentPort", true); // Then - Assertions.assertTrue(portOpt.isPresent(), "Port is not present"); - Assertions.assertSame(port, portOpt.get()); + assertTrue(portOpt.isPresent(), "Port is not present"); + assertSame(port, portOpt.get()); } @Test @@ -120,7 +121,7 @@ public void getIncomingPortsShouldSkipSurrogate() { List ports = surrogate.getIncomingPorts(); // Then - Assertions.assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); + assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); } @Test @@ -136,8 +137,8 @@ public void getIncomingPortByNameShouldSkipSurrogate() { Optional portOpt = surrogate.getIncomingPort("myPort"); // Then - Assertions.assertTrue(portOpt.isPresent(), "Port is not present"); - Assertions.assertSame(port, portOpt.get()); + assertTrue(portOpt.isPresent(), "Port is not present"); + assertSame(port, portOpt.get()); } @Test @@ -156,8 +157,8 @@ public void getInheritedIncomingPortByNameShouldSkipSurrogate() { Optional portOpt = surrogate.getIncomingPort("parentPort", true); // Then - Assertions.assertTrue(portOpt.isPresent(), "Port is not present"); - Assertions.assertSame(port, portOpt.get()); + assertTrue(portOpt.isPresent(), "Port is not present"); + assertSame(port, portOpt.get()); } @Test @@ -174,7 +175,7 @@ void isPresentParentShouldSkipSurrogate() { boolean parentIsPresent = !surrogate.isEmptySuperComponents(); // Then - Assertions.assertTrue(parentIsPresent, "No parent present"); + assertTrue(parentIsPresent, "No parent present"); } @@ -193,7 +194,7 @@ void getParentShouldSkipSurrogate() { CompKindExpression parentCalculated = surrogate.getSuperComponents(0); // Then - Assertions.assertSame(parentExpr, parentCalculated); + assertSame(parentExpr, parentCalculated); } @@ -211,7 +212,7 @@ void setParentShouldSkipSurrogate() { surrogate.setSuperComponentsList(Collections.singletonList(parentExpr)); // Then - Assertions.assertSame(parentExpr, comp.getSuperComponents(0)); + assertSame(parentExpr, comp.getSuperComponents(0)); } @Test @@ -229,7 +230,7 @@ void isPresentRefinementShouldSkipSurrogate() { boolean refinedCompIsPresent = !surrogate.isEmptyRefinements(); // Then - Assertions.assertTrue(refinedCompIsPresent, "No refined component present"); + assertTrue(refinedCompIsPresent, "No refined component present"); } @@ -248,7 +249,7 @@ void getRefinementShouldSkipSurrogate() { CompKindExpression parentCalculated = surrogate.getRefinements(0); // Then - Assertions.assertSame(abstractionExpr, parentCalculated); + assertSame(abstractionExpr, parentCalculated); } @@ -266,7 +267,7 @@ void setRefinementShouldSkipSurrogate() { surrogate.setRefinementsList(Collections.singletonList(abstractionExpr)); // Then - Assertions.assertSame(abstractionExpr, comp.getRefinements(0)); + assertSame(abstractionExpr, comp.getRefinements(0)); } @Test @@ -282,7 +283,7 @@ void getParameterListShouldSkipSurrogate() { List params = surrogate.getParameterList(); // Then - Assertions.assertArrayEquals(new VariableSymbol[]{param}, params.toArray()); + assertArrayEquals(new VariableSymbol[]{param}, params.toArray()); } @Test @@ -298,8 +299,8 @@ void getParameterShouldSkipSurrogate() { Optional paramOpt = surrogate.getParameter("myParam"); // Then - Assertions.assertTrue(paramOpt.isPresent(), "No parameter"); - Assertions.assertSame(param, paramOpt.get()); + assertTrue(paramOpt.isPresent(), "No parameter"); + assertSame(param, paramOpt.get()); } @Test @@ -320,7 +321,7 @@ void addParameterShouldSkipSurrogate() { surrogate.addParameter(param); // Then - Assertions.assertArrayEquals(new VariableSymbol[]{param}, comp.getParameterList().toArray()); + assertArrayEquals(new VariableSymbol[]{param}, comp.getParameterList().toArray()); } @@ -342,7 +343,7 @@ void addParametersShouldSkipSurrogate() { surrogate.addAllParameter(Collections.singletonList(param)); // Then - Assertions.assertArrayEquals(new VariableSymbol[]{param}, comp.getParameterList().toArray()); + assertArrayEquals(new VariableSymbol[]{param}, comp.getParameterList().toArray()); } @Test @@ -358,7 +359,7 @@ void hasParametersShouldSkipSurrogate() { boolean hasParameters = surrogate.hasParameters(); // Then - Assertions.assertTrue(hasParameters, "No parameters found"); + assertTrue(hasParameters, "No parameters found"); } @Test @@ -374,7 +375,7 @@ void getTypeParametersShouldSkipSurrogate() { List typeParams = surrogate.getTypeParameters(); // Then - Assertions.assertArrayEquals(new TypeVarSymbol[]{typeParam}, typeParams.toArray()); + assertArrayEquals(new TypeVarSymbol[]{typeParam}, typeParams.toArray()); } @Test @@ -390,7 +391,7 @@ void hasTypeParameterShouldSkipSurrogate() { boolean hasTypeParams = surrogate.hasTypeParameter(); // then - Assertions.assertTrue(hasTypeParams, "No type parameters found"); + assertTrue(hasTypeParams, "No type parameters found"); } @Test @@ -406,7 +407,7 @@ void getFieldsShouldSkipSurrogate() { List fields = surrogate.getFields(); // Then - Assertions.assertArrayEquals(new VariableSymbol[]{field}, fields.toArray()); + assertArrayEquals(new VariableSymbol[]{field}, fields.toArray()); } @Test @@ -423,8 +424,8 @@ void getFieldByNameShouldSkipSurrogate() { // Then - Assertions.assertTrue(fieldOpt.isPresent(), "No field"); - Assertions.assertSame(field, fieldOpt.get()); + assertTrue(fieldOpt.isPresent(), "No field"); + assertSame(field, fieldOpt.get()); } @Test @@ -440,7 +441,7 @@ void getOutgoingPortsShouldSkipSurrogate() { List ports = surrogate.getOutgoingPorts(); // Then - Assertions.assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); + assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); } @Test @@ -456,8 +457,8 @@ void getOutgoingPortByNameShouldSkipSurrogate() { Optional portOpt = surrogate.getOutgoingPort("myPort"); // Then - Assertions.assertTrue(portOpt.isPresent(), "Port is not present"); - Assertions.assertSame(port, portOpt.get()); + assertTrue(portOpt.isPresent(), "Port is not present"); + assertSame(port, portOpt.get()); } @Test @@ -477,8 +478,8 @@ void getInheritedOutgoingPortByNameShouldSkipSurrogate() { Optional portOpt = surrogate.getOutgoingPort("myPort", true); // Then - Assertions.assertTrue(portOpt.isPresent(), "Port is not present"); - Assertions.assertSame(port, portOpt.get()); + assertTrue(portOpt.isPresent(), "Port is not present"); + assertSame(port, portOpt.get()); } @Test @@ -495,7 +496,7 @@ void getPortsWithDirectionShouldSkipSurrogate() { List ports = surrogate.getPorts(true, false); // Then - Assertions.assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); + assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); } @Test @@ -511,7 +512,7 @@ void getAllIncomingPortsShouldSkipSurrogate() { Set ports = surrogate.getAllIncomingPorts(); // Then - Assertions.assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); + assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); } @Test @@ -527,7 +528,7 @@ void getAllOutgoingPortsShouldSkipSurrogate() { List ports = surrogate.getOutgoingPorts(); // Then - Assertions.assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); + assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); } @Test @@ -543,7 +544,7 @@ void getAllPortsWithDirectionShouldSkipSurrogate() { Set ports = surrogate.getAllPorts(true, false); // Then - Assertions.assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); + assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); } @Test @@ -559,7 +560,7 @@ void getAllPortsShouldSkipSurrogate() { Set ports = surrogate.getAllPorts(); // Then - Assertions.assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); + assertArrayEquals(new PortSymbol[]{port}, ports.toArray()); } @Test @@ -575,7 +576,7 @@ void getSubComponentsShouldSkipSurrogate() { List subs = surrogate.getSubcomponents(); // Then - Assertions.assertArrayEquals(new SubcomponentSymbol[]{sub}, subs.toArray()); + assertArrayEquals(new SubcomponentSymbol[]{sub}, subs.toArray()); } @Test @@ -591,8 +592,8 @@ void getSubComponentShouldSkipSurrogate() { Optional subOpt = surrogate.getSubcomponents("mySub"); // Then - Assertions.assertTrue(subOpt.isPresent(), "Sub component is not present"); - Assertions.assertSame(sub, subOpt.get()); + assertTrue(subOpt.isPresent(), "Sub component is not present"); + assertSame(sub, subOpt.get()); } @@ -609,7 +610,7 @@ void isDecomposedShouldSkipSurrogate() { boolean isDecomposed = surrogate.isDecomposed(); // Then - Assertions.assertTrue(isDecomposed, "Should be decomposed"); + assertTrue(isDecomposed, "Should be decomposed"); } @Test @@ -625,7 +626,7 @@ void isAtomicShouldSkipSurrogate() { boolean isAtomic = surrogate.isAtomic(); // Then - Assertions.assertFalse(isAtomic, "Should not be atomic"); + assertFalse(isAtomic, "Should not be atomic"); } /** diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolTest.java index e663771e1e..36ff1e0fb4 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/ComponentTypeSymbolTest.java @@ -6,7 +6,6 @@ import de.monticore.symbols.compsymbols.CompSymbolsMill; import de.monticore.types.check.CompKindOfComponentType; import de.monticore.types.check.SymTypeExpressionFactory; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -21,6 +20,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.params.provider.Arguments.arguments; /** @@ -52,7 +52,7 @@ void shouldGetAllInheritedPortsWithOverlappingName() { Set ports = sut.getAllPorts(); // Then - Assertions.assertIterableEquals(List.of(p1, p2), ports); + assertIterableEquals(List.of(p1, p2), ports); } @Test @@ -73,9 +73,9 @@ public void shouldStateIfHasParameters() { compWithParameters.addAllParameter(params); // Then - Assertions.assertFalse(compWithoutParameters.hasParameters()); - Assertions.assertTrue(compWithParameters.hasParameters()); - Assertions.assertEquals(3, compWithParameters.getParameterList().size()); + assertFalse(compWithoutParameters.hasParameters()); + assertTrue(compWithParameters.hasParameters()); + assertEquals(3, compWithParameters.getParameterList().size()); } @Test @@ -97,8 +97,8 @@ public void shouldReturnParametersIfPresent() { // Then for (VariableSymbol param : params) { - Assertions.assertTrue(compWithParameters.getParameter(param.getName()).isPresent()); - Assertions.assertFalse(compWithoutParameters.getParameter(param.getName()).isPresent()); + assertTrue(compWithParameters.getParameter(param.getName()).isPresent()); + assertFalse(compWithoutParameters.getParameter(param.getName()).isPresent()); } } @@ -117,15 +117,15 @@ public void shouldStateIfHasTypeParameters() { typeParams.forEach(compWithTypeParameters.getSpannedScope()::add); // When & Then - Assertions.assertFalse(compWithoutTypeParameters.hasTypeParameter()); - Assertions.assertTrue(compWithTypeParameters.hasTypeParameter()); + assertFalse(compWithoutTypeParameters.hasTypeParameter()); + assertTrue(compWithTypeParameters.hasTypeParameter()); } @ParameterizedTest @MethodSource("portNameAndDirectionProvider") public void shouldReturnIncomingPortsOnly(Map ports) { ComponentTypeSymbol symbol = buildTestComponentWithPorts(ports); - Assertions.assertIterableEquals(ports.entrySet().stream() + assertIterableEquals(ports.entrySet().stream() .filter(p -> p.getValue().equals(true)).map(Map.Entry::getKey).collect(Collectors.toList()), symbol.getIncomingPorts().stream().map(PortSymbol::getName).collect(Collectors.toList())); } @@ -134,7 +134,7 @@ public void shouldReturnIncomingPortsOnly(Map ports) { @MethodSource("portNameAndDirectionProvider") public void shouldReturnOutgoingPortsOnly(Map ports) { ComponentTypeSymbol symbol = buildTestComponentWithPorts(ports); - Assertions.assertIterableEquals(ports.entrySet().stream() + assertIterableEquals(ports.entrySet().stream() .filter(p -> p.getValue().equals(false)).map(Map.Entry::getKey).collect(Collectors.toList()), symbol.getOutgoingPorts().stream().map(PortSymbol::getName).collect(Collectors.toList())); } @@ -145,11 +145,11 @@ public void shouldFindPortWithExpectedDirection(Map ports) { ComponentTypeSymbol symbol = buildTestComponentWithPorts(ports); for (String port : ports.keySet()) { if (ports.get(port)) { - Assertions.assertTrue(symbol.getIncomingPort(port).isPresent()); - Assertions.assertFalse(symbol.getOutgoingPort(port).isPresent()); + assertTrue(symbol.getIncomingPort(port).isPresent()); + assertFalse(symbol.getOutgoingPort(port).isPresent()); } else { - Assertions.assertFalse(symbol.getIncomingPort(port).isPresent()); - Assertions.assertTrue(symbol.getOutgoingPort(port).isPresent()); + assertFalse(symbol.getIncomingPort(port).isPresent()); + assertTrue(symbol.getOutgoingPort(port).isPresent()); } } } @@ -159,9 +159,9 @@ public void shouldFindPortWithExpectedDirection(Map ports) { public void shouldStateCorrectlyIFHasPorts(Map ports) { ComponentTypeSymbol symbol = buildTestComponentWithPorts(ports); if (ports.isEmpty()) { - Assertions.assertFalse(symbol.hasPorts()); + assertFalse(symbol.hasPorts()); } else { - Assertions.assertTrue(symbol.hasPorts()); + assertTrue(symbol.hasPorts()); } } @@ -196,8 +196,8 @@ private ComponentTypeSymbol buildTestComponentWithPorts(Map por @MethodSource("instanceNamesProvider") public void shouldFindSubComponents(List instances) { ComponentTypeSymbol symbol = builtTestComponentWithInstances(instances); - Assertions.assertEquals(symbol.getSubcomponents().size(), instances.size()); - Assertions.assertIterableEquals(symbol.getSubcomponents() + assertEquals(symbol.getSubcomponents().size(), instances.size()); + assertIterableEquals(symbol.getSubcomponents() .stream().map(SubcomponentSymbol::getName).collect(Collectors.toList()), instances); } @@ -212,8 +212,8 @@ public void shouldFindExpectedSubComponent() { List instances = Arrays.asList("sub1", "sub2", "sub3"); ComponentTypeSymbol symbol = this.builtTestComponentWithInstances(instances); for (String instance : instances) { - Assertions.assertTrue(symbol.getSubcomponents(instance).isPresent()); - Assertions.assertEquals(symbol.getSubcomponents(instance).get().getName(), instance); + assertTrue(symbol.getSubcomponents(instance).isPresent()); + assertEquals(symbol.getSubcomponents(instance).get().getName(), instance); } } @@ -222,8 +222,8 @@ public void shouldNotFindUnexpectedSubComponent() { ComponentTypeSymbol symbol1 = this.builtTestComponentWithInstances(Collections.emptyList()); ComponentTypeSymbol symbol2 = this.builtTestComponentWithInstances( Arrays.asList("sub1", "sub2", "sub3")); - Assertions.assertFalse(symbol1.getSubcomponents("sub4").isPresent()); - Assertions.assertFalse(symbol2.getSubcomponents("sub4").isPresent()); + assertFalse(symbol1.getSubcomponents("sub4").isPresent()); + assertFalse(symbol2.getSubcomponents("sub4").isPresent()); } @Test @@ -232,10 +232,10 @@ void shouldBeAtomicOrDecomposed() { builtTestComponentWithInstances(Arrays.asList("a", "b", "c")); ComponentTypeSymbol atomicComponent = builtTestComponentWithInstances(Collections.emptyList()); - Assertions.assertTrue(composedComponent.isDecomposed()); - Assertions.assertFalse(composedComponent.isAtomic()); - Assertions.assertFalse(atomicComponent.isDecomposed()); - Assertions.assertTrue(atomicComponent.isAtomic()); + assertTrue(composedComponent.isDecomposed()); + assertFalse(composedComponent.isAtomic()); + assertFalse(atomicComponent.isDecomposed()); + assertTrue(atomicComponent.isAtomic()); } private ComponentTypeSymbol builtTestComponentWithInstances(List instances) { diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/Port2VariableAdapterTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/Port2VariableAdapterTest.java index 679cd110c8..4e638b8356 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/Port2VariableAdapterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/Port2VariableAdapterTest.java @@ -7,11 +7,13 @@ import de.monticore.symboltable.modifiers.BasicAccessModifier; import de.monticore.types.check.SymTypeExpressionFactory; import org.checkerframework.checker.nullness.qual.NonNull; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class Port2VariableAdapterTest { @BeforeEach @@ -46,20 +48,20 @@ void shouldAdaptFields(@NonNull String name, boolean in, boolean out) { Port2VariableAdapter adapter = new Port2VariableAdapter(adaptee); // Then - Assertions.assertAll( - () -> Assertions.assertEquals(adaptee.getName(), adapter.getName(), + assertAll( + () -> assertEquals(adaptee.getName(), adapter.getName(), "The adapter's name should match the adaptee's name."), - () -> Assertions.assertEquals(adaptee.getFullName(), adapter.getFullName(), + () -> assertEquals(adaptee.getFullName(), adapter.getFullName(), "The adapter's full name should match the adaptee's full name."), - () -> Assertions.assertEquals(adaptee.getType(), adapter.getType(), + () -> assertEquals(adaptee.getType(), adapter.getType(), "The adapter's type should match the adaptee's type."), - () -> Assertions.assertEquals(adaptee.isIncoming(), adapter.isIsReadOnly(), + () -> assertEquals(adaptee.isIncoming(), adapter.isIsReadOnly(), "The adapter should be read only if the adaptee is an incoming port."), - () -> Assertions.assertEquals(adaptee.getEnclosingScope(), adapter.getEnclosingScope(), + () -> assertEquals(adaptee.getEnclosingScope(), adapter.getEnclosingScope(), "The adapter's enclosing scope should match the adaptee's enclosing scope."), - () -> Assertions.assertEquals(adaptee.getSourcePosition(), adapter.getSourcePosition(), + () -> assertEquals(adaptee.getSourcePosition(), adapter.getSourcePosition(), "The adapter's source position should match the adaptee's source position."), - () -> Assertions.assertEquals(BasicAccessModifier.PUBLIC, adapter.getAccessModifier(), + () -> assertEquals(BasicAccessModifier.PUBLIC, adapter.getAccessModifier(), "The adapter should have a public access modifier as ports are the public interface of a component.") ); } @@ -92,22 +94,22 @@ void shouldDeepClone(@NonNull String name, boolean in, boolean out) { Port2VariableAdapter clone = adapter.deepClone(); // Then - Assertions.assertAll( - () -> Assertions.assertEquals(adapter.getAdaptee(), clone.getAdaptee(), + assertAll( + () -> assertEquals(adapter.getAdaptee(), clone.getAdaptee(), "The clone's adaptee should match the adapter's adaptee."), - () -> Assertions.assertEquals(adapter.getName(), clone.getName(), + () -> assertEquals(adapter.getName(), clone.getName(), "The clone's name should match the adapter's name."), - () -> Assertions.assertEquals(adapter.getFullName(), clone.getFullName(), + () -> assertEquals(adapter.getFullName(), clone.getFullName(), "The clone's full name should match the adapter's full name."), - () -> Assertions.assertEquals(adapter.getType(), clone.getType(), + () -> assertEquals(adapter.getType(), clone.getType(), "The clone's type should match the adapter's type."), - () -> Assertions.assertEquals(adapter.isIsReadOnly(), clone.isIsReadOnly(), + () -> assertEquals(adapter.isIsReadOnly(), clone.isIsReadOnly(), "The clone should be read only if the adapter is read only."), - () -> Assertions.assertEquals(adapter.getEnclosingScope(), clone.getEnclosingScope(), + () -> assertEquals(adapter.getEnclosingScope(), clone.getEnclosingScope(), "The clone's enclosing scope should match the adapter's enclosing scope."), - () -> Assertions.assertEquals(adapter.isPresentAstNode(), clone.isPresentAstNode(), + () -> assertEquals(adapter.isPresentAstNode(), clone.isPresentAstNode(), "The clone should have an ast node if the adapter has an ast node."), - () -> Assertions.assertEquals(adapter.getAccessModifier(), clone.getAccessModifier(), + () -> assertEquals(adapter.getAccessModifier(), clone.getAccessModifier(), "The clone's access modifier should match the adapter's access modifier.") ); } diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/Subcomponent2VariableAdapterTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/Subcomponent2VariableAdapterTest.java index 7174d855d5..f3d4d27cfe 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/Subcomponent2VariableAdapterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/compsymbols/_symboltable/Subcomponent2VariableAdapterTest.java @@ -4,9 +4,10 @@ import de.monticore.symbols.compsymbols.CompSymbolsMill; import de.monticore.symboltable.modifiers.BasicAccessModifier; import de.monticore.types.check.CompKindOfComponentType; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + /** * Holds tests for {@link Subcomponent2VariableAdapter}. */ @@ -28,18 +29,18 @@ void shouldAdaptFields() { Subcomponent2VariableAdapter adapter = new Subcomponent2VariableAdapter(adaptee); // Then - Assertions.assertAll( - () -> Assertions.assertEquals(adaptee.getName(), adapter.getName(), + assertAll( + () -> assertEquals(adaptee.getName(), adapter.getName(), "The adapter's name should match the adaptee's name."), - () -> Assertions.assertEquals(adaptee.getFullName(), adapter.getFullName(), + () -> assertEquals(adaptee.getFullName(), adapter.getFullName(), "The adapter's full name should match the adaptee's full name."), - () -> Assertions.assertEquals(adaptee.getType().getTypeInfo(), ((ComponentType2TypeSymbolAdapter) adapter.getType().getTypeInfo()).getAdaptee(), + () -> assertEquals(adaptee.getType().getTypeInfo(), ((ComponentType2TypeSymbolAdapter) adapter.getType().getTypeInfo()).getAdaptee(), "The adapter's type should match the adaptee's type."), - () -> Assertions.assertEquals(adaptee.getEnclosingScope(), adapter.getEnclosingScope(), + () -> assertEquals(adaptee.getEnclosingScope(), adapter.getEnclosingScope(), "The adapter's enclosing scope should match the adaptee's enclosing scope."), - () -> Assertions.assertEquals(adaptee.getSourcePosition(), adapter.getSourcePosition(), + () -> assertEquals(adaptee.getSourcePosition(), adapter.getSourcePosition(), "The adapter's source position should match the adaptee's source position."), - () -> Assertions.assertEquals(BasicAccessModifier.PRIVATE, adapter.getAccessModifier(), + () -> assertEquals(BasicAccessModifier.PRIVATE, adapter.getAccessModifier(), "The adapter should have a public access modifier as ports are the public interface of a component.") ); } @@ -63,22 +64,22 @@ void shouldDeepClone() { Subcomponent2VariableAdapter clone = adapter.deepClone(); // Then - Assertions.assertAll( - () -> Assertions.assertEquals(adapter.getAdaptee(), clone.getAdaptee(), + assertAll( + () -> assertEquals(adapter.getAdaptee(), clone.getAdaptee(), "The clone's adaptee should match the adapter's adaptee."), - () -> Assertions.assertEquals(adapter.getName(), clone.getName(), + () -> assertEquals(adapter.getName(), clone.getName(), "The clone's name should match the adapter's name."), - () -> Assertions.assertEquals(adapter.getFullName(), clone.getFullName(), + () -> assertEquals(adapter.getFullName(), clone.getFullName(), "The clone's full name should match the adapter's full name."), - () -> Assertions.assertEquals(((ComponentType2TypeSymbolAdapter) adapter.getType().getTypeInfo()).getAdaptee(), ((ComponentType2TypeSymbolAdapter) clone.getType().getTypeInfo()).getAdaptee(), + () -> assertEquals(((ComponentType2TypeSymbolAdapter) adapter.getType().getTypeInfo()).getAdaptee(), ((ComponentType2TypeSymbolAdapter) clone.getType().getTypeInfo()).getAdaptee(), "The clone's type should match the adapter's type."), - () -> Assertions.assertEquals(adapter.isIsReadOnly(), clone.isIsReadOnly(), + () -> assertEquals(adapter.isIsReadOnly(), clone.isIsReadOnly(), "The clone should be read only if the adapter is read only."), - () -> Assertions.assertEquals(adapter.getEnclosingScope(), clone.getEnclosingScope(), + () -> assertEquals(adapter.getEnclosingScope(), clone.getEnclosingScope(), "The clone's enclosing scope should match the adapter's enclosing scope."), - () -> Assertions.assertEquals(adapter.isPresentAstNode(), clone.isPresentAstNode(), + () -> assertEquals(adapter.isPresentAstNode(), clone.isPresentAstNode(), "The clone should have an ast node if the adapter has an ast node."), - () -> Assertions.assertEquals(adapter.getAccessModifier(), clone.getAccessModifier(), + () -> assertEquals(adapter.getAccessModifier(), clone.getAccessModifier(), "The clone's access modifier should match the adapter's access modifier.") ); } @@ -97,18 +98,18 @@ void shouldNotThrowErrorIfTypeIsMissing() { Subcomponent2VariableAdapter adapter = new Subcomponent2VariableAdapter(adaptee); // Then - Assertions.assertAll( - () -> Assertions.assertEquals(adaptee.getName(), adapter.getName(), + assertAll( + () -> assertEquals(adaptee.getName(), adapter.getName(), "The adapter's name should match the adaptee's name."), - () -> Assertions.assertEquals(adaptee.getFullName(), adapter.getFullName(), + () -> assertEquals(adaptee.getFullName(), adapter.getFullName(), "The adapter's full name should match the adaptee's full name."), - () -> Assertions.assertTrue(adapter.getType().isObscureType(), + () -> assertTrue(adapter.getType().isObscureType(), "The adapter's type should be obscure."), - () -> Assertions.assertEquals(adaptee.getEnclosingScope(), adapter.getEnclosingScope(), + () -> assertEquals(adaptee.getEnclosingScope(), adapter.getEnclosingScope(), "The adapter's enclosing scope should match the adaptee's enclosing scope."), - () -> Assertions.assertEquals(adaptee.getSourcePosition(), adapter.getSourcePosition(), + () -> assertEquals(adaptee.getSourcePosition(), adapter.getSourcePosition(), "The adapter's source position should match the adaptee's source position."), - () -> Assertions.assertEquals(BasicAccessModifier.PRIVATE, adapter.getAccessModifier(), + () -> assertEquals(BasicAccessModifier.PRIVATE, adapter.getAccessModifier(), "The adapter should have a public access modifier as ports are the public interface of a component.") ); } diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/CloneTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/CloneTest.java index adc2136bc8..264c7ad22d 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/CloneTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/CloneTest.java @@ -7,13 +7,12 @@ import de.monticore.types.check.SymTypeExpressionFactory; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.List; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class CloneTest { @@ -54,43 +53,43 @@ public void init(){ @Test public void testMethod(){ List methodsAllInclusion = symbolTable.resolveMethodMany("foo"); - Assertions.assertEquals(1, methodsAllInclusion.size()); + assertEquals(1, methodsAllInclusion.size()); MethodSymbol methodSymbol = methodsAllInclusion.get(0); MethodSymbol cloneSymbol = methodSymbol.deepClone(); - Assertions.assertEquals(methodSymbol.getName(), cloneSymbol.getName()); - Assertions.assertEquals(methodSymbol.getParameterList().size(), cloneSymbol.getParameterList().size()); - Assertions.assertEquals(methodSymbol.isIsMethod(), cloneSymbol.isIsMethod()); - Assertions.assertEquals(methodSymbol.isIsPrivate(), cloneSymbol.isIsPrivate()); - Assertions.assertEquals(methodSymbol.isIsPublic(), cloneSymbol.isIsPublic()); - Assertions.assertEquals(methodSymbol.isIsProtected(), cloneSymbol.isIsProtected()); - Assertions.assertEquals(methodSymbol.isIsAbstract(), cloneSymbol.isIsAbstract()); - Assertions.assertEquals(methodSymbol.isIsStatic(), cloneSymbol.isIsStatic()); - Assertions.assertEquals(methodSymbol.isIsFinal(), cloneSymbol.isIsFinal()); - Assertions.assertEquals(methodSymbol.isIsElliptic(), cloneSymbol.isIsElliptic()); - Assertions.assertEquals(methodSymbol.isIsConstructor(), cloneSymbol.isIsConstructor()); - Assertions.assertEquals(methodSymbol.getType().asPrimitive().getPrimitiveName(), cloneSymbol.getType().asPrimitive().getPrimitiveName()); + assertEquals(methodSymbol.getName(), cloneSymbol.getName()); + assertEquals(methodSymbol.getParameterList().size(), cloneSymbol.getParameterList().size()); + assertEquals(methodSymbol.isIsMethod(), cloneSymbol.isIsMethod()); + assertEquals(methodSymbol.isIsPrivate(), cloneSymbol.isIsPrivate()); + assertEquals(methodSymbol.isIsPublic(), cloneSymbol.isIsPublic()); + assertEquals(methodSymbol.isIsProtected(), cloneSymbol.isIsProtected()); + assertEquals(methodSymbol.isIsAbstract(), cloneSymbol.isIsAbstract()); + assertEquals(methodSymbol.isIsStatic(), cloneSymbol.isIsStatic()); + assertEquals(methodSymbol.isIsFinal(), cloneSymbol.isIsFinal()); + assertEquals(methodSymbol.isIsElliptic(), cloneSymbol.isIsElliptic()); + assertEquals(methodSymbol.isIsConstructor(), cloneSymbol.isIsConstructor()); + assertEquals(methodSymbol.getType().asPrimitive().getPrimitiveName(), cloneSymbol.getType().asPrimitive().getPrimitiveName()); } @Test public void testField(){ List fieldsAllInclusion = symbolTable.resolveFieldMany("bar"); - Assertions.assertEquals(1, fieldsAllInclusion.size()); + assertEquals(1, fieldsAllInclusion.size()); FieldSymbol fieldSymbol = fieldsAllInclusion.get(0); FieldSymbol cloneSymbol = fieldSymbol.deepClone(); - Assertions.assertEquals(fieldSymbol.getName(), cloneSymbol.getName()); - Assertions.assertEquals(fieldSymbol.getType().asPrimitive().getPrimitiveName(), cloneSymbol.getType().asPrimitive().getPrimitiveName()); - Assertions.assertEquals(fieldSymbol.isIsFinal(), cloneSymbol.isIsFinal()); - Assertions.assertEquals(fieldSymbol.isIsPrivate(), cloneSymbol.isIsPrivate()); - Assertions.assertEquals(fieldSymbol.isIsProtected(), cloneSymbol.isIsProtected()); - Assertions.assertEquals(fieldSymbol.isIsPublic(), cloneSymbol.isIsPublic()); - Assertions.assertEquals(fieldSymbol.isIsStatic(), cloneSymbol.isIsStatic()); - Assertions.assertEquals(fieldSymbol.isIsEnumConstant(), cloneSymbol.isIsEnumConstant()); - Assertions.assertEquals(fieldSymbol.isIsDerived(), cloneSymbol.isIsDerived()); - Assertions.assertEquals(fieldSymbol.isIsReadOnly(), cloneSymbol.isIsReadOnly()); + assertEquals(fieldSymbol.getName(), cloneSymbol.getName()); + assertEquals(fieldSymbol.getType().asPrimitive().getPrimitiveName(), cloneSymbol.getType().asPrimitive().getPrimitiveName()); + assertEquals(fieldSymbol.isIsFinal(), cloneSymbol.isIsFinal()); + assertEquals(fieldSymbol.isIsPrivate(), cloneSymbol.isIsPrivate()); + assertEquals(fieldSymbol.isIsProtected(), cloneSymbol.isIsProtected()); + assertEquals(fieldSymbol.isIsPublic(), cloneSymbol.isIsPublic()); + assertEquals(fieldSymbol.isIsStatic(), cloneSymbol.isIsStatic()); + assertEquals(fieldSymbol.isIsEnumConstant(), cloneSymbol.isIsEnumConstant()); + assertEquals(fieldSymbol.isIsDerived(), cloneSymbol.isIsDerived()); + assertEquals(fieldSymbol.isIsReadOnly(), cloneSymbol.isIsReadOnly()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/ModifierTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/ModifierTest.java index 412265c11a..6d93f4fc10 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/ModifierTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/ModifierTest.java @@ -10,12 +10,13 @@ import de.monticore.types.check.SymTypeExpressionFactory; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class ModifierTest { protected IOOSymbolsScope symbolTable; @@ -98,67 +99,67 @@ public void init(){ @Test public void testType(){ List typesAllInclusion = symbolTable.resolveOOTypeMany("Test"); - Assertions.assertEquals(6, typesAllInclusion.size()); + assertEquals(6, typesAllInclusion.size()); List typesPublic = symbolTable.resolveOOTypeMany("Test", BasicAccessModifier.PUBLIC); - Assertions.assertEquals(1, typesPublic.size()); + assertEquals(1, typesPublic.size()); List typesProtected = symbolTable.resolveOOTypeMany("Test", BasicAccessModifier.PROTECTED); - Assertions.assertEquals(2, typesProtected.size()); + assertEquals(2, typesProtected.size()); List typesPrivate = symbolTable.resolveOOTypeMany("Test", BasicAccessModifier.PRIVATE); - Assertions.assertEquals(6, typesPrivate.size()); + assertEquals(6, typesPrivate.size()); List typesStatic = symbolTable.resolveOOTypeMany("Test", StaticAccessModifier.STATIC); - Assertions.assertEquals(2, typesStatic.size()); + assertEquals(2, typesStatic.size()); List typesPrivateStatic = symbolTable .resolveOOTypeMany("Test", new CompoundAccessModifier(List.of(BasicAccessModifier.PRIVATE, StaticAccessModifier.STATIC))); - Assertions.assertEquals(2, typesPrivateStatic.size()); + assertEquals(2, typesPrivateStatic.size()); } @Test public void testMethod(){ List methodsAllInclusion = symbolTable.resolveMethodMany("foo"); - Assertions.assertEquals(6, methodsAllInclusion.size()); + assertEquals(6, methodsAllInclusion.size()); List methodsPublic = symbolTable.resolveMethodMany("foo", BasicAccessModifier.PUBLIC); - Assertions.assertEquals(1, methodsPublic.size()); + assertEquals(1, methodsPublic.size()); List methodsProtected = symbolTable.resolveMethodMany("foo", BasicAccessModifier.PROTECTED); - Assertions.assertEquals(3, methodsProtected.size()); + assertEquals(3, methodsProtected.size()); List methodsPrivate = symbolTable.resolveMethodMany("foo", BasicAccessModifier.PRIVATE); - Assertions.assertEquals(6, methodsPrivate.size()); + assertEquals(6, methodsPrivate.size()); List methodsStatic = symbolTable.resolveMethodMany("foo", StaticAccessModifier.STATIC); - Assertions.assertEquals(2, methodsStatic.size()); + assertEquals(2, methodsStatic.size()); List methodsProtectedStatic = symbolTable .resolveMethodMany("foo", new CompoundAccessModifier(List.of(BasicAccessModifier.PROTECTED, StaticAccessModifier.STATIC))); - Assertions.assertEquals(1, methodsProtectedStatic.size()); + assertEquals(1, methodsProtectedStatic.size()); } @Test public void testField(){ List fieldsAllInclusion = symbolTable.resolveFieldMany("bar"); - Assertions.assertEquals(6, fieldsAllInclusion.size()); + assertEquals(6, fieldsAllInclusion.size()); List fieldsPublic = symbolTable.resolveFieldMany("bar", BasicAccessModifier.PUBLIC); - Assertions.assertEquals(2, fieldsPublic.size()); + assertEquals(2, fieldsPublic.size()); List fieldsProtected = symbolTable.resolveFieldMany("bar", BasicAccessModifier.PROTECTED); - Assertions.assertEquals(3, fieldsProtected.size()); + assertEquals(3, fieldsProtected.size()); List fieldsPrivate = symbolTable.resolveFieldMany("bar", BasicAccessModifier.PRIVATE); - Assertions.assertEquals(6, fieldsPrivate.size()); + assertEquals(6, fieldsPrivate.size()); List fieldsStatic = symbolTable.resolveFieldMany("bar", StaticAccessModifier.STATIC); - Assertions.assertEquals(2, fieldsStatic.size()); + assertEquals(2, fieldsStatic.size()); List fieldsPublicStatic = symbolTable .resolveFieldMany("bar", new CompoundAccessModifier(BasicAccessModifier.PUBLIC, StaticAccessModifier.STATIC)); - Assertions.assertEquals(1, fieldsPublicStatic.size()); + assertEquals(1, fieldsPublicStatic.size()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/OOSymbolsModifierTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/OOSymbolsModifierTest.java index 8bc77956e1..79888b9d4c 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/OOSymbolsModifierTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/OOSymbolsModifierTest.java @@ -2,13 +2,11 @@ package de.monticore.symbols.oosymbols._symboltable; import de.monticore.symbols.oosymbols.OOSymbolsMill; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class OOSymbolsModifierTest { @@ -22,105 +20,105 @@ public void setup() { public void testOOTypeSymbolModifier() { OOTypeSymbol symbol = OOSymbolsMill.oOTypeSymbolBuilder().setName("Foo").build(); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); symbol.setIsPublic(true); - Assertions.assertTrue(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertTrue(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); symbol.setIsPrivate(true); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertTrue(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertTrue(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); symbol.setIsProtected(true); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertTrue(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertTrue(symbol.isIsProtected()); symbol.setIsProtected(false); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); } @Test public void testFieldSymbolModifier() { FieldSymbol symbol = OOSymbolsMill.fieldSymbolBuilder().setName("Foo").build(); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); symbol.setIsPublic(true); - Assertions.assertTrue(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertTrue(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); symbol.setIsPrivate(true); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertTrue(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertTrue(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); symbol.setIsProtected(true); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertTrue(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertTrue(symbol.isIsProtected()); symbol.setIsProtected(false); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); } @Test public void testMethodSymbolModifier() { MethodSymbol symbol = OOSymbolsMill.methodSymbolBuilder().setName("Foo").build(); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); symbol.setIsPublic(true); - Assertions.assertTrue(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertTrue(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); symbol.setIsPrivate(true); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertTrue(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertTrue(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); symbol.setIsProtected(true); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertTrue(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertTrue(symbol.isIsProtected()); symbol.setIsProtected(false); - Assertions.assertFalse(symbol.isIsPublic()); - Assertions.assertFalse(symbol.isIsPrivate()); - Assertions.assertFalse(symbol.isIsProtected()); + assertFalse(symbol.isIsPublic()); + assertFalse(symbol.isIsPrivate()); + assertFalse(symbol.isIsProtected()); - Assertions.assertFalse(symbol.isAbstract); + assertFalse(symbol.isAbstract); symbol.setIsAbstract(true); - Assertions.assertTrue(symbol.isAbstract); + assertTrue(symbol.isAbstract); } diff --git a/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/OOSymbolsSymbols2JsonTest.java b/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/OOSymbolsSymbols2JsonTest.java index 8a279043a4..d507d25221 100644 --- a/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/OOSymbolsSymbols2JsonTest.java +++ b/monticore-grammar/src/test/java/de/monticore/symbols/oosymbols/_symboltable/OOSymbolsSymbols2JsonTest.java @@ -8,12 +8,13 @@ import de.monticore.types.check.SymTypeExpressionFactory; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class OOSymbolsSymbols2JsonTest { private IOOSymbolsArtifactScope scope; @@ -84,7 +85,7 @@ public void init() { public void testDeSer(){ performRoundTripSerialization(scope); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -95,23 +96,23 @@ public void performRoundTripSerialization(IOOSymbolsScope scope){ // then deserialize it OOSymbolsSymbols2Json symbols2Json = new OOSymbolsSymbols2Json(); IOOSymbolsArtifactScope deserialized = symbols2Json.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); // and assert that the deserialized scope equals the one before Optional type = scope.resolveOOType("Type"); Optional deserializedType = deserialized.resolveOOType("Type"); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(deserializedType.isPresent()); + assertTrue(type.isPresent()); + assertTrue(deserializedType.isPresent()); //check that both can resolve the type "SubType" with the supertype "Type" Optional subtype = scope.resolveOOType("SubType"); Optional deserializedSubType = deserialized.resolveOOType("SubType"); - Assertions.assertTrue(subtype.isPresent()); - Assertions.assertTrue(deserializedSubType.isPresent()); - Assertions.assertEquals(1, subtype.get().getSuperTypesList().size()); - Assertions.assertEquals(1, deserializedSubType.get().getSuperTypesList().size()); - Assertions.assertEquals("Type", subtype.get().getSuperTypesList().get(0).print()); - Assertions.assertEquals("Type", deserializedSubType.get().getSuperTypesList().get(0).print()); + assertTrue(subtype.isPresent()); + assertTrue(deserializedSubType.isPresent()); + assertEquals(1, subtype.get().getSuperTypesList().size()); + assertEquals(1, deserializedSubType.get().getSuperTypesList().size()); + assertEquals("Type", subtype.get().getSuperTypesList().get(0).print()); + assertEquals("Type", deserializedSubType.get().getSuperTypesList().get(0).print()); IOOSymbolsScope typeSpanned = type.get().getSpannedScope(); IOOSymbolsScope deserializedTypeSpanned = deserializedType.get().getSpannedScope(); @@ -119,27 +120,27 @@ public void performRoundTripSerialization(IOOSymbolsScope scope){ //check for Variable variable in Type Optional variable = typeSpanned.resolveField("variable"); Optional deserializedVariable = deserializedTypeSpanned.resolveField("variable"); - Assertions.assertTrue(variable.isPresent()); - Assertions.assertTrue(deserializedVariable.isPresent()); - Assertions.assertEquals("double", variable.get().getType().print()); - Assertions.assertEquals("double", deserializedVariable.get().getType().print()); + assertTrue(variable.isPresent()); + assertTrue(deserializedVariable.isPresent()); + assertEquals("double", variable.get().getType().print()); + assertEquals("double", deserializedVariable.get().getType().print()); //check for Function function in Type Optional function = typeSpanned.resolveMethod("function"); Optional deserializedFunction = deserializedTypeSpanned.resolveMethod("function"); - Assertions.assertTrue(function.isPresent()); - Assertions.assertTrue(deserializedFunction.isPresent()); - Assertions.assertEquals("int", function.get().getType().print()); - Assertions.assertEquals("int", deserializedFunction.get().getType().print()); + assertTrue(function.isPresent()); + assertTrue(deserializedFunction.isPresent()); + assertEquals("int", function.get().getType().print()); + assertEquals("int", deserializedFunction.get().getType().print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSerializedUnknownKind() { OOSymbolsSymbols2Json symbols2Json = new OOSymbolsSymbols2Json(); symbols2Json.deserialize("{\"symbols\": [{\"kind\":\"unknown\", \"name\":\"test\"}]}"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -150,13 +151,13 @@ public void testInvalidJsonForSerializingReturnsError(){ OOSymbolsSymbols2Json symbols2Json = new OOSymbolsSymbols2Json(); symbols2Json.deserialize(invalidJsonForSerializing); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith("0xA1238")); + assertTrue(Log.getFindings().get(0).getMsg().startsWith("0xA1238")); symbols2Json.deserialize(invalidJsonForSerializing2); - Assertions.assertTrue(Log.getFindings().get(1).getMsg().startsWith("0xA1233")); + assertTrue(Log.getFindings().get(1).getMsg().startsWith("0xA1233")); symbols2Json.deserialize(invalidJsonForSerializing3); - Assertions.assertTrue(Log.getFindings().get(2).getMsg().startsWith("0xA0572")); + assertTrue(Log.getFindings().get(2).getMsg().startsWith("0xA0572")); } } diff --git a/monticore-grammar/src/test/java/de/monticore/testsymtabmill/MillTest.java b/monticore-grammar/src/test/java/de/monticore/testsymtabmill/MillTest.java index b309436cf6..f1702ecfbc 100644 --- a/monticore-grammar/src/test/java/de/monticore/testsymtabmill/MillTest.java +++ b/monticore-grammar/src/test/java/de/monticore/testsymtabmill/MillTest.java @@ -6,12 +6,10 @@ import de.monticore.testsymtabmill.testsymtabmill._symboltable.*; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class MillTest { @@ -36,10 +34,10 @@ public void testMill(){ TestSymTabMillScopesGenitorDelegator symbolTableCreatorDelegator = TestSymTabMillMill.scopesGenitorDelegator(); - Assertions.assertFalse(scope.isShadowing()); - Assertions.assertTrue(symbolTableCreator.getCurrentScope().get().equals(scope)); + assertFalse(scope.isShadowing()); + assertEquals(symbolTableCreator.getCurrentScope().get(), scope); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/typepersistence/TypePersistenceTest.java b/monticore-grammar/src/test/java/de/monticore/typepersistence/TypePersistenceTest.java index df28e0db16..d91d49f99c 100644 --- a/monticore-grammar/src/test/java/de/monticore/typepersistence/TypePersistenceTest.java +++ b/monticore-grammar/src/test/java/de/monticore/typepersistence/TypePersistenceTest.java @@ -10,14 +10,13 @@ import de.monticore.typepersistence.variable._symboltable.VariableScopesGenitorDelegator; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TypePersistenceTest { @@ -52,8 +51,8 @@ public void test() throws IOException { Optional varModel = blahParser.parse_String("var String a"); VariableScopesGenitorDelegator varSymbolTableCreator = VariableMill.scopesGenitorDelegator(); IVariableScope blahSymbolTable = varSymbolTableCreator.createFromAST(varModel.get()); - Assertions.assertTrue(varModel.isPresent()); + assertTrue(varModel.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/AlwaysTheSameASTTest.java b/monticore-grammar/src/test/java/de/monticore/types/AlwaysTheSameASTTest.java index 599e0ad82e..2bf5a29430 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/AlwaysTheSameASTTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/AlwaysTheSameASTTest.java @@ -15,13 +15,14 @@ import de.monticore.types.mcsimplegenerictypestest._parser.MCSimpleGenericTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class AlwaysTheSameASTTest { private MCBasicTypesTestParser basicTypesTestParser; @@ -58,41 +59,41 @@ public void testMCListType() throws IOException { String list = "List"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCGenericType(list); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCListType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCListType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCGenericType(list); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCListType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCListType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCGenericType(list); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCListType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCListType.class, genericAST.get()); ASTMCListType basicGenericList = (ASTMCListType) basicGenericAst.get(); ASTMCListType customList = (ASTMCListType) customAst.get(); ASTMCListType genericList = (ASTMCListType) genericAST.get(); - Assertions.assertTrue(basicGenericList.deepEquals(customList)); - Assertions.assertTrue(basicGenericList.deepEquals(genericList)); - Assertions.assertTrue(genericList.deepEquals(customList)); + assertTrue(basicGenericList.deepEquals(customList)); + assertTrue(basicGenericList.deepEquals(genericList)); + assertTrue(genericList.deepEquals(customList)); - Assertions.assertEquals(basicGenericAst.get().printType().split("\\.").length, 1); + assertEquals(1, basicGenericAst.get().printType().split("\\.").length); - Assertions.assertEquals(basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0], "List"); + assertEquals("List", basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0]); - Assertions.assertEquals(basicGenericAst.get().getMCTypeArgumentList().size(), 1); + assertEquals(1, basicGenericAst.get().getMCTypeArgumentList().size()); ASTMCTypeArgument argument = basicGenericAst.get().getMCTypeArgumentList().get(0); Optional argument2 = mcCollectionTypesTestParser.parse_StringMCTypeArgument("String"); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(argument2.isPresent()); - Assertions.assertTrue(argument.deepEquals(argument2.get())); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(argument2.isPresent()); + assertTrue(argument.deepEquals(argument2.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -101,33 +102,33 @@ public void testMCListTypeWithCollectionTypeParser() throws IOException { String list = "List"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCGenericType(list); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCListType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCListType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCGenericType(list); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCListType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCListType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCGenericType(list); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCListType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCListType.class, genericAST.get()); ASTMCListType basicGenericList = (ASTMCListType) basicGenericAst.get(); ASTMCListType customList = (ASTMCListType) customAst.get(); ASTMCListType genericList = (ASTMCListType) genericAST.get(); - Assertions.assertTrue(basicGenericList.deepEquals(customList)); - Assertions.assertTrue(basicGenericList.deepEquals(genericList)); - Assertions.assertTrue(genericList.deepEquals(customList)); + assertTrue(basicGenericList.deepEquals(customList)); + assertTrue(basicGenericList.deepEquals(genericList)); + assertTrue(genericList.deepEquals(customList)); - Assertions.assertEquals(basicGenericAst.get().printType().split("\\.").length, 1); + assertEquals(1, basicGenericAst.get().printType().split("\\.").length); - Assertions.assertEquals(basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0], "List"); + assertEquals("List", basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0]); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -135,29 +136,29 @@ public void testMCListTypeWithTypeParser() throws IOException { String list = "List"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCType(list); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCListType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCListType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCType(list); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCListType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCListType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCType(list); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCListType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCListType.class, genericAST.get()); ASTMCListType basicGenericList = (ASTMCListType) basicGenericAst.get(); ASTMCListType customList = (ASTMCListType) customAst.get(); ASTMCListType genericList = (ASTMCListType) genericAST.get(); - Assertions.assertTrue(basicGenericList.deepEquals(customList)); - Assertions.assertTrue(basicGenericList.deepEquals(genericList)); - Assertions.assertTrue(genericList.deepEquals(customList)); + assertTrue(basicGenericList.deepEquals(customList)); + assertTrue(basicGenericList.deepEquals(genericList)); + assertTrue(genericList.deepEquals(customList)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -165,37 +166,37 @@ public void testMCMapTypeWithGenericCollectionTypeParser() throws IOException { String map = "Map"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCGenericType(map); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCMapType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCMapType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCGenericType(map); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCMapType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCMapType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCGenericType(map); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCMapType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCMapType.class, genericAST.get()); - Assertions.assertTrue(basicGenericAst.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertEquals(basicGenericAst.get().printType().split("\\.").length, 1); + assertEquals(1, basicGenericAst.get().printType().split("\\.").length); - Assertions.assertEquals(basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0], "Map"); + assertEquals("Map", basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0]); - Assertions.assertEquals(basicGenericAst.get().getMCTypeArgumentList().size(), 2); + assertEquals(2, basicGenericAst.get().getMCTypeArgumentList().size()); ASTMCTypeArgument argument = basicGenericAst.get().getMCTypeArgumentList().get(0); Optional argument2 = mcCollectionTypesTestParser.parse_StringMCTypeArgument("Integer"); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(argument2.isPresent()); - Assertions.assertTrue(argument.deepEquals(argument2.get())); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(argument2.isPresent()); + assertTrue(argument.deepEquals(argument2.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -203,25 +204,25 @@ public void testMCMapTypeWithTypeParser() throws IOException { String map = "Map"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCType(map); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCMapType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCMapType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCType(map); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCMapType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCMapType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCType(map); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCMapType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCMapType.class, genericAST.get()); - Assertions.assertTrue(basicGenericAst.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -229,29 +230,29 @@ public void testMCMapTypeWithCollectionTypeParser() throws IOException { String map = "Map"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCGenericType(map); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCMapType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCMapType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCGenericType(map); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCMapType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCMapType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCGenericType(map); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCMapType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCMapType.class, genericAST.get()); - Assertions.assertTrue(basicGenericAst.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertEquals(basicGenericAst.get().printType().split("\\.").length, 1); + assertEquals(1, basicGenericAst.get().printType().split("\\.").length); - Assertions.assertEquals(basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0], "Map"); + assertEquals("Map", basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0]); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -259,38 +260,38 @@ public void testMCOptionalType() throws IOException { String optional = "Optional"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCGenericType(optional); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCOptionalType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCOptionalType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCGenericType(optional); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCOptionalType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCOptionalType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCGenericType(optional); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCOptionalType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCOptionalType.class, genericAST.get()); - Assertions.assertTrue(basicGenericAst.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertEquals(basicGenericAst.get().printType().split("\\.").length, 1); + assertEquals(1, basicGenericAst.get().printType().split("\\.").length); - Assertions.assertEquals(basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0], "Optional"); + assertEquals("Optional", basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0]); - Assertions.assertEquals(basicGenericAst.get().getMCTypeArgumentList().size(), 1); + assertEquals(1, basicGenericAst.get().getMCTypeArgumentList().size()); ASTMCTypeArgument argument = basicGenericAst.get().getMCTypeArgumentList().get(0); Optional argument2 = mcCollectionTypesTestParser.parse_StringMCTypeArgument("String"); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(argument2.isPresent()); - Assertions.assertTrue(argument.deepEquals(argument2.get())); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(argument2.isPresent()); + assertTrue(argument.deepEquals(argument2.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -298,26 +299,26 @@ public void testMCOptionalTypeWithTypeParser() throws IOException { String optional = "Optional"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCType(optional); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCOptionalType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCOptionalType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCType(optional); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCOptionalType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCOptionalType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCType(optional); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCOptionalType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCOptionalType.class, genericAST.get()); - Assertions.assertTrue(basicGenericAst.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -325,30 +326,30 @@ public void testMCOptionalTypeWithCollectionTypeParser() throws IOException { String optional = "Optional"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCGenericType(optional); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCOptionalType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCOptionalType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCGenericType(optional); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCOptionalType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCOptionalType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCGenericType(optional); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCOptionalType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCOptionalType.class, genericAST.get()); - Assertions.assertTrue(basicGenericAst.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertEquals(basicGenericAst.get().printType().split("\\.").length, 1); + assertEquals(1, basicGenericAst.get().printType().split("\\.").length); - Assertions.assertEquals(basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0], "Optional"); + assertEquals("Optional", basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0]); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -356,38 +357,38 @@ public void testMCSetTypeWithGenericCollectionTypeParser() throws IOException { String set = "Set"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCGenericType(set); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCSetType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCSetType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCGenericType(set); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCSetType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCSetType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCGenericType(set); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCSetType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCSetType.class, genericAST.get()); - Assertions.assertTrue(basicGenericAst.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertEquals(basicGenericAst.get().printType().split("\\.").length, 1); + assertEquals(1, basicGenericAst.get().printType().split("\\.").length); - Assertions.assertEquals(basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0], "Set"); + assertEquals("Set", basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0]); - Assertions.assertEquals(basicGenericAst.get().getMCTypeArgumentList().size(), 1); + assertEquals(1, basicGenericAst.get().getMCTypeArgumentList().size()); ASTMCTypeArgument argument = basicGenericAst.get().getMCTypeArgumentList().get(0); Optional argument2 = mcCollectionTypesTestParser.parse_StringMCTypeArgument("String"); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(argument2.isPresent()); - Assertions.assertTrue(argument.deepEquals(argument2.get())); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(argument2.isPresent()); + assertTrue(argument.deepEquals(argument2.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -395,26 +396,26 @@ public void testMCSetTypeWithTypeParser() throws IOException { String set = "Set"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCType(set); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCSetType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCSetType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCType(set); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCSetType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCSetType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCType(set); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCSetType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCSetType.class, genericAST.get()); - Assertions.assertTrue(basicGenericAst.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -422,30 +423,30 @@ public void testMCSetTypeWithCollectionTypeParser() throws IOException { String set = "Set"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCGenericType(set); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCSetType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCSetType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCGenericType(set); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCSetType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCSetType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCGenericType(set); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCSetType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCSetType.class, genericAST.get()); - Assertions.assertTrue(basicGenericAst.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertEquals(basicGenericAst.get().printType().split("\\.").length, 1); + assertEquals(1, basicGenericAst.get().printType().split("\\.").length); - Assertions.assertEquals(basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0], "Set"); + assertEquals("Set", basicGenericAst.get().printWithoutTypeArguments().split("\\.")[0]); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -453,25 +454,25 @@ public void testMCBasicTypeArgument() throws IOException { String type = "de.monticore.ASTNode"; Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCTypeArgument(type); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCBasicTypeArgument); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCBasicTypeArgument.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCTypeArgument(type); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCBasicTypeArgument); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCBasicTypeArgument.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCTypeArgument(type); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCBasicTypeArgument); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCBasicTypeArgument.class, genericAST.get()); - Assertions.assertTrue(basicGenericAst.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -479,18 +480,18 @@ public void testMCCustomTypeArgument() throws IOException { String type = "List"; Optional customAst = customGenericTypesTestParser.parse_StringMCTypeArgument(type); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCCustomTypeArgument); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCCustomTypeArgument.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCTypeArgument(type); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCCustomTypeArgument); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCCustomTypeArgument.class, genericAST.get()); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -498,32 +499,32 @@ public void testMCQualifiedType() throws IOException { String type = "de.monticore.ASTNode"; Optional basicAST = basicTypesTestParser.parse_StringMCType(type); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicAST.isPresent()); - Assertions.assertTrue(basicAST.get() instanceof ASTMCQualifiedType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicAST.isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, basicAST.get()); Optional basicGenericAst = mcCollectionTypesTestParser.parse_StringMCType(type); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(basicGenericAst.isPresent()); - Assertions.assertTrue(basicGenericAst.get() instanceof ASTMCQualifiedType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(basicGenericAst.isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, basicGenericAst.get()); Optional customAst = customGenericTypesTestParser.parse_StringMCType(type); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(customAst.isPresent()); - Assertions.assertTrue(customAst.get() instanceof ASTMCQualifiedType); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(customAst.isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, customAst.get()); Optional genericAST = genericTypesTestParser.parse_StringMCType(type); - Assertions.assertFalse(mcCollectionTypesTestParser.hasErrors()); - Assertions.assertTrue(genericAST.isPresent()); - Assertions.assertTrue(genericAST.get() instanceof ASTMCQualifiedType); - - Assertions.assertTrue(basicAST.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicAST.get().deepEquals(basicGenericAst.get())); - Assertions.assertTrue(basicAST.get().deepEquals(genericAST.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(customAst.get())); - Assertions.assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); - Assertions.assertTrue(genericAST.get().deepEquals(customAst.get())); + assertFalse(mcCollectionTypesTestParser.hasErrors()); + assertTrue(genericAST.isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, genericAST.get()); + + assertTrue(basicAST.get().deepEquals(customAst.get())); + assertTrue(basicAST.get().deepEquals(basicGenericAst.get())); + assertTrue(basicAST.get().deepEquals(genericAST.get())); + assertTrue(basicGenericAst.get().deepEquals(customAst.get())); + assertTrue(basicGenericAst.get().deepEquals(genericAST.get())); + assertTrue(genericAST.get().deepEquals(customAst.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/MCBasicTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/MCBasicTypesTest.java index 4b3b10f88a..c722bfda73 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/MCBasicTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/MCBasicTypesTest.java @@ -6,13 +6,14 @@ import de.monticore.types.mcbasictypestest._parser.MCBasicTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCBasicTypesTest { @BeforeEach @@ -28,28 +29,28 @@ public void init() { public void testPrimitiveTypesAPI() throws IOException { MCBasicTypesTestParser mcBasicTypesParser = new MCBasicTypesTestParser(); Optional boolOpt = mcBasicTypesParser.parse_StringMCPrimitiveType("boolean"); - Assertions.assertTrue(boolOpt.isPresent()); + assertTrue(boolOpt.isPresent()); ASTMCPrimitiveType bool = boolOpt.get(); boolean isBool = bool.isBoolean(); - Assertions.assertTrue(isBool); + assertTrue(isBool); boolean isByte = bool.isByte(); - Assertions.assertFalse(isByte); + assertFalse(isByte); boolean isChar = bool.isChar(); - Assertions.assertFalse(isChar); + assertFalse(isChar); boolean isDouble = bool.isDouble(); - Assertions.assertFalse(isDouble); + assertFalse(isDouble); boolean isFloat = bool.isFloat(); - Assertions.assertFalse(isFloat); + assertFalse(isFloat); boolean isInt = bool.isInt(); - Assertions.assertFalse(isInt); + assertFalse(isInt); boolean isShort = bool.isShort(); - Assertions.assertFalse(isShort); + assertFalse(isShort); - Assertions.assertEquals(bool.toString(), "boolean"); + assertEquals("boolean", bool.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -67,15 +68,15 @@ public void testPrimitiveTypes() { Optional type = mcBasicTypesParser.parse_String(primitive); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCPrimitiveType); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCPrimitiveType.class, type.get()); } } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -84,12 +85,12 @@ public void testMCQualifiedType() throws IOException { for (String type : types) { MCBasicTypesTestParser mcBasicTypesParser = new MCBasicTypesTestParser(); Optional astType = mcBasicTypesParser.parse_String(type); - Assertions.assertNotNull(astType); - Assertions.assertTrue(astType.isPresent()); - Assertions.assertTrue(astType.get() instanceof ASTMCQualifiedType); + assertNotNull(astType); + assertTrue(astType.isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, astType.get()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -98,13 +99,13 @@ public void testMCQualifiedName() throws IOException { for (String type : types) { MCBasicTypesTestParser mcBasicTypesParser = new MCBasicTypesTestParser(); Optional astType = mcBasicTypesParser.parse_StringMCQualifiedName(type); - Assertions.assertNotNull(astType); - Assertions.assertTrue(astType.isPresent()); + assertNotNull(astType); + assertTrue(astType.isPresent()); //test toString - Assertions.assertEquals(astType.get().toString(), type); + assertEquals(astType.get().toString(), type); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -113,11 +114,11 @@ public void testMCImportStatement() throws IOException { String type = "import socnet.Person.*;"; MCBasicTypesTestParser mcBasicTypesParser = new MCBasicTypesTestParser(); Optional astType = mcBasicTypesParser.parse_StringMCImportStatement(type); - Assertions.assertNotNull(astType); - Assertions.assertTrue(astType.isPresent()); + assertNotNull(astType); + assertTrue(astType.isPresent()); //test getQName method - Assertions.assertEquals(astType.get().getQName(), "socnet.Person"); + assertEquals("socnet.Person", astType.get().getQName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/MCCollectionTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/MCCollectionTypesTest.java index 8b5d2dcf4d..96b30bcb4d 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/MCCollectionTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/MCCollectionTypesTest.java @@ -14,13 +14,14 @@ import de.monticore.types.mccollectiontypeswithoutprimitivestest._parser.MCCollectionTypesWithoutPrimitivesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCCollectionTypesTest { @BeforeEach @@ -43,9 +44,9 @@ public void testBasicGenericsTypes() throws IOException { // .parseType(primitive); Optional type = mcBasicTypesParser.parse_StringMCType(testType); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCObjectType); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCObjectType.class, type.get()); ASTMCObjectType t = (ASTMCObjectType) type.get(); MCCollectionTypesTraverser traverser = MCCollectionTypesMill.traverser(); @@ -53,13 +54,13 @@ public void testBasicGenericsTypes() throws IOException { t.accept(traverser); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private class CheckTypeVisitor implements MCCollectionTypesVisitor2 { public void visit(ASTMCType node) { if (!(node instanceof ASTMCQualifiedType)) { - Assertions.fail("Found not String"); + fail("Found not String"); } } } @@ -68,68 +69,68 @@ public void visit(ASTMCType node) { public void testMCListTypeValid() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional type = parser.parse_StringMCGenericType("List"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCListType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCListType.class, type.get()); //test specific methods ASTMCListType listType = (ASTMCListType) type.get(); - Assertions.assertEquals(listType.getNameList().size(), 1); + assertEquals(1, listType.getNameList().size()); - Assertions.assertEquals(listType.getNameList().get(0), "List"); + assertEquals("List", listType.getNameList().get(0)); - Assertions.assertEquals(listType.getMCTypeArgumentList().size(), 1); + assertEquals(1, listType.getMCTypeArgumentList().size()); ASTMCTypeArgument argument = listType.getMCTypeArgumentList().get(0); Optional argument2 = parser.parse_StringMCTypeArgument("String"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(argument2.isPresent()); - Assertions.assertTrue(argument.deepEquals(argument2.get())); + assertFalse(parser.hasErrors()); + assertTrue(argument2.isPresent()); + assertTrue(argument.deepEquals(argument2.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCListTypeInvalid() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional type = parser.parse_StringMCGenericType("java.util.List"); - Assertions.assertTrue(parser.hasErrors()); - Assertions.assertFalse(type.isPresent()); + assertTrue(parser.hasErrors()); + assertFalse(type.isPresent()); } @Test public void testMCMapTypeValid() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional type = parser.parse_StringMCGenericType("Map"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCMapType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCMapType.class, type.get()); //test specific methods ASTMCMapType mapType = (ASTMCMapType) type.get(); - Assertions.assertEquals(mapType.getNameList().size(), 1); + assertEquals(1, mapType.getNameList().size()); - Assertions.assertEquals(mapType.getNameList().get(0), "Map"); + assertEquals("Map", mapType.getNameList().get(0)); - Assertions.assertEquals(mapType.getMCTypeArgumentList().size(), 2); + assertEquals(2, mapType.getMCTypeArgumentList().size()); ASTMCTypeArgument argument = mapType.getMCTypeArgumentList().get(0); Optional argument2 = parser.parse_StringMCTypeArgument("Integer"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(argument2.isPresent()); - Assertions.assertTrue(argument.deepEquals(argument2.get())); + assertFalse(parser.hasErrors()); + assertTrue(argument2.isPresent()); + assertTrue(argument.deepEquals(argument2.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCMapTypeInvalid() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional type = parser.parse_StringMCGenericType("java.util.Map"); - Assertions.assertTrue(parser.hasErrors()); - Assertions.assertFalse(type.isPresent()); + assertTrue(parser.hasErrors()); + assertFalse(type.isPresent()); } @@ -137,34 +138,34 @@ public void testMCMapTypeInvalid() throws IOException { public void testMCOptionalTypeValid() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional type = parser.parse_StringMCGenericType("Optional"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCOptionalType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCOptionalType.class, type.get()); //test specific methods ASTMCOptionalType optionalType = (ASTMCOptionalType) type.get(); - Assertions.assertEquals(optionalType.getNameList().size(), 1); + assertEquals(1, optionalType.getNameList().size()); - Assertions.assertEquals(optionalType.getNameList().get(0), "Optional"); + assertEquals("Optional", optionalType.getNameList().get(0)); - Assertions.assertEquals(optionalType.getMCTypeArgumentList().size(), 1); + assertEquals(1, optionalType.getMCTypeArgumentList().size()); ASTMCTypeArgument argument = optionalType.getMCTypeArgumentList().get(0); Optional argument2 = parser.parse_StringMCTypeArgument("String"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(argument2.isPresent()); - Assertions.assertTrue(argument.deepEquals(argument2.get())); + assertFalse(parser.hasErrors()); + assertTrue(argument2.isPresent()); + assertTrue(argument.deepEquals(argument2.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCOptionalTypeInvalid() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional type = parser.parse_StringMCGenericType("java.util.Optional"); - Assertions.assertTrue(parser.hasErrors()); - Assertions.assertFalse(type.isPresent()); + assertTrue(parser.hasErrors()); + assertFalse(type.isPresent()); } @@ -172,54 +173,54 @@ public void testMCOptionalTypeInvalid() throws IOException { public void testMCSetTypeValid() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional type = parser.parse_StringMCGenericType("Set"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCSetType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCSetType.class, type.get()); //test specific methods ASTMCSetType setType = (ASTMCSetType) type.get(); - Assertions.assertEquals(setType.getNameList().size(), 1); + assertEquals(1, setType.getNameList().size()); - Assertions.assertEquals(setType.getNameList().get(0), "Set"); + assertEquals("Set", setType.getNameList().get(0)); - Assertions.assertEquals(setType.getMCTypeArgumentList().size(), 1); + assertEquals(1, setType.getMCTypeArgumentList().size()); ASTMCTypeArgument argument = setType.getMCTypeArgumentList().get(0); Optional argument2 = parser.parse_StringMCTypeArgument("String"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(argument2.isPresent()); - Assertions.assertTrue(argument.deepEquals(argument2.get())); + assertFalse(parser.hasErrors()); + assertTrue(argument2.isPresent()); + assertTrue(argument.deepEquals(argument2.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCSetTypeInvalid() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional type = parser.parse_StringMCGenericType("java.util.Set"); - Assertions.assertTrue(parser.hasErrors()); - Assertions.assertFalse(type.isPresent()); + assertTrue(parser.hasErrors()); + assertFalse(type.isPresent()); } @Test public void testMCTypeArgumentValid() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional type = parser.parse_StringMCTypeArgument("a.b.c"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCBasicTypeArgument); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCBasicTypeArgument.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCTypeArgumentInvalid() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional type = parser.parse_StringMCTypeArgument("List"); - Assertions.assertTrue(parser.hasErrors()); - Assertions.assertFalse(type.isPresent()); + assertTrue(parser.hasErrors()); + assertFalse(type.isPresent()); } @@ -227,11 +228,11 @@ public void testMCTypeArgumentInvalid() throws IOException { public void collectionTypeWithInt() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional type = parser.parse_StringMCGenericType("List"); - Assertions.assertTrue(type.isPresent()); - Assertions.assertEquals("List", type.get().printWithoutTypeArguments()); - Assertions.assertTrue(type.get().getMCTypeArgumentList().get(0) instanceof ASTMCPrimitiveTypeArgument); + assertTrue(type.isPresent()); + assertEquals("List", type.get().printWithoutTypeArguments()); + assertInstanceOf(ASTMCPrimitiveTypeArgument.class, type.get().getMCTypeArgumentList().get(0)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -239,8 +240,8 @@ public void collectionTypeWithInt() throws IOException { public void collectionTypeWithIntFail() throws IOException { MCCollectionTypesWithoutPrimitivesTestParser parser = new MCCollectionTypesWithoutPrimitivesTestParser(); Optional type = parser.parse_StringMCGenericType("List"); - Assertions.assertTrue(parser.hasErrors()); - Assertions.assertFalse(type.isPresent()); + assertTrue(parser.hasErrors()); + assertFalse(type.isPresent()); } @Test @@ -251,18 +252,18 @@ public void testPrintTypeWithoutTypeArguments() throws IOException { Optional setType = parser.parse_StringMCSetType("Set"); Optional mapType = parser.parse_StringMCMapType("Map"); Optional genericType = parser.parse_StringMCGenericType("Map"); - Assertions.assertTrue(listType.isPresent()); - Assertions.assertTrue(optionalType.isPresent()); - Assertions.assertTrue(setType.isPresent()); - Assertions.assertTrue(mapType.isPresent()); - Assertions.assertTrue(genericType.isPresent()); - Assertions.assertEquals("List", listType.get().printWithoutTypeArguments()); - Assertions.assertEquals("Optional", optionalType.get().printWithoutTypeArguments()); - Assertions.assertEquals("Set", setType.get().printWithoutTypeArguments()); - Assertions.assertEquals("Map", genericType.get().printWithoutTypeArguments()); - Assertions.assertEquals("Map", genericType.get().printWithoutTypeArguments()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(listType.isPresent()); + assertTrue(optionalType.isPresent()); + assertTrue(setType.isPresent()); + assertTrue(mapType.isPresent()); + assertTrue(genericType.isPresent()); + assertEquals("List", listType.get().printWithoutTypeArguments()); + assertEquals("Optional", optionalType.get().printWithoutTypeArguments()); + assertEquals("Set", setType.get().printWithoutTypeArguments()); + assertEquals("Map", genericType.get().printWithoutTypeArguments()); + assertEquals("Map", genericType.get().printWithoutTypeArguments()); + assertFalse(parser.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/MCFullGenericTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/MCFullGenericTypesTest.java index e666a96512..72b8317ad6 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/MCFullGenericTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/MCFullGenericTypesTest.java @@ -7,13 +7,14 @@ import de.monticore.types.mcfullgenerictypestest._parser.MCFullGenericTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCFullGenericTypesTest { @BeforeEach @@ -29,13 +30,13 @@ public void testPrintTypeWithoutTypeArguments() throws IOException { MCFullGenericTypesTestParser parser = new MCFullGenericTypesTestParser(); Optional multipleGenericType = parser.parse_StringMCMultipleGenericType("a.B.D.E.G"); Optional genericType = parser.parse_StringMCGenericType("a.B.D.E.G"); - Assertions.assertTrue(genericType.isPresent()); - Assertions.assertTrue(multipleGenericType.isPresent()); - Assertions.assertEquals("a.B.D.E.G", multipleGenericType.get().printWithoutTypeArguments()); - Assertions.assertEquals("a.B.D.E.G", genericType.get().printWithoutTypeArguments()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(genericType.isPresent()); + assertTrue(multipleGenericType.isPresent()); + assertEquals("a.B.D.E.G", multipleGenericType.get().printWithoutTypeArguments()); + assertEquals("a.B.D.E.G", genericType.get().printWithoutTypeArguments()); + assertFalse(parser.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/MCFunctionTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/MCFunctionTypesTest.java index d24f6fe9f5..0069d2f9f3 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/MCFunctionTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/MCFunctionTypesTest.java @@ -8,17 +8,13 @@ import de.monticore.types.mcfunctiontypestest._parser.MCFunctionTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class MCFunctionTypesTest { @@ -33,108 +29,108 @@ public void init() { @Test public void testRunnableFunctionType() throws IOException { ASTMCFunctionType type = parseMCFunctionType("() -> void"); - Assertions.assertEquals("void", type.getMCReturnType() + assertEquals("void", type.getMCReturnType() .printType()); - Assertions.assertFalse(type.getMCFunctionParTypes().isPresentIsElliptic()); - Assertions.assertEquals(0, type.getMCFunctionParTypes().getMCTypeList().size()); + assertFalse(type.getMCFunctionParTypes().isPresentIsElliptic()); + assertEquals(0, type.getMCFunctionParTypes().getMCTypeList().size()); } @Test public void testSupplierFunctionType() throws IOException { ASTMCFunctionType type = parseMCFunctionType("() -> int"); - Assertions.assertEquals("int", type.getMCReturnType() + assertEquals("int", type.getMCReturnType() .printType()); - Assertions.assertFalse(type.getMCFunctionParTypes().isPresentIsElliptic()); - Assertions.assertEquals(0, type.getMCFunctionParTypes().getMCTypeList().size()); + assertFalse(type.getMCFunctionParTypes().isPresentIsElliptic()); + assertEquals(0, type.getMCFunctionParTypes().getMCTypeList().size()); } @Test public void testWithInputFunctionType1() throws IOException { ASTMCUnaryFunctionType type = parseMCFunctionTypeNoParentheses("int -> void"); - Assertions.assertEquals("void", type.getMCReturnType().printType()); - Assertions.assertEquals("int", type.getMCType().printType()); + assertEquals("void", type.getMCReturnType().printType()); + assertEquals("int", type.getMCType().printType()); } @Test public void testWithInputFunctionType2() throws IOException { ASTMCFunctionType type = parseMCFunctionType("(int, long) -> void"); - Assertions.assertEquals("void", type.getMCReturnType().printType()); - Assertions.assertFalse(type.getMCFunctionParTypes().isPresentIsElliptic()); - Assertions.assertEquals(2, type.getMCFunctionParTypes().getMCTypeList().size()); - Assertions.assertEquals("int", type.getMCFunctionParTypes().getMCType(0).printType()); - Assertions.assertEquals("long", type.getMCFunctionParTypes().getMCType(1).printType()); + assertEquals("void", type.getMCReturnType().printType()); + assertFalse(type.getMCFunctionParTypes().isPresentIsElliptic()); + assertEquals(2, type.getMCFunctionParTypes().getMCTypeList().size()); + assertEquals("int", type.getMCFunctionParTypes().getMCType(0).printType()); + assertEquals("long", type.getMCFunctionParTypes().getMCType(1).printType()); } @Test public void testEllipticFunctionType1() throws IOException { ASTMCFunctionType type = parseMCFunctionType("(long...) -> void"); - Assertions.assertEquals("void", type.getMCReturnType() + assertEquals("void", type.getMCReturnType() .printType()); - Assertions.assertTrue(type.getMCFunctionParTypes().isPresentIsElliptic()); - Assertions.assertEquals(1, type.getMCFunctionParTypes().getMCTypeList().size()); - Assertions.assertEquals("long", type.getMCFunctionParTypes().getMCType(0) + assertTrue(type.getMCFunctionParTypes().isPresentIsElliptic()); + assertEquals(1, type.getMCFunctionParTypes().getMCTypeList().size()); + assertEquals("long", type.getMCFunctionParTypes().getMCType(0) .printType()); } @Test public void testEllipticFunctionType2() throws IOException { ASTMCFunctionType type = parseMCFunctionType("(int, long...) -> long"); - Assertions.assertEquals("long", type.getMCReturnType() + assertEquals("long", type.getMCReturnType() .printType()); - Assertions.assertTrue(type.getMCFunctionParTypes().isPresentIsElliptic()); - Assertions.assertEquals(2, type.getMCFunctionParTypes().getMCTypeList().size()); - Assertions.assertEquals("int", type.getMCFunctionParTypes().getMCType(0) + assertTrue(type.getMCFunctionParTypes().isPresentIsElliptic()); + assertEquals(2, type.getMCFunctionParTypes().getMCTypeList().size()); + assertEquals("int", type.getMCFunctionParTypes().getMCType(0) .printType()); - Assertions.assertEquals("long", type.getMCFunctionParTypes().getMCType(1) + assertEquals("long", type.getMCFunctionParTypes().getMCType(1) .printType()); } @Test public void testHigherOrderFunctionType1() throws IOException { ASTMCFunctionType type = parseMCFunctionType("() -> () -> void"); - Assertions.assertFalse(type.getMCFunctionParTypes().isPresentIsElliptic()); - Assertions.assertEquals(0, type.getMCFunctionParTypes().getMCTypeList().size()); + assertFalse(type.getMCFunctionParTypes().isPresentIsElliptic()); + assertEquals(0, type.getMCFunctionParTypes().getMCTypeList().size()); } @Test public void testHigherOrderFunctionType2() throws IOException { ASTMCFunctionType type = parseMCFunctionType("((long) -> void) -> (int) -> long"); - Assertions.assertFalse(type.getMCFunctionParTypes().isPresentIsElliptic()); - Assertions.assertEquals(1, type.getMCFunctionParTypes().getMCTypeList().size()); + assertFalse(type.getMCFunctionParTypes().isPresentIsElliptic()); + assertEquals(1, type.getMCFunctionParTypes().getMCTypeList().size()); } @Test public void testHigherOrderFunctionType3() throws IOException { ASTMCUnaryFunctionType type = parseMCFunctionTypeNoParentheses("int -> long -> void"); - Assertions.assertEquals("int", type.getMCType().printType()); - Assertions.assertTrue(type.getMCReturnType().isPresentMCType()); + assertEquals("int", type.getMCType().printType()); + assertTrue(type.getMCReturnType().isPresentMCType()); ASTMCType returnType = type.getMCReturnType().getMCType(); - Assertions.assertTrue(returnType instanceof ASTMCUnaryFunctionType); + assertInstanceOf(ASTMCUnaryFunctionType.class, returnType); ASTMCUnaryFunctionType returnFuncType = (ASTMCUnaryFunctionType) returnType; - Assertions.assertEquals("long", returnFuncType.getMCType().printType()); - Assertions.assertEquals("void", returnFuncType.getMCReturnType().printType()); + assertEquals("long", returnFuncType.getMCType().printType()); + assertEquals("void", returnFuncType.getMCReturnType().printType()); } @Test public void testHigherOrderFunctionType5() throws IOException { ASTMCUnaryFunctionType type = parseMCFunctionTypeNoParentheses("int -> (long -> void) -> long"); - Assertions.assertEquals("int", type.getMCType().printType()); - Assertions.assertEquals("(long->void)->long", type.getMCReturnType().printType()); + assertEquals("int", type.getMCType().printType()); + assertEquals("(long->void)->long", type.getMCReturnType().printType()); } protected ASTMCFunctionType parseMCFunctionType(String mcTypeStr) throws IOException { MCFunctionTypesTestParser parser = new MCFunctionTypesTestParser(); Optional typeOpt = parser.parse_StringMCType(mcTypeStr); - Assertions.assertNotNull(typeOpt); - Assertions.assertTrue(typeOpt.isPresent()); - Assertions.assertTrue(typeOpt.get() instanceof ASTMCFunctionType); + assertNotNull(typeOpt); + assertTrue(typeOpt.isPresent()); + assertInstanceOf(ASTMCFunctionType.class, typeOpt.get()); ASTMCFunctionType type = (ASTMCFunctionType) typeOpt.get(); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); return type; } @@ -143,12 +139,12 @@ protected ASTMCUnaryFunctionType parseMCFunctionTypeNoParentheses( ) throws IOException { MCFunctionTypesTestParser parser = new MCFunctionTypesTestParser(); Optional typeOpt = parser.parse_StringMCType(mcTypeStr); - Assertions.assertNotNull(typeOpt); - Assertions.assertTrue(typeOpt.isPresent()); - Assertions.assertTrue(typeOpt.get() instanceof ASTMCUnaryFunctionType); + assertNotNull(typeOpt); + assertTrue(typeOpt.isPresent()); + assertInstanceOf(ASTMCUnaryFunctionType.class, typeOpt.get()); ASTMCUnaryFunctionType type = (ASTMCUnaryFunctionType) typeOpt.get(); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); return type; } diff --git a/monticore-grammar/src/test/java/de/monticore/types/MCGenericsTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/MCGenericsTypesTest.java index 30006e392b..ced4284409 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/MCGenericsTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/MCGenericsTypesTest.java @@ -13,7 +13,6 @@ import de.monticore.types.mcfullgenerictypestest._parser.MCFullGenericTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -21,6 +20,8 @@ import java.util.LinkedHashMap; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCGenericsTypesTest { @BeforeEach @@ -45,14 +46,14 @@ public void testBasicGenericsTypes() throws IOException { // .parseType(primitive); Optional type = mcBasicTypesParser.parse_StringMCType(testType); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCObjectType); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCObjectType.class, type.get()); System.out.println(type.get().getClass()); ASTMCObjectType t = (ASTMCObjectType) type.get(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -70,14 +71,14 @@ public void testArrayTypes() throws IOException { Optional type = genericTypesTestParser.parse_StringMCType(testType); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCArrayType); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCArrayType.class, type.get()); ASTMCArrayType t = (ASTMCArrayType) type.get(); - Assertions.assertEquals(2, t.getDimensions()); + assertEquals(2, t.getDimensions()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -86,12 +87,12 @@ public void testMCComplexReferenceTypeValid() throws IOException { MCFullGenericTypesTestMill.init(); MCFullGenericTypesTestParser parser = new MCFullGenericTypesTestParser(); Optional type = parser.parse_StringMCType("java.util.List.Set.some.Collection"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCMultipleGenericType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCMultipleGenericType.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -100,12 +101,12 @@ public void testMcWildcardTypeArgument() throws IOException { MCFullGenericTypesTestMill.init(); MCFullGenericTypesTestParser parser = new MCFullGenericTypesTestParser(); Optional type = parser.parse_StringMCTypeArgument("? extends java.util.Set"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCWildcardTypeArgument); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCWildcardTypeArgument.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -126,19 +127,19 @@ public void testOldComplexArrayTypes() { // checks for (String teststring : testdata.keySet()) { Optional type = parser.parse_StringMCType(teststring); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); // check typing and dimension: - Assertions.assertTrue(type.get() instanceof ASTMCArrayType); + assertInstanceOf(ASTMCArrayType.class, type.get()); ASTMCArrayType arrayType = (ASTMCArrayType) type.get(); - Assertions.assertEquals(testdata.get(teststring).intValue(), arrayType.getDimensions()); - Assertions.assertTrue(arrayType.getMCType() instanceof ASTMCObjectType); + assertEquals(testdata.get(teststring).intValue(), arrayType.getDimensions()); + assertInstanceOf(ASTMCObjectType.class, arrayType.getMCType()); } } catch (IOException e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -184,13 +185,13 @@ public void testOldComplexTypes() throws IOException { Optional type = genericTypesTestParser.parse_StringMCType(testType); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); + assertNotNull(type); + assertTrue(type.isPresent()); //assertTrue(type.get() instanceof ASTMCMultipleGenericType); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/MCSimpleGenericsTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/MCSimpleGenericsTypesTest.java index 86406f2aaa..e75b66af7a 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/MCSimpleGenericsTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/MCSimpleGenericsTypesTest.java @@ -9,13 +9,14 @@ import de.monticore.types.mcsimplegenerictypestest._parser.MCSimpleGenericTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCSimpleGenericsTypesTest { @BeforeEach @@ -36,99 +37,99 @@ public void testCustomGenericsTypes() throws IOException { Optional type = mcBasicTypesParser.parse_StringMCType(testType); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCObjectType); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCObjectType.class, type.get()); System.out.println(type.get().getClass()); ASTMCObjectType t = (ASTMCObjectType) type.get(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCListTypeValid() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCGenericType("List"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCListType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCListType.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCListTypeValid2() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCGenericType("java.util.List"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCBasicGenericType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCBasicGenericType.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCMapTypeValid() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCGenericType("Map"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCMapType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCMapType.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCMapTypeValid2() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCGenericType("java.util.Map, String>"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCBasicGenericType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCBasicGenericType.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCMapTypeValid3() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCGenericType("java.util.HashMap>"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCBasicGenericType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCBasicGenericType.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCOptionalTypeValid() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCGenericType("Optional"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCOptionalType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCOptionalType.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCOptionalTypeValid2() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCGenericType("java.util.Optional>"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCBasicGenericType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCBasicGenericType.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -136,48 +137,48 @@ public void testMCOptionalTypeValid2() throws IOException { public void testMCSetTypeValid() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCGenericType("Set"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCSetType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCSetType.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCSetTypeValid2() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCGenericType("java.util.Set>"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCBasicGenericType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCBasicGenericType.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCTypeArgumentValid() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCTypeArgument("a.b.c"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCBasicTypeArgument); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCBasicTypeArgument.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCTypeArgumentValid2() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCGenericType("List"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isPresent()); - Assertions.assertTrue(type.get() instanceof ASTMCListType); + assertFalse(parser.hasErrors()); + assertNotNull(type); + assertTrue(type.isPresent()); + assertInstanceOf(ASTMCListType.class, type.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -185,8 +186,8 @@ public void testMCComplexReferenceTypeInvalid() throws IOException { //not defined in that grammar, only in MCGenericsTypes MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional type = parser.parse_StringMCType("java.util.List.Set.some.Collection"); - Assertions.assertTrue(parser.hasErrors()); - Assertions.assertFalse(type.isPresent()); + assertTrue(parser.hasErrors()); + assertFalse(type.isPresent()); } @Test @@ -194,12 +195,12 @@ public void testPrintTypeWithoutTypeArguments() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional basicGenericType = parser.parse_StringMCBasicGenericType("a.B"); Optional genericType = parser.parse_StringMCGenericType("a.B"); - Assertions.assertTrue(genericType.isPresent()); - Assertions.assertTrue(basicGenericType.isPresent()); - Assertions.assertEquals("a.B", basicGenericType.get().printWithoutTypeArguments()); - Assertions.assertEquals("a.B", genericType.get().printWithoutTypeArguments()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(genericType.isPresent()); + assertTrue(basicGenericType.isPresent()); + assertEquals("a.B", basicGenericType.get().printWithoutTypeArguments()); + assertEquals("a.B", genericType.get().printWithoutTypeArguments()); + assertFalse(parser.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/MCTypeFacadeTest.java b/monticore-grammar/src/test/java/de/monticore/types/MCTypeFacadeTest.java index 732c1783b1..31bb0fd8a6 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/MCTypeFacadeTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/MCTypeFacadeTest.java @@ -12,10 +12,11 @@ import de.monticore.types.mcsimplegenerictypes._ast.ASTMCBasicGenericType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class MCTypeFacadeTest { private MCTypeFacade mcTypeFacade; @@ -30,339 +31,339 @@ public void init() { @Test public void testCreateQualifiedTypeName() { ASTMCQualifiedType qualifiedType = mcTypeFacade.createQualifiedType("a.b.c.Foo"); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), qualifiedType.getNameList()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), qualifiedType.getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateQualifiedTypeClass() { ASTMCQualifiedType qualifiedType = mcTypeFacade.createQualifiedType(java.lang.String.class); - Assertions.assertEquals(Lists.newArrayList("String"), qualifiedType.getNameList()); + assertEquals(Lists.newArrayList("String"), qualifiedType.getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateBasicTypeArgumentOf() { ASTMCBasicTypeArgument type = mcTypeFacade.createBasicTypeArgumentOf("a.b.c.Foo"); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), type.getMCQualifiedType().getNameList()); - Assertions.assertTrue(type.getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeOpt().get()).getNameList()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), type.getMCQualifiedType().getNameList()); + assertTrue(type.getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateWildCardWithNoBounds() { ASTMCWildcardTypeArgument type = mcTypeFacade.createWildCardWithNoBounds(); - Assertions.assertFalse(type.isPresentLowerBound()); - Assertions.assertFalse(type.isPresentUpperBound()); + assertFalse(type.isPresentLowerBound()); + assertFalse(type.isPresentUpperBound()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateWildCardWithUpperBoundTypeClass() { ASTMCWildcardTypeArgument type = mcTypeFacade.createWildCardWithUpperBoundType(String.class); - Assertions.assertFalse(type.isPresentLowerBound()); - Assertions.assertTrue(type.isPresentUpperBound()); - Assertions.assertTrue(type.getUpperBound() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getUpperBound()).getNameList()); + assertFalse(type.isPresentLowerBound()); + assertTrue(type.isPresentUpperBound()); + assertInstanceOf(ASTMCQualifiedType.class, type.getUpperBound()); + assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getUpperBound()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateWildCardWithUpperBoundTypeName() { ASTMCWildcardTypeArgument type = mcTypeFacade.createWildCardWithUpperBoundType("a.b.c.Foo"); - Assertions.assertFalse(type.isPresentLowerBound()); - Assertions.assertTrue(type.isPresentUpperBound()); - Assertions.assertTrue(type.getUpperBound() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getUpperBound()).getNameList()); + assertFalse(type.isPresentLowerBound()); + assertTrue(type.isPresentUpperBound()); + assertInstanceOf(ASTMCQualifiedType.class, type.getUpperBound()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getUpperBound()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateWildCardWithUpperBoundTypeType() { ASTMCWildcardTypeArgument type = mcTypeFacade.createWildCardWithUpperBoundType(mcTypeFacade.createQualifiedType("a.b.c.Foo")); - Assertions.assertFalse(type.isPresentLowerBound()); - Assertions.assertTrue(type.isPresentUpperBound()); - Assertions.assertTrue(type.getUpperBound() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getUpperBound()).getNameList()); + assertFalse(type.isPresentLowerBound()); + assertTrue(type.isPresentUpperBound()); + assertInstanceOf(ASTMCQualifiedType.class, type.getUpperBound()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getUpperBound()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateOptionalTypeOfClass() { ASTMCOptionalType type = mcTypeFacade.createOptionalTypeOf(String.class); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Optional", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Optional", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateOptionalTypeOfName() { ASTMCOptionalType type = mcTypeFacade.createOptionalTypeOf("a.b.c.Foo"); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Optional", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Optional", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateOptionalTypeOfType() { ASTMCOptionalType type = mcTypeFacade.createOptionalTypeOf(mcTypeFacade.createQualifiedType("a.b.c.Foo")); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Optional", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Optional", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateOptionalTypeOfTypeArgument() { ASTMCOptionalType type = mcTypeFacade.createOptionalTypeOf(mcTypeFacade.createBasicTypeArgumentOf("a.b.c.Foo")); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Optional", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Optional", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateListTypeOfClass() { ASTMCListType type = mcTypeFacade.createListTypeOf(String.class); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("List", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("List", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateListTypeOfName() { ASTMCListType type = mcTypeFacade.createListTypeOf("a.b.c.Foo"); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("List", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("List", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateListTypeOfType() { ASTMCListType type = mcTypeFacade.createListTypeOf(mcTypeFacade.createQualifiedType("a.b.c.Foo")); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("List", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("List", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateListTypeOfTypeArgument() { ASTMCListType type = mcTypeFacade.createListTypeOf(mcTypeFacade.createBasicTypeArgumentOf("a.b.c.Foo")); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("List", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("List", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateSetTypeOfClass() { ASTMCSetType type = mcTypeFacade.createSetTypeOf(String.class); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Set", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Set", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateSetTypeOfName() { ASTMCSetType type = mcTypeFacade.createSetTypeOf("a.b.c.Foo"); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Set", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Set", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateSetTypeOfType() { ASTMCSetType type = mcTypeFacade.createSetTypeOf(mcTypeFacade.createQualifiedType("a.b.c.Foo")); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Set", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Set", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateSetTypeOfTypeArgument() { ASTMCSetType type = mcTypeFacade.createSetTypeOf(mcTypeFacade.createBasicTypeArgumentOf("a.b.c.Foo")); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Set", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Set", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateCollectionTypeOfClass() { ASTMCGenericType type = mcTypeFacade.createCollectionTypeOf(String.class); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Collection", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Collection", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument(0).getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateCollectionTypeOfName() { ASTMCGenericType type = mcTypeFacade.createCollectionTypeOf("a.b.c.Foo"); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Collection", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Collection", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument(0).getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateCollectionTypeOfType() { ASTMCGenericType type = mcTypeFacade.createCollectionTypeOf(mcTypeFacade.createQualifiedType("a.b.c.Foo")); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Collection", type.getName(0)); - Assertions.assertEquals(1, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Collection", type.getName(0)); + assertEquals(1, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument(0).getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateMapTypeOfClass() { ASTMCMapType type = mcTypeFacade.createMapTypeOf(String.class, Integer.class); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Map", type.getName(0)); - Assertions.assertEquals(2, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getKey().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getKey().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getKey().getMCTypeOpt().get()).getNameList()); - - Assertions.assertTrue(type.getValue().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getValue().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("Integer"), ((ASTMCQualifiedType) type.getValue().getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Map", type.getName(0)); + assertEquals(2, type.sizeMCTypeArguments()); + assertTrue(type.getKey().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getKey().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type.getKey().getMCTypeOpt().get()).getNameList()); + + assertTrue(type.getValue().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getValue().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("Integer"), ((ASTMCQualifiedType) type.getValue().getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateMapTypeOfName() { ASTMCMapType type = mcTypeFacade.createMapTypeOf("a.b.c.Foo", "d.e.f.Bla"); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Map", type.getName(0)); - Assertions.assertEquals(2, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getKey().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getKey().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getKey().getMCTypeOpt().get()).getNameList()); - - Assertions.assertTrue(type.getValue().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getValue().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getValue().getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Map", type.getName(0)); + assertEquals(2, type.sizeMCTypeArguments()); + assertTrue(type.getKey().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getKey().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getKey().getMCTypeOpt().get()).getNameList()); + + assertTrue(type.getValue().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getValue().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getValue().getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateMapTypeOfType() { ASTMCMapType type = mcTypeFacade.createMapTypeOf(mcTypeFacade.createQualifiedType("a.b.c.Foo"), mcTypeFacade.createQualifiedType("d.e.f.Bla")); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Map", type.getName(0)); - Assertions.assertEquals(2, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getKey().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getKey().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getKey().getMCTypeOpt().get()).getNameList()); - - Assertions.assertTrue(type.getValue().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getValue().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getValue().getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Map", type.getName(0)); + assertEquals(2, type.sizeMCTypeArguments()); + assertTrue(type.getKey().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getKey().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getKey().getMCTypeOpt().get()).getNameList()); + + assertTrue(type.getValue().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getValue().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getValue().getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateMapTypeOfTypeArgument() { ASTMCMapType type = mcTypeFacade.createMapTypeOf(mcTypeFacade.createBasicTypeArgumentOf("a.b.c.Foo"), mcTypeFacade.createBasicTypeArgumentOf("d.e.f.Bla")); - Assertions.assertEquals(1, type.sizeNames()); - Assertions.assertEquals("Map", type.getName(0)); - Assertions.assertEquals(2, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getKey().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getKey().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getKey().getMCTypeOpt().get()).getNameList()); - - Assertions.assertTrue(type.getValue().getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getValue().getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getValue().getMCTypeOpt().get()).getNameList()); + assertEquals(1, type.sizeNames()); + assertEquals("Map", type.getName(0)); + assertEquals(2, type.sizeMCTypeArguments()); + assertTrue(type.getKey().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getKey().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getKey().getMCTypeOpt().get()).getNameList()); + + assertTrue(type.getValue().getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getValue().getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getValue().getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -373,18 +374,18 @@ public void testCreateBasicGenericTypeOfNameList() { ASTMCBasicGenericType type = mcTypeFacade.createBasicGenericTypeOf( Lists.newArrayList("my", "special", "GenericType"), Lists.newArrayList(basicTypeArgumentOfFoo, basicTypeArgumentOfBla)); - Assertions.assertEquals(3, type.sizeNames()); - Assertions.assertEquals(Lists.newArrayList("my","special","GenericType"), type.getNameList()); - Assertions.assertEquals(2, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - - Assertions.assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getMCTypeArgument(1).getMCTypeOpt().get()).getNameList()); + assertEquals(3, type.sizeNames()); + assertEquals(Lists.newArrayList("my","special","GenericType"), type.getNameList()); + assertEquals(2, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument(0).getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + + assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument(1).getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getMCTypeArgument(1).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -395,18 +396,18 @@ public void testCreateBasicGenericTypeOfArgumentList() { ASTMCBasicGenericType type = mcTypeFacade.createBasicGenericTypeOf( "my.special.GenericType", Lists.newArrayList(basicTypeArgumentOfFoo, basicTypeArgumentOfBla)); - Assertions.assertEquals(3, type.sizeNames()); - Assertions.assertEquals(Lists.newArrayList("my","special","GenericType"), type.getNameList()); - Assertions.assertEquals(2, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - - Assertions.assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getMCTypeArgument(1).getMCTypeOpt().get()).getNameList()); + assertEquals(3, type.sizeNames()); + assertEquals(Lists.newArrayList("my","special","GenericType"), type.getNameList()); + assertEquals(2, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument(0).getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + + assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument(1).getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getMCTypeArgument(1).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -416,108 +417,108 @@ public void testCreateBasicGenericTypeOfArgumentVarArgs() { ASTMCBasicGenericType type = mcTypeFacade.createBasicGenericTypeOf( "my.special.GenericType", basicTypeArgumentOfFoo, basicTypeArgumentOfBla); - Assertions.assertEquals(3, type.sizeNames()); - Assertions.assertEquals(Lists.newArrayList("my","special","GenericType"), type.getNameList()); - Assertions.assertEquals(2, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - - Assertions.assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getMCTypeArgument(1).getMCTypeOpt().get()).getNameList()); + assertEquals(3, type.sizeNames()); + assertEquals(Lists.newArrayList("my","special","GenericType"), type.getNameList()); + assertEquals(2, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument(0).getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + + assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument(1).getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getMCTypeArgument(1).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateBasicGenericTypeOfArgumentString() { ASTMCBasicGenericType type = mcTypeFacade.createBasicGenericTypeOf( "my.special.GenericType", "a.b.c.Foo", "d.e.f.Bla"); - Assertions.assertEquals(3, type.sizeNames()); - Assertions.assertEquals(Lists.newArrayList("my","special","GenericType"), type.getNameList()); - Assertions.assertEquals(2, type.sizeMCTypeArguments()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); - - Assertions.assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().isPresent()); - Assertions.assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().get() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getMCTypeArgument(1).getMCTypeOpt().get()).getNameList()); + assertEquals(3, type.sizeNames()); + assertEquals(Lists.newArrayList("my","special","GenericType"), type.getNameList()); + assertEquals(2, type.sizeMCTypeArguments()); + assertTrue(type.getMCTypeArgument(0).getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument(0).getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("a", "b", "c", "Foo"), ((ASTMCQualifiedType) type.getMCTypeArgument(0).getMCTypeOpt().get()).getNameList()); + + assertTrue(type.getMCTypeArgument(1).getMCTypeOpt().isPresent()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCTypeArgument(1).getMCTypeOpt().get()); + assertEquals(Lists.newArrayList("d", "e", "f", "Bla"), ((ASTMCQualifiedType) type.getMCTypeArgument(1).getMCTypeOpt().get()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateArrayTypeString() { ASTMCArrayType type = mcTypeFacade.createArrayType("int", 3); - Assertions.assertEquals(3, type.getDimensions()); - Assertions.assertTrue(type.getMCType() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("int"), ((ASTMCQualifiedType) type.getMCType()).getNameList()); + assertEquals(3, type.getDimensions()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCType()); + assertEquals(Lists.newArrayList("int"), ((ASTMCQualifiedType) type.getMCType()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateArrayTypeClass() { ASTMCArrayType type = mcTypeFacade.createArrayType(Integer.class, 3); - Assertions.assertEquals(3, type.getDimensions()); - Assertions.assertTrue(type.getMCType() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("Integer"), ((ASTMCQualifiedType) type.getMCType()).getNameList()); + assertEquals(3, type.getDimensions()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCType()); + assertEquals(Lists.newArrayList("Integer"), ((ASTMCQualifiedType) type.getMCType()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateArrayTypeType() { ASTMCArrayType type = mcTypeFacade.createArrayType(mcTypeFacade.createQualifiedType("int"), 3); - Assertions.assertEquals(3, type.getDimensions()); - Assertions.assertTrue(type.getMCType() instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("int"), ((ASTMCQualifiedType) type.getMCType()).getNameList()); + assertEquals(3, type.getDimensions()); + assertInstanceOf(ASTMCQualifiedType.class, type.getMCType()); + assertEquals(Lists.newArrayList("int"), ((ASTMCQualifiedType) type.getMCType()).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateVoidType() { ASTMCVoidType type = mcTypeFacade.createVoidType(); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateBooleanType() { ASTMCPrimitiveType type = mcTypeFacade.createBooleanType(); - Assertions.assertTrue(type.isBoolean()); + assertTrue(type.isBoolean()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testIsBooleanType() { ASTMCPrimitiveType booleanType = mcTypeFacade.createBooleanType(); - Assertions.assertTrue(mcTypeFacade.isBooleanType(booleanType)); + assertTrue(mcTypeFacade.isBooleanType(booleanType)); ASTMCType stringType = mcTypeFacade.createStringType(); - Assertions.assertFalse(mcTypeFacade.isBooleanType(stringType)); + assertFalse(mcTypeFacade.isBooleanType(stringType)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreateIntType() { ASTMCPrimitiveType type = mcTypeFacade.createIntType(); - Assertions.assertTrue(type.isInt()); + assertTrue(type.isInt()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCreatePrimitiveType() { ASTMCType type = mcTypeFacade.createStringType(); - Assertions.assertTrue(type instanceof ASTMCQualifiedType); - Assertions.assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type).getNameList()); + assertInstanceOf(ASTMCQualifiedType.class, type); + assertEquals(Lists.newArrayList("String"), ((ASTMCQualifiedType) type).getNameList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/MCollectionTypesCorrectStateTest.java b/monticore-grammar/src/test/java/de/monticore/types/MCollectionTypesCorrectStateTest.java index ab70981f2a..c565f07a44 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/MCollectionTypesCorrectStateTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/MCollectionTypesCorrectStateTest.java @@ -9,13 +9,14 @@ import de.monticore.types.mccollectiontypeswithoutprimitivestest._parser.MCCollectionTypesWithoutPrimitivesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCollectionTypesCorrectStateTest { private ASTMCListType listTypeParser; @@ -40,23 +41,23 @@ public void init() { public void setUp() throws IOException { MCCollectionTypesWithoutPrimitivesTestParser parser = new MCCollectionTypesWithoutPrimitivesTestParser(); Optional listTypeParser = parser.parse_StringMCListType("List"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(listTypeParser.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(listTypeParser.isPresent()); this.listTypeParser = listTypeParser.get(); Optional optionalTypeParser = parser.parse_StringMCOptionalType("Optional"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(optionalTypeParser.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(optionalTypeParser.isPresent()); this.optTypeParser = optionalTypeParser.get(); Optional setType = parser.parse_StringMCSetType("Set"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(setType.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(setType.isPresent()); this.setTypeParser = setType.get(); Optional mapType = parser.parse_StringMCMapType("Map"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(mapType.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(mapType.isPresent()); this.mapTypeParser = mapType.get(); @@ -68,64 +69,64 @@ public void setUp() throws IOException { ASTMCQualifiedType stringType = MCCollectionTypesMill.mCQualifiedTypeBuilder().setMCQualifiedName(stringName).build(); typeArgumentString = MCCollectionTypesMill.mCBasicTypeArgumentBuilder().setMCQualifiedType(stringType).build(); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void mCListTypeNameListFinal() { // test that MCListType only contains one element 'List' - Assertions.assertEquals(1, listTypeParser.getNameList().size()); - Assertions.assertEquals("List", listTypeParser.getName(0)); + assertEquals(1, listTypeParser.getNameList().size()); + assertEquals("List", listTypeParser.getName(0)); // set name over getter listTypeParser.getNameList().set(0, "Foo"); - Assertions.assertEquals(1, listTypeParser.getNameList().size()); - Assertions.assertEquals("List", listTypeParser.getName(0)); + assertEquals(1, listTypeParser.getNameList().size()); + assertEquals("List", listTypeParser.getName(0)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void mCOptionalTypeNameListFinal() { // test that MCListType only contains one element 'Optional' - Assertions.assertEquals(1, optTypeParser.getNameList().size()); - Assertions.assertEquals("Optional", optTypeParser.getName(0)); + assertEquals(1, optTypeParser.getNameList().size()); + assertEquals("Optional", optTypeParser.getName(0)); // set name over getter optTypeParser.getNameList().set(0, "Foo"); - Assertions.assertEquals(1, optTypeParser.getNameList().size()); - Assertions.assertEquals("Optional", optTypeParser.getName(0)); + assertEquals(1, optTypeParser.getNameList().size()); + assertEquals("Optional", optTypeParser.getName(0)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void mCSetTypeNameListFinal() { // test that MCListType only contains one element 'Set' - Assertions.assertEquals(1, setTypeParser.getNameList().size()); - Assertions.assertEquals("Set", setTypeParser.getName(0)); + assertEquals(1, setTypeParser.getNameList().size()); + assertEquals("Set", setTypeParser.getName(0)); // set name over getter setTypeParser.getNameList().set(0, "Foo"); - Assertions.assertEquals(1, setTypeParser.getNameList().size()); - Assertions.assertEquals("Set", setTypeParser.getName(0)); + assertEquals(1, setTypeParser.getNameList().size()); + assertEquals("Set", setTypeParser.getName(0)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void mCMapTypeNameListFinal() throws IOException { // test that MCListType only contains one element 'Map' - Assertions.assertEquals(1, mapTypeParser.getNameList().size()); - Assertions.assertEquals("Map", mapTypeParser.getName(0)); + assertEquals(1, mapTypeParser.getNameList().size()); + assertEquals("Map", mapTypeParser.getName(0)); // set name over getter mapTypeParser.getNameList().set(0, "Foo"); - Assertions.assertEquals(1, mapTypeParser.getNameList().size()); - Assertions.assertEquals("Map", mapTypeParser.getName(0)); + assertEquals(1, mapTypeParser.getNameList().size()); + assertEquals("Map", mapTypeParser.getName(0)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -134,10 +135,10 @@ public void mCListTypeNameListFinalFromBuilder() { ASTMCListType listBuild = MCCollectionTypesMill.mCListTypeBuilder() .setMCTypeArgument(typeArgumentInt) .build(); - Assertions.assertEquals(1, listBuild.getNameList().size()); - Assertions.assertEquals("List", listBuild.getName(0)); + assertEquals(1, listBuild.getNameList().size()); + assertEquals("List", listBuild.getName(0)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -146,10 +147,10 @@ public void mCOptionalTypeNameListFinalFromBuilder() { ASTMCOptionalType optBuild = MCCollectionTypesMill.mCOptionalTypeBuilder() .setMCTypeArgument(typeArgumentInt) .build(); - Assertions.assertEquals(1, optBuild.getNameList().size()); - Assertions.assertEquals("Optional", optBuild.getName(0)); + assertEquals(1, optBuild.getNameList().size()); + assertEquals("Optional", optBuild.getName(0)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -158,10 +159,10 @@ public void mCSetTypeNameListFinalFromBuilder() { ASTMCSetType setBuild = MCCollectionTypesMill.mCSetTypeBuilder() .setMCTypeArgument(typeArgumentInt) .build(); - Assertions.assertEquals(1, setBuild.getNameList().size()); - Assertions.assertEquals("Set", setBuild.getName(0)); + assertEquals(1, setBuild.getNameList().size()); + assertEquals("Set", setBuild.getName(0)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -171,40 +172,40 @@ public void mCMapTypeNameListFinalFromBuilder() { .setKey(typeArgumentInt) .setValue(typeArgumentString) .build(); - Assertions.assertEquals(1, mapBuildNoName.getNameList().size()); - Assertions.assertEquals("Map", mapBuildNoName.getName(0)); + assertEquals(1, mapBuildNoName.getNameList().size()); + assertEquals("Map", mapBuildNoName.getName(0)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void mCListTypeSetTypeArgument() { listTypeParser.setMCTypeArgument(typeArgumentString); - Assertions.assertEquals(1, listTypeParser.getMCTypeArgumentList().size()); - Assertions.assertEquals("String", listTypeParser.getMCTypeArgument().printType()); + assertEquals(1, listTypeParser.getMCTypeArgumentList().size()); + assertEquals("String", listTypeParser.getMCTypeArgument().printType()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void mcOptionalTypeSetTypeArgument() { optTypeParser.setMCTypeArgument(typeArgumentString); - Assertions.assertEquals(1, optTypeParser.getMCTypeArgumentList().size()); - Assertions.assertEquals("String", optTypeParser.getMCTypeArgument().printType()); + assertEquals(1, optTypeParser.getMCTypeArgumentList().size()); + assertEquals("String", optTypeParser.getMCTypeArgument().printType()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void mcMapTypeSetKey() { mapTypeParser.setKey(typeArgumentString); - Assertions.assertEquals(2, mapTypeParser.getMCTypeArgumentList().size()); - Assertions.assertEquals("String", mapTypeParser.getKey().printType()); - Assertions.assertEquals("Integer", mapTypeParser.getValue().printType()); + assertEquals(2, mapTypeParser.getMCTypeArgumentList().size()); + assertEquals("String", mapTypeParser.getKey().printType()); + assertEquals("Integer", mapTypeParser.getValue().printType()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/AbstractDeriveTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/AbstractDeriveTest.java index d1c5e6bcc2..30756f853a 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/AbstractDeriveTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/AbstractDeriveTest.java @@ -14,7 +14,6 @@ import de.monticore.symbols.basicsymbols._symboltable.VariableSymbol; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -22,8 +21,8 @@ import java.util.Optional; import static de.monticore.types.check.DefsTypeBasic.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class AbstractDeriveTest { @@ -130,56 +129,56 @@ public AbstractTypeCheckTestTraverser getTraverser(FlatExpressionScopeSetter fla @Test public void testFieldAccessInnerVariables() throws IOException { Optional expr = p.parse_StringExpression("person1.bar"); - Assertions.assertTrue(expr.isPresent()); + assertTrue(expr.isPresent()); expr.get().accept(traverser); - Assertions.assertEquals("int", tc.typeOf(expr.get()).print()); + assertEquals("int", tc.typeOf(expr.get()).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testFieldAccessInnerTypes() throws IOException { Optional expr = p.parse_StringExpression("person1.Address"); - Assertions.assertTrue(expr.isPresent()); + assertTrue(expr.isPresent()); expr.get().accept(traverser); - Assertions.assertEquals("Address", tc.typeOf(expr.get()).print()); + assertEquals("Address", tc.typeOf(expr.get()).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testCallInnerMethods() throws IOException { Optional expr = p.parse_StringExpression("person1.foo()"); - Assertions.assertTrue(expr.isPresent()); + assertTrue(expr.isPresent()); expr.get().accept(traverser); - Assertions.assertEquals("void", tc.typeOf(expr.get()).print()); + assertEquals("void", tc.typeOf(expr.get()).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInheritanceVariables() throws IOException { Optional expr = p.parse_StringExpression("firstsemester.bar"); - Assertions.assertTrue(expr.isPresent()); + assertTrue(expr.isPresent()); expr.get().accept(traverser); - Assertions.assertEquals("int", tc.typeOf(expr.get()).print()); + assertEquals("int", tc.typeOf(expr.get()).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInheritanceMethods() throws IOException { Optional expr = p.parse_StringExpression("firstsemester.foo()"); - Assertions.assertTrue(expr.isPresent()); + assertTrue(expr.isPresent()); expr.get().accept(traverser); - Assertions.assertEquals("void", tc.typeOf(expr.get()).print()); + assertEquals("void", tc.typeOf(expr.get()).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/CompKindOfComponentTypeTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/CompKindOfComponentTypeTest.java index f07a60b420..aef2fbcce6 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/CompKindOfComponentTypeTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/CompKindOfComponentTypeTest.java @@ -6,7 +6,6 @@ import de.monticore.symbols.compsymbols.CompSymbolsMill; import de.monticore.symbols.compsymbols._symboltable.ComponentTypeSymbol; import de.monticore.symbols.compsymbols._symboltable.PortSymbol; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -14,6 +13,8 @@ import java.util.List; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + /** * Holds test for {@link CompKindOfComponentType} */ @@ -38,12 +39,12 @@ void testDeepClone() { CompKindOfComponentType clone = comp.deepClone().asComponentType(); // Then - Assertions.assertEquals(comp.getTypeInfo(), clone.getTypeInfo()); - Assertions.assertNotSame(comp.getArguments(), clone.getArguments()); - Assertions.assertIterableEquals(comp.getArguments(), clone.getArguments()); - Assertions.assertNotSame(comp.getParamBindings(), clone.getParamBindings()); - Assertions.assertIterableEquals(comp.getParamBindingsAsList(), clone.getParamBindingsAsList()); - Assertions.assertEquals(comp.getSourceNode().isPresent(), clone.getSourceNode().isPresent()); + assertEquals(comp.getTypeInfo(), clone.getTypeInfo()); + assertNotSame(comp.getArguments(), clone.getArguments()); + assertIterableEquals(comp.getArguments(), clone.getArguments()); + assertNotSame(comp.getParamBindings(), clone.getParamBindings()); + assertIterableEquals(comp.getParamBindingsAsList(), clone.getParamBindingsAsList()); + assertEquals(comp.getSourceNode().isPresent(), clone.getSourceNode().isPresent()); } /** @@ -80,8 +81,8 @@ public void getParentShouldReturnExpected() { List parentOfTypeExpr = compTypeExpr.getSuperComponents(); // Then - Assertions.assertFalse(parentOfTypeExpr.isEmpty(), "Parent not present."); - Assertions.assertEquals(parentTypeExpr, parentOfTypeExpr.get(0)); + assertFalse(parentOfTypeExpr.isEmpty(), "Parent not present."); + assertEquals(parentTypeExpr, parentOfTypeExpr.get(0)); } /** @@ -100,7 +101,7 @@ public void getParentShouldReturnOptionalEmpty() { List parentOfTypeExpr = compTypeExpr.getSuperComponents(); // Then - Assertions.assertTrue(parentOfTypeExpr.isEmpty()); + assertTrue(parentOfTypeExpr.isEmpty()); } @Test @@ -135,9 +136,9 @@ public void shouldGetTypeExprOfPort() { Optional portsType = compTypeExpr.getTypeOfPort(portName); // Then - Assertions.assertTrue(portsType.isPresent(), "Port not present"); - Assertions.assertInstanceOf(SymTypePrimitive.class, portsType.get()); - Assertions.assertEquals(BasicSymbolsMill.INT, portsType.get().print()); + assertTrue(portsType.isPresent(), "Port not present"); + assertInstanceOf(SymTypePrimitive.class, portsType.get()); + assertEquals(BasicSymbolsMill.INT, portsType.get().print()); } @Test @@ -167,9 +168,9 @@ public void shouldGetTypeExprOfInheritedPort() { Optional portsType = compTypeExpr.getTypeOfPort(portName); // Then - Assertions.assertTrue(portsType.isPresent()); - Assertions.assertTrue(portsType.get() instanceof SymTypePrimitive); - Assertions.assertEquals(BasicSymbolsMill.INT, portsType.get().print()); + assertTrue(portsType.isPresent()); + assertTrue(portsType.get() instanceof SymTypePrimitive); + assertEquals(BasicSymbolsMill.INT, portsType.get().print()); } @Test @@ -204,8 +205,8 @@ public void shouldGetTypeExprOfParameter() { Optional paramType = compTypeExpr.getTypeOfParameter(paramName); // Then - Assertions.assertTrue(paramType.isPresent(), "Param not present"); - Assertions.assertInstanceOf(SymTypePrimitive.class, paramType.get()); - Assertions.assertEquals(BasicSymbolsMill.INT, paramType.get().print()); + assertTrue(paramType.isPresent(), "Param not present"); + assertInstanceOf(SymTypePrimitive.class, paramType.get()); + assertEquals(BasicSymbolsMill.INT, paramType.get().print()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/CompKindOfGenericComponentTypeTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/CompKindOfGenericComponentTypeTest.java index 3ccc0b6e22..4c72123b65 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/CompKindOfGenericComponentTypeTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/CompKindOfGenericComponentTypeTest.java @@ -11,7 +11,6 @@ import de.monticore.symbols.compsymbols._symboltable.ComponentTypeSymbolSurrogate; import de.monticore.symbols.compsymbols._symboltable.PortSymbol; import org.checkerframework.checker.nullness.qual.NonNull; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Named; import org.junit.jupiter.api.Test; @@ -25,6 +24,8 @@ import java.util.Optional; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.*; + /** * Holds test for {@link CompKindOfGenericComponentType} */ @@ -50,13 +51,13 @@ void testDeepClone() { CompKindOfGenericComponentType clone = comp.deepClone().asGenericComponentType(); // Then - Assertions.assertEquals(comp.getTypeInfo(), clone.getTypeInfo()); - Assertions.assertNotSame(comp.getArguments(), clone.getArguments()); - Assertions.assertIterableEquals(comp.getArguments(), clone.getArguments()); - Assertions.assertNotSame(comp.getParamBindings(), clone.getParamBindings()); - Assertions.assertIterableEquals(comp.getParamBindingsAsList(), clone.getParamBindingsAsList()); - Assertions.assertEquals(comp.getSourceNode().isPresent(), clone.getSourceNode().isPresent()); - Assertions.assertNotSame(comp.getTypeBindingsAsList(), clone.getTypeBindingsAsList()); + assertEquals(comp.getTypeInfo(), clone.getTypeInfo()); + assertNotSame(comp.getArguments(), clone.getArguments()); + assertIterableEquals(comp.getArguments(), clone.getArguments()); + assertNotSame(comp.getParamBindings(), clone.getParamBindings()); + assertIterableEquals(comp.getParamBindingsAsList(), clone.getParamBindingsAsList()); + assertEquals(comp.getSourceNode().isPresent(), clone.getSourceNode().isPresent()); + assertNotSame(comp.getTypeBindingsAsList(), clone.getTypeBindingsAsList()); } @Test @@ -76,8 +77,8 @@ public void shouldGetParentComponent() { CompKindOfComponentType compTypeExpr = new CompKindOfComponentType(component); // When && Then - Assertions.assertFalse(compTypeExpr.getSuperComponents().isEmpty()); - Assertions.assertEquals(parentTypeExpr, compTypeExpr.getSuperComponents().get(0)); + assertFalse(compTypeExpr.getSuperComponents().isEmpty()); + assertEquals(parentTypeExpr, compTypeExpr.getSuperComponents().get(0)); } @Test @@ -96,10 +97,10 @@ public void shouldGetParentWithTypeVarPrimitive() { CompKindOfGenericComponentType bParent = ((CompKindOfGenericComponentType) bChild.getSuperComponents().get(0)); // Then - Assertions.assertSame(parent, bParent.getTypeInfo()); - Assertions.assertInstanceOf(CompKindOfGenericComponentType.class, bParent); - Assertions.assertTrue(bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).isPresent()); - Assertions.assertEquals(typeArg, bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).get()); + assertSame(parent, bParent.getTypeInfo()); + assertInstanceOf(CompKindOfGenericComponentType.class, bParent); + assertTrue(bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).isPresent()); + assertEquals(typeArg, bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).get()); } @Test @@ -123,10 +124,10 @@ public void shouldGetParentWithTypeVarObject() { CompKindOfGenericComponentType bParent = ((CompKindOfGenericComponentType) bChild.getSuperComponents().get(0)); // Then - Assertions.assertSame(parent, bParent.getTypeInfo()); - Assertions.assertInstanceOf(CompKindOfGenericComponentType.class, bParent); - Assertions.assertTrue(bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).isPresent()); - Assertions.assertEquals(typeArg, bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).get()); + assertSame(parent, bParent.getTypeInfo()); + assertInstanceOf(CompKindOfGenericComponentType.class, bParent); + assertTrue(bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).isPresent()); + assertEquals(typeArg, bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).get()); } @Test @@ -155,12 +156,12 @@ public void shouldGetParentWithTypeVarObjects() { CompKindOfGenericComponentType bParent = ((CompKindOfGenericComponentType) bChild.getSuperComponents().get(0)); // Then - Assertions.assertSame(parent, bParent.getTypeInfo()); - Assertions.assertInstanceOf(CompKindOfGenericComponentType.class, bParent); - Assertions.assertTrue(bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).isPresent()); - Assertions.assertEquals(typeArg1, bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).get()); - Assertions.assertTrue(bParent.getTypeBindingFor(parent.getTypeParameters().get(1)).isPresent()); - Assertions.assertEquals(typeArg2, bParent.getTypeBindingFor(parent.getTypeParameters().get(1)).get()); + assertSame(parent, bParent.getTypeInfo()); + assertInstanceOf(CompKindOfGenericComponentType.class, bParent); + assertTrue(bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).isPresent()); + assertEquals(typeArg1, bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).get()); + assertTrue(bParent.getTypeBindingFor(parent.getTypeParameters().get(1)).isPresent()); + assertEquals(typeArg2, bParent.getTypeBindingFor(parent.getTypeParameters().get(1)).get()); } @Test @@ -180,10 +181,10 @@ public void shouldGetParentWithTypeVar() { CompKindOfGenericComponentType bParent = ((CompKindOfGenericComponentType) bChild.getSuperComponents().get(0)); // Then - Assertions.assertSame(parent, bParent.getTypeInfo()); - Assertions.assertInstanceOf(CompKindOfGenericComponentType.class, bParent); - Assertions.assertTrue(bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).isPresent()); - Assertions.assertEquals(typeArg, bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).get()); + assertSame(parent, bParent.getTypeInfo()); + assertInstanceOf(CompKindOfGenericComponentType.class, bParent); + assertTrue(bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).isPresent()); + assertEquals(typeArg, bParent.getTypeBindingFor(parent.getTypeParameters().get(0)).get()); } protected static Stream compWithTypeParamAndOptionallySurrogateProvider() { @@ -237,9 +238,9 @@ public void shouldGetTypeExprOfPortWithOwnTypeVarReplaced(@NonNull ComponentType Optional portsType = boundCompTypeExpr.getTypeOfPort(portName); // Then - Assertions.assertTrue(portsType.isPresent(), "Port missing"); - Assertions.assertInstanceOf(SymTypePrimitive.class, portsType.get()); - Assertions.assertEquals(BasicSymbolsMill.INT, portsType.get().print()); + assertTrue(portsType.isPresent(), "Port missing"); + assertInstanceOf(SymTypePrimitive.class, portsType.get()); + assertEquals(BasicSymbolsMill.INT, portsType.get().print()); } @Test @@ -272,9 +273,9 @@ public void shouldGetTypeExprOfPortWithParentTypeVarReplaced() { Optional portsType = boundCompTypeExpr.getTypeOfPort(portName); // Then - Assertions.assertTrue(portsType.isPresent()); - Assertions.assertTrue(portsType.get() instanceof SymTypePrimitive); - Assertions.assertEquals(BasicSymbolsMill.INT, portsType.get().print()); + assertTrue(portsType.isPresent()); + assertTrue(portsType.get() instanceof SymTypePrimitive); + assertEquals(BasicSymbolsMill.INT, portsType.get().print()); } /** @@ -312,9 +313,9 @@ public void shouldGetTypeExprOfParameterWithOwnTypeVarReplaced(@NonNull Componen Optional paramTypeExpr = boundCompTypeExpr.getTypeOfParameter(paramName); // Then - Assertions.assertTrue(paramTypeExpr.isPresent(), "param missing"); - Assertions.assertInstanceOf(SymTypePrimitive.class, paramTypeExpr.get()); - Assertions.assertEquals(BasicSymbolsMill.INT, paramTypeExpr.get().print()); + assertTrue(paramTypeExpr.isPresent(), "param missing"); + assertInstanceOf(SymTypePrimitive.class, paramTypeExpr.get()); + assertEquals(BasicSymbolsMill.INT, paramTypeExpr.get().print()); } @Test @@ -353,9 +354,9 @@ public void shouldGetTypeExprOfParameterWithParentTypeVarReplaced() { Optional paramTypeExpr = boundCompTypeExpr.getTypeOfParameter(name); // Then - Assertions.assertTrue(paramTypeExpr.isPresent()); - Assertions.assertTrue(paramTypeExpr.get() instanceof SymTypePrimitive); - Assertions.assertEquals(BasicSymbolsMill.INT, paramTypeExpr.get().print()); + assertTrue(paramTypeExpr.isPresent()); + assertTrue(paramTypeExpr.get() instanceof SymTypePrimitive); + assertEquals(BasicSymbolsMill.INT, paramTypeExpr.get().print()); } @Test @@ -373,7 +374,7 @@ public void shouldGetBindingsAsListInCorrectOrder() { // Then List returnedBindings = compTypeExpr.getTypeBindingsAsList(); - Assertions.assertEquals(typeExprList, returnedBindings); + assertEquals(typeExprList, returnedBindings); } @Test @@ -397,11 +398,11 @@ public void shouldGetTypeParamBindingsSkippingSurrogate() { CompKindOfGenericComponentType compTypeExpr = new CompKindOfGenericComponentType(compSurrogate, typeExprList); // Then - Assertions.assertAll( - () -> Assertions.assertEquals(floatTypeExpr, compTypeExpr.getTypeBindingFor("A").orElseThrow()), - () -> Assertions.assertEquals(intTypeExpr, compTypeExpr.getTypeBindingFor("B").orElseThrow()), - () -> Assertions.assertEquals(boolTypeExpr, compTypeExpr.getTypeBindingFor("C").orElseThrow()), - () -> Assertions.assertEquals(3, compTypeExpr.getTypeVarBindings().size()) + assertAll( + () -> assertEquals(floatTypeExpr, compTypeExpr.getTypeBindingFor("A").orElseThrow()), + () -> assertEquals(intTypeExpr, compTypeExpr.getTypeBindingFor("B").orElseThrow()), + () -> assertEquals(boolTypeExpr, compTypeExpr.getTypeBindingFor("C").orElseThrow()), + () -> assertEquals(3, compTypeExpr.getTypeVarBindings().size()) ); } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/DefiningSymbolsTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/DefiningSymbolsTest.java index 0ac3108de5..bd3183d824 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/DefiningSymbolsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/DefiningSymbolsTest.java @@ -21,15 +21,13 @@ import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class DefiningSymbolsTest { @@ -73,99 +71,100 @@ public void init() { @Test public void testQualified() throws IOException { Optional expr = p.parse_StringExpression("ListOfInt.e"); - Assertions.assertTrue(expr.isPresent()); - Assertions.assertTrue(expr.get() instanceof ASTFieldAccessExpression); + assertTrue(expr.isPresent()); + assertInstanceOf(ASTFieldAccessExpression.class, expr.get()); ASTFieldAccessExpression e = (ASTFieldAccessExpression) expr.get(); e.accept(getFlatExpressionScopeSetter(as)); TypeCalculator tc = new TypeCalculator(null, deriver); tc.typeOf(e); - Assertions.assertTrue(e.getDefiningSymbol().isPresent()); + assertTrue(e.getDefiningSymbol().isPresent()); ISymbol definingSymbol = e.getDefiningSymbol().get(); - Assertions.assertTrue(definingSymbol instanceof FieldSymbol); - Assertions.assertEquals("e", definingSymbol.getName()); - - Assertions.assertTrue(e.getExpression() instanceof ASTNameExpression); + assertInstanceOf(FieldSymbol.class, definingSymbol); + assertEquals("e", definingSymbol.getName()); + + assertInstanceOf(ASTNameExpression.class, e.getExpression()); ASTNameExpression listOfInt = (ASTNameExpression) e.getExpression(); - Assertions.assertTrue(listOfInt.getDefiningSymbol().isPresent()); - Assertions.assertEquals(listOfInt.getDefiningSymbol().get(), this.listOfInt); + assertTrue(listOfInt.getDefiningSymbol().isPresent()); + assertEquals(listOfInt.getDefiningSymbol().get(), this.listOfInt); expr = p.parse_StringExpression("ListOfInt.add(3)"); - Assertions.assertTrue(expr.isPresent()); - Assertions.assertTrue(expr.get() instanceof ASTCallExpression); + assertTrue(expr.isPresent()); + assertInstanceOf(ASTCallExpression.class, expr.get()); ASTCallExpression add = (ASTCallExpression) expr.get(); add.accept(getFlatExpressionScopeSetter(as)); tc.typeOf(add); - Assertions.assertTrue(add.getDefiningSymbol().isPresent()); + assertTrue(add.getDefiningSymbol().isPresent()); definingSymbol = add.getDefiningSymbol().get(); - Assertions.assertTrue(definingSymbol instanceof MethodSymbol); - Assertions.assertEquals("add", definingSymbol.getName()); - - Assertions.assertTrue(add.getExpression() instanceof ASTFieldAccessExpression); - Assertions.assertTrue(((ASTFieldAccessExpression) add.getExpression()).getExpression() instanceof ASTNameExpression); + assertInstanceOf(MethodSymbol.class, definingSymbol); + assertEquals("add", definingSymbol.getName()); + + assertInstanceOf(ASTFieldAccessExpression.class, add.getExpression()); + assertInstanceOf(ASTNameExpression.class, + ((ASTFieldAccessExpression) add.getExpression()).getExpression()); listOfInt = (ASTNameExpression) ((ASTFieldAccessExpression) add.getExpression()).getExpression(); - Assertions.assertTrue(listOfInt.getDefiningSymbol().isPresent()); - Assertions.assertEquals(listOfInt.getDefiningSymbol().get(), this.listOfInt); + assertTrue(listOfInt.getDefiningSymbol().isPresent()); + assertEquals(listOfInt.getDefiningSymbol().get(), this.listOfInt); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testUnqualified() throws IOException { Optional expr = p.parse_StringExpression("e"); - Assertions.assertTrue(expr.isPresent()); - Assertions.assertTrue(expr.get() instanceof ASTNameExpression); + assertTrue(expr.isPresent()); + assertInstanceOf(ASTNameExpression.class, expr.get()); ASTNameExpression e = (ASTNameExpression) expr.get(); e.accept(getFlatExpressionScopeSetter(typeScope)); TypeCalculator tc = new TypeCalculator(null, deriver); tc.typeOf(e); - Assertions.assertTrue(e.getDefiningSymbol().isPresent()); + assertTrue(e.getDefiningSymbol().isPresent()); ISymbol definingSymbol = e.getDefiningSymbol().get(); - Assertions.assertTrue(definingSymbol instanceof FieldSymbol); - Assertions.assertEquals("e", definingSymbol.getName()); + assertInstanceOf(FieldSymbol.class, definingSymbol); + assertEquals("e", definingSymbol.getName()); expr = p.parse_StringExpression("add(3)"); - Assertions.assertTrue(expr.isPresent()); - Assertions.assertTrue(expr.get() instanceof ASTCallExpression); + assertTrue(expr.isPresent()); + assertInstanceOf(ASTCallExpression.class, expr.get()); ASTCallExpression add = (ASTCallExpression) expr.get(); add.accept(getFlatExpressionScopeSetter(typeScope)); tc.typeOf(add); - Assertions.assertTrue(add.getDefiningSymbol().isPresent()); + assertTrue(add.getDefiningSymbol().isPresent()); definingSymbol = add.getDefiningSymbol().get(); - Assertions.assertTrue(definingSymbol instanceof MethodSymbol); - Assertions.assertEquals("add", definingSymbol.getName()); + assertInstanceOf(MethodSymbol.class, definingSymbol); + assertEquals("add", definingSymbol.getName()); expr = p.parse_StringExpression("ListOfInt"); - Assertions.assertTrue(expr.isPresent()); - Assertions.assertTrue(expr.get() instanceof ASTNameExpression); + assertTrue(expr.isPresent()); + assertInstanceOf(ASTNameExpression.class, expr.get()); ASTNameExpression listOfInt = (ASTNameExpression) expr.get(); listOfInt.accept(getFlatExpressionScopeSetter(as)); tc.typeOf(listOfInt); - Assertions.assertTrue(listOfInt.getDefiningSymbol().isPresent()); - Assertions.assertEquals(listOfInt.getDefiningSymbol().get(), this.listOfInt); + assertTrue(listOfInt.getDefiningSymbol().isPresent()); + assertEquals(listOfInt.getDefiningSymbol().get(), this.listOfInt); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testTypes() throws IOException { Optional type = as.resolveType("int"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); Optional intType = p.parse_StringMCType("int"); - Assertions.assertTrue(intType.isPresent()); + assertTrue(intType.isPresent()); intType.get().accept(getFlatExpressionScopeSetter(as)); TypeCalculator tc = new TypeCalculator(synthesizer, null); tc.symTypeFromAST(intType.get()); - Assertions.assertTrue(intType.get().getDefiningSymbol().isPresent()); - Assertions.assertEquals(intType.get().getDefiningSymbol().get(), type.get()); + assertTrue(intType.get().getDefiningSymbol().isPresent()); + assertEquals(intType.get().getDefiningSymbol().get(), type.get()); Optional listOfIntType = p.parse_StringMCType("ListOfInt"); - Assertions.assertTrue(listOfIntType.isPresent()); + assertTrue(listOfIntType.isPresent()); listOfIntType.get().accept(getFlatExpressionScopeSetter(as)); tc.symTypeFromAST(listOfIntType.get()); - Assertions.assertTrue(listOfIntType.get().getDefiningSymbol().isPresent()); - Assertions.assertEquals(listOfIntType.get().getDefiningSymbol().get(), this.listOfInt); + assertTrue(listOfIntType.get().getDefiningSymbol().isPresent()); + assertEquals(listOfIntType.get().getDefiningSymbol().get(), this.listOfInt); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } protected CombineExpressionsWithLiteralsTraverser getFlatExpressionScopeSetter(IExpressionsBasisScope scope){ diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeAbstractTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeAbstractTest.java index 98f25697f0..ccd1c9f744 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeAbstractTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeAbstractTest.java @@ -17,7 +17,6 @@ import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import java.io.IOException; @@ -26,6 +25,8 @@ import java.util.Optional; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.*; + public abstract class DeriveSymTypeAbstractTest { @BeforeEach @@ -55,7 +56,7 @@ protected TypeCalculator getTypeCalculator() { protected ASTExpression parseExpression(String expression) throws IOException { Optional astExpression = parseStringExpression(expression); - Assertions.assertTrue(astExpression.isPresent()); + assertTrue(astExpression.isPresent()); return astExpression.get(); } @@ -77,7 +78,7 @@ protected final void check(String expression, String expectedType) throws IOExce ASTExpression astex = parseExpression(expression); setFlatExpressionScope(astex); - Assertions.assertEquals(expectedType, tc.typeOf(astex).print(), "Wrong return type for expression " + expression); + assertEquals(expectedType, tc.typeOf(astex).print(), "Wrong return type for expression " + expression); } protected final void checkError(String expression, String expectedError) throws IOException { @@ -88,10 +89,10 @@ protected final void checkError(String expression, String expectedError) throws Log.getFindings().clear(); try { SymTypeExpression result = tc.typeOf(astex); - Assertions.assertTrue(result.isObscureType()); - Assertions.assertEquals(expectedError, getFirstErrorCode()); + assertTrue(result.isObscureType()); + assertEquals(expectedError, getFirstErrorCode()); } catch (RuntimeException e) { - Assertions.assertEquals(expectedError, getFirstErrorCode()); + assertEquals(expectedError, getFirstErrorCode()); } } @@ -104,10 +105,10 @@ protected final void checkErrors(String expression, List expectedErrors) try { tc.typeOf(astex); } catch (RuntimeException e) { - Assertions.assertEquals(expectedErrors, getAllErrorCodes()); + assertEquals(expectedErrors, getAllErrorCodes()); return; } - Assertions.fail(); + fail(); } protected final void checkErrors(String expression, String... expectedErrors) throws IOException { @@ -125,14 +126,14 @@ protected final void checkErrorsAndFailOnException(String expression, List sType = p.parse_StringExpression("C.D"); - Assertions.assertTrue(sType.isPresent()); + assertTrue(sType.isPresent()); //TODO ND: complete when inner types are added } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfExpressionTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfExpressionTest.java index d0e64b9f8b..39fec6c078 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfExpressionTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfExpressionTest.java @@ -20,7 +20,6 @@ import java.util.Optional; import static de.monticore.types.check.DefsTypeBasic.*; -import static org.junit.Assert.assertEquals; public class DeriveSymTypeOfExpressionTest extends DeriveSymTypeAbstractTest { diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfJavaClassExpressionsTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfJavaClassExpressionsTest.java index 4e45887a3a..06bc7776a4 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfJavaClassExpressionsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfJavaClassExpressionsTest.java @@ -13,7 +13,6 @@ import de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol; import de.monticore.symbols.oosymbols.OOSymbolsMill; import de.monticore.symbols.oosymbols._symboltable.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -21,6 +20,7 @@ import java.util.Optional; import static de.monticore.types.check.DefsTypeBasic.*; +import static org.junit.jupiter.api.Assertions.assertFalse; public class DeriveSymTypeOfJavaClassExpressionsTest extends DeriveSymTypeAbstractTest { @@ -362,10 +362,10 @@ public void failDeriveSymTypeOfClassExpression() throws IOException{ //test that types must have a name Optional class1 = p.parse_StringExpression("3.class"); - Assertions.assertFalse(class1.isPresent()); + assertFalse(class1.isPresent()); Optional class2 = p.parse_StringExpression("\"Hallo\".class"); - Assertions.assertFalse(class2.isPresent()); + assertFalse(class2.isPresent()); } @Test diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfLambdaExpressionsTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfLambdaExpressionsTest.java index e3825475ba..5e81ebf180 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfLambdaExpressionsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfLambdaExpressionsTest.java @@ -12,17 +12,17 @@ import de.monticore.grammar.grammar_withconcepts.FullSynthesizeFromMCSGT4Grammar; import de.monticore.symbols.basicsymbols.BasicSymbolsMill; import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import de.se_rwth.commons.logging.Log; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class DeriveSymTypeOfLambdaExpressionsTest extends DeriveSymTypeAbstractTest { /** @@ -88,9 +88,9 @@ protected void checkWithST(String expression, String expectedType) throws IOExce setupTypeCheck(); ASTExpression astex = parseAndGenerateSymbolTable(expression); - Assertions.assertEquals(expectedType, getTypeCalculator().typeOf(astex).print()); + assertEquals(expectedType, getTypeCalculator().typeOf(astex).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /*--------------------------------------------------- TESTS ---------------------------------------------------------*/ diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfLiteralsTest.java index 369137d38f..25d83a360c 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfLiteralsTest.java @@ -7,12 +7,11 @@ import de.monticore.symbols.basicsymbols.BasicSymbolsMill; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DeriveSymTypeOfLiteralsTest { @@ -45,9 +44,9 @@ public void before() { @Test public void deriveTFromLiteral1(){ ASTLiteral lit = MCCommonLiteralsMill.natLiteralBuilder().setDigits("17").build(); - Assertions.assertEquals("int", tc.typeOf(lit).print()); + assertEquals("int", tc.typeOf(lit).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfMCCommonLiteralsTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfMCCommonLiteralsTest.java index a1dcd637eb..2e4f617ed1 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfMCCommonLiteralsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/DeriveSymTypeOfMCCommonLiteralsTest.java @@ -8,14 +8,13 @@ import de.monticore.symbols.basicsymbols.BasicSymbolsMill; import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; import de.se_rwth.commons.logging.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DeriveSymTypeOfMCCommonLiteralsTest { @@ -47,25 +46,25 @@ public void before() { @Test public void deriveTFromLiteral1Null() throws IOException { ASTLiteral lit = MCCommonLiteralsMill.nullLiteralBuilder().build(); - Assertions.assertEquals("null", tc.typeOf(lit).print()); + assertEquals("null", tc.typeOf(lit).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void deriveTFromLiteral1Boolean() throws IOException { ASTLiteral lit = MCCommonLiteralsMill.booleanLiteralBuilder().setSource(0).build(); - Assertions.assertEquals("boolean", tc.typeOf(lit).print()); + assertEquals("boolean", tc.typeOf(lit).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void deriveTFromLiteral1Char() throws IOException { ASTLiteral lit = MCCommonLiteralsMill.charLiteralBuilder().setSource("c").build(); - Assertions.assertEquals("char", tc.typeOf(lit).print()); + assertEquals("char", tc.typeOf(lit).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -79,43 +78,43 @@ public void deriveTFromLiteral1String() throws IOException { gs.add(str); ASTLiteral lit = MCCommonLiteralsMill.stringLiteralBuilder().setSource("hjasdk").build(); lit.setEnclosingScope(gs); - Assertions.assertEquals("String", tc.typeOf(lit).print()); + assertEquals("String", tc.typeOf(lit).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void deriveTFromLiteral1Int() throws IOException { ASTLiteral lit = MCCommonLiteralsMill.natLiteralBuilder().setDigits("17").build(); - Assertions.assertEquals("int", tc.typeOf(lit).print()); + assertEquals("int", tc.typeOf(lit).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void deriveTFromLiteral1BasicLong() throws IOException { ASTLiteral lit = MCCommonLiteralsMill.basicLongLiteralBuilder().setDigits("17").build(); - Assertions.assertEquals("long", tc.typeOf(lit).print()); + assertEquals("long", tc.typeOf(lit).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void deriveTFromLiteral1BasicFloat() throws IOException { ASTLiteral lit = MCCommonLiteralsMill.basicFloatLiteralBuilder().setPre("10").setPost("03").build(); - Assertions.assertEquals("float", tc.typeOf(lit).print()); + assertEquals("float", tc.typeOf(lit).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void deriveTFromLiteral1BasicDouble() throws IOException { ASTLiteral lit = MCCommonLiteralsMill.basicDoubleLiteralBuilder().setPre("710").setPost("93").build(); - Assertions.assertEquals("double", tc.typeOf(lit).print()); + assertEquals("double", tc.typeOf(lit).print()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/FullSynthesizeCompKindFromMCBasicTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/FullSynthesizeCompKindFromMCBasicTypesTest.java index a4a3b8c832..fca627a2a6 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/FullSynthesizeCompKindFromMCBasicTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/FullSynthesizeCompKindFromMCBasicTypesTest.java @@ -9,12 +9,14 @@ import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class FullSynthesizeCompKindFromMCBasicTypesTest extends AbstractMCTest { @BeforeEach @@ -46,9 +48,9 @@ public void synthesizesCompKind_forResolvableComponentTypeSymbol() { Optional res = synth.synthesize(ast); // Then - Assertions.assertTrue(res.isPresent()); - Assertions.assertTrue(res.get().isComponentType()); - Assertions.assertEquals(typeA, res.get().getTypeInfo()); + assertTrue(res.isPresent()); + assertTrue(res.get().isComponentType()); + assertEquals(typeA, res.get().getTypeInfo()); } @Test @@ -61,7 +63,7 @@ public void shouldLogErrorOnPrimitive() { Optional result = synth.synthesize(ast); // Then - Assertions.assertTrue(result.isEmpty(), "Expected no CompKindExpression for primitive 'int'"); + assertTrue(result.isEmpty(), "Expected no CompKindExpression for primitive 'int'"); MCAssertions.assertHasFindingStartingWith("0xD0104 Cannot resolve component 'int'"); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/SymTypeExpressionDeSerTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/SymTypeExpressionDeSerTest.java index 7ffdbb58d4..84f791f63a 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/SymTypeExpressionDeSerTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/SymTypeExpressionDeSerTest.java @@ -13,7 +13,6 @@ import de.monticore.symboltable.serialization.json.JsonObject; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -22,6 +21,7 @@ import java.util.Optional; import static de.monticore.types.check.SymTypeExpressionFactory.*; +import static org.junit.jupiter.api.Assertions.*; public class SymTypeExpressionDeSerTest { // setup of objects (unchanged during tests) @@ -252,10 +252,10 @@ protected void performRoundTripSerialization(SymTypeExpression expr) { String serialized = deser.serialize(expr); // then deserialize it SymTypeExpression deserialized = deser.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); // and assert that the serialized and deserialized symtype expression equals the one before - Assertions.assertEquals(expr.print(), deserialized.print()); - Assertions.assertEquals(expr.printAsJson(), deserialized.printAsJson()); + assertEquals(expr.print(), deserialized.print()); + assertEquals(expr.printAsJson(), deserialized.printAsJson()); if (!deserialized.isWildcard() && !deserialized.isRegExType() && !deserialized.isSIUnitType() && @@ -263,7 +263,7 @@ protected void performRoundTripSerialization(SymTypeExpression expr) { ) { TypeSymbol expectedTS = deserialized.getTypeInfo(); TypeSymbol actualTS = expr.getTypeInfo(); - Assertions.assertEquals(expectedTS.getName(), actualTS.getName()); + assertEquals(expectedTS.getName(), actualTS.getName()); } } @@ -273,13 +273,13 @@ protected void performRoundTripSerializationSymTypeOfGenerics(SymTypeOfGenerics String serialized = deser.serialize(expr); SymTypeExpression deserialized = deser.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); - Assertions.assertEquals(expr.print(), deserialized.print()); - Assertions.assertEquals(expr.printAsJson(), deserialized.printAsJson()); + assertEquals(expr.print(), deserialized.print()); + assertEquals(expr.printAsJson(), deserialized.printAsJson()); TypeSymbol expectedTS = deserialized.getTypeInfo(); TypeSymbol actualTS = deserialized.getTypeInfo(); - Assertions.assertEquals(expectedTS.getName(), actualTS.getName()); + assertEquals(expectedTS.getName(), actualTS.getName()); } protected void performRoundTripSerializationSymTypeOfFunction(SymTypeOfFunction expr) { @@ -288,13 +288,13 @@ protected void performRoundTripSerializationSymTypeOfFunction(SymTypeOfFunction String serialized = deser.serialize(expr); SymTypeExpression deserialized = deser.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); - Assertions.assertEquals(expr.print(), deserialized.print()); - Assertions.assertEquals(expr.printAsJson(), deserialized.printAsJson()); + assertEquals(expr.print(), deserialized.print()); + assertEquals(expr.printAsJson(), deserialized.printAsJson()); TypeSymbol expectedTS = deserialized.getTypeInfo(); TypeSymbol actualTS = deserialized.getTypeInfo(); - Assertions.assertEquals(expectedTS.getName(), actualTS.getName()); + assertEquals(expectedTS.getName(), actualTS.getName()); } protected void performRoundTripSerializationSymTypeOfObject(SymTypeOfObject expr) { @@ -303,13 +303,13 @@ protected void performRoundTripSerializationSymTypeOfObject(SymTypeOfObject expr String serialized = deser.serialize(expr); SymTypeExpression deserialized = deser.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); - Assertions.assertEquals(expr.print(), deserialized.print()); - Assertions.assertEquals(expr.printAsJson(), deserialized.printAsJson()); + assertEquals(expr.print(), deserialized.print()); + assertEquals(expr.printAsJson(), deserialized.printAsJson()); TypeSymbol expectedTS = deserialized.getTypeInfo(); TypeSymbol actualTS = deserialized.getTypeInfo(); - Assertions.assertEquals(expectedTS.getName(), actualTS.getName()); + assertEquals(expectedTS.getName(), actualTS.getName()); } protected void performRoundTripSerializationSymTypeVariable(SymTypeVariable expr) { @@ -318,13 +318,13 @@ protected void performRoundTripSerializationSymTypeVariable(SymTypeVariable expr String serialized = deser.serialize(expr); SymTypeExpression deserialized = deser.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); - Assertions.assertEquals(expr.print(), deserialized.print()); - Assertions.assertEquals(expr.printAsJson(), deserialized.printAsJson()); + assertEquals(expr.print(), deserialized.print()); + assertEquals(expr.printAsJson(), deserialized.printAsJson()); TypeSymbol expectedTS = deserialized.getTypeInfo(); TypeSymbol actualTS = deserialized.getTypeInfo(); - Assertions.assertEquals(expectedTS.getName(), actualTS.getName()); + assertEquals(expectedTS.getName(), actualTS.getName()); } protected void performRoundTripSerializationSymTypeArray(SymTypeArray expr) { @@ -333,13 +333,13 @@ protected void performRoundTripSerializationSymTypeArray(SymTypeArray expr) { String serialized = deser.serialize(expr); SymTypeExpression deserialized = deser.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); - Assertions.assertEquals(expr.print(), deserialized.print()); - Assertions.assertEquals(expr.printAsJson(), deserialized.printAsJson()); + assertEquals(expr.print(), deserialized.print()); + assertEquals(expr.printAsJson(), deserialized.printAsJson()); TypeSymbol expectedTS = deserialized.getTypeInfo(); TypeSymbol actualTS = deserialized.getTypeInfo(); - Assertions.assertEquals(expectedTS.getName(), actualTS.getName()); + assertEquals(expectedTS.getName(), actualTS.getName()); //assertTrue(Log.getFindings().isEmpty()); } @@ -350,13 +350,13 @@ protected void performRoundTripSerializationSymTypePrimitive(SymTypePrimitive ex String serialized = deser.serialize(expr); SymTypeExpression deserialized = deser.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); - Assertions.assertEquals(expr.print(), deserialized.print()); - Assertions.assertEquals(expr.printAsJson(), deserialized.printAsJson()); + assertEquals(expr.print(), deserialized.print()); + assertEquals(expr.printAsJson(), deserialized.printAsJson()); TypeSymbol expectedTS = deserialized.getTypeInfo(); TypeSymbol actualTS = deserialized.getTypeInfo(); - Assertions.assertEquals(expectedTS.getName(), actualTS.getName()); + assertEquals(expectedTS.getName(), actualTS.getName()); } protected void performRoundTripSerializationSymTypeOfSIUnit(SymTypeOfSIUnit expr) { @@ -365,10 +365,10 @@ protected void performRoundTripSerializationSymTypeOfSIUnit(SymTypeOfSIUnit expr String serialized = deser.serialize(expr); SymTypeExpression deserialized = deser.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); - Assertions.assertEquals(expr.print(), deserialized.print()); - Assertions.assertEquals(expr.printAsJson(), deserialized.printAsJson()); + assertEquals(expr.print(), deserialized.print()); + assertEquals(expr.printAsJson(), deserialized.printAsJson()); } protected void performRoundTripSerializationSymTypeOfNumericWithSIUnit( @@ -379,10 +379,10 @@ protected void performRoundTripSerializationSymTypeOfNumericWithSIUnit( String serialized = deser.serialize(expr); SymTypeExpression deserialized = deser.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); - Assertions.assertEquals(expr.print(), deserialized.print()); - Assertions.assertEquals(expr.printAsJson(), deserialized.printAsJson()); + assertEquals(expr.print(), deserialized.print()); + assertEquals(expr.printAsJson(), deserialized.printAsJson()); } protected void performRoundTripSerializationSymTypeOfUnion(SymTypeOfUnion expr) { @@ -391,13 +391,13 @@ protected void performRoundTripSerializationSymTypeOfUnion(SymTypeOfUnion expr) String serialized = deser.serialize(expr); SymTypeExpression deserialized = deser.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); - Assertions.assertTrue(expr.deepEquals(deserialized)); - Assertions.assertEquals(deser.serialize(expr), deser.serialize((SymTypeOfUnion) deserialized)); + assertTrue(expr.deepEquals(deserialized)); + assertEquals(deser.serialize(expr), deser.serialize((SymTypeOfUnion) deserialized)); TypeSymbol expectedTS = deserialized.getTypeInfo(); TypeSymbol actualTS = deserialized.getTypeInfo(); - Assertions.assertEquals(expectedTS.getName(), actualTS.getName()); + assertEquals(expectedTS.getName(), actualTS.getName()); } protected void performRoundTripSerializationSymTypeOfRegEx(SymTypeOfRegEx expr) { @@ -406,10 +406,10 @@ protected void performRoundTripSerializationSymTypeOfRegEx(SymTypeOfRegEx expr) String serialized = deser.serialize(expr); SymTypeExpression deserialized = deser.deserialize(serialized); - Assertions.assertNotNull(deserialized); + assertNotNull(deserialized); - Assertions.assertTrue(expr.deepEquals(deserialized)); - Assertions.assertEquals(deser.serialize(expr), deser.serialize((SymTypeOfRegEx) deserialized)); + assertTrue(expr.deepEquals(deserialized)); + assertEquals(deser.serialize(expr), deser.serialize((SymTypeOfRegEx) deserialized)); } @Test @@ -453,10 +453,10 @@ protected void performRoundtrip2(SymTypeExpression expr) { // then deserialize it SymTypeExpression loaded = deser.deserialize(serialized); - Assertions.assertNotNull(loaded); + assertNotNull(loaded); // and assert that the serialized and deserialized symtype expression equals the one before - Assertions.assertEquals(expr.print(), loaded.print()); - Assertions.assertEquals(expr.printAsJson(), loaded.printAsJson()); + assertEquals(expr.print(), loaded.print()); + assertEquals(expr.printAsJson(), loaded.printAsJson()); if (!loaded.isWildcard() && !loaded.isRegExType() && !loaded.isSIUnitType() && @@ -464,7 +464,7 @@ protected void performRoundtrip2(SymTypeExpression expr) { ) { TypeSymbol expectedTS = loaded.getTypeInfo(); TypeSymbol actualTS = expr.getTypeInfo(); - Assertions.assertEquals(expectedTS.getName(), actualTS.getName()); + assertEquals(expectedTS.getName(), actualTS.getName()); } // usual member @@ -475,7 +475,7 @@ protected void performRoundtrip2(SymTypeExpression expr) { //produce a fake JSON object from the serialized member and parse this JsonObject json = JsonParser.parseJsonObject(printer.getContent()); SymTypeExpression deserialized = SymTypeExpressionDeSer.deserializeMember("foo", json); - Assertions.assertEquals(expr.print(), deserialized.print()); + assertEquals(expr.print(), deserialized.print()); // optional member that is present printer = new JsonPrinter(); @@ -485,8 +485,8 @@ protected void performRoundtrip2(SymTypeExpression expr) { json = JsonParser.parseJsonObject(printer.getContent()); Optional deserializedOpt = SymTypeExpressionDeSer .deserializeOptionalMember("foo", json); - Assertions.assertTrue(deserializedOpt.isPresent()); - Assertions.assertEquals(expr.print(), deserializedOpt.get().print()); + assertTrue(deserializedOpt.isPresent()); + assertEquals(expr.print(), deserializedOpt.get().print()); // optional member that is empty printer = new JsonPrinter(true); @@ -495,7 +495,7 @@ protected void performRoundtrip2(SymTypeExpression expr) { printer.endObject(); json = JsonParser.parseJsonObject(printer.getContent()); deserializedOpt = SymTypeExpressionDeSer.deserializeOptionalMember("foo", json); - Assertions.assertTrue(!deserializedOpt.isPresent()); + assertTrue(!deserializedOpt.isPresent()); // list member that is empty printer = new JsonPrinter(true); @@ -505,7 +505,7 @@ protected void performRoundtrip2(SymTypeExpression expr) { json = JsonParser.parseJsonObject(printer.getContent()); List deserializedList = SymTypeExpressionDeSer .deserializeListMember("foo", json); - Assertions.assertEquals(0, deserializedList.size()); + assertEquals(0, deserializedList.size()); // list member with single element printer = new JsonPrinter(); @@ -514,8 +514,8 @@ protected void performRoundtrip2(SymTypeExpression expr) { printer.endObject(); json = JsonParser.parseJsonObject(printer.getContent()); deserializedList = SymTypeExpressionDeSer.deserializeListMember("foo", json); - Assertions.assertEquals(1, deserializedList.size()); - Assertions.assertEquals(expr.print(), deserializedList.get(0).print()); + assertEquals(1, deserializedList.size()); + assertEquals(expr.print(), deserializedList.get(0).print()); // list member with two elements printer = new JsonPrinter(); @@ -524,9 +524,9 @@ protected void performRoundtrip2(SymTypeExpression expr) { printer.endObject(); json = JsonParser.parseJsonObject(printer.getContent()); deserializedList = SymTypeExpressionDeSer.deserializeListMember("foo", json); - Assertions.assertEquals(2, deserializedList.size()); - Assertions.assertEquals(expr.print(), deserializedList.get(0).print()); - Assertions.assertEquals(expr.print(), deserializedList.get(1).print()); + assertEquals(2, deserializedList.size()); + assertEquals(expr.print(), deserializedList.get(0).print()); + assertEquals(expr.print(), deserializedList.get(1).print()); } @Test @@ -535,38 +535,38 @@ public void testInvalidJsonForSerializingReturnsError() { String invalidJsonForSerializing2 = "{\n\t\"symTypeExpression\": {\n\t\t\"foo\":\"bar\", \n\t\t\"foo2\":\"bar2\"\n\t}\n}"; SymTypeExpressionDeSer.getInstance().deserialize(invalidJsonForSerializing); - Assertions.assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823FE")); + assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823FE")); SymTypeExpressionDeSer.getInstance().deserialize(invalidJsonForSerializing2); - Assertions.assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823FE")); + assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823FE")); SymTypeOfGenericsDeSer symTypeOfGenericsDeSer = new SymTypeOfGenericsDeSer(); symTypeOfGenericsDeSer.deserialize(invalidJsonForSerializing2); - Assertions.assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823F6")); + assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823F6")); SymTypeArrayDeSer symTypeArrayDeSer = new SymTypeArrayDeSer(); symTypeArrayDeSer.deserialize(invalidJsonForSerializing2); - Assertions.assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823F2")); + assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823F2")); SymTypeOfObjectDeSer symTypeOfObjectDeSer = new SymTypeOfObjectDeSer(); symTypeOfObjectDeSer.deserialize(invalidJsonForSerializing2); - Assertions.assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823F4")); + assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823F4")); SymTypeVariableDeSer symTypeVariableDeSer = new SymTypeVariableDeSer(); symTypeVariableDeSer.deserialize(invalidJsonForSerializing2); - Assertions.assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823F5")); + assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823F5")); SymTypePrimitiveDeSer symTypePrimitiveDeser = new SymTypePrimitiveDeSer(); symTypePrimitiveDeser.deserialize(invalidJsonForSerializing2); - Assertions.assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823F1")); + assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x823F1")); SymTypeOfUnionDeSer symTypeOfUnionDeser = new SymTypeOfUnionDeSer(); symTypeOfUnionDeser.deserialize(invalidJsonForSerializing2); - Assertions.assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x9E2F7")); + assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x9E2F7")); SymTypeOfRegExDeSer symTypeOfRegExDeSer = new SymTypeOfRegExDeSer(); symTypeOfRegExDeSer.deserialize(invalidJsonForSerializing2); - Assertions.assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x9E2F9")); + assertTrue(Log.getFindings().get(Log.getFindings().size() - 1).getMsg().startsWith("0x9E2F9")); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/SymTypeExpressionTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/SymTypeExpressionTest.java index 833008294d..c6e4c4c290 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/SymTypeExpressionTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/SymTypeExpressionTest.java @@ -12,7 +12,6 @@ import de.monticore.types3.util.DefsTypesForTests; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -25,8 +24,7 @@ import static de.monticore.types.check.DefsTypeBasic._intSymType; import static de.monticore.types.check.SymTypeExpressionFactory.*; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class SymTypeExpressionTest { @@ -215,547 +213,547 @@ public void init(){ @Test public void subTypeTest() { - Assertions.assertTrue(teInt.isPrimitive()); - Assertions.assertFalse(teInt.isGenericType()); - Assertions.assertFalse(teInt.isTypeVariable()); - Assertions.assertFalse(teInt.isArrayType()); - Assertions.assertFalse(teInt.isVoidType()); - Assertions.assertFalse(teInt.isNullType()); - Assertions.assertFalse(teInt.isObjectType()); - Assertions.assertFalse(teInt.isFunctionType()); - Assertions.assertFalse(teInt.isObscureType()); - Assertions.assertFalse(teInt.isWildcard()); - Assertions.assertFalse(teInt.isUnionType()); - - Assertions.assertTrue(teVarA.isTypeVariable()); - Assertions.assertTrue(teP.isObjectType()); - Assertions.assertTrue(teVoid.isVoidType()); - Assertions.assertTrue(teNull.isNullType()); - Assertions.assertTrue(teArr1.isArrayType()); - Assertions.assertTrue(teSet.isGenericType()); - Assertions.assertTrue(teUpperBound.isWildcard()); - Assertions.assertTrue(teFunc1.isFunctionType()); - Assertions.assertTrue(teSIUnit1.isSIUnitType()); - Assertions.assertTrue(teNumWithSIUnit1.isNumericWithSIUnitType()); - Assertions.assertTrue(teUnion1.isUnionType()); - Assertions.assertTrue(teInter1.isIntersectionType()); - Assertions.assertTrue(teTuple1.isTupleType()); - Assertions.assertTrue(teRegEx1.isRegExType()); - Assertions.assertTrue(teObscure.isObscureType()); + assertTrue(teInt.isPrimitive()); + assertFalse(teInt.isGenericType()); + assertFalse(teInt.isTypeVariable()); + assertFalse(teInt.isArrayType()); + assertFalse(teInt.isVoidType()); + assertFalse(teInt.isNullType()); + assertFalse(teInt.isObjectType()); + assertFalse(teInt.isFunctionType()); + assertFalse(teInt.isObscureType()); + assertFalse(teInt.isWildcard()); + assertFalse(teInt.isUnionType()); + + assertTrue(teVarA.isTypeVariable()); + assertTrue(teP.isObjectType()); + assertTrue(teVoid.isVoidType()); + assertTrue(teNull.isNullType()); + assertTrue(teArr1.isArrayType()); + assertTrue(teSet.isGenericType()); + assertTrue(teUpperBound.isWildcard()); + assertTrue(teFunc1.isFunctionType()); + assertTrue(teSIUnit1.isSIUnitType()); + assertTrue(teNumWithSIUnit1.isNumericWithSIUnitType()); + assertTrue(teUnion1.isUnionType()); + assertTrue(teInter1.isIntersectionType()); + assertTrue(teTuple1.isTupleType()); + assertTrue(teRegEx1.isRegExType()); + assertTrue(teObscure.isObscureType()); } @Test public void printTest() { - Assertions.assertEquals("double", teDouble.print()); - Assertions.assertEquals("int", teInt.print()); - Assertions.assertEquals("A", teVarA.print()); - Assertions.assertEquals("de.x.Person", teP.print()); - Assertions.assertEquals("void", teVoid.print()); - Assertions.assertEquals("null", teNull.print()); - Assertions.assertEquals("Human[]", teArr1.print()); - Assertions.assertEquals("int[][][]", teArr3.print()); - Assertions.assertEquals("java.util.Set", teSet.printFullName()); - Assertions.assertEquals("java.util.Set", teSetA.printFullName()); - Assertions.assertEquals("Map", teMap.printFullName()); - Assertions.assertEquals("x.Foo", teFoo.printFullName()); - Assertions.assertEquals("java.util.Set>", teDeep1.printFullName()); - Assertions.assertEquals("java.util.Map2>>", teDeep2.printFullName()); - Assertions.assertEquals("? extends int", teUpperBound.print()); - Assertions.assertEquals("? super Human", teLowerBound.print()); - Assertions.assertEquals("?", teWildcard.print()); - Assertions.assertEquals("java.util.Map", teMap3.printFullName()); - Assertions.assertEquals("() -> void", teFunc1.print()); - Assertions.assertEquals("(double, int) -> int", teFunc2.print()); - Assertions.assertEquals("((double, int) -> int) -> () -> void", teFunc3.print()); - Assertions.assertEquals("(double, int...) -> void", teFunc4.print()); - Assertions.assertEquals("[m/ms^2]", teSIUnit1.print()); - Assertions.assertEquals("[1]", teSIUnit2.print()); - Assertions.assertEquals("[m/ms^2]", teNumWithSIUnit1.print()); - Assertions.assertEquals("double | int", teUnion1.print()); - Assertions.assertEquals("double & int", teInter1.print()); - Assertions.assertEquals("(int, double)", teTuple1.print()); - Assertions.assertEquals("R\"gr(a|e)y\"", teRegEx1.print()); + assertEquals("double", teDouble.print()); + assertEquals("int", teInt.print()); + assertEquals("A", teVarA.print()); + assertEquals("de.x.Person", teP.print()); + assertEquals("void", teVoid.print()); + assertEquals("null", teNull.print()); + assertEquals("Human[]", teArr1.print()); + assertEquals("int[][][]", teArr3.print()); + assertEquals("java.util.Set", teSet.printFullName()); + assertEquals("java.util.Set", teSetA.printFullName()); + assertEquals("Map", teMap.printFullName()); + assertEquals("x.Foo", teFoo.printFullName()); + assertEquals("java.util.Set>", teDeep1.printFullName()); + assertEquals("java.util.Map2>>", teDeep2.printFullName()); + assertEquals("? extends int", teUpperBound.print()); + assertEquals("? super Human", teLowerBound.print()); + assertEquals("?", teWildcard.print()); + assertEquals("java.util.Map", teMap3.printFullName()); + assertEquals("() -> void", teFunc1.print()); + assertEquals("(double, int) -> int", teFunc2.print()); + assertEquals("((double, int) -> int) -> () -> void", teFunc3.print()); + assertEquals("(double, int...) -> void", teFunc4.print()); + assertEquals("[m/ms^2]", teSIUnit1.print()); + assertEquals("[1]", teSIUnit2.print()); + assertEquals("[m/ms^2]", teNumWithSIUnit1.print()); + assertEquals("double | int", teUnion1.print()); + assertEquals("double & int", teInter1.print()); + assertEquals("(int, double)", teTuple1.print()); + assertEquals("R\"gr(a|e)y\"", teRegEx1.print()); } @Test public void printAsJsonTest() { JsonElement result = JsonParser.parse(teDouble.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teDoubleJson = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", teDoubleJson.getStringMember("kind")); - Assertions.assertEquals("double", teDoubleJson.getStringMember("primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", teDoubleJson.getStringMember("kind")); + assertEquals("double", teDoubleJson.getStringMember("primitiveName")); result = JsonParser.parse(teInt.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teIntJson = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", teIntJson.getStringMember("kind")); - Assertions.assertEquals("int", teIntJson.getStringMember("primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", teIntJson.getStringMember("kind")); + assertEquals("int", teIntJson.getStringMember("primitiveName")); result = JsonParser.parse(teVarA.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teVarAJson = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeVariable", teVarAJson.getStringMember("kind")); - Assertions.assertEquals("A", teVarAJson.getStringMember("varName")); + assertEquals("de.monticore.types.check.SymTypeVariable", teVarAJson.getStringMember("kind")); + assertEquals("A", teVarAJson.getStringMember("varName")); result = JsonParser.parse(teP.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject tePJson = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfObject", tePJson.getStringMember("kind")); - Assertions.assertEquals("de.x.Person", tePJson.getStringMember("objName")); + assertEquals("de.monticore.types.check.SymTypeOfObject", tePJson.getStringMember("kind")); + assertEquals("de.x.Person", tePJson.getStringMember("objName")); result = JsonParser.parse(teVoid.printAsJson()); - Assertions.assertTrue(result.isJsonString()); - Assertions.assertEquals("void", result.getAsJsonString().getValue()); + assertTrue(result.isJsonString()); + assertEquals("void", result.getAsJsonString().getValue()); result = JsonParser.parse(teNull.printAsJson()); - Assertions.assertTrue(result.isJsonString()); - Assertions.assertEquals("null", result.getAsJsonString().getValue()); + assertTrue(result.isJsonString()); + assertEquals("null", result.getAsJsonString().getValue()); result = JsonParser.parse(teArr1.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teArr1Json = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeArray", teArr1Json.getStringMember("kind")); - Assertions.assertEquals(1, teArr1Json.getIntegerMember("dim"), 0.01); + assertEquals("de.monticore.types.check.SymTypeArray", teArr1Json.getStringMember("kind")); + assertEquals(1, teArr1Json.getIntegerMember("dim"), 0.01); JsonObject teArr1ArgJson = teArr1Json.getObjectMember("argument"); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfObject", teArr1ArgJson.getStringMember("kind")); - Assertions.assertEquals("Human", teArr1ArgJson.getStringMember("objName")); + assertEquals("de.monticore.types.check.SymTypeOfObject", teArr1ArgJson.getStringMember("kind")); + assertEquals("Human", teArr1ArgJson.getStringMember("objName")); result = JsonParser.parse(teArr3.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teArr3Json = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeArray", teArr3Json.getStringMember("kind")); - Assertions.assertEquals(3, teArr3Json.getIntegerMember("dim"), 0.01); + assertEquals("de.monticore.types.check.SymTypeArray", teArr3Json.getStringMember("kind")); + assertEquals(3, teArr3Json.getIntegerMember("dim"), 0.01); JsonObject teArr3ArgJson = teArr3Json.getObjectMember("argument"); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", teArr3ArgJson.getStringMember("kind")); - Assertions.assertEquals("int", teArr3ArgJson.getStringMember("primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", teArr3ArgJson.getStringMember("kind")); + assertEquals("int", teArr3ArgJson.getStringMember("primitiveName")); result = JsonParser.parse(teSet.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teSetJson = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfGenerics", teSetJson.getStringMember("kind")); - Assertions.assertEquals("java.util.Set", teSetJson.getStringMember("typeConstructorFullName")); + assertEquals("de.monticore.types.check.SymTypeOfGenerics", teSetJson.getStringMember("kind")); + assertEquals("java.util.Set", teSetJson.getStringMember("typeConstructorFullName")); List teSetArgsJson = teSetJson.getArrayMember("arguments"); - Assertions.assertEquals(1, teSetArgsJson.size(), 0.01); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfObject", teSetArgsJson.get(0).getAsJsonObject().getStringMember("kind")); - Assertions.assertEquals("de.x.Person", teSetArgsJson.get(0).getAsJsonObject().getStringMember("objName")); + assertEquals(1, teSetArgsJson.size(), 0.01); + assertEquals("de.monticore.types.check.SymTypeOfObject", teSetArgsJson.get(0).getAsJsonObject().getStringMember("kind")); + assertEquals("de.x.Person", teSetArgsJson.get(0).getAsJsonObject().getStringMember("objName")); result = JsonParser.parse(teSetA.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teSetAJson = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfGenerics", teSetAJson.getStringMember("kind")); - Assertions.assertEquals("java.util.Set", teSetAJson.getStringMember("typeConstructorFullName")); + assertEquals("de.monticore.types.check.SymTypeOfGenerics", teSetAJson.getStringMember("kind")); + assertEquals("java.util.Set", teSetAJson.getStringMember("typeConstructorFullName")); List teSetAArgsJson = teSetAJson.getArrayMember("arguments"); - Assertions.assertEquals(1, teSetAArgsJson.size(), 0.01); - Assertions.assertEquals("de.monticore.types.check.SymTypeVariable", teSetAArgsJson.get(0).getAsJsonObject().getStringMember("kind")); - Assertions.assertEquals("A", teSetAArgsJson.get(0).getAsJsonObject().getStringMember("varName")); + assertEquals(1, teSetAArgsJson.size(), 0.01); + assertEquals("de.monticore.types.check.SymTypeVariable", teSetAArgsJson.get(0).getAsJsonObject().getStringMember("kind")); + assertEquals("A", teSetAArgsJson.get(0).getAsJsonObject().getStringMember("varName")); result = JsonParser.parse(teMap.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teMapJson = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfGenerics", teMapJson.getStringMember("kind")); - Assertions.assertEquals("Map", teMapJson.getStringMember("typeConstructorFullName")); + assertEquals("de.monticore.types.check.SymTypeOfGenerics", teMapJson.getStringMember("kind")); + assertEquals("Map", teMapJson.getStringMember("typeConstructorFullName")); List teMapArgsJson = teMapJson.getArrayMember("arguments"); - Assertions.assertEquals(2, teMapArgsJson.size(), 0.01); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", teMapArgsJson.get(0).getAsJsonObject().getStringMember("kind")); - Assertions.assertEquals("int", teMapArgsJson.get(0).getAsJsonObject().getStringMember("primitiveName")); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfObject", teMapArgsJson.get(1).getAsJsonObject().getStringMember("kind")); - Assertions.assertEquals("de.x.Person", teMapArgsJson.get(1).getAsJsonObject().getStringMember("objName")); + assertEquals(2, teMapArgsJson.size(), 0.01); + assertEquals("de.monticore.types.check.SymTypePrimitive", teMapArgsJson.get(0).getAsJsonObject().getStringMember("kind")); + assertEquals("int", teMapArgsJson.get(0).getAsJsonObject().getStringMember("primitiveName")); + assertEquals("de.monticore.types.check.SymTypeOfObject", teMapArgsJson.get(1).getAsJsonObject().getStringMember("kind")); + assertEquals("de.x.Person", teMapArgsJson.get(1).getAsJsonObject().getStringMember("objName")); result = JsonParser.parse(teFoo.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teFooJson = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfGenerics", teFooJson.getStringMember("kind")); - Assertions.assertEquals("x.Foo", teFooJson.getStringMember("typeConstructorFullName")); + assertEquals("de.monticore.types.check.SymTypeOfGenerics", teFooJson.getStringMember("kind")); + assertEquals("x.Foo", teFooJson.getStringMember("typeConstructorFullName")); List teFooArgsJson = teFooJson.getArrayMember("arguments"); - Assertions.assertEquals(4, teFooArgsJson.size(), 0.01); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfObject", teFooArgsJson.get(0).getAsJsonObject().getStringMember("kind")); - Assertions.assertEquals("de.x.Person", teFooArgsJson.get(0).getAsJsonObject().getStringMember("objName")); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", teFooArgsJson.get(1).getAsJsonObject().getStringMember("kind")); - Assertions.assertEquals("double", teFooArgsJson.get(1).getAsJsonObject().getStringMember("primitiveName")); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", teFooArgsJson.get(2).getAsJsonObject().getStringMember("kind")); - Assertions.assertEquals("int", teFooArgsJson.get(2).getAsJsonObject().getStringMember("primitiveName")); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfObject", teFooArgsJson.get(3).getAsJsonObject().getStringMember("kind")); - Assertions.assertEquals("Human", teFooArgsJson.get(3).getAsJsonObject().getStringMember("objName")); + assertEquals(4, teFooArgsJson.size(), 0.01); + assertEquals("de.monticore.types.check.SymTypeOfObject", teFooArgsJson.get(0).getAsJsonObject().getStringMember("kind")); + assertEquals("de.x.Person", teFooArgsJson.get(0).getAsJsonObject().getStringMember("objName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", teFooArgsJson.get(1).getAsJsonObject().getStringMember("kind")); + assertEquals("double", teFooArgsJson.get(1).getAsJsonObject().getStringMember("primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", teFooArgsJson.get(2).getAsJsonObject().getStringMember("kind")); + assertEquals("int", teFooArgsJson.get(2).getAsJsonObject().getStringMember("primitiveName")); + assertEquals("de.monticore.types.check.SymTypeOfObject", teFooArgsJson.get(3).getAsJsonObject().getStringMember("kind")); + assertEquals("Human", teFooArgsJson.get(3).getAsJsonObject().getStringMember("objName")); result = JsonParser.parse(teDeep1.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teDeep1Json = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfGenerics", teDeep1Json.getStringMember("kind")); - Assertions.assertEquals("java.util.Set", teDeep1Json.getStringMember("typeConstructorFullName")); + assertEquals("de.monticore.types.check.SymTypeOfGenerics", teDeep1Json.getStringMember("kind")); + assertEquals("java.util.Set", teDeep1Json.getStringMember("typeConstructorFullName")); List teDeep1ArgsJson = teDeep1Json.getArrayMember("arguments"); - Assertions.assertEquals(1, teDeep1ArgsJson.size(), 0.01); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfGenerics", teDeep1ArgsJson.get(0).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("Map", teDeep1ArgsJson.get(0).getAsJsonObject().getStringMember( "typeConstructorFullName")); + assertEquals(1, teDeep1ArgsJson.size(), 0.01); + assertEquals("de.monticore.types.check.SymTypeOfGenerics", teDeep1ArgsJson.get(0).getAsJsonObject().getStringMember( "kind")); + assertEquals("Map", teDeep1ArgsJson.get(0).getAsJsonObject().getStringMember( "typeConstructorFullName")); List teDeep1teMapArgsJson = teDeep1ArgsJson.get(0).getAsJsonObject() .getArrayMember("arguments"); - Assertions.assertEquals(2, teDeep1teMapArgsJson.size(), 0.01); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", teDeep1teMapArgsJson.get(0).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("int", teDeep1teMapArgsJson.get(0).getAsJsonObject().getStringMember("primitiveName")); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfObject", teDeep1teMapArgsJson.get(1).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("de.x.Person", teDeep1teMapArgsJson.get(1).getAsJsonObject().getStringMember( "objName")); + assertEquals(2, teDeep1teMapArgsJson.size(), 0.01); + assertEquals("de.monticore.types.check.SymTypePrimitive", teDeep1teMapArgsJson.get(0).getAsJsonObject().getStringMember( "kind")); + assertEquals("int", teDeep1teMapArgsJson.get(0).getAsJsonObject().getStringMember("primitiveName")); + assertEquals("de.monticore.types.check.SymTypeOfObject", teDeep1teMapArgsJson.get(1).getAsJsonObject().getStringMember( "kind")); + assertEquals("de.x.Person", teDeep1teMapArgsJson.get(1).getAsJsonObject().getStringMember( "objName")); result = JsonParser.parse(teDeep2.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teDeep2Json = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfGenerics", teDeep2Json.getStringMember("kind")); - Assertions.assertEquals("java.util.Map2", teDeep2Json.getStringMember("typeConstructorFullName")); + assertEquals("de.monticore.types.check.SymTypeOfGenerics", teDeep2Json.getStringMember("kind")); + assertEquals("java.util.Map2", teDeep2Json.getStringMember("typeConstructorFullName")); List teDeep2ArgsJson = teDeep2Json.getArrayMember("arguments"); - Assertions.assertEquals(2, teDeep2ArgsJson.size(), 0.01); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", teDeep2ArgsJson.get(0).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("int", teDeep2ArgsJson.get(0).getAsJsonObject().getStringMember( "primitiveName")); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfGenerics", teDeep2ArgsJson.get(1).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("java.util.Set", teDeep2ArgsJson.get(1).getAsJsonObject().getStringMember( "typeConstructorFullName")); + assertEquals(2, teDeep2ArgsJson.size(), 0.01); + assertEquals("de.monticore.types.check.SymTypePrimitive", teDeep2ArgsJson.get(0).getAsJsonObject().getStringMember( "kind")); + assertEquals("int", teDeep2ArgsJson.get(0).getAsJsonObject().getStringMember( "primitiveName")); + assertEquals("de.monticore.types.check.SymTypeOfGenerics", teDeep2ArgsJson.get(1).getAsJsonObject().getStringMember( "kind")); + assertEquals("java.util.Set", teDeep2ArgsJson.get(1).getAsJsonObject().getStringMember( "typeConstructorFullName")); List teDeep2SetArgsJson = teDeep2ArgsJson.get(1).getAsJsonObject() .getArrayMember("arguments"); - Assertions.assertEquals(1, teDeep2SetArgsJson.size(), 0.01); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfGenerics", teDeep2SetArgsJson.get(0).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("Map", teDeep2SetArgsJson.get(0).getAsJsonObject().getStringMember( "typeConstructorFullName")); + assertEquals(1, teDeep2SetArgsJson.size(), 0.01); + assertEquals("de.monticore.types.check.SymTypeOfGenerics", teDeep2SetArgsJson.get(0).getAsJsonObject().getStringMember( "kind")); + assertEquals("Map", teDeep2SetArgsJson.get(0).getAsJsonObject().getStringMember( "typeConstructorFullName")); List teDeep2SetMapArgsJson = teDeep2SetArgsJson.get(0).getAsJsonObject() .getArrayMember("arguments"); - Assertions.assertEquals(2, teDeep2SetMapArgsJson.size(), 0.01); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", teDeep2SetMapArgsJson.get(0).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("int", teDeep2SetMapArgsJson.get(0).getAsJsonObject().getStringMember( "primitiveName")); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfObject", teDeep2SetMapArgsJson.get(1).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("de.x.Person", teDeep2SetMapArgsJson.get(1).getAsJsonObject().getStringMember( "objName")); + assertEquals(2, teDeep2SetMapArgsJson.size(), 0.01); + assertEquals("de.monticore.types.check.SymTypePrimitive", teDeep2SetMapArgsJson.get(0).getAsJsonObject().getStringMember( "kind")); + assertEquals("int", teDeep2SetMapArgsJson.get(0).getAsJsonObject().getStringMember( "primitiveName")); + assertEquals("de.monticore.types.check.SymTypeOfObject", teDeep2SetMapArgsJson.get(1).getAsJsonObject().getStringMember( "kind")); + assertEquals("de.x.Person", teDeep2SetMapArgsJson.get(1).getAsJsonObject().getStringMember( "objName")); result = JsonParser.parse(teUpperBound.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teUpperBound2Json = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfWildcard", teUpperBound2Json.getStringMember("kind")); - Assertions.assertTrue(teUpperBound2Json.getBooleanMember("isUpper")); + assertEquals("de.monticore.types.check.SymTypeOfWildcard", teUpperBound2Json.getStringMember("kind")); + assertTrue(teUpperBound2Json.getBooleanMember("isUpper")); JsonObject bound = teUpperBound2Json.getObjectMember("bound"); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", bound.getStringMember("kind")); - Assertions.assertEquals("int", bound.getStringMember("primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", bound.getStringMember("kind")); + assertEquals("int", bound.getStringMember("primitiveName")); result = JsonParser.parse(teFunc2.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teFunc2Json = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfFunction", teFunc2Json.getStringMember("kind")); + assertEquals("de.monticore.types.check.SymTypeOfFunction", teFunc2Json.getStringMember("kind")); JsonObject func2returnType = teFunc2Json.getObjectMember("returnType"); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", func2returnType.getStringMember( "kind")); - Assertions.assertEquals("int", func2returnType.getStringMember( "primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", func2returnType.getStringMember( "kind")); + assertEquals("int", func2returnType.getStringMember( "primitiveName")); List func2Arguments = teFunc2Json.getArrayMember("argumentTypes"); - Assertions.assertEquals(2, func2Arguments.size()); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", func2Arguments.get(0).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("double", func2Arguments.get(0).getAsJsonObject().getStringMember( "primitiveName")); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", func2Arguments.get(1).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("int", func2Arguments.get(1).getAsJsonObject().getStringMember( "primitiveName")); - Assertions.assertFalse(teFunc2Json.getBooleanMember("elliptic")); + assertEquals(2, func2Arguments.size()); + assertEquals("de.monticore.types.check.SymTypePrimitive", func2Arguments.get(0).getAsJsonObject().getStringMember( "kind")); + assertEquals("double", func2Arguments.get(0).getAsJsonObject().getStringMember( "primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", func2Arguments.get(1).getAsJsonObject().getStringMember( "kind")); + assertEquals("int", func2Arguments.get(1).getAsJsonObject().getStringMember( "primitiveName")); + assertFalse(teFunc2Json.getBooleanMember("elliptic")); result = JsonParser.parse(teFunc4.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teFunc4Json = result.getAsJsonObject(); - Assertions.assertTrue(teFunc4Json.getBooleanMember("elliptic")); + assertTrue(teFunc4Json.getBooleanMember("elliptic")); result = JsonParser.parse(teUnion1.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teUnion1Json = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfUnion", teUnion1Json.getStringMember("kind")); - Assertions.assertEquals(2, teUnion1Json.getArrayMember("unionizedTypes").size()); + assertEquals("de.monticore.types.check.SymTypeOfUnion", teUnion1Json.getStringMember("kind")); + assertEquals(2, teUnion1Json.getArrayMember("unionizedTypes").size()); List union1Types = teUnion1Json.getArrayMember("unionizedTypes"); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", union1Types.get(0).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("double", union1Types.get(0).getAsJsonObject().getStringMember( "primitiveName")); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", union1Types.get(1).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("int", union1Types.get(1).getAsJsonObject().getStringMember( "primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", union1Types.get(0).getAsJsonObject().getStringMember( "kind")); + assertEquals("double", union1Types.get(0).getAsJsonObject().getStringMember( "primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", union1Types.get(1).getAsJsonObject().getStringMember( "kind")); + assertEquals("int", union1Types.get(1).getAsJsonObject().getStringMember( "primitiveName")); result = JsonParser.parse(teInter1.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teInter1Json = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfIntersection", teInter1Json.getStringMember("kind")); - Assertions.assertEquals(2, teInter1Json.getArrayMember("intersectedTypes").size()); + assertEquals("de.monticore.types.check.SymTypeOfIntersection", teInter1Json.getStringMember("kind")); + assertEquals(2, teInter1Json.getArrayMember("intersectedTypes").size()); List intersected1Types = teInter1Json.getArrayMember("intersectedTypes"); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", intersected1Types.get(0).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("double", intersected1Types.get(0).getAsJsonObject().getStringMember( "primitiveName")); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", intersected1Types.get(1).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("int", intersected1Types.get(1).getAsJsonObject().getStringMember( "primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", intersected1Types.get(0).getAsJsonObject().getStringMember( "kind")); + assertEquals("double", intersected1Types.get(0).getAsJsonObject().getStringMember( "primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", intersected1Types.get(1).getAsJsonObject().getStringMember( "kind")); + assertEquals("int", intersected1Types.get(1).getAsJsonObject().getStringMember( "primitiveName")); result = JsonParser.parse(teTuple1.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teTuple1Json = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfTuple", teTuple1Json.getStringMember("kind")); - Assertions.assertEquals(2, teTuple1Json.getArrayMember("listedTypes").size()); + assertEquals("de.monticore.types.check.SymTypeOfTuple", teTuple1Json.getStringMember("kind")); + assertEquals(2, teTuple1Json.getArrayMember("listedTypes").size()); List tuple1types = teTuple1Json.getArrayMember("listedTypes"); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", tuple1types.get(0).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("int", tuple1types.get(0).getAsJsonObject().getStringMember( "primitiveName")); - Assertions.assertEquals("de.monticore.types.check.SymTypePrimitive", tuple1types.get(1).getAsJsonObject().getStringMember( "kind")); - Assertions.assertEquals("double", tuple1types.get(1).getAsJsonObject().getStringMember( "primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", tuple1types.get(0).getAsJsonObject().getStringMember( "kind")); + assertEquals("int", tuple1types.get(0).getAsJsonObject().getStringMember( "primitiveName")); + assertEquals("de.monticore.types.check.SymTypePrimitive", tuple1types.get(1).getAsJsonObject().getStringMember( "kind")); + assertEquals("double", tuple1types.get(1).getAsJsonObject().getStringMember( "primitiveName")); result = JsonParser.parse(teRegEx1.printAsJson()); - Assertions.assertTrue(result.isJsonObject()); + assertTrue(result.isJsonObject()); JsonObject teRegEx1Json = result.getAsJsonObject(); - Assertions.assertEquals("de.monticore.types.check.SymTypeOfRegEx", teRegEx1Json.getStringMember("kind")); - Assertions.assertEquals("gr(a|e)y", teRegEx1Json.getStringMember("regex")); + assertEquals("de.monticore.types.check.SymTypeOfRegEx", teRegEx1Json.getStringMember("kind")); + assertEquals("gr(a|e)y", teRegEx1Json.getStringMember("regex")); } @Test public void unboxTest(){ - Assertions.assertEquals("Set>", SymTypeOfGenerics.unbox((SymTypeOfGenerics)teSetB)); - Assertions.assertEquals("Set", SymTypeOfGenerics.unbox((SymTypeOfGenerics)teSet)); - Assertions.assertEquals("Set", SymTypeOfGenerics.unbox((SymTypeOfGenerics)teSetA)); - Assertions.assertEquals("Map", SymTypeOfGenerics.unbox((SymTypeOfGenerics)teMap)); - Assertions.assertEquals("Map,x.Foo>", SymTypeOfGenerics.unbox((SymTypeOfGenerics)teMap2)); + assertEquals("Set>", SymTypeOfGenerics.unbox((SymTypeOfGenerics)teSetB)); + assertEquals("Set", SymTypeOfGenerics.unbox((SymTypeOfGenerics)teSet)); + assertEquals("Set", SymTypeOfGenerics.unbox((SymTypeOfGenerics)teSetA)); + assertEquals("Map", SymTypeOfGenerics.unbox((SymTypeOfGenerics)teMap)); + assertEquals("Map,x.Foo>", SymTypeOfGenerics.unbox((SymTypeOfGenerics)teMap2)); } @Test public void boxTest() { - Assertions.assertEquals("java.util.Set>", SymTypeOfGenerics.box((SymTypeOfGenerics) teSetB)); - Assertions.assertEquals("java.util.Set", SymTypeOfGenerics.box((SymTypeOfGenerics) teSet)); - Assertions.assertEquals("java.util.Set", SymTypeOfGenerics.box((SymTypeOfGenerics) teSetA)); - Assertions.assertEquals("java.util.Map", SymTypeOfGenerics.box((SymTypeOfGenerics)teMap)); - Assertions.assertEquals("java.util.Map,x.Foo>", SymTypeOfGenerics.box((SymTypeOfGenerics)teMap2)); + assertEquals("java.util.Set>", SymTypeOfGenerics.box((SymTypeOfGenerics) teSetB)); + assertEquals("java.util.Set", SymTypeOfGenerics.box((SymTypeOfGenerics) teSet)); + assertEquals("java.util.Set", SymTypeOfGenerics.box((SymTypeOfGenerics) teSetA)); + assertEquals("java.util.Map", SymTypeOfGenerics.box((SymTypeOfGenerics)teMap)); + assertEquals("java.util.Map,x.Foo>", SymTypeOfGenerics.box((SymTypeOfGenerics)teMap2)); } @Test public void testHasTypeInfo() { - Assertions.assertTrue(teInt.hasTypeInfo()); - Assertions.assertFalse(teVarA.hasTypeInfo()); - Assertions.assertFalse(teVarB.hasTypeInfo()); - Assertions.assertFalse(teVarUpper.hasTypeInfo()); - Assertions.assertFalse(teVarLower.hasTypeInfo()); - Assertions.assertTrue(teIntA.hasTypeInfo()); - Assertions.assertTrue(teP.hasTypeInfo()); - Assertions.assertTrue(teH.hasTypeInfo()); - Assertions.assertFalse(teVoid.hasTypeInfo()); - Assertions.assertFalse(teNull.hasTypeInfo()); - Assertions.assertFalse(teArr1.hasTypeInfo()); - Assertions.assertFalse(teArr3.hasTypeInfo()); - Assertions.assertTrue(teSetA.hasTypeInfo()); - Assertions.assertTrue(teSetB.hasTypeInfo()); - Assertions.assertTrue(teSetC.hasTypeInfo()); - Assertions.assertTrue(teMap.hasTypeInfo()); - Assertions.assertTrue(teMapA.hasTypeInfo()); - Assertions.assertTrue(teMap3.hasTypeInfo()); - Assertions.assertTrue(teFoo.hasTypeInfo()); - Assertions.assertTrue(teDeep1.hasTypeInfo()); - Assertions.assertTrue(teDeep2.hasTypeInfo()); - Assertions.assertFalse(teUpperBound.hasTypeInfo()); - Assertions.assertFalse(teLowerBound.hasTypeInfo()); - Assertions.assertFalse(teWildcard.hasTypeInfo()); - Assertions.assertFalse(teFunc1.hasTypeInfo()); - Assertions.assertFalse(teFunc2.hasTypeInfo()); - Assertions.assertFalse(teFunc3.hasTypeInfo()); - Assertions.assertFalse(teFunc4.hasTypeInfo()); - Assertions.assertFalse(teSIUnit1.hasTypeInfo()); - Assertions.assertFalse(teNumWithSIUnit1.hasTypeInfo()); - Assertions.assertFalse(teUnion1.hasTypeInfo()); - Assertions.assertFalse(teTuple1.hasTypeInfo()); - Assertions.assertFalse(teRegEx1.hasTypeInfo()); - Assertions.assertFalse(teObscure.hasTypeInfo()); + assertTrue(teInt.hasTypeInfo()); + assertFalse(teVarA.hasTypeInfo()); + assertFalse(teVarB.hasTypeInfo()); + assertFalse(teVarUpper.hasTypeInfo()); + assertFalse(teVarLower.hasTypeInfo()); + assertTrue(teIntA.hasTypeInfo()); + assertTrue(teP.hasTypeInfo()); + assertTrue(teH.hasTypeInfo()); + assertFalse(teVoid.hasTypeInfo()); + assertFalse(teNull.hasTypeInfo()); + assertFalse(teArr1.hasTypeInfo()); + assertFalse(teArr3.hasTypeInfo()); + assertTrue(teSetA.hasTypeInfo()); + assertTrue(teSetB.hasTypeInfo()); + assertTrue(teSetC.hasTypeInfo()); + assertTrue(teMap.hasTypeInfo()); + assertTrue(teMapA.hasTypeInfo()); + assertTrue(teMap3.hasTypeInfo()); + assertTrue(teFoo.hasTypeInfo()); + assertTrue(teDeep1.hasTypeInfo()); + assertTrue(teDeep2.hasTypeInfo()); + assertFalse(teUpperBound.hasTypeInfo()); + assertFalse(teLowerBound.hasTypeInfo()); + assertFalse(teWildcard.hasTypeInfo()); + assertFalse(teFunc1.hasTypeInfo()); + assertFalse(teFunc2.hasTypeInfo()); + assertFalse(teFunc3.hasTypeInfo()); + assertFalse(teFunc4.hasTypeInfo()); + assertFalse(teSIUnit1.hasTypeInfo()); + assertFalse(teNumWithSIUnit1.hasTypeInfo()); + assertFalse(teUnion1.hasTypeInfo()); + assertFalse(teTuple1.hasTypeInfo()); + assertFalse(teRegEx1.hasTypeInfo()); + assertFalse(teObscure.hasTypeInfo()); } @Test public void deepCloneTest(){ //SymTypeVoid - Assertions.assertTrue(teVoid.deepClone() instanceof SymTypeVoid); - Assertions.assertEquals(teVoid.getTypeInfo().getName(), teVoid.deepClone().getTypeInfo().getName()); - Assertions.assertEquals(teVoid.print(), teVoid.deepClone().print()); + assertTrue(teVoid.deepClone() instanceof SymTypeVoid); + assertEquals(teVoid.getTypeInfo().getName(), teVoid.deepClone().getTypeInfo().getName()); + assertEquals(teVoid.print(), teVoid.deepClone().print()); //SymTypeOfNull - Assertions.assertTrue(teNull.deepClone() instanceof SymTypeOfNull); - Assertions.assertEquals(teNull.getTypeInfo().getName(), teNull.deepClone().getTypeInfo().getName()); - Assertions.assertEquals(teNull.print(), teNull.deepClone().print()); + assertTrue(teNull.deepClone() instanceof SymTypeOfNull); + assertEquals(teNull.getTypeInfo().getName(), teNull.deepClone().getTypeInfo().getName()); + assertEquals(teNull.print(), teNull.deepClone().print()); //SymTypeVariable - Assertions.assertTrue(teVarA.deepClone() instanceof SymTypeVariable); - Assertions.assertFalse(teVarA.deepClone().isPrimitive()); - Assertions.assertTrue(teVarA.deepClone().isTypeVariable()); - Assertions.assertEquals(teVarA.print(), teVarA.deepClone().print()); + assertTrue(teVarA.deepClone() instanceof SymTypeVariable); + assertFalse(teVarA.deepClone().isPrimitive()); + assertTrue(teVarA.deepClone().isTypeVariable()); + assertEquals(teVarA.print(), teVarA.deepClone().print()); - Assertions.assertTrue(teVarUpper.deepClone() instanceof SymTypeInferenceVariable); - Assertions.assertFalse(teVarUpper.deepClone().isPrimitive()); - Assertions.assertTrue(teVarUpper.deepClone().isInferenceVariable()); - Assertions.assertEquals(teVarUpper.print(), teVarUpper.deepClone().print()); + assertTrue(teVarUpper.deepClone() instanceof SymTypeInferenceVariable); + assertFalse(teVarUpper.deepClone().isPrimitive()); + assertTrue(teVarUpper.deepClone().isInferenceVariable()); + assertEquals(teVarUpper.print(), teVarUpper.deepClone().print()); - Assertions.assertTrue(teVarLower.deepClone() instanceof SymTypeInferenceVariable); - Assertions.assertFalse(teVarLower.deepClone().isPrimitive()); - Assertions.assertTrue(teVarLower.deepClone().isInferenceVariable()); - Assertions.assertEquals(teVarLower.print(), teVarLower.deepClone().print()); + assertTrue(teVarLower.deepClone() instanceof SymTypeInferenceVariable); + assertFalse(teVarLower.deepClone().isPrimitive()); + assertTrue(teVarLower.deepClone().isInferenceVariable()); + assertEquals(teVarLower.print(), teVarLower.deepClone().print()); //SymTypePrimitive - Assertions.assertTrue(teInt.deepClone() instanceof SymTypePrimitive); - Assertions.assertEquals(teInt.getTypeInfo().getName(), teInt.deepClone().getTypeInfo().getName()); - Assertions.assertTrue(teInt.deepClone().isPrimitive()); - Assertions.assertEquals(teInt.print(), teInt.deepClone().print()); + assertTrue(teInt.deepClone() instanceof SymTypePrimitive); + assertEquals(teInt.getTypeInfo().getName(), teInt.deepClone().getTypeInfo().getName()); + assertTrue(teInt.deepClone().isPrimitive()); + assertEquals(teInt.print(), teInt.deepClone().print()); //SymTypeOfObject - Assertions.assertTrue(teH.deepClone() instanceof SymTypeOfObject); - Assertions.assertEquals(teH.print(), teH.deepClone().print()); + assertTrue(teH.deepClone() instanceof SymTypeOfObject); + assertEquals(teH.print(), teH.deepClone().print()); //SymTypeArray - Assertions.assertTrue(teArr1.deepClone() instanceof SymTypeArray); - Assertions.assertEquals(teArr1.print(), teArr1.deepClone().print()); - Assertions.assertEquals(((SymTypeArray)teArr1).getDim(), ((SymTypeArray)teArr1.deepClone()).getDim()); - Assertions.assertEquals(((SymTypeArray)teArr1).getArgument().print(), ((SymTypeArray)teArr1.deepClone()).getArgument().print()); + assertTrue(teArr1.deepClone() instanceof SymTypeArray); + assertEquals(teArr1.print(), teArr1.deepClone().print()); + assertEquals(((SymTypeArray)teArr1).getDim(), ((SymTypeArray)teArr1.deepClone()).getDim()); + assertEquals(((SymTypeArray)teArr1).getArgument().print(), ((SymTypeArray)teArr1.deepClone()).getArgument().print()); //SymTypeOfGenerics - Assertions.assertTrue(teDeep1.deepClone() instanceof SymTypeOfGenerics); - Assertions.assertTrue(teDeep1.deepClone().isGenericType()); - Assertions.assertEquals(teDeep1.print(), teDeep1.deepClone().print()); + assertTrue(teDeep1.deepClone() instanceof SymTypeOfGenerics); + assertTrue(teDeep1.deepClone().isGenericType()); + assertEquals(teDeep1.print(), teDeep1.deepClone().print()); //SymTypeOfWildcard - Assertions.assertTrue(teUpperBound.deepClone() instanceof SymTypeOfWildcard); - Assertions.assertEquals(((SymTypeOfWildcard) teUpperBound).getBound().print(), ((SymTypeOfWildcard) teUpperBound.deepClone()).getBound().print()); - Assertions.assertEquals(teUpperBound.print(), teUpperBound.deepClone().print()); + assertTrue(teUpperBound.deepClone() instanceof SymTypeOfWildcard); + assertEquals(((SymTypeOfWildcard) teUpperBound).getBound().print(), ((SymTypeOfWildcard) teUpperBound.deepClone()).getBound().print()); + assertEquals(teUpperBound.print(), teUpperBound.deepClone().print()); //SymTypeOfFunction - Assertions.assertTrue(teFunc3.deepClone() instanceof SymTypeOfFunction); - Assertions.assertTrue(teFunc3.deepClone().isFunctionType()); - Assertions.assertEquals(teFunc3.print(), teFunc3.deepClone().print()); + assertTrue(teFunc3.deepClone() instanceof SymTypeOfFunction); + assertTrue(teFunc3.deepClone().isFunctionType()); + assertEquals(teFunc3.print(), teFunc3.deepClone().print()); // SymTypeOfSIUnit - Assertions.assertTrue(teSIUnit1.deepClone() instanceof SymTypeOfSIUnit); - Assertions.assertTrue(teSIUnit1.deepClone().isSIUnitType()); - Assertions.assertEquals(teSIUnit1.print(), teSIUnit1.deepClone().print()); + assertTrue(teSIUnit1.deepClone() instanceof SymTypeOfSIUnit); + assertTrue(teSIUnit1.deepClone().isSIUnitType()); + assertEquals(teSIUnit1.print(), teSIUnit1.deepClone().print()); // SymTypeOfNumericWithSIUnit - Assertions.assertTrue(teNumWithSIUnit1.deepClone() instanceof SymTypeOfNumericWithSIUnit); - Assertions.assertTrue(teNumWithSIUnit1.deepClone().isNumericWithSIUnitType()); - Assertions.assertEquals(teNumWithSIUnit1.print(), teNumWithSIUnit1.deepClone().print()); + assertTrue(teNumWithSIUnit1.deepClone() instanceof SymTypeOfNumericWithSIUnit); + assertTrue(teNumWithSIUnit1.deepClone().isNumericWithSIUnitType()); + assertEquals(teNumWithSIUnit1.print(), teNumWithSIUnit1.deepClone().print()); //SymTypeOfUnion - Assertions.assertTrue(teUnion1.deepClone() instanceof SymTypeOfUnion); - Assertions.assertTrue(teUnion1.deepClone().isUnionType()); - Assertions.assertEquals(teUnion1.print(), teUnion1.deepClone().print()); + assertTrue(teUnion1.deepClone() instanceof SymTypeOfUnion); + assertTrue(teUnion1.deepClone().isUnionType()); + assertEquals(teUnion1.print(), teUnion1.deepClone().print()); //SymTypeOfIntersection - Assertions.assertTrue(teInter1.deepClone() instanceof SymTypeOfIntersection); - Assertions.assertTrue(teInter1.deepClone().isIntersectionType()); - Assertions.assertEquals(teInter1.print(), teInter1.deepClone().print()); + assertTrue(teInter1.deepClone() instanceof SymTypeOfIntersection); + assertTrue(teInter1.deepClone().isIntersectionType()); + assertEquals(teInter1.print(), teInter1.deepClone().print()); //SymTypeOfTuple - Assertions.assertTrue(teTuple1.deepClone() instanceof SymTypeOfTuple); - Assertions.assertTrue(teTuple1.deepClone().isTupleType()); - Assertions.assertEquals(teTuple1.print(), teTuple1.deepClone().print()); + assertTrue(teTuple1.deepClone() instanceof SymTypeOfTuple); + assertTrue(teTuple1.deepClone().isTupleType()); + assertEquals(teTuple1.print(), teTuple1.deepClone().print()); - Assertions.assertTrue(teRegEx1.deepClone() instanceof SymTypeOfRegEx); - Assertions.assertTrue(teRegEx1.deepClone().isRegExType()); - Assertions.assertEquals(teRegEx1.print(), teRegEx1.deepClone().print()); + assertTrue(teRegEx1.deepClone() instanceof SymTypeOfRegEx); + assertTrue(teRegEx1.deepClone().isRegExType()); + assertEquals(teRegEx1.print(), teRegEx1.deepClone().print()); } @Test public void testSymTypeExpressionFactory(){ SymTypeVoid tVoid = SymTypeExpressionFactory.createTypeVoid(); - Assertions.assertEquals("void", tVoid.print()); + assertEquals("void", tVoid.print()); SymTypeOfNull tNull = SymTypeExpressionFactory.createTypeOfNull(); - Assertions.assertEquals("null", tNull.print()); + assertEquals("null", tNull.print()); SymTypePrimitive tInt = SymTypeExpressionFactory.createPrimitive("int"); - Assertions.assertEquals("int", tInt.print()); - Assertions.assertTrue(tInt.isIntegralType()); + assertEquals("int", tInt.print()); + assertTrue(tInt.isIntegralType()); SymTypeOfGenerics tA = SymTypeExpressionFactory.createGenerics("A",scope); - Assertions.assertEquals("A<>", tA.print()); - Assertions.assertTrue(tA.isEmptyArguments()); + assertEquals("A<>", tA.print()); + assertTrue(tA.isEmptyArguments()); SymTypeOfGenerics tB = SymTypeExpressionFactory.createGenerics("B",scope,Lists.newArrayList(teArr1,teIntA)); - Assertions.assertEquals("B", tB.printFullName()); - Assertions.assertEquals(2, tB.sizeArguments()); + assertEquals("B", tB.printFullName()); + assertEquals(2, tB.sizeArguments()); SymTypeOfGenerics tC = SymTypeExpressionFactory.createGenerics("C",scope,teDeep1,teDeep2); - Assertions.assertEquals("C>,java.util.Map2>>>", tC.printFullName()); - Assertions.assertEquals(2, tC.sizeArguments()); + assertEquals("C>,java.util.Map2>>>", tC.printFullName()); + assertEquals(2, tC.sizeArguments()); SymTypeOfGenerics tD = SymTypeExpressionFactory.createGenerics("D",scope); - Assertions.assertEquals("D<>", tD.printFullName()); - Assertions.assertTrue(tD.isEmptyArguments()); + assertEquals("D<>", tD.printFullName()); + assertTrue(tD.isEmptyArguments()); SymTypeOfGenerics tE = SymTypeExpressionFactory.createGenerics("E",scope,Lists.newArrayList(teDouble,teMap)); - Assertions.assertEquals("E>", tE.printFullName()); - Assertions.assertEquals(2, tE.sizeArguments()); + assertEquals("E>", tE.printFullName()); + assertEquals(2, tE.sizeArguments()); SymTypeOfGenerics tF = SymTypeExpressionFactory.createGenerics("F",scope,teH,teP); - Assertions.assertEquals("F", tF.printFullName()); - Assertions.assertEquals(2, tF.sizeArguments()); + assertEquals("F", tF.printFullName()); + assertEquals(2, tF.sizeArguments()); SymTypeArray tHuman = SymTypeExpressionFactory.createTypeArray("Human",scope,1,teH); - Assertions.assertEquals("Human[]", tHuman.print()); - Assertions.assertEquals(1, tHuman.getDim()); - Assertions.assertEquals("Human", tHuman.getArgument().print()); + assertEquals("Human[]", tHuman.print()); + assertEquals(1, tHuman.getDim()); + assertEquals("Human", tHuman.getArgument().print()); SymTypeArray tPerson = SymTypeExpressionFactory.createTypeArray("de.x.Person",scope,2,teP); - Assertions.assertEquals("de.x.Person[][]", tPerson.print()); - Assertions.assertEquals(2, tPerson.getDim()); - Assertions.assertEquals("de.x.Person", tPerson.getArgument().print()); + assertEquals("de.x.Person[][]", tPerson.print()); + assertEquals(2, tPerson.getDim()); + assertEquals("de.x.Person", tPerson.getArgument().print()); SymTypeOfObject tG = SymTypeExpressionFactory.createTypeObjectViaSurrogate("G",scope); - Assertions.assertEquals("G", tG.print()); + assertEquals("G", tG.print()); SymTypeOfObject tH = SymTypeExpressionFactory.createTypeObjectViaSurrogate("H",scope); - Assertions.assertEquals("H", tH.print()); + assertEquals("H", tH.print()); SymTypeVariable tT = SymTypeExpressionFactory.createTypeVariable("T",scope); - Assertions.assertEquals("T", tT.print()); + assertEquals("T", tT.print()); SymTypeVariable tS = SymTypeExpressionFactory.createTypeVariable("S",scope); - Assertions.assertEquals("S", tS.print()); + assertEquals("S", tS.print()); SymTypeExpression tExpr = SymTypeExpressionFactory.createTypeExpression("void",scope); - Assertions.assertTrue(tExpr instanceof SymTypeVoid); - Assertions.assertEquals("void", tExpr.print()); + assertInstanceOf(SymTypeVoid.class, tExpr); + assertEquals("void", tExpr.print()); SymTypeOfFunction tFunc1 = SymTypeExpressionFactory.createFunction(tVoid); - Assertions.assertEquals("() -> void", tFunc1.print()); + assertEquals("() -> void", tFunc1.print()); SymTypeOfFunction tFunc2 = SymTypeExpressionFactory.createFunction(tVoid, Lists.newArrayList(tFunc1, tFunc1)); - Assertions.assertEquals("((() -> void), (() -> void)) -> void", tFunc2.print()); + assertEquals("((() -> void), (() -> void)) -> void", tFunc2.print()); SymTypeOfFunction tFunc3 = SymTypeExpressionFactory.createFunction(tVoid, tFunc1, tFunc1); - Assertions.assertEquals("((() -> void), (() -> void)) -> void", tFunc3.print()); + assertEquals("((() -> void), (() -> void)) -> void", tFunc3.print()); SymTypeOfFunction tFunc4 = SymTypeExpressionFactory.createFunction(tVoid, Lists.newArrayList(teDouble, teInt), true); - Assertions.assertEquals("(double, int...) -> void", tFunc4.print()); + assertEquals("(double, int...) -> void", tFunc4.print()); SIUnitBasic tSIUnitBasic1 = createSIUnitBasic("m"); - Assertions.assertEquals("m", tSIUnitBasic1.print()); + assertEquals("m", tSIUnitBasic1.print()); SIUnitBasic tSIUnitBasic2 = createSIUnitBasic("s", 2); - Assertions.assertEquals("s^2", tSIUnitBasic2.print()); + assertEquals("s^2", tSIUnitBasic2.print()); SIUnitBasic tSIUnitBasic3 = createSIUnitBasic("g", "m", -2); - Assertions.assertEquals("mg^-2", tSIUnitBasic3.print()); + assertEquals("mg^-2", tSIUnitBasic3.print()); SymTypeOfSIUnit tSIUnit1 = createSIUnit(List.of(tSIUnitBasic1), List.of()); - Assertions.assertEquals("[m]", tSIUnit1.print()); + assertEquals("[m]", tSIUnit1.print()); SymTypeOfSIUnit tSIUnit2 = createSIUnit(List.of(), List.of(tSIUnitBasic2)); - Assertions.assertEquals("[1/s^2]", tSIUnit2.print()); + assertEquals("[1/s^2]", tSIUnit2.print()); SymTypeOfSIUnit tSIUnit3 = createSIUnit( List.of(tSIUnitBasic1), List.of(tSIUnitBasic2, tSIUnitBasic3) ); - Assertions.assertEquals("[m/s^2mg^-2]", tSIUnit3.print()); + assertEquals("[m/s^2mg^-2]", tSIUnit3.print()); SymTypeOfNumericWithSIUnit tNumSIUnit1 = createNumericWithSIUnit(tSIUnit1, teInt); - Assertions.assertEquals("[m]", tNumSIUnit1.print()); + assertEquals("[m]", tNumSIUnit1.print()); SymTypeOfNumericWithSIUnit tNumSIUnit2 = createNumericWithSIUnit( List.of(tSIUnitBasic1), List.of(tSIUnitBasic2, tSIUnitBasic3), teInt ); - Assertions.assertEquals("[m/s^2mg^-2]", tNumSIUnit2.print()); + assertEquals("[m/s^2mg^-2]", tNumSIUnit2.print()); SymTypeOfUnion tUnion1 = createUnion(teInt, teDouble); - Assertions.assertEquals("double | int", tUnion1.print()); + assertEquals("double | int", tUnion1.print()); SymTypeOfUnion tUnion2 = createUnion(Set.of(teInt, teDouble, teArr1)); - Assertions.assertEquals("Human[] | double | int", tUnion2.print()); + assertEquals("Human[] | double | int", tUnion2.print()); SymTypeOfIntersection tInter1 = createIntersection(teInt, teDouble); - Assertions.assertEquals("double & int", tInter1.print()); + assertEquals("double & int", tInter1.print()); SymTypeOfIntersection tInter2 = createIntersection(Set.of(teInt, teDouble, teArr1)); - Assertions.assertEquals("Human[] & double & int", tInter2.print()); + assertEquals("Human[] & double & int", tInter2.print()); SymTypeOfTuple tTuple1 = createTuple(teInt, teDouble); - Assertions.assertEquals("(int, double)", tTuple1.print()); + assertEquals("(int, double)", tTuple1.print()); SymTypeOfTuple tTuple2 = createTuple(List.of(teInt, teDouble)); - Assertions.assertEquals("(int, double)", tTuple2.print()); + assertEquals("(int, double)", tTuple2.print()); SymTypeOfRegEx tRegEx1 = createTypeRegEx("rege(x(es)?|xps?)"); - Assertions.assertEquals("R\"rege(x(es)?|xps?)\"", tRegEx1.print()); + assertEquals("R\"rege(x(es)?|xps?)\"", tRegEx1.print()); } @Test @@ -778,402 +776,402 @@ public void testSymTypeExpressionFactoryString() { @Test public void testGenericArguments(){ SymTypeExpression teFoo = createGenerics("x.Foo", scope, Lists.newArrayList(teP, teDouble, teInt, teH)); - Assertions.assertTrue(teFoo.isGenericType()); + assertTrue(teFoo.isGenericType()); SymTypeOfGenerics teFoo2 = (SymTypeOfGenerics) teFoo; //getArgumentList & getArgument - Assertions.assertEquals(4, teFoo2.getArgumentList().size()); - Assertions.assertEquals(teP, teFoo2.getArgument(0)); - Assertions.assertEquals(teDouble, teFoo2.getArgument(1)); - Assertions.assertEquals(teInt, teFoo2.getArgument(2)); - Assertions.assertEquals(teH, teFoo2.getArgument(3)); + assertEquals(4, teFoo2.getArgumentList().size()); + assertEquals(teP, teFoo2.getArgument(0)); + assertEquals(teDouble, teFoo2.getArgument(1)); + assertEquals(teInt, teFoo2.getArgument(2)); + assertEquals(teH, teFoo2.getArgument(3)); List arguments = teFoo2.getArgumentList(); //toArrayArguments Object[] args = teFoo2.toArrayArguments(); - Assertions.assertEquals(teP, args[0]); - Assertions.assertEquals(teDouble, args[1]); - Assertions.assertEquals(teInt, args[2]); - Assertions.assertEquals(teH, args[3]); + assertEquals(teP, args[0]); + assertEquals(teDouble, args[1]); + assertEquals(teInt, args[2]); + assertEquals(teH, args[3]); //toArrayArguments2 SymTypeExpression[] symArgs = teFoo2.toArrayArguments(new SymTypeExpression[4]); - Assertions.assertEquals(teP, symArgs[0]); - Assertions.assertEquals(teDouble, symArgs[1]); - Assertions.assertEquals(teInt, symArgs[2]); - Assertions.assertEquals(teH, symArgs[3]); + assertEquals(teP, symArgs[0]); + assertEquals(teDouble, symArgs[1]); + assertEquals(teInt, symArgs[2]); + assertEquals(teH, symArgs[3]); //subListArguments List subList = teFoo2.subListArguments(1,3); - Assertions.assertEquals(2, subList.size()); - Assertions.assertEquals(teDouble, subList.get(0)); - Assertions.assertEquals(teInt, subList.get(1)); + assertEquals(2, subList.size()); + assertEquals(teDouble, subList.get(0)); + assertEquals(teInt, subList.get(1)); //containsArgument - Assertions.assertTrue(teFoo2.containsArgument(teDouble)); - Assertions.assertFalse(teFoo2.containsArgument(teDeep1)); + assertTrue(teFoo2.containsArgument(teDouble)); + assertFalse(teFoo2.containsArgument(teDeep1)); //containsAllArguments - Assertions.assertTrue(teFoo2.containsAllArguments(subList)); + assertTrue(teFoo2.containsAllArguments(subList)); //indexOfArgument - Assertions.assertEquals(0, teFoo2.indexOfArgument(teP)); + assertEquals(0, teFoo2.indexOfArgument(teP)); //lastIndexOfArgument - Assertions.assertEquals(0, teFoo2.lastIndexOfArgument(teP)); + assertEquals(0, teFoo2.lastIndexOfArgument(teP)); //equalsArguments - Assertions.assertTrue(teFoo2.equalsArguments(teFoo2.getArgumentList())); - Assertions.assertFalse(teFoo2.equalsArguments(subList)); + assertTrue(teFoo2.equalsArguments(teFoo2.getArgumentList())); + assertFalse(teFoo2.equalsArguments(subList)); //listIteratorArguments Iterator it = teFoo2.listIteratorArguments(); int i = 0; while(it.hasNext()){ - Assertions.assertEquals(symArgs[i], it.next()); + assertEquals(symArgs[i], it.next()); ++i; } - Assertions.assertEquals(4, i); + assertEquals(4, i); //listIteratorArguments Iterator it3 = teFoo2.listIteratorArguments(1); i=0; while(it3.hasNext()){ - Assertions.assertEquals(symArgs[i+1], it3.next()); + assertEquals(symArgs[i+1], it3.next()); ++i; } - Assertions.assertEquals(3, i); + assertEquals(3, i); //iteratorArguments Iterator it2 = teFoo2.iteratorArguments(); i = 0; while(it2.hasNext()){ - Assertions.assertEquals(symArgs[i], it2.next()); + assertEquals(symArgs[i], it2.next()); ++i; } - Assertions.assertEquals(4, i); + assertEquals(4, i); //spliteratorArguments Spliterator split = teFoo2.spliteratorArguments(); - Assertions.assertEquals(4, split.getExactSizeIfKnown()); + assertEquals(4, split.getExactSizeIfKnown()); split.forEachRemaining(SymTypeExpression::print); //sizeArguments - Assertions.assertEquals(4, teFoo2.sizeArguments()); + assertEquals(4, teFoo2.sizeArguments()); //streamArguments Stream stream =teFoo2.streamArguments(); List list = stream.filter(SymTypeExpression::isPrimitive) .collect(Collectors.toList()); - Assertions.assertEquals(2, list.size()); - Assertions.assertEquals(teDouble, list.get(0)); - Assertions.assertEquals(teInt, list.get(1)); + assertEquals(2, list.size()); + assertEquals(teDouble, list.get(0)); + assertEquals(teInt, list.get(1)); //parallelStreamArguments Stream parStream = teFoo2.parallelStreamArguments(); List parList = parStream.filter(SymTypeExpression::isPrimitive) .collect(Collectors.toList()); - Assertions.assertEquals(2, parList.size()); - Assertions.assertEquals(teDouble, parList.get(0)); - Assertions.assertEquals(teInt, parList.get(1)); + assertEquals(2, parList.size()); + assertEquals(teDouble, parList.get(0)); + assertEquals(teInt, parList.get(1)); //hashCodeArguments - Assertions.assertEquals(teFoo2.getArgumentList().hashCode(), teFoo2.hashCodeArguments()); + assertEquals(teFoo2.getArgumentList().hashCode(), teFoo2.hashCodeArguments()); //forEachArguments teFoo2.forEachArguments(SymTypeExpression::deepClone); - Assertions.assertEquals(teP, teFoo2.getArgument(0)); + assertEquals(teP, teFoo2.getArgument(0)); //setArgument teFoo2.setArgument(2,teDeep2); - Assertions.assertEquals(teDeep2, teFoo2.getArgument(2)); + assertEquals(teDeep2, teFoo2.getArgument(2)); //addArgument teFoo2.addArgument(teSetA); - Assertions.assertEquals(5, teFoo2.sizeArguments()); - Assertions.assertEquals(teSetA, teFoo2.getArgument(4)); + assertEquals(5, teFoo2.sizeArguments()); + assertEquals(teSetA, teFoo2.getArgument(4)); teFoo2.addArgument(3,teArr3); - Assertions.assertEquals(6, teFoo2.sizeArguments()); - Assertions.assertEquals(teArr3, teFoo2.getArgument(3)); + assertEquals(6, teFoo2.sizeArguments()); + assertEquals(teArr3, teFoo2.getArgument(3)); //removeArgument teFoo2.removeArgument(teArr3); - Assertions.assertFalse(teFoo2.containsArgument(teArr3)); - Assertions.assertEquals(5, teFoo2.sizeArguments()); + assertFalse(teFoo2.containsArgument(teArr3)); + assertEquals(5, teFoo2.sizeArguments()); teFoo2.removeArgument(4); - Assertions.assertFalse(teFoo2.containsArgument(teSetA)); - Assertions.assertEquals(4, teFoo2.sizeArguments()); + assertFalse(teFoo2.containsArgument(teSetA)); + assertEquals(4, teFoo2.sizeArguments()); //clearArguments, isEmptyArguments - Assertions.assertFalse(teFoo2.isEmptyArguments()); + assertFalse(teFoo2.isEmptyArguments()); teFoo2.clearArguments(); - Assertions.assertEquals(0, teFoo2.sizeArguments()); - Assertions.assertTrue(teFoo2.isEmptyArguments()); + assertEquals(0, teFoo2.sizeArguments()); + assertTrue(teFoo2.isEmptyArguments()); //setArgumentList arguments = Lists.newArrayList(teP,teDouble,teInt,teH); teFoo2.setArgumentList(arguments); - Assertions.assertEquals(4, teFoo2.sizeArguments()); - Assertions.assertEquals(teP, teFoo2.getArgument(0)); - Assertions.assertEquals(teDouble, teFoo2.getArgument(1)); - Assertions.assertEquals(teInt, teFoo2.getArgument(2)); - Assertions.assertEquals(teH, teFoo2.getArgument(3)); + assertEquals(4, teFoo2.sizeArguments()); + assertEquals(teP, teFoo2.getArgument(0)); + assertEquals(teDouble, teFoo2.getArgument(1)); + assertEquals(teInt, teFoo2.getArgument(2)); + assertEquals(teH, teFoo2.getArgument(3)); //sortArguments teFoo2.sortArguments((arg1,arg2) -> arg1.hashCode()+arg2.hashCode()); - Assertions.assertEquals(4, teFoo2.sizeArguments()); + assertEquals(4, teFoo2.sizeArguments()); //addAllArguments teFoo2.setArgumentList(Lists.newArrayList()); - Assertions.assertTrue(teFoo2.isEmptyArguments()); + assertTrue(teFoo2.isEmptyArguments()); arguments = Lists.newArrayList(teP,teDouble,teInt,teH); teFoo2.addAllArguments(arguments); - Assertions.assertEquals(4, teFoo2.getArgumentList().size()); - Assertions.assertEquals(teP, teFoo2.getArgument(0)); - Assertions.assertEquals(teDouble, teFoo2.getArgument(1)); - Assertions.assertEquals(teInt, teFoo2.getArgument(2)); - Assertions.assertEquals(teH, teFoo2.getArgument(3)); + assertEquals(4, teFoo2.getArgumentList().size()); + assertEquals(teP, teFoo2.getArgument(0)); + assertEquals(teDouble, teFoo2.getArgument(1)); + assertEquals(teInt, teFoo2.getArgument(2)); + assertEquals(teH, teFoo2.getArgument(3)); //retainAllArguments subList = Lists.newArrayList(teP,teH); teFoo2.retainAllArguments(subList); - Assertions.assertEquals(2, teFoo2.sizeArguments()); - Assertions.assertEquals(teP, teFoo2.getArgument(0)); - Assertions.assertEquals(teH, teFoo2.getArgument(1)); + assertEquals(2, teFoo2.sizeArguments()); + assertEquals(teP, teFoo2.getArgument(0)); + assertEquals(teH, teFoo2.getArgument(1)); //removeAllArguments teFoo2.removeAllArguments(subList); - Assertions.assertTrue(teFoo2.isEmptyArguments()); + assertTrue(teFoo2.isEmptyArguments()); //replaceAllArguments arguments = Lists.newArrayList(teP,teDouble,teInt,teH); teFoo2.setArgumentList(arguments); teFoo2.replaceAllArguments(SymTypeExpression::deepClone); - Assertions.assertEquals(4, teFoo2.sizeArguments()); - Assertions.assertTrue(teFoo2.equalsArguments(arguments)); + assertEquals(4, teFoo2.sizeArguments()); + assertTrue(teFoo2.equalsArguments(arguments)); //removeIfArgument teFoo2.removeIfArgument(SymTypeExpression::isPrimitive); - Assertions.assertEquals(2, teFoo2.sizeArguments()); + assertEquals(2, teFoo2.sizeArguments()); } @Test public void symTypeArrayTest(){ SymTypeArray array = SymTypeExpressionFactory.createTypeArray("int",scope,1,_intSymType); - Assertions.assertEquals("int[]", array.print()); + assertEquals("int[]", array.print()); array.setDim(2); - Assertions.assertEquals("int[][]", array.print()); + assertEquals("int[][]", array.print()); } @Test public void symTypeArrayCloneWithLessDimTest() { SymTypeArray arr3 = (SymTypeArray) teArr3; - Assertions.assertEquals("int[][][][]", arr3.cloneWithLessDim(-1).print()); - Assertions.assertEquals("int[][][]", arr3.cloneWithLessDim(0).print()); - Assertions.assertEquals("int[][]", arr3.cloneWithLessDim(1).print()); - Assertions.assertEquals("int[]", arr3.cloneWithLessDim(2).print()); - Assertions.assertEquals("int", arr3.cloneWithLessDim(3).print()); - Assertions.assertFalse(arr3.cloneWithLessDim(3).isArrayType()); + assertEquals("int[][][][]", arr3.cloneWithLessDim(-1).print()); + assertEquals("int[][][]", arr3.cloneWithLessDim(0).print()); + assertEquals("int[][]", arr3.cloneWithLessDim(1).print()); + assertEquals("int[]", arr3.cloneWithLessDim(2).print()); + assertEquals("int", arr3.cloneWithLessDim(3).print()); + assertFalse(arr3.cloneWithLessDim(3).isArrayType()); } @Test public void symTypePrimitiveTest(){ SymTypePrimitive intType = SymTypeExpressionFactory.createPrimitive("int"); - Assertions.assertEquals("int", intType.print()); + assertEquals("int", intType.print()); - Assertions.assertEquals("java.lang.Integer", intType.getBoxedPrimitiveName()); - Assertions.assertTrue(intType.isIntegralType()); - Assertions.assertTrue(intType.isNumericType()); + assertEquals("java.lang.Integer", intType.getBoxedPrimitiveName()); + assertTrue(intType.isIntegralType()); + assertTrue(intType.isNumericType()); } @Test public void symTypeOfWildcardTest(){ SymTypeOfWildcard upperBoundInt = (SymTypeOfWildcard) teUpperBound; - Assertions.assertEquals("? extends int", upperBoundInt.print()); - Assertions.assertEquals("int", upperBoundInt.getBound().print()); - Assertions.assertTrue(upperBoundInt.isUpper()); + assertEquals("? extends int", upperBoundInt.print()); + assertEquals("int", upperBoundInt.getBound().print()); + assertTrue(upperBoundInt.isUpper()); } @Test public void testFunctionArguments() { SymTypeExpression teFunExp = createFunction(teVoid, Lists.newArrayList(teP, teDouble, teInt, teH)); - Assertions.assertTrue(teFunExp.isFunctionType()); + assertTrue(teFunExp.isFunctionType()); SymTypeOfFunction teFun = (SymTypeOfFunction) teFunExp; //getArgumentTypeList & getArgumentType - Assertions.assertEquals(4, teFun.getArgumentTypeList().size()); - Assertions.assertEquals(teP, teFun.getArgumentType(0)); - Assertions.assertEquals(teDouble, teFun.getArgumentType(1)); - Assertions.assertEquals(teInt, teFun.getArgumentType(2)); - Assertions.assertEquals(teH, teFun.getArgumentType(3)); + assertEquals(4, teFun.getArgumentTypeList().size()); + assertEquals(teP, teFun.getArgumentType(0)); + assertEquals(teDouble, teFun.getArgumentType(1)); + assertEquals(teInt, teFun.getArgumentType(2)); + assertEquals(teH, teFun.getArgumentType(3)); List arguments = teFun.getArgumentTypeList(); //toArrayArguments Object[] args = teFun.toArrayArgumentTypes(); - Assertions.assertEquals(teP, args[0]); - Assertions.assertEquals(teDouble, args[1]); - Assertions.assertEquals(teInt, args[2]); - Assertions.assertEquals(teH, args[3]); + assertEquals(teP, args[0]); + assertEquals(teDouble, args[1]); + assertEquals(teInt, args[2]); + assertEquals(teH, args[3]); //toArrayArguments2 SymTypeExpression[] symArgs = teFun.toArrayArgumentTypes(new SymTypeExpression[4]); - Assertions.assertEquals(teP, symArgs[0]); - Assertions.assertEquals(teDouble, symArgs[1]); - Assertions.assertEquals(teInt, symArgs[2]); - Assertions.assertEquals(teH, symArgs[3]); + assertEquals(teP, symArgs[0]); + assertEquals(teDouble, symArgs[1]); + assertEquals(teInt, symArgs[2]); + assertEquals(teH, symArgs[3]); //subListArguments List subList = teFun.subListArgumentTypes(1, 3); - Assertions.assertEquals(2, subList.size()); - Assertions.assertEquals(teDouble, subList.get(0)); - Assertions.assertEquals(teInt, subList.get(1)); + assertEquals(2, subList.size()); + assertEquals(teDouble, subList.get(0)); + assertEquals(teInt, subList.get(1)); //containsArgument - Assertions.assertTrue(teFun.containsArgumentType(teDouble)); - Assertions.assertFalse(teFun.containsArgumentType(teDeep1)); + assertTrue(teFun.containsArgumentType(teDouble)); + assertFalse(teFun.containsArgumentType(teDeep1)); //containsAllArgumentTypes - Assertions.assertTrue(teFun.containsAllArgumentTypes(subList)); + assertTrue(teFun.containsAllArgumentTypes(subList)); //indexOfArgument - Assertions.assertEquals(0, teFun.indexOfArgumentType(teP)); + assertEquals(0, teFun.indexOfArgumentType(teP)); //lastIndexOfArgument - Assertions.assertEquals(0, teFun.lastIndexOfArgumentType(teP)); + assertEquals(0, teFun.lastIndexOfArgumentType(teP)); //equalsArgumentTypes - Assertions.assertTrue(teFun.equalsArgumentTypeTypes(teFun.getArgumentTypeList())); - Assertions.assertFalse(teFun.equalsArgumentTypeTypes(subList)); + assertTrue(teFun.equalsArgumentTypeTypes(teFun.getArgumentTypeList())); + assertFalse(teFun.equalsArgumentTypeTypes(subList)); //listIteratorArgumentTypes Iterator it = teFun.listIteratorArgumentTypes(); int i = 0; while (it.hasNext()) { - Assertions.assertEquals(symArgs[i], it.next()); + assertEquals(symArgs[i], it.next()); ++i; } - Assertions.assertEquals(4, i); + assertEquals(4, i); //listIteratorArgumentTypes Iterator it3 = teFun.listIteratorArgumentTypes(1); i = 0; while (it3.hasNext()) { - Assertions.assertEquals(symArgs[i + 1], it3.next()); + assertEquals(symArgs[i + 1], it3.next()); ++i; } - Assertions.assertEquals(3, i); + assertEquals(3, i); //iteratorArgumentTypes Iterator it2 = teFun.iteratorArgumentTypes(); i = 0; while (it2.hasNext()) { - Assertions.assertEquals(symArgs[i], it2.next()); + assertEquals(symArgs[i], it2.next()); ++i; } - Assertions.assertEquals(4, i); + assertEquals(4, i); //spliteratorArgumentTypes Spliterator split = teFun.spliteratorArgumentTypes(); - Assertions.assertEquals(4, split.getExactSizeIfKnown()); + assertEquals(4, split.getExactSizeIfKnown()); split.forEachRemaining(SymTypeExpression::print); //sizeArgumentTypes - Assertions.assertEquals(4, teFun.sizeArgumentTypes()); + assertEquals(4, teFun.sizeArgumentTypes()); //streamArgumentTypes Stream stream = teFun.streamArgumentTypes(); List list = stream.filter(SymTypeExpression::isPrimitive) .collect(Collectors.toList()); - Assertions.assertEquals(2, list.size()); - Assertions.assertEquals(teDouble, list.get(0)); - Assertions.assertEquals(teInt, list.get(1)); + assertEquals(2, list.size()); + assertEquals(teDouble, list.get(0)); + assertEquals(teInt, list.get(1)); //parallelStreamArgumentTypes Stream parStream = teFun.parallelStreamArgumentTypes(); List parList = parStream.filter(SymTypeExpression::isPrimitive) .collect(Collectors.toList()); - Assertions.assertEquals(2, parList.size()); - Assertions.assertEquals(teDouble, parList.get(0)); - Assertions.assertEquals(teInt, parList.get(1)); + assertEquals(2, parList.size()); + assertEquals(teDouble, parList.get(0)); + assertEquals(teInt, parList.get(1)); //hashCodeArgumentTypes - Assertions.assertEquals(teFun.getArgumentTypeList().hashCode(), teFun.hashCodeArgumentTypes()); + assertEquals(teFun.getArgumentTypeList().hashCode(), teFun.hashCodeArgumentTypes()); //forEachArgumentTypes teFun.forEachArgumentTypes(SymTypeExpression::deepClone); - Assertions.assertEquals(teP, teFun.getArgumentType(0)); + assertEquals(teP, teFun.getArgumentType(0)); //setArgument teFun.setArgumentType(2, teDeep2); - Assertions.assertEquals(teDeep2, teFun.getArgumentType(2)); + assertEquals(teDeep2, teFun.getArgumentType(2)); //addArgument teFun.addArgumentType(teSetA); - Assertions.assertEquals(5, teFun.sizeArgumentTypes()); - Assertions.assertEquals(teSetA, teFun.getArgumentType(4)); + assertEquals(5, teFun.sizeArgumentTypes()); + assertEquals(teSetA, teFun.getArgumentType(4)); teFun.addArgumentType(3, teArr3); - Assertions.assertEquals(6, teFun.sizeArgumentTypes()); - Assertions.assertEquals(teArr3, teFun.getArgumentType(3)); + assertEquals(6, teFun.sizeArgumentTypes()); + assertEquals(teArr3, teFun.getArgumentType(3)); //removeArgument teFun.removeArgumentType(teArr3); - Assertions.assertFalse(teFun.containsArgumentType(teArr3)); - Assertions.assertEquals(5, teFun.sizeArgumentTypes()); + assertFalse(teFun.containsArgumentType(teArr3)); + assertEquals(5, teFun.sizeArgumentTypes()); teFun.removeArgumentType(4); - Assertions.assertFalse(teFun.containsArgumentType(teSetA)); - Assertions.assertEquals(4, teFun.sizeArgumentTypes()); + assertFalse(teFun.containsArgumentType(teSetA)); + assertEquals(4, teFun.sizeArgumentTypes()); //clearArgumentTypes, isEmptyArgumentTypes - Assertions.assertFalse(teFun.isEmptyArgumentTypes()); + assertFalse(teFun.isEmptyArgumentTypes()); teFun.clearArgumentTypes(); - Assertions.assertEquals(0, teFun.sizeArgumentTypes()); - Assertions.assertTrue(teFun.isEmptyArgumentTypes()); + assertEquals(0, teFun.sizeArgumentTypes()); + assertTrue(teFun.isEmptyArgumentTypes()); //setArgumentList arguments = Lists.newArrayList(teP, teDouble, teInt, teH); teFun.setArgumentTypeList(arguments); - Assertions.assertEquals(4, teFun.sizeArgumentTypes()); - Assertions.assertEquals(teP, teFun.getArgumentType(0)); - Assertions.assertEquals(teDouble, teFun.getArgumentType(1)); - Assertions.assertEquals(teInt, teFun.getArgumentType(2)); - Assertions.assertEquals(teH, teFun.getArgumentType(3)); + assertEquals(4, teFun.sizeArgumentTypes()); + assertEquals(teP, teFun.getArgumentType(0)); + assertEquals(teDouble, teFun.getArgumentType(1)); + assertEquals(teInt, teFun.getArgumentType(2)); + assertEquals(teH, teFun.getArgumentType(3)); //sortArgumentTypes teFun.sortArgumentTypes((arg1, arg2) -> arg1.hashCode() + arg2.hashCode()); - Assertions.assertEquals(4, teFun.sizeArgumentTypes()); + assertEquals(4, teFun.sizeArgumentTypes()); //addAllArgumentTypes teFun.setArgumentTypeList(Lists.newArrayList()); - Assertions.assertTrue(teFun.isEmptyArgumentTypes()); + assertTrue(teFun.isEmptyArgumentTypes()); arguments = Lists.newArrayList(teP, teDouble, teInt, teH); teFun.addAllArgumentTypes(arguments); - Assertions.assertEquals(4, teFun.getArgumentTypeList().size()); - Assertions.assertEquals(teP, teFun.getArgumentType(0)); - Assertions.assertEquals(teDouble, teFun.getArgumentType(1)); - Assertions.assertEquals(teInt, teFun.getArgumentType(2)); - Assertions.assertEquals(teH, teFun.getArgumentType(3)); + assertEquals(4, teFun.getArgumentTypeList().size()); + assertEquals(teP, teFun.getArgumentType(0)); + assertEquals(teDouble, teFun.getArgumentType(1)); + assertEquals(teInt, teFun.getArgumentType(2)); + assertEquals(teH, teFun.getArgumentType(3)); //retainAllArgumentTypes subList = Lists.newArrayList(teP, teH); teFun.retainAllArgumentTypes(subList); - Assertions.assertEquals(2, teFun.sizeArgumentTypes()); - Assertions.assertEquals(teP, teFun.getArgumentType(0)); - Assertions.assertEquals(teH, teFun.getArgumentType(1)); + assertEquals(2, teFun.sizeArgumentTypes()); + assertEquals(teP, teFun.getArgumentType(0)); + assertEquals(teH, teFun.getArgumentType(1)); //removeAllArgumentTypes teFun.removeAllArgumentTypes(subList); - Assertions.assertTrue(teFun.isEmptyArgumentTypes()); + assertTrue(teFun.isEmptyArgumentTypes()); //replaceAllArgumentTypes arguments = Lists.newArrayList(teP, teDouble, teInt, teH); teFun.setArgumentTypeList(arguments); teFun.replaceAllArgumentTypes(SymTypeExpression::deepClone); - Assertions.assertEquals(4, teFun.sizeArgumentTypes()); - Assertions.assertTrue(teFun.equalsArgumentTypeTypes(arguments)); + assertEquals(4, teFun.sizeArgumentTypes()); + assertTrue(teFun.equalsArgumentTypeTypes(arguments)); //removeIfArgument teFun.removeIfArgumentType(SymTypeExpression::isPrimitive); - Assertions.assertEquals(2, teFun.sizeArgumentTypes()); + assertEquals(2, teFun.sizeArgumentTypes()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeComponentFromMCBasicTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeComponentFromMCBasicTypesTest.java index c3a57cdfa6..1643297797 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeComponentFromMCBasicTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeComponentFromMCBasicTypesTest.java @@ -11,12 +11,13 @@ import de.monticore.types.mcbasictypes._ast.ASTMCVoidType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import static org.junit.jupiter.api.Assertions.*; + public class SynthesizeComponentFromMCBasicTypesTest extends AbstractMCTest { @BeforeEach @@ -61,9 +62,9 @@ public void shouldHandleMCQualifiedType(String qualifiedCompName) { synth.handle(ast); // Then - Assertions.assertTrue(result.getResult().isPresent()); - Assertions.assertTrue(result.getResult().get().isComponentType()); - Assertions.assertEquals(symbol, result.getResult().get().getTypeInfo()); + assertTrue(result.getResult().isPresent()); + assertTrue(result.getResult().get().isComponentType()); + assertEquals(symbol, result.getResult().get().getTypeInfo()); } @Test @@ -94,9 +95,9 @@ public void shouldLogErrorForDuplicateSymbols() { synth.handle(ast); // Then - Assertions.assertTrue(result.getResult().isPresent()); - Assertions.assertTrue(result.getResult().get().isComponentType()); - Assertions.assertEquals(compSymbol1, result.getResult().get().getTypeInfo()); + assertTrue(result.getResult().isPresent()); + assertTrue(result.getResult().get().isComponentType()); + assertEquals(compSymbol1, result.getResult().get().getTypeInfo()); MCAssertions.assertHasFindingStartingWith("0xD0105"); } @@ -114,7 +115,7 @@ public void shouldNotLogErrorForMissingSymbol(String qualifiedName) { synth4normal.handle(astNormalComp); // Then - Assertions.assertFalse(result.getResult().isPresent()); + assertFalse(result.getResult().isPresent()); } @Test @@ -134,6 +135,6 @@ public void shouldNotHandleVoidType() { synth.handle(voidType); // Then - Assertions.assertFalse(resultWrapper.getResult().isPresent()); + assertFalse(resultWrapper.getResult().isPresent()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeComponentFromMCSimpleGenericTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeComponentFromMCSimpleGenericTypesTest.java index 7c5e00d8cd..3be25b332d 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeComponentFromMCSimpleGenericTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeComponentFromMCSimpleGenericTypesTest.java @@ -28,7 +28,6 @@ import de.monticore.types3.util.MapBasedTypeCheck3; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.api.Test; @@ -39,6 +38,8 @@ import java.util.List; import java.util.Objects; +import static org.junit.jupiter.api.Assertions.*; + public class SynthesizeComponentFromMCSimpleGenericTypesTest extends AbstractMCTest { @BeforeEach @@ -127,20 +128,20 @@ public void shouldHandleMCBasicGenericType(String qualifiedCompName) { new SynthesizeCompKindFromMCSimpleGenericTypes(wrapper).handle(astComp); // Then - Assertions.assertTrue(wrapper.getResult().isPresent(), "Expected synthesis result to be present"); - Assertions.assertInstanceOf(CompKindOfGenericComponentType.class, wrapper.getResult().get()); + assertTrue(wrapper.getResult().isPresent(), "Expected synthesis result to be present"); + assertInstanceOf(CompKindOfGenericComponentType.class, wrapper.getResult().get()); CompKindOfGenericComponentType result = (CompKindOfGenericComponentType) wrapper.getResult().get(); - Assertions.assertEquals(compSym, result.getTypeInfo()); - Assertions.assertEquals(astComp, result.getSourceNode().orElseThrow()); + assertEquals(compSym, result.getTypeInfo()); + assertEquals(astComp, result.getSourceNode().orElseThrow()); - Assertions.assertEquals(stringSym, result.getTypeBindingFor("K").orElseThrow().getTypeInfo()); + assertEquals(stringSym, result.getTypeBindingFor("K").orElseThrow().getTypeInfo()); SymTypeExpression v = result.getTypeBindingFor("V").orElseThrow(); - Assertions.assertInstanceOf(SymTypeOfGenerics.class, v); + assertInstanceOf(SymTypeOfGenerics.class, v); SymTypeOfGenerics vGen = (SymTypeOfGenerics) v; - Assertions.assertEquals(listSym, vGen.getTypeInfo()); - Assertions.assertEquals(stringSym, vGen.getArgument(0).getTypeInfo()); + assertEquals(listSym, vGen.getTypeInfo()); + assertEquals(stringSym, vGen.getArgument(0).getTypeInfo()); MCAssertions.assertNoFindings(); } @@ -165,7 +166,7 @@ public void shouldNotHandleMCBasicGenericTypeBecauseCompTypeUnresolvable() { new SynthesizeCompKindFromMCSimpleGenericTypes(wrapper).handle(astComp); // Then - Assertions.assertTrue(wrapper.getResult().isEmpty()); + assertTrue(wrapper.getResult().isEmpty()); } @Test @@ -198,9 +199,9 @@ public void shouldLogErrorForDuplicateSymbols() { // Then MCAssertions.assertHasFindingStartingWith("0xD0105"); - Assertions.assertTrue(wrapper.getResult().isPresent()); - Assertions.assertInstanceOf(CompKindOfGenericComponentType.class, wrapper.getResult().get()); - Assertions.assertEquals(astComp, wrapper.getResult().get().getSourceNode().orElseThrow()); + assertTrue(wrapper.getResult().isPresent()); + assertInstanceOf(CompKindOfGenericComponentType.class, wrapper.getResult().get()); + assertEquals(astComp, wrapper.getResult().get().getSourceNode().orElseThrow()); } private static void addWithSpannedScope(IComponentSymbolsWithMCBasicTypesTestScope scope, ComponentTypeSymbol sym) { diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCArrayTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCArrayTypesTest.java index 2ddd9ffa24..50509956e9 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCArrayTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCArrayTypesTest.java @@ -16,13 +16,12 @@ import de.monticore.types.mcbasictypes._ast.ASTMCVoidType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SynthesizeSymTypeFromMCArrayTypesTest { @@ -77,7 +76,7 @@ public void symTypeFromAST_Test1() throws IOException { String s = "double"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -85,7 +84,7 @@ public void symTypeFromAST_Test2() throws IOException { String s = "int"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -93,7 +92,7 @@ public void symTypeFromAST_Test3() throws IOException { String s = "A"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -101,7 +100,7 @@ public void symTypeFromAST_Test4() throws IOException { String s = "Person"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -109,27 +108,27 @@ public void symTypeFromAST_Test5() throws IOException { String s = "de.x.Person"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test public void symTypeFromAST_VoidTest() throws IOException { ASTMCVoidType v = MCBasicTypesMill.mCVoidTypeBuilder().build(); - Assertions.assertEquals("void", tc.symTypeFromAST(v).printFullName()); + assertEquals("void", tc.symTypeFromAST(v).printFullName()); } @Test public void symTypeFromAST_ReturnTest() throws IOException { ASTMCVoidType v = MCBasicTypesMill.mCVoidTypeBuilder().build(); ASTMCReturnType r = MCBasicTypesMill.mCReturnTypeBuilder().setMCVoidType(v).build(); - Assertions.assertEquals("void", tc.symTypeFromAST(r).printFullName()); + assertEquals("void", tc.symTypeFromAST(r).printFullName()); } @Test public void symTypeFromAST_ReturnTest2() throws IOException { // im Prinzip dassselbe via Parser: ASTMCReturnType r = parser.parse_StringMCReturnType("void").get(); - Assertions.assertEquals("void", tc.symTypeFromAST(r).printFullName()); + assertEquals("void", tc.symTypeFromAST(r).printFullName()); } @Test @@ -138,7 +137,7 @@ public void symTypeFromAST_ReturnTest3() throws IOException { String s = "Person"; ASTMCReturnType r = parser.parse_StringMCReturnType(s).get(); r.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(r).printFullName()); + assertEquals(s, tc.symTypeFromAST(r).printFullName()); } @Test @@ -146,7 +145,7 @@ public void symTypeFrom_AST_ArrayTest() throws IOException { ASTMCType prim = parser.parse_StringMCType("int").get(); ASTMCArrayType asttype = MCArrayTypesMill.mCArrayTypeBuilder().setMCType(prim).addDimT("[]").addDimT("[]").build(); asttype.accept(traverser); - Assertions.assertEquals("int[][]", tc.symTypeFromAST(asttype).printFullName()); + assertEquals("int[][]", tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -154,7 +153,7 @@ public void symTypeFrom_AST_ArrayTest2() throws IOException { ASTMCType person = parser.parse_StringMCType("Person").get(); ASTMCArrayType asttype = MCArrayTypesMill.mCArrayTypeBuilder().setMCType(person).addDimT("[]").build(); asttype.accept(traverser); - Assertions.assertEquals("Person[]", tc.symTypeFromAST(asttype).printFullName()); + assertEquals("Person[]", tc.symTypeFromAST(asttype).printFullName()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCBasicTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCBasicTypesTest.java index 8affc8e600..e5c73244d4 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCBasicTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCBasicTypesTest.java @@ -12,13 +12,12 @@ import de.monticore.types.mcbasictypes.MCBasicTypesMill; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SynthesizeSymTypeFromMCBasicTypesTest { @@ -71,7 +70,7 @@ public void symTypeFromAST_Test1() throws IOException { String s = "double"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -79,7 +78,7 @@ public void symTypeFromAST_Test2() throws IOException { String s = "int"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -87,7 +86,7 @@ public void symTypeFromAST_Test3() throws IOException { String s = "A"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -95,7 +94,7 @@ public void symTypeFromAST_Test4() throws IOException { String s = "Person"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -103,27 +102,27 @@ public void symTypeFromAST_Test5() throws IOException { String s = "de.x.Person"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test public void symTypeFromAST_VoidTest() throws IOException { ASTMCVoidType v = MCBasicTypesMill.mCVoidTypeBuilder().build(); - Assertions.assertEquals("void", tc.symTypeFromAST(v).printFullName()); + assertEquals("void", tc.symTypeFromAST(v).printFullName()); } @Test public void symTypeFromAST_ReturnTest() throws IOException { ASTMCVoidType v = MCBasicTypesMill.mCVoidTypeBuilder().build(); ASTMCReturnType r = MCBasicTypesMill.mCReturnTypeBuilder().setMCVoidType(v).build(); - Assertions.assertEquals("void", tc.symTypeFromAST(r).printFullName()); + assertEquals("void", tc.symTypeFromAST(r).printFullName()); } @Test public void symTypeFromAST_ReturnTest2() throws IOException { // im Prinzip dassselbe via Parser: ASTMCReturnType r = parser.parse_StringMCReturnType("void").get(); - Assertions.assertEquals("void", tc.symTypeFromAST(r).printFullName()); + assertEquals("void", tc.symTypeFromAST(r).printFullName()); } @Test @@ -132,7 +131,7 @@ public void symTypeFromAST_ReturnTest3() throws IOException { String s = "Person"; ASTMCReturnType r = parser.parse_StringMCReturnType(s).get(); r.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(r).printFullName()); + assertEquals(s, tc.symTypeFromAST(r).printFullName()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCCollectionTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCCollectionTypesTest.java index dc5b9c7d2d..d1fa7c4073 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCCollectionTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCCollectionTypesTest.java @@ -19,7 +19,6 @@ import de.monticore.types.mccollectiontypes._ast.ASTMCListType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -29,6 +28,8 @@ import java.util.List; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.*; + public class SynthesizeSymTypeFromMCCollectionTypesTest { /** @@ -101,7 +102,7 @@ public void symTypeFromAST_Test1() throws IOException { String s = "double"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -109,7 +110,7 @@ public void symTypeFromAST_Test4() throws IOException { String s = "Person"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -117,7 +118,7 @@ public void symTypeFromAST_Test5() throws IOException { String s = "de.x.Person"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -125,7 +126,7 @@ public void symTypeFromAST_ReturnTest() throws IOException { ASTMCVoidType v = MCBasicTypesMill.mCVoidTypeBuilder().build(); ASTMCReturnType r = MCBasicTypesMill.mCReturnTypeBuilder() .setMCVoidType(v).build(); - Assertions.assertEquals("void", tc.symTypeFromAST(r).printFullName()); + assertEquals("void", tc.symTypeFromAST(r).printFullName()); } @Test @@ -134,7 +135,7 @@ public void symTypeFromAST_ReturnTest3() throws IOException { String s = "Person"; ASTMCReturnType r = parser.parse_StringMCReturnType(s).get(); r.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(r).printFullName()); + assertEquals(s, tc.symTypeFromAST(r).printFullName()); } // new forms of Types coming from MCCollectionType @@ -150,12 +151,12 @@ public void symTypeFromAST_TestListQual() throws IOException { SymTypeExpression result = tc.symTypeFromAST(asttype); // Then - Assertions.assertEquals(s, result.printFullName()); - Assertions.assertTrue(result instanceof SymTypeOfGenerics); - Assertions.assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertEquals(s, result.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, result); + assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof OOTypeSymbolSurrogate); } @@ -170,12 +171,12 @@ public void symTypeFromAST_TestListQual2() throws IOException { SymTypeExpression result = tc.symTypeFromAST(asttype); // Then - Assertions.assertEquals(s, result.printFullName()); - Assertions.assertTrue(result instanceof SymTypeOfGenerics); - Assertions.assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertEquals(s, result.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, result); + assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof OOTypeSymbolSurrogate); } @Test @@ -189,14 +190,14 @@ public void symTypeFromAST_TestListQual3() throws IOException { SymTypeExpression result = tc.symTypeFromAST(asttype); // Then - Assertions.assertEquals(s, result.printFullName()); - Assertions.assertTrue(result instanceof SymTypeOfGenerics); - Assertions.assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(1).getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(1).getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertEquals(s, result.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, result); + assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(1).getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(1).getTypeInfo() instanceof OOTypeSymbolSurrogate); } @Test @@ -210,12 +211,12 @@ public void symTypeFromAST_TestListQual4() throws IOException { SymTypeExpression result = tc.symTypeFromAST(asttype); // Then - Assertions.assertEquals(s, result.printFullName()); - Assertions.assertTrue(result instanceof SymTypeOfGenerics); - Assertions.assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertEquals(s, result.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, result); + assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof OOTypeSymbolSurrogate); } @Test @@ -229,12 +230,12 @@ public void symTypeFromAST_TestListQual5() throws IOException { SymTypeExpression result = tc.symTypeFromAST(asttype); // Then - Assertions.assertEquals(s, result.printFullName()); - Assertions.assertTrue(result instanceof SymTypeOfGenerics); - Assertions.assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertEquals(s, result.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, result); + assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0).getTypeInfo() instanceof OOTypeSymbolSurrogate); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCFullGenericTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCFullGenericTypesTest.java index ebfcf8aac4..178ecde25b 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCFullGenericTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCFullGenericTypesTest.java @@ -18,13 +18,12 @@ import de.monticore.types.mcsimplegenerictypes._ast.ASTMCBasicGenericType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SynthesizeSymTypeFromMCFullGenericTypesTest { @@ -108,7 +107,7 @@ public void symTypeFromAST_Test1() throws IOException { parser = new CombineExpressionsWithLiteralsParser(); ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -116,7 +115,7 @@ public void symTypeFromAST_Test4() throws IOException { String s = "Person"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -124,7 +123,7 @@ public void symTypeFromAST_Test5() throws IOException { String s = "de.x.Person"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -132,7 +131,7 @@ public void symTypeFromAST_ReturnTest() throws IOException { ASTMCVoidType v = MCBasicTypesMill.mCVoidTypeBuilder().build(); ASTMCReturnType r = MCBasicTypesMill.mCReturnTypeBuilder() .setMCVoidType(v).build(); - Assertions.assertEquals("void", tc.symTypeFromAST(r).printFullName()); + assertEquals("void", tc.symTypeFromAST(r).printFullName()); } @Test @@ -141,7 +140,7 @@ public void symTypeFromAST_ReturnTest3() throws IOException { String s = "Person"; ASTMCReturnType r = parser.parse_StringMCReturnType(s).get(); r.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(r).printFullName()); + assertEquals(s, tc.symTypeFromAST(r).printFullName()); } // reuse some of the tests from MCCollectionType @@ -151,7 +150,7 @@ public void symTypeFromAST_TestListQual() throws IOException { String s = "List"; ASTMCListType asttype = parser.parse_StringMCListType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -159,7 +158,7 @@ public void symTypeFromAST_TestListQual2() throws IOException { String s = "Set"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -167,7 +166,7 @@ public void symTypeFromAST_TestListQual3() throws IOException { String s = "Map"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -175,7 +174,7 @@ public void symTypeFromAST_TestListQual4() throws IOException { String s = "Set"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } //new tests coming from MCSimpleGenericTypes @@ -185,7 +184,7 @@ public void symTypeFromAST_TestGeneric() throws IOException { String s = "Iterator"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -193,7 +192,7 @@ public void symTypeFromAST_TestGeneric2() throws IOException { String s = "java.util.Iterator"; ASTMCBasicGenericType asttype = parser.parse_StringMCBasicGenericType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -201,7 +200,7 @@ public void symTypeFromAST_TestGeneric3() throws IOException { String s = "Collection"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -209,7 +208,7 @@ public void symTypeFromAST_TestGeneric4() throws IOException { String s = "java.util.Iterator"; ASTMCBasicGenericType asttype = parser.parse_StringMCBasicGenericType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -217,7 +216,7 @@ public void symTypeFromAST_TestGeneric5() throws IOException { String s = "java.util.Iterator"; ASTMCBasicGenericType asttype = parser.parse_StringMCBasicGenericType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -225,7 +224,7 @@ public void symTypeFromAST_TestGeneric6() throws IOException { String s = "java.util.Iterator>>"; ASTMCBasicGenericType asttype = parser.parse_StringMCBasicGenericType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -233,7 +232,7 @@ public void symTypeFromAST_TestGeneric7() throws IOException { String s = "java.util.Iterator>>"; ASTMCBasicGenericType asttype = parser.parse_StringMCBasicGenericType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -241,7 +240,7 @@ public void symTypeFromAST_TestGeneric8() throws IOException { String s = "List"; ASTMCBasicGenericType asttype = parser.parse_StringMCBasicGenericType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCSimpleGenericTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCSimpleGenericTypesTest.java index a7191d43cc..33474f059a 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCSimpleGenericTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCSimpleGenericTypesTest.java @@ -16,13 +16,12 @@ import de.monticore.types.mcsimplegenerictypes._ast.ASTMCBasicGenericType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SynthesizeSymTypeFromMCSimpleGenericTypesTest { @@ -102,7 +101,7 @@ public void symTypeFromAST_Test1() throws IOException { parser = new CombineExpressionsWithLiteralsParser(); ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -110,7 +109,7 @@ public void symTypeFromAST_Test4() throws IOException { String s = "Person"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -118,7 +117,7 @@ public void symTypeFromAST_Test5() throws IOException { String s = "de.x.Person"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -126,7 +125,7 @@ public void symTypeFromAST_ReturnTest() throws IOException { ASTMCVoidType v = MCBasicTypesMill.mCVoidTypeBuilder().build(); ASTMCReturnType r = MCBasicTypesMill.mCReturnTypeBuilder() .setMCVoidType(v).build(); - Assertions.assertEquals("void", tc.symTypeFromAST(r).printFullName()); + assertEquals("void", tc.symTypeFromAST(r).printFullName()); } @Test @@ -135,7 +134,7 @@ public void symTypeFromAST_ReturnTest3() throws IOException { String s = "Person"; ASTMCReturnType r = parser.parse_StringMCReturnType(s).get(); r.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(r).printFullName()); + assertEquals(s, tc.symTypeFromAST(r).printFullName()); } // reuse some of the tests from MCCollectionType @@ -145,7 +144,7 @@ public void symTypeFromAST_TestListQual() throws IOException { String s = "List"; ASTMCListType asttype = parser.parse_StringMCListType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -153,7 +152,7 @@ public void symTypeFromAST_TestListQual2() throws IOException { String s = "Set"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -161,7 +160,7 @@ public void symTypeFromAST_TestListQual3() throws IOException { String s = "Map"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -169,7 +168,7 @@ public void symTypeFromAST_TestListQual4() throws IOException { String s = "Set"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } //new tests coming from MCSimpleGenericTypes @@ -179,7 +178,7 @@ public void symTypeFromAST_TestGeneric() throws IOException { String s = "Iterator"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -187,7 +186,7 @@ public void symTypeFromAST_TestGeneric2() throws IOException { String s = "java.util.Iterator"; ASTMCBasicGenericType asttype = parser.parse_StringMCBasicGenericType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -195,7 +194,7 @@ public void symTypeFromAST_TestGeneric3() throws IOException { String s = "Collection"; ASTMCType asttype = parser.parse_StringMCType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -203,7 +202,7 @@ public void symTypeFromAST_TestGeneric4() throws IOException { String s = "java.util.Iterator"; ASTMCBasicGenericType asttype = parser.parse_StringMCBasicGenericType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -211,7 +210,7 @@ public void symTypeFromAST_TestGeneric5() throws IOException { String s = "java.util.Iterator"; ASTMCBasicGenericType asttype = parser.parse_StringMCBasicGenericType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -219,7 +218,7 @@ public void symTypeFromAST_TestGeneric6() throws IOException { String s = "java.util.Iterator>>"; ASTMCBasicGenericType asttype = parser.parse_StringMCBasicGenericType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } @Test @@ -227,7 +226,7 @@ public void symTypeFromAST_TestGeneric7() throws IOException { String s = "java.util.Iterator>>"; ASTMCBasicGenericType asttype = parser.parse_StringMCBasicGenericType(s).get(); asttype.accept(traverser); - Assertions.assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); + assertEquals(s, tc.symTypeFromAST(asttype).printFullName()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCcFunctionTypesTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCcFunctionTypesTest.java index 5ce5f56fa3..371c5160e1 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCcFunctionTypesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/SynthesizeSymTypeFromMCcFunctionTypesTest.java @@ -9,7 +9,6 @@ import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -17,10 +16,7 @@ import java.util.Optional; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class SynthesizeSymTypeFromMCcFunctionTypesTest { @@ -74,11 +70,11 @@ public void symTypeFromAST_TestHigherOrderEllipticFunction() throws IOException protected ASTMCFunctionType parse(String mcTypeStr) throws IOException { MCFunctionTypesTestParser parser = new MCFunctionTypesTestParser(); Optional typeOpt = parser.parse_StringMCFunctionType(mcTypeStr); - Assertions.assertNotNull(typeOpt); - Assertions.assertTrue(typeOpt.isPresent(), Log.getFindings().stream() + assertNotNull(typeOpt); + assertTrue(typeOpt.isPresent(), Log.getFindings().stream() .map(Finding::toString) .collect(Collectors.joining("\n"))); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); return typeOpt.get(); } @@ -94,19 +90,19 @@ protected SymTypeOfFunction synthesizeType(ASTMCFunctionType mcType) { mcType.accept(traverser); SymTypeExpression symType = tc.symTypeFromAST(mcType); - Assertions.assertTrue(symType.isFunctionType()); + assertTrue(symType.isFunctionType()); SymTypeOfFunction funcType = (SymTypeOfFunction) symType; - Assertions.assertNotNull(funcType.getTypeInfo()); - Assertions.assertEquals(SymTypeOfFunction.TYPESYMBOL_NAME, funcType.getTypeInfo().getName()); - Assertions.assertNotNull(funcType.getType()); - Assertions.assertFalse(funcType.getType().isObscureType()); - Assertions.assertNotNull(funcType.getArgumentTypeList()); + assertNotNull(funcType.getTypeInfo()); + assertEquals(SymTypeOfFunction.TYPESYMBOL_NAME, funcType.getTypeInfo().getName()); + assertNotNull(funcType.getType()); + assertFalse(funcType.getType().isObscureType()); + assertNotNull(funcType.getArgumentTypeList()); for (SymTypeExpression argType : funcType.getArgumentTypeList()) { - Assertions.assertNotNull(argType); - Assertions.assertFalse(argType.isObscureType()); + assertNotNull(argType); + assertFalse(argType.isObscureType()); } - Assertions.assertTrue(mcType.getDefiningSymbol().isPresent()); - Assertions.assertEquals(SymTypeOfFunction.TYPESYMBOL_NAME, mcType.getDefiningSymbol().get().getName()); + assertTrue(mcType.getDefiningSymbol().isPresent()); + assertEquals(SymTypeOfFunction.TYPESYMBOL_NAME, mcType.getDefiningSymbol().get().getName()); return funcType; } @@ -120,7 +116,7 @@ protected void testSynthesizePrintCompare(String mcTypeStr, String expected) throws IOException { ASTMCFunctionType mcType = parse(mcTypeStr); SymTypeOfFunction symType = synthesizeType(mcType); - Assertions.assertEquals(expected, symType.printFullName()); + assertEquals(expected, symType.printFullName()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/TypeCalculatorTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/TypeCalculatorTest.java index 03d87807dc..a4ff0d1676 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/TypeCalculatorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/TypeCalculatorTest.java @@ -14,7 +14,6 @@ import de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -26,8 +25,8 @@ import static de.monticore.types.check.DefsTypeBasic.*; import static de.monticore.types.check.SymTypeExpressionFactory.createPrimitive; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test Class for {@link TypeCalculator} @@ -111,16 +110,16 @@ public void testIsOfTypeForAssign() throws IOException { ASTExpression char1 = p.parse_StringExpression("\'a\'").get(); char1.accept(traverser); - Assertions.assertTrue(tc.isOfTypeForAssign(tc.typeOf(bool1), bool2)); - Assertions.assertTrue(tc.isOfTypeForAssign(tc.typeOf(double1), int1)); - Assertions.assertFalse(tc.isOfTypeForAssign(tc.typeOf(bool1), int1)); - Assertions.assertTrue(tc.isOfTypeForAssign(tc.typeOf(float1), int1)); - Assertions.assertTrue(tc.isOfTypeForAssign(tc.typeOf(long1), int1)); - Assertions.assertTrue(tc.isOfTypeForAssign(tc.typeOf(char1), char1)); - Assertions.assertFalse(tc.isOfTypeForAssign(tc.typeOf(char1), int1)); - Assertions.assertFalse(tc.isOfTypeForAssign(tc.typeOf(double1), bool1)); - Assertions.assertFalse(tc.isOfTypeForAssign(tc.typeOf(long1), float1)); - Assertions.assertTrue(tc.isOfTypeForAssign(tc.typeOf(float1), int1)); + assertTrue(tc.isOfTypeForAssign(tc.typeOf(bool1), bool2)); + assertTrue(tc.isOfTypeForAssign(tc.typeOf(double1), int1)); + assertFalse(tc.isOfTypeForAssign(tc.typeOf(bool1), int1)); + assertTrue(tc.isOfTypeForAssign(tc.typeOf(float1), int1)); + assertTrue(tc.isOfTypeForAssign(tc.typeOf(long1), int1)); + assertTrue(tc.isOfTypeForAssign(tc.typeOf(char1), char1)); + assertFalse(tc.isOfTypeForAssign(tc.typeOf(char1), int1)); + assertFalse(tc.isOfTypeForAssign(tc.typeOf(double1), bool1)); + assertFalse(tc.isOfTypeForAssign(tc.typeOf(long1), float1)); + assertTrue(tc.isOfTypeForAssign(tc.typeOf(float1), int1)); //non-primitives ASTExpression pers = p.parse_StringExpression("Person").get(); @@ -130,15 +129,15 @@ public void testIsOfTypeForAssign() throws IOException { ASTExpression fstud = p.parse_StringExpression("FirstSemesterStudent").get(); fstud.accept(traverser); - Assertions.assertTrue(tc.isOfTypeForAssign(tc.typeOf(pers), stud)); - Assertions.assertTrue(tc.isOfTypeForAssign(tc.typeOf(pers), fstud)); - Assertions.assertTrue(tc.isOfTypeForAssign(tc.typeOf(stud), fstud)); - Assertions.assertFalse(tc.isOfTypeForAssign(tc.typeOf(stud), pers)); - Assertions.assertFalse(tc.isOfTypeForAssign(tc.typeOf(fstud), pers)); - Assertions.assertFalse(tc.isOfTypeForAssign(tc.typeOf(fstud), stud)); - Assertions.assertTrue(tc.isOfTypeForAssign(tc.typeOf(pers), pers)); + assertTrue(tc.isOfTypeForAssign(tc.typeOf(pers), stud)); + assertTrue(tc.isOfTypeForAssign(tc.typeOf(pers), fstud)); + assertTrue(tc.isOfTypeForAssign(tc.typeOf(stud), fstud)); + assertFalse(tc.isOfTypeForAssign(tc.typeOf(stud), pers)); + assertFalse(tc.isOfTypeForAssign(tc.typeOf(fstud), pers)); + assertFalse(tc.isOfTypeForAssign(tc.typeOf(fstud), stud)); + assertTrue(tc.isOfTypeForAssign(tc.typeOf(pers), pers)); - Assertions.assertFalse(tc.isOfTypeForAssign(tc.typeOf(int1), pers)); + assertFalse(tc.isOfTypeForAssign(tc.typeOf(int1), pers)); } @Test @@ -161,16 +160,16 @@ public void testIsSubtype() throws IOException { char1.accept(traverser); - Assertions.assertTrue(tc.isSubtypeOf(tc.typeOf(bool1), tc.typeOf(bool2))); - Assertions.assertTrue(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(double1))); - Assertions.assertFalse(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(bool1))); - Assertions.assertTrue(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(float1))); - Assertions.assertTrue(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(long1))); - Assertions.assertTrue(tc.isSubtypeOf(tc.typeOf(char1), tc.typeOf(char1))); - Assertions.assertFalse(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(char1))); - Assertions.assertFalse(tc.isSubtypeOf(tc.typeOf(bool1), tc.typeOf(double1))); - Assertions.assertFalse(tc.isSubtypeOf(tc.typeOf(float1), tc.typeOf(long1))); - Assertions.assertTrue(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(float1))); + assertTrue(tc.isSubtypeOf(tc.typeOf(bool1), tc.typeOf(bool2))); + assertTrue(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(double1))); + assertFalse(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(bool1))); + assertTrue(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(float1))); + assertTrue(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(long1))); + assertTrue(tc.isSubtypeOf(tc.typeOf(char1), tc.typeOf(char1))); + assertFalse(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(char1))); + assertFalse(tc.isSubtypeOf(tc.typeOf(bool1), tc.typeOf(double1))); + assertFalse(tc.isSubtypeOf(tc.typeOf(float1), tc.typeOf(long1))); + assertTrue(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(float1))); //non-primitives ASTExpression pers = p.parse_StringExpression("Person").get(); @@ -180,15 +179,15 @@ public void testIsSubtype() throws IOException { ASTExpression fstud = p.parse_StringExpression("FirstSemesterStudent").get(); fstud.accept(traverser); - Assertions.assertTrue(tc.isSubtypeOf(tc.typeOf(stud), tc.typeOf(pers))); - Assertions.assertTrue(tc.isSubtypeOf(tc.typeOf(fstud), tc.typeOf(pers))); - Assertions.assertTrue(tc.isSubtypeOf(tc.typeOf(fstud), tc.typeOf(stud))); - Assertions.assertFalse(tc.isSubtypeOf(tc.typeOf(pers), tc.typeOf(stud))); - Assertions.assertFalse(tc.isSubtypeOf(tc.typeOf(pers), tc.typeOf(fstud))); - Assertions.assertFalse(tc.isSubtypeOf(tc.typeOf(stud), tc.typeOf(fstud))); - Assertions.assertTrue(tc.isSubtypeOf(tc.typeOf(pers), tc.typeOf(pers))); + assertTrue(tc.isSubtypeOf(tc.typeOf(stud), tc.typeOf(pers))); + assertTrue(tc.isSubtypeOf(tc.typeOf(fstud), tc.typeOf(pers))); + assertTrue(tc.isSubtypeOf(tc.typeOf(fstud), tc.typeOf(stud))); + assertFalse(tc.isSubtypeOf(tc.typeOf(pers), tc.typeOf(stud))); + assertFalse(tc.isSubtypeOf(tc.typeOf(pers), tc.typeOf(fstud))); + assertFalse(tc.isSubtypeOf(tc.typeOf(stud), tc.typeOf(fstud))); + assertTrue(tc.isSubtypeOf(tc.typeOf(pers), tc.typeOf(pers))); - Assertions.assertFalse(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(pers))); + assertFalse(tc.isSubtypeOf(tc.typeOf(int1), tc.typeOf(pers))); } @Test @@ -202,33 +201,33 @@ public void testCompatibilityForPrimitives() { SymTypeExpression floatT = createPrimitive(BasicSymbolsMill.FLOAT); SymTypeExpression doubleT = createPrimitive(BasicSymbolsMill.DOUBLE); - Assertions.assertTrue(tc.compatible(booleanT, booleanT)); - Assertions.assertTrue(tc.compatible(byteT, byteT)); - Assertions.assertTrue(tc.compatible(shortT, byteT)); - Assertions.assertTrue(tc.compatible(shortT, shortT)); - Assertions.assertTrue(tc.compatible(charT, charT)); - Assertions.assertTrue(tc.compatible(intT, byteT)); - Assertions.assertTrue(tc.compatible(intT, shortT)); - Assertions.assertTrue(tc.compatible(intT, charT)); - Assertions.assertTrue(tc.compatible(intT, intT)); - Assertions.assertTrue(tc.compatible(longT, byteT)); - Assertions.assertTrue(tc.compatible(longT, shortT)); - Assertions.assertTrue(tc.compatible(longT, charT)); - Assertions.assertTrue(tc.compatible(longT, intT)); - Assertions.assertTrue(tc.compatible(longT, longT)); - Assertions.assertTrue(tc.compatible(floatT, byteT)); - Assertions.assertTrue(tc.compatible(floatT, shortT)); - Assertions.assertTrue(tc.compatible(floatT, charT)); - Assertions.assertTrue(tc.compatible(floatT, intT)); - Assertions.assertTrue(tc.compatible(floatT, longT)); - Assertions.assertTrue(tc.compatible(floatT, floatT)); - Assertions.assertTrue(tc.compatible(doubleT, byteT)); - Assertions.assertTrue(tc.compatible(doubleT, shortT)); - Assertions.assertTrue(tc.compatible(doubleT, charT)); - Assertions.assertTrue(tc.compatible(doubleT, intT)); - Assertions.assertTrue(tc.compatible(doubleT, longT)); - Assertions.assertTrue(tc.compatible(doubleT, floatT)); - Assertions.assertTrue(tc.compatible(doubleT, doubleT)); + assertTrue(tc.compatible(booleanT, booleanT)); + assertTrue(tc.compatible(byteT, byteT)); + assertTrue(tc.compatible(shortT, byteT)); + assertTrue(tc.compatible(shortT, shortT)); + assertTrue(tc.compatible(charT, charT)); + assertTrue(tc.compatible(intT, byteT)); + assertTrue(tc.compatible(intT, shortT)); + assertTrue(tc.compatible(intT, charT)); + assertTrue(tc.compatible(intT, intT)); + assertTrue(tc.compatible(longT, byteT)); + assertTrue(tc.compatible(longT, shortT)); + assertTrue(tc.compatible(longT, charT)); + assertTrue(tc.compatible(longT, intT)); + assertTrue(tc.compatible(longT, longT)); + assertTrue(tc.compatible(floatT, byteT)); + assertTrue(tc.compatible(floatT, shortT)); + assertTrue(tc.compatible(floatT, charT)); + assertTrue(tc.compatible(floatT, intT)); + assertTrue(tc.compatible(floatT, longT)); + assertTrue(tc.compatible(floatT, floatT)); + assertTrue(tc.compatible(doubleT, byteT)); + assertTrue(tc.compatible(doubleT, shortT)); + assertTrue(tc.compatible(doubleT, charT)); + assertTrue(tc.compatible(doubleT, intT)); + assertTrue(tc.compatible(doubleT, longT)); + assertTrue(tc.compatible(doubleT, floatT)); + assertTrue(tc.compatible(doubleT, doubleT)); } @Test @@ -242,43 +241,43 @@ public void testIncompatibilityForPrimitives() { SymTypeExpression floatT = createPrimitive(BasicSymbolsMill.FLOAT); SymTypeExpression doubleT = createPrimitive(BasicSymbolsMill.DOUBLE); - Assertions.assertFalse(tc.compatible(booleanT, byteT)); - Assertions.assertFalse(tc.compatible(booleanT, shortT)); - Assertions.assertFalse(tc.compatible(booleanT, charT)); - Assertions.assertFalse(tc.compatible(booleanT, intT)); - Assertions.assertFalse(tc.compatible(booleanT, longT)); - Assertions.assertFalse(tc.compatible(booleanT, floatT)); - Assertions.assertFalse(tc.compatible(booleanT, doubleT)); - Assertions.assertFalse(tc.compatible(byteT, booleanT)); - Assertions.assertFalse(tc.compatible(byteT, shortT)); - Assertions.assertFalse(tc.compatible(byteT, charT)); - Assertions.assertFalse(tc.compatible(byteT, intT)); - Assertions.assertFalse(tc.compatible(byteT, longT)); - Assertions.assertFalse(tc.compatible(byteT, floatT)); - Assertions.assertFalse(tc.compatible(byteT, doubleT)); - Assertions.assertFalse(tc.compatible(shortT, booleanT)); - Assertions.assertFalse(tc.compatible(shortT, charT)); - Assertions.assertFalse(tc.compatible(shortT, intT)); - Assertions.assertFalse(tc.compatible(shortT, longT)); - Assertions.assertFalse(tc.compatible(shortT, floatT)); - Assertions.assertFalse(tc.compatible(shortT, doubleT)); - Assertions.assertFalse(tc.compatible(charT, booleanT)); - Assertions.assertFalse(tc.compatible(charT, byteT)); - Assertions.assertFalse(tc.compatible(charT, shortT)); - Assertions.assertFalse(tc.compatible(charT, intT)); - Assertions.assertFalse(tc.compatible(charT, longT)); - Assertions.assertFalse(tc.compatible(charT, floatT)); - Assertions.assertFalse(tc.compatible(charT, doubleT)); - Assertions.assertFalse(tc.compatible(intT, booleanT)); - Assertions.assertFalse(tc.compatible(intT, longT)); - Assertions.assertFalse(tc.compatible(intT, floatT)); - Assertions.assertFalse(tc.compatible(intT, doubleT)); - Assertions.assertFalse(tc.compatible(longT, booleanT)); - Assertions.assertFalse(tc.compatible(longT, floatT)); - Assertions.assertFalse(tc.compatible(longT, doubleT)); - Assertions.assertFalse(tc.compatible(floatT, booleanT)); - Assertions.assertFalse(tc.compatible(floatT, doubleT)); - Assertions.assertFalse(tc.compatible(doubleT, booleanT)); + assertFalse(tc.compatible(booleanT, byteT)); + assertFalse(tc.compatible(booleanT, shortT)); + assertFalse(tc.compatible(booleanT, charT)); + assertFalse(tc.compatible(booleanT, intT)); + assertFalse(tc.compatible(booleanT, longT)); + assertFalse(tc.compatible(booleanT, floatT)); + assertFalse(tc.compatible(booleanT, doubleT)); + assertFalse(tc.compatible(byteT, booleanT)); + assertFalse(tc.compatible(byteT, shortT)); + assertFalse(tc.compatible(byteT, charT)); + assertFalse(tc.compatible(byteT, intT)); + assertFalse(tc.compatible(byteT, longT)); + assertFalse(tc.compatible(byteT, floatT)); + assertFalse(tc.compatible(byteT, doubleT)); + assertFalse(tc.compatible(shortT, booleanT)); + assertFalse(tc.compatible(shortT, charT)); + assertFalse(tc.compatible(shortT, intT)); + assertFalse(tc.compatible(shortT, longT)); + assertFalse(tc.compatible(shortT, floatT)); + assertFalse(tc.compatible(shortT, doubleT)); + assertFalse(tc.compatible(charT, booleanT)); + assertFalse(tc.compatible(charT, byteT)); + assertFalse(tc.compatible(charT, shortT)); + assertFalse(tc.compatible(charT, intT)); + assertFalse(tc.compatible(charT, longT)); + assertFalse(tc.compatible(charT, floatT)); + assertFalse(tc.compatible(charT, doubleT)); + assertFalse(tc.compatible(intT, booleanT)); + assertFalse(tc.compatible(intT, longT)); + assertFalse(tc.compatible(intT, floatT)); + assertFalse(tc.compatible(intT, doubleT)); + assertFalse(tc.compatible(longT, booleanT)); + assertFalse(tc.compatible(longT, floatT)); + assertFalse(tc.compatible(longT, doubleT)); + assertFalse(tc.compatible(floatT, booleanT)); + assertFalse(tc.compatible(floatT, doubleT)); + assertFalse(tc.compatible(doubleT, booleanT)); } @Test @@ -308,9 +307,9 @@ public void testCompatibilityForGenerics() { SymTypeExpression linkedlistOfPersonExpr = SymTypeExpressionFactory.createGenerics(linkedListSym, personExpr); // When & Then - Assertions.assertTrue(tc.compatible(listOfPersonExpr, listOfPersonExpr)); - Assertions.assertTrue(tc.compatible(listOfPersonExpr, personListExpr)); - Assertions.assertTrue(tc.compatible(listOfPersonExpr, linkedlistOfPersonExpr)); + assertTrue(tc.compatible(listOfPersonExpr, listOfPersonExpr)); + assertTrue(tc.compatible(listOfPersonExpr, personListExpr)); + assertTrue(tc.compatible(listOfPersonExpr, linkedlistOfPersonExpr)); } @Test @@ -333,13 +332,13 @@ public void testIncompatibilityForGenerics() { SymTypeExpression personListExpr = SymTypeExpressionFactory.createTypeObject(personListSym); // When & Then - Assertions.assertFalse(tc.compatible(listOfIntExpr, _intSymType)); - Assertions.assertFalse(tc.compatible(listOfIntExpr, listOfBoolExpr)); - Assertions.assertFalse(tc.compatible(listOfBoolExpr, listOfIntExpr)); - Assertions.assertFalse(tc.compatible(listOfBoolExpr, listOfPersonExpr)); - Assertions.assertFalse(tc.compatible(listOfPersonExpr, listOfBoolExpr)); - Assertions.assertFalse(tc.compatible(listOfBoolExpr, personListExpr)); - Assertions.assertFalse(tc.compatible(personListExpr, listOfBoolExpr)); + assertFalse(tc.compatible(listOfIntExpr, _intSymType)); + assertFalse(tc.compatible(listOfIntExpr, listOfBoolExpr)); + assertFalse(tc.compatible(listOfBoolExpr, listOfIntExpr)); + assertFalse(tc.compatible(listOfBoolExpr, listOfPersonExpr)); + assertFalse(tc.compatible(listOfPersonExpr, listOfBoolExpr)); + assertFalse(tc.compatible(listOfBoolExpr, personListExpr)); + assertFalse(tc.compatible(personListExpr, listOfBoolExpr)); } public CombineExpressionsWithLiteralsTraverser getTraverser(FlatExpressionScopeSetter flatExpressionScopeSetter){ diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/helpers/DefiningSymbolSetter4CommonExpressionsTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/helpers/DefiningSymbolSetter4CommonExpressionsTest.java index 7f43ee8abf..0f88eb5b95 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/helpers/DefiningSymbolSetter4CommonExpressionsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/helpers/DefiningSymbolSetter4CommonExpressionsTest.java @@ -9,10 +9,11 @@ import de.monticore.symboltable.ISymbol; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class DefiningSymbolSetter4CommonExpressionsTest { @BeforeEach @@ -42,8 +43,8 @@ public void setDefiningSymbolForNameExprTest() { definingSymbolSetter.setDefiningSymbol((ASTExpression) expr, symbol); // Then - Assertions.assertTrue(expr.getDefiningSymbol().isPresent()); - Assertions.assertSame(symbol, expr.getDefiningSymbol().get()); + assertTrue(expr.getDefiningSymbol().isPresent()); + assertSame(symbol, expr.getDefiningSymbol().get()); } @@ -71,10 +72,10 @@ public void setDefiningSymbolForFieldAccessExprTest() { definingSymbolSetter.setDefiningSymbol((ASTExpression) fieldAccessExpr, symbol); // Then - Assertions.assertTrue(fieldAccessExpr.getDefiningSymbol().isPresent()); - Assertions.assertSame(symbol, fieldAccessExpr.getDefiningSymbol().get()); + assertTrue(fieldAccessExpr.getDefiningSymbol().isPresent()); + assertSame(symbol, fieldAccessExpr.getDefiningSymbol().get()); - Assertions.assertFalse(qualExpr.getDefiningSymbol().isPresent()); + assertFalse(qualExpr.getDefiningSymbol().isPresent()); } @Test @@ -99,10 +100,10 @@ public void setDefiningSymbolForCallExprTest() { definingSymbolSetter.setDefiningSymbol((ASTExpression) callExpr, symbol); // Then - Assertions.assertTrue(callExpr.getDefiningSymbol().isPresent()); - Assertions.assertSame(symbol, callExpr.getDefiningSymbol().get()); + assertTrue(callExpr.getDefiningSymbol().isPresent()); + assertSame(symbol, callExpr.getDefiningSymbol().get()); - Assertions.assertFalse(methodNameExpr.getDefiningSymbol().isPresent()); + assertFalse(methodNameExpr.getDefiningSymbol().isPresent()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/helpers/SubExprNameExtractionResultTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/helpers/SubExprNameExtractionResultTest.java index dc47ae4c05..e766604b36 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/helpers/SubExprNameExtractionResultTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/helpers/SubExprNameExtractionResultTest.java @@ -5,7 +5,6 @@ import de.monticore.expressions.testcommonexpressions.TestCommonExpressionsMill; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -13,6 +12,8 @@ import java.util.List; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class SubExprNameExtractionResultTest { @BeforeEach @@ -41,8 +42,8 @@ public void resetCreatesNewList() { // Then List subExprListAfter = extractionResult.getNamePartsRaw(); - Assertions.assertEquals(1, subExprListAfter.size()); - Assertions.assertNotEquals(subExprListBefore, subExprListAfter); + assertEquals(1, subExprListAfter.size()); + assertNotEquals(subExprListBefore, subExprListAfter); } @Test @@ -58,10 +59,10 @@ public void testSetSubExpressions() { // Then List returnedSubExprList = extractionResult.getNamePartsRaw(); - Assertions.assertEquals(1, returnedSubExprList.size()); - Assertions.assertEquals(nameToInsert, returnedSubExprList.get(0).getExpression()); - Assertions.assertEquals("a", returnedSubExprList.get(0).getName().orElse("no name inserted")); - Assertions.assertEquals(subExprList, returnedSubExprList); + assertEquals(1, returnedSubExprList.size()); + assertEquals(nameToInsert, returnedSubExprList.get(0).getExpression()); + assertEquals("a", returnedSubExprList.get(0).getName().orElse("no name inserted")); + assertEquals(subExprList, returnedSubExprList); } @Test @@ -75,9 +76,9 @@ public void maybeAppendInvalidSubExprToEmptyList() { // Then List subExprList = extractionResult.getNamePartsRaw(); - Assertions.assertEquals(1, subExprList.size()); - Assertions.assertEquals(expr, subExprList.get(0).getExpression()); - Assertions.assertFalse(subExprList.get(0).getName().isPresent()); + assertEquals(1, subExprList.size()); + assertEquals(expr, subExprList.get(0).getExpression()); + assertFalse(subExprList.get(0).getName().isPresent()); } @Test @@ -92,13 +93,13 @@ public void maybeAppendInvalidSubExprToFilledListContainingDifferentValidNameExp // Then List subExprList = extractionResult.getNamePartsRaw(); - Assertions.assertEquals(2, subExprList.size()); + assertEquals(2, subExprList.size()); - Assertions.assertEquals(newExpr, subExprList.get(0).getExpression()); - Assertions.assertFalse(subExprList.get(0).getName().isPresent()); + assertEquals(newExpr, subExprList.get(0).getExpression()); + assertFalse(subExprList.get(0).getName().isPresent()); - Assertions.assertEquals(oldExpr, subExprList.get(1).getExpression()); - Assertions.assertEquals("a", subExprList.get(1).getName().orElse("no name inserted")); + assertEquals(oldExpr, subExprList.get(1).getExpression()); + assertEquals("a", subExprList.get(1).getName().orElse("no name inserted")); } @Test @@ -113,13 +114,13 @@ public void maybeAppendInvalidSubExprToFilledListContainingDifferentInvalidNameE // Then List subExprList = extractionResult.getNamePartsRaw(); - Assertions.assertEquals(2, subExprList.size()); + assertEquals(2, subExprList.size()); - Assertions.assertEquals(newExpr, subExprList.get(0).getExpression()); - Assertions.assertFalse(subExprList.get(0).getName().isPresent()); + assertEquals(newExpr, subExprList.get(0).getExpression()); + assertFalse(subExprList.get(0).getName().isPresent()); - Assertions.assertEquals(oldExpr, subExprList.get(1).getExpression()); - Assertions.assertFalse(subExprList.get(1).getName().isPresent()); + assertEquals(oldExpr, subExprList.get(1).getExpression()); + assertFalse(subExprList.get(1).getName().isPresent()); } @Test @@ -134,9 +135,9 @@ public void maybeAppendInvalidSubExprDoesNotOverwriteSameExpression() { // Then List subExprList = extractionResult.getNamePartsRaw(); - Assertions.assertEquals(1, subExprList.size()); - Assertions.assertEquals(expr, subExprList.get(0).getExpression()); - Assertions.assertEquals("a", subExprList.get(0).getName().orElse("no name inserted")); + assertEquals(1, subExprList.size()); + assertEquals(expr, subExprList.get(0).getExpression()); + assertEquals("a", subExprList.get(0).getName().orElse("no name inserted")); } @Test @@ -150,9 +151,9 @@ public void putNameAtStartOfEmptyList() { // Then List subExprList = extractionResult.getNamePartsRaw(); - Assertions.assertEquals(1, subExprList.size()); - Assertions.assertEquals(expr, subExprList.get(0).getExpression()); - Assertions.assertEquals("a", subExprList.get(0).getName().orElse("no name inserted")); + assertEquals(1, subExprList.size()); + assertEquals(expr, subExprList.get(0).getExpression()); + assertEquals("a", subExprList.get(0).getName().orElse("no name inserted")); } @Test @@ -169,13 +170,13 @@ public void putNameAtStartOfFilledListContainingDifferentValidExpressions() { // Then List subExprList = extractionResult.getNamePartsRaw(); - Assertions.assertEquals(2, subExprList.size()); + assertEquals(2, subExprList.size()); - Assertions.assertEquals(newExpr, subExprList.get(0).getExpression()); - Assertions.assertEquals("b", subExprList.get(0).getName().orElse("no name inserted")); + assertEquals(newExpr, subExprList.get(0).getExpression()); + assertEquals("b", subExprList.get(0).getName().orElse("no name inserted")); - Assertions.assertEquals(oldExpr, subExprList.get(1).getExpression()); - Assertions.assertEquals("a", subExprList.get(1).getName().orElse("no name inserted")); + assertEquals(oldExpr, subExprList.get(1).getExpression()); + assertEquals("a", subExprList.get(1).getName().orElse("no name inserted")); } @Test @@ -192,13 +193,13 @@ public void putNameAtStartOverwritesSameExpressionThatHasNoNameYet() { // Then List subExprList = extractionResult.getNamePartsRaw(); - Assertions.assertEquals(2, subExprList.size()); + assertEquals(2, subExprList.size()); - Assertions.assertEquals(expr, subExprList.get(0).getExpression()); - Assertions.assertEquals("b", subExprList.get(0).getName().orElse("no name inserted")); + assertEquals(expr, subExprList.get(0).getExpression()); + assertEquals("b", subExprList.get(0).getName().orElse("no name inserted")); - Assertions.assertEquals(dummyExprNotToAlter, subExprList.get(1).getExpression()); - Assertions.assertFalse(subExprList.get(1).getName().isPresent()); + assertEquals(dummyExprNotToAlter, subExprList.get(1).getExpression()); + assertFalse(subExprList.get(1).getName().isPresent()); } @Test @@ -215,13 +216,13 @@ public void putNameAtStartOverwritesSameExpressionThatAlreadyHasAName() { // Then List subExprList = extractionResult.getNamePartsRaw(); - Assertions.assertEquals(2, subExprList.size()); + assertEquals(2, subExprList.size()); - Assertions.assertEquals(expr, subExprList.get(0).getExpression()); - Assertions.assertEquals("b", subExprList.get(0).getName().orElse("no name inserted")); + assertEquals(expr, subExprList.get(0).getExpression()); + assertEquals("b", subExprList.get(0).getName().orElse("no name inserted")); - Assertions.assertEquals(dummyExprNotToAlter, subExprList.get(1).getExpression()); - Assertions.assertFalse(subExprList.get(1).getName().isPresent()); + assertEquals(dummyExprNotToAlter, subExprList.get(1).getExpression()); + assertFalse(subExprList.get(1).getName().isPresent()); } @Test @@ -233,7 +234,7 @@ public void getNamePartsIfValidOnEmptyNameList() { Optional> subExprList = extractionResult.getNamePartsIfValid(); // Then - Assertions.assertFalse(subExprList.isPresent()); + assertFalse(subExprList.isPresent()); } @Test @@ -253,7 +254,7 @@ public void getNamePartsIfValidOnFilledInvalidNameList() { Optional> subExprList = extractionResult.getNamePartsIfValid(); // Then - Assertions.assertFalse(subExprList.isPresent()); + assertFalse(subExprList.isPresent()); } @Test @@ -271,14 +272,14 @@ public void getNamePartsIfValidOnValidNameList() { Optional> subExprList = extractionResult.getNamePartsIfValid(); // Then - Assertions.assertTrue(subExprList.isPresent()); - Assertions.assertEquals(2, subExprList.get().size()); + assertTrue(subExprList.isPresent()); + assertEquals(2, subExprList.get().size()); - Assertions.assertEquals(bExpr, subExprList.get().get(0).getExpression()); - Assertions.assertEquals("b", subExprList.get().get(0).getName()); + assertEquals(bExpr, subExprList.get().get(0).getExpression()); + assertEquals("b", subExprList.get().get(0).getName()); - Assertions.assertEquals(aExpr, subExprList.get().get(1).getExpression()); - Assertions.assertEquals("a", subExprList.get().get(1).getName()); + assertEquals(aExpr, subExprList.get().get(1).getExpression()); + assertEquals("a", subExprList.get().get(1).getName()); } @Test @@ -290,7 +291,7 @@ public void getNamePartsRawOnEmptyList() { List subExprList = extractionResult.getNamePartsRaw(); // Then - Assertions.assertTrue(subExprList.isEmpty()); + assertTrue(subExprList.isEmpty()); } @Test @@ -309,15 +310,15 @@ public void getNamePartsRawOnFilledList() { List subExprList = extractionResult.getNamePartsRaw(); // Then - Assertions.assertEquals(3, subExprList.size()); + assertEquals(3, subExprList.size()); - Assertions.assertEquals(cExpr, subExprList.get(0).getExpression()); - Assertions.assertEquals(bExpr, subExprList.get(1).getExpression()); - Assertions.assertEquals(aExpr, subExprList.get(2).getExpression()); + assertEquals(cExpr, subExprList.get(0).getExpression()); + assertEquals(bExpr, subExprList.get(1).getExpression()); + assertEquals(aExpr, subExprList.get(2).getExpression()); - Assertions.assertEquals("c", subExprList.get(0).getName().orElse("no name was inserted")); - Assertions.assertFalse(subExprList.get(1).getName().isPresent()); - Assertions.assertEquals("a", subExprList.get(2).getName().orElse("no name was inserted")); + assertEquals("c", subExprList.get(0).getName().orElse("no name was inserted")); + assertFalse(subExprList.get(1).getName().isPresent()); + assertEquals("a", subExprList.get(2).getName().orElse("no name was inserted")); } @Test @@ -329,7 +330,7 @@ public void getLastNameOnEmptyList() { Optional lastName = extractionResult.getLastName(); // Then - Assertions.assertFalse(lastName.isPresent()); + assertFalse(lastName.isPresent()); } @Test @@ -346,7 +347,7 @@ public void getLastNameOnAbsentName() { Optional lastName = extractionResult.getLastName(); // Then - Assertions.assertFalse(lastName.isPresent()); + assertFalse(lastName.isPresent()); } @Test @@ -363,8 +364,8 @@ public void getLastNameOnValidLastName() { Optional lastName = extractionResult.getLastName(); // Then - Assertions.assertTrue(lastName.isPresent()); - Assertions.assertEquals("a", lastName.get()); + assertTrue(lastName.isPresent()); + assertEquals("a", lastName.get()); } @Test @@ -376,7 +377,7 @@ public void resultIsValidNameOnEmptyNameList() { boolean resultIsValidName = extractionResult.resultIsValidName(); // Then - Assertions.assertFalse(resultIsValidName); + assertFalse(resultIsValidName); } @Test @@ -395,7 +396,7 @@ public void resultIsValidNameOnInvalidNameList() { boolean resultIsValidName = extractionResult.resultIsValidName(); // Then - Assertions.assertFalse(resultIsValidName); + assertFalse(resultIsValidName); } @Test @@ -413,7 +414,7 @@ public void resultIsValidOnValidNameList() { boolean resultIsValidName = extractionResult.resultIsValidName(); // Then - Assertions.assertTrue(resultIsValidName); + assertTrue(resultIsValidName); } @Test @@ -437,14 +438,14 @@ public void testCopy() { // Then List originalExpressions = originalResult.getNamePartsRaw(); List copiedSubExpressions = copiedResult.getNamePartsRaw(); - Assertions.assertNotEquals(originalExpressions, copiedSubExpressions); + assertNotEquals(originalExpressions, copiedSubExpressions); - Assertions.assertEquals(3, copiedSubExpressions.size()); - Assertions.assertEquals(cExpr, copiedSubExpressions.get(0).getExpression()); - Assertions.assertEquals(bExpr, copiedSubExpressions.get(1).getExpression()); - Assertions.assertEquals(aExpr, copiedSubExpressions.get(2).getExpression()); + assertEquals(3, copiedSubExpressions.size()); + assertEquals(cExpr, copiedSubExpressions.get(0).getExpression()); + assertEquals(bExpr, copiedSubExpressions.get(1).getExpression()); + assertEquals(aExpr, copiedSubExpressions.get(2).getExpression()); - Assertions.assertEquals(1, originalExpressions.size()); - Assertions.assertEquals(dExpr, originalExpressions.get(0).getExpression()); + assertEquals(1, originalExpressions.size()); + assertEquals(dExpr, originalExpressions.get(0).getExpression()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/check/helpers/SubExprNameExtractor4CommonExpressionsTest.java b/monticore-grammar/src/test/java/de/monticore/types/check/helpers/SubExprNameExtractor4CommonExpressionsTest.java index 08f3660493..c53cacb52a 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/check/helpers/SubExprNameExtractor4CommonExpressionsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/check/helpers/SubExprNameExtractor4CommonExpressionsTest.java @@ -8,13 +8,14 @@ import de.monticore.expressions.expressionsbasis._ast.ASTExpression; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.List; +import static org.junit.jupiter.api.Assertions.*; + public class SubExprNameExtractor4CommonExpressionsTest { private CombineExpressionsWithLiteralsParser parser = new CombineExpressionsWithLiteralsParser(); @@ -41,12 +42,12 @@ public void nameTest() throws IOException { SubExprNameExtractionResult result = nameCalculator.calculateNameParts(methodNameExpr); // Then - Assertions.assertTrue(result.resultIsValidName()); - Assertions.assertEquals(1, result.getNamePartsRaw().size()); - Assertions.assertEquals("test", result.getLastName().get()); - Assertions.assertEquals(methodNameExpr, result.getNamePartsIfValid().get().get(0).getExpression()); + assertTrue(result.resultIsValidName()); + assertEquals(1, result.getNamePartsRaw().size()); + assertEquals("test", result.getLastName().get()); + assertEquals(methodNameExpr, result.getNamePartsIfValid().get().get(0).getExpression()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -63,15 +64,15 @@ public void fieldAccessTest() throws IOException { SubExprNameExtractionResult result = nameCalculator.calculateNameParts(methodNameExpr); // Then - Assertions.assertTrue(result.resultIsValidName()); + assertTrue(result.resultIsValidName()); List nameParts = result.getNamePartsIfValid().get(); - Assertions.assertEquals(3, result.getNamePartsRaw().size()); - Assertions.assertEquals("test", result.getLastName().get()); - Assertions.assertEquals(methodNameExpr, nameParts.get(nameParts.size() - 1).getExpression()); - Assertions.assertEquals(((ASTFieldAccessExpression) methodNameExpr).getExpression(), nameParts.get(nameParts.size() - 2).getExpression()); + assertEquals(3, result.getNamePartsRaw().size()); + assertEquals("test", result.getLastName().get()); + assertEquals(methodNameExpr, nameParts.get(nameParts.size() - 1).getExpression()); + assertEquals(((ASTFieldAccessExpression) methodNameExpr).getExpression(), nameParts.get(nameParts.size() - 2).getExpression()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -85,17 +86,17 @@ public void methodChainTest() throws IOException { SubExprNameExtractionResult result = nameCalculator.calculateNameParts(methodNameExpr); // Then - Assertions.assertFalse(result.resultIsValidName()); - Assertions.assertTrue(result.getLastName().isPresent()); + assertFalse(result.resultIsValidName()); + assertTrue(result.getLastName().isPresent()); List subExprs = result.getNamePartsRaw(); - Assertions.assertEquals(3, result.getNamePartsRaw().size()); // tezt NameExpr, tezt() CallExpr, tezt().test fAccExpr - Assertions.assertEquals("test", result.getLastName().get()); - Assertions.assertEquals(methodNameExpr, subExprs.get(subExprs.size() - 1).getExpression()); - Assertions.assertEquals(((ASTFieldAccessExpression) methodNameExpr).getExpression(), subExprs.get(subExprs.size() - 2).getExpression()); + assertEquals(3, result.getNamePartsRaw().size()); // tezt NameExpr, tezt() CallExpr, tezt().test fAccExpr + assertEquals("test", result.getLastName().get()); + assertEquals(methodNameExpr, subExprs.get(subExprs.size() - 1).getExpression()); + assertEquals(((ASTFieldAccessExpression) methodNameExpr).getExpression(), subExprs.get(subExprs.size() - 2).getExpression()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/helper/MCArrayTypesNodeIdentHelperTest.java b/monticore-grammar/src/test/java/de/monticore/types/helper/MCArrayTypesNodeIdentHelperTest.java index 5659e6e865..664a8b2365 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/helper/MCArrayTypesNodeIdentHelperTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/helper/MCArrayTypesNodeIdentHelperTest.java @@ -9,15 +9,13 @@ import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class MCArrayTypesNodeIdentHelperTest { @@ -36,12 +34,12 @@ public void testGetIdent() throws IOException { Optional astmcArrayType = p.parse_StringMCType("A[]"); - Assertions.assertTrue(astmcArrayType.isPresent()); - Assertions.assertTrue(astmcArrayType.get() instanceof ASTMCArrayType); + assertTrue(astmcArrayType.isPresent()); + assertInstanceOf(ASTMCArrayType.class, astmcArrayType.get()); - Assertions.assertEquals("@A!MCArrayType", identHelper.getIdent((ASTMCArrayType)astmcArrayType.get())); + assertEquals("@A!MCArrayType", identHelper.getIdent((ASTMCArrayType)astmcArrayType.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/helper/MCBasicTypesHelperTest.java b/monticore-grammar/src/test/java/de/monticore/types/helper/MCBasicTypesHelperTest.java index cc1bcb1c99..bcbb84c177 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/helper/MCBasicTypesHelperTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/helper/MCBasicTypesHelperTest.java @@ -6,12 +6,11 @@ import de.monticore.types.mcbasictypes._ast.ASTConstantsMCBasicTypes; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCBasicTypesHelperTest { @@ -25,17 +24,17 @@ public void init() { @Test public void testGetPrimitive(){ - Assertions.assertEquals(ASTConstantsMCBasicTypes.BOOLEAN, MCBasicTypesHelper.primitiveName2Const("boolean")); - Assertions.assertEquals(-1, MCBasicTypesHelper.primitiveName2Const(null)); - Assertions.assertEquals(-1, MCBasicTypesHelper.primitiveName2Const("")); - Assertions.assertEquals(ASTConstantsMCBasicTypes.BYTE, MCBasicTypesHelper.primitiveName2Const("byte")); - Assertions.assertEquals(ASTConstantsMCBasicTypes.CHAR, MCBasicTypesHelper.primitiveName2Const("char")); - Assertions.assertEquals(ASTConstantsMCBasicTypes.DOUBLE, MCBasicTypesHelper.primitiveName2Const("double")); - Assertions.assertEquals(ASTConstantsMCBasicTypes.FLOAT, MCBasicTypesHelper.primitiveName2Const("float")); - Assertions.assertEquals(ASTConstantsMCBasicTypes.INT, MCBasicTypesHelper.primitiveName2Const("int")); - Assertions.assertEquals(ASTConstantsMCBasicTypes.LONG, MCBasicTypesHelper.primitiveName2Const("long")); - Assertions.assertEquals(ASTConstantsMCBasicTypes.SHORT, MCBasicTypesHelper.primitiveName2Const("short")); + assertEquals(ASTConstantsMCBasicTypes.BOOLEAN, MCBasicTypesHelper.primitiveName2Const("boolean")); + assertEquals(-1, MCBasicTypesHelper.primitiveName2Const(null)); + assertEquals(-1, MCBasicTypesHelper.primitiveName2Const("")); + assertEquals(ASTConstantsMCBasicTypes.BYTE, MCBasicTypesHelper.primitiveName2Const("byte")); + assertEquals(ASTConstantsMCBasicTypes.CHAR, MCBasicTypesHelper.primitiveName2Const("char")); + assertEquals(ASTConstantsMCBasicTypes.DOUBLE, MCBasicTypesHelper.primitiveName2Const("double")); + assertEquals(ASTConstantsMCBasicTypes.FLOAT, MCBasicTypesHelper.primitiveName2Const("float")); + assertEquals(ASTConstantsMCBasicTypes.INT, MCBasicTypesHelper.primitiveName2Const("int")); + assertEquals(ASTConstantsMCBasicTypes.LONG, MCBasicTypesHelper.primitiveName2Const("long")); + assertEquals(ASTConstantsMCBasicTypes.SHORT, MCBasicTypesHelper.primitiveName2Const("short")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/helper/MCBasicTypesNodeIdentHelperTest.java b/monticore-grammar/src/test/java/de/monticore/types/helper/MCBasicTypesNodeIdentHelperTest.java index bd2ab6e86b..d7a04f9700 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/helper/MCBasicTypesNodeIdentHelperTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/helper/MCBasicTypesNodeIdentHelperTest.java @@ -7,13 +7,14 @@ import de.monticore.types.mcbasictypestest._parser.MCBasicTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCBasicTypesNodeIdentHelperTest { @BeforeEach @@ -34,23 +35,23 @@ public void testGetIdent() throws IOException { Optional astmcReturnType = parser.parse_StringMCReturnType("float"); Optional astmcReturnTypeVoid = parser.parse_StringMCReturnType("void"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astmcQualifiedName.isPresent()); - Assertions.assertTrue(astmcPrimitiveType.isPresent()); - Assertions.assertTrue(astmcQualifiedType.isPresent()); - Assertions.assertTrue(astmcVoidType.isPresent()); - Assertions.assertTrue(astmcReturnType.isPresent()); - Assertions.assertTrue(astmcReturnTypeVoid.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astmcQualifiedName.isPresent()); + assertTrue(astmcPrimitiveType.isPresent()); + assertTrue(astmcQualifiedType.isPresent()); + assertTrue(astmcVoidType.isPresent()); + assertTrue(astmcReturnType.isPresent()); + assertTrue(astmcReturnTypeVoid.isPresent()); MCBasicTypesNodeIdentHelper helper = new MCBasicTypesNodeIdentHelper(); - Assertions.assertEquals("@java.util.List!MCQualifiedName", helper.getIdent(astmcQualifiedName.get())); - Assertions.assertEquals("@int!MCPrimitiveType", helper.getIdent(astmcPrimitiveType.get())); - Assertions.assertEquals("@java.util.Set!MCQualifiedType", helper.getIdent(astmcQualifiedType.get())); - Assertions.assertEquals("@void!MCVoidType", helper.getIdent(astmcVoidType.get())); - Assertions.assertEquals("@float!MCPrimitiveType", helper.getIdent(astmcReturnType.get())); - Assertions.assertEquals("@void!MCVoidType", helper.getIdent(astmcReturnTypeVoid.get())); + assertEquals("@java.util.List!MCQualifiedName", helper.getIdent(astmcQualifiedName.get())); + assertEquals("@int!MCPrimitiveType", helper.getIdent(astmcPrimitiveType.get())); + assertEquals("@java.util.Set!MCQualifiedType", helper.getIdent(astmcQualifiedType.get())); + assertEquals("@void!MCVoidType", helper.getIdent(astmcVoidType.get())); + assertEquals("@float!MCPrimitiveType", helper.getIdent(astmcReturnType.get())); + assertEquals("@void!MCVoidType", helper.getIdent(astmcReturnTypeVoid.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/helper/MCCollectionTypesNodeIdentHelperTest.java b/monticore-grammar/src/test/java/de/monticore/types/helper/MCCollectionTypesNodeIdentHelperTest.java index 78cf135a34..a9ae603a6c 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/helper/MCCollectionTypesNodeIdentHelperTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/helper/MCCollectionTypesNodeIdentHelperTest.java @@ -9,13 +9,14 @@ import de.monticore.types.mccollectiontypestest._parser.MCCollectionTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCCollectionTypesNodeIdentHelperTest { @BeforeEach @@ -36,20 +37,20 @@ public void testGetIdent() throws IOException { Optional astmcBasicTypeArgument = parser.parse_StringMCBasicTypeArgument("a.B.C"); Optional astmcPrimitiveTypeArgument = parser.parse_StringMCPrimitiveTypeArgument("boolean"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astmcGenericType.isPresent()); - Assertions.assertTrue(astmcGenericType1.isPresent()); - Assertions.assertTrue(astmcGenericType2.isPresent()); - Assertions.assertTrue(astmcGenericType3.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astmcGenericType.isPresent()); + assertTrue(astmcGenericType1.isPresent()); + assertTrue(astmcGenericType2.isPresent()); + assertTrue(astmcGenericType3.isPresent()); MCCollectionTypesNodeIdentHelper helper = new MCCollectionTypesNodeIdentHelper(); - Assertions.assertEquals("@Map!MCMapType", helper.getIdent(astmcGenericType.get())); - Assertions.assertEquals("@List!MCListType", helper.getIdent(astmcGenericType1.get())); - Assertions.assertEquals("@Set!MCSetType", helper.getIdent(astmcGenericType2.get())); - Assertions.assertEquals("@Optional!MCOptionalType", helper.getIdent(astmcGenericType3.get())); - Assertions.assertEquals("@a.B.C!MCBasicTypeArgument", helper.getIdent(astmcBasicTypeArgument.get())); - Assertions.assertEquals("@boolean!MCPrimitiveTypeArgument", helper.getIdent(astmcPrimitiveTypeArgument.get())); + assertEquals("@Map!MCMapType", helper.getIdent(astmcGenericType.get())); + assertEquals("@List!MCListType", helper.getIdent(astmcGenericType1.get())); + assertEquals("@Set!MCSetType", helper.getIdent(astmcGenericType2.get())); + assertEquals("@Optional!MCOptionalType", helper.getIdent(astmcGenericType3.get())); + assertEquals("@a.B.C!MCBasicTypeArgument", helper.getIdent(astmcBasicTypeArgument.get())); + assertEquals("@boolean!MCPrimitiveTypeArgument", helper.getIdent(astmcPrimitiveTypeArgument.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/helper/MCFullGenericTypesNodeIdentHelperTest.java b/monticore-grammar/src/test/java/de/monticore/types/helper/MCFullGenericTypesNodeIdentHelperTest.java index e27d3187bb..4992f73435 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/helper/MCFullGenericTypesNodeIdentHelperTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/helper/MCFullGenericTypesNodeIdentHelperTest.java @@ -8,15 +8,14 @@ import de.monticore.types.mcfullgenerictypestest._parser.MCFullGenericTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCFullGenericTypesNodeIdentHelperTest { @@ -34,11 +33,11 @@ public void testGetIdent() throws IOException { MCFullGenericTypesNodeIdentHelper identHelper = new MCFullGenericTypesNodeIdentHelper(); Optional astmcMultipleGenericType = p.parse_StringMCMultipleGenericType("a.b.D.d.E"); - Assertions.assertTrue(astmcMultipleGenericType.isPresent()); + assertTrue(astmcMultipleGenericType.isPresent()); - Assertions.assertEquals("@a.b.D.d.E!MCMultipleGenericType", identHelper.getIdent(astmcMultipleGenericType.get())); + assertEquals("@a.b.D.d.E!MCMultipleGenericType", identHelper.getIdent(astmcMultipleGenericType.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/helper/MCSimpleGenericTypesNodeIdentHelperTest.java b/monticore-grammar/src/test/java/de/monticore/types/helper/MCSimpleGenericTypesNodeIdentHelperTest.java index 9cec87751a..bf486d6cdb 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/helper/MCSimpleGenericTypesNodeIdentHelperTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/helper/MCSimpleGenericTypesNodeIdentHelperTest.java @@ -7,14 +7,13 @@ import de.monticore.types.mcsimplegenerictypestest._parser.MCSimpleGenericTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class MCSimpleGenericTypesNodeIdentHelperTest { @@ -35,19 +34,19 @@ public void testGetIdent() throws IOException { Optional astmcType3 = parser.parse_StringMCBasicGenericType("java.util.Optional"); Optional astmcType4 = parser.parse_StringMCBasicGenericType("a.b.c.D"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astmcType.isPresent()); - Assertions.assertTrue(astmcType1.isPresent()); - Assertions.assertTrue(astmcType2.isPresent()); - Assertions.assertTrue(astmcType3.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astmcType.isPresent()); + assertTrue(astmcType1.isPresent()); + assertTrue(astmcType2.isPresent()); + assertTrue(astmcType3.isPresent()); MCSimpleGenericTypesNodeIdentHelper helper = new MCSimpleGenericTypesNodeIdentHelper(); - Assertions.assertEquals("@List!MCBasicGenericType", helper.getIdent(astmcType.get())); - Assertions.assertEquals("@java.util.List!MCBasicGenericType", helper.getIdent(astmcType1.get())); - Assertions.assertEquals("@Optional!MCBasicGenericType", helper.getIdent(astmcType2.get())); - Assertions.assertEquals("@java.util.Optional!MCBasicGenericType", helper.getIdent(astmcType3.get())); - Assertions.assertEquals("@a.b.c.D!MCBasicGenericType", helper.getIdent(astmcType4.get())); + assertEquals("@List!MCBasicGenericType", helper.getIdent(astmcType.get())); + assertEquals("@java.util.List!MCBasicGenericType", helper.getIdent(astmcType1.get())); + assertEquals("@Optional!MCBasicGenericType", helper.getIdent(astmcType2.get())); + assertEquals("@java.util.Optional!MCBasicGenericType", helper.getIdent(astmcType3.get())); + assertEquals("@a.b.c.D!MCBasicGenericType", helper.getIdent(astmcType4.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/helper/MCType2SymTypeExpressionTest.java b/monticore-grammar/src/test/java/de/monticore/types/helper/MCType2SymTypeExpressionTest.java index 10b3f39ba6..11ee8c73dd 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/helper/MCType2SymTypeExpressionTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/helper/MCType2SymTypeExpressionTest.java @@ -18,7 +18,6 @@ import de.monticore.types.mcsimplegenerictypes._ast.ASTMCBasicGenericType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -27,8 +26,7 @@ import java.util.List; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class MCType2SymTypeExpressionTest { @@ -113,81 +111,81 @@ private SymTypeExpression mcType2TypeExpression(ASTMCQualifiedName qName){ @Test public void testBasicGeneric() throws IOException { Optional type = new MCFullGenericTypesTestParser().parse_StringMCBasicGenericType("de.util.Pair"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression listSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(listSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("de.util.Pair", ((SymTypeOfGenerics) listSymTypeExpression).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, listSymTypeExpression); + assertEquals("de.util.Pair", ((SymTypeOfGenerics) listSymTypeExpression).getTypeConstructorFullName()); SymTypeExpression keyTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(keyTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("de.mc.PairA", keyTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, keyTypeArgument); + assertEquals("de.mc.PairA", keyTypeArgument.printFullName()); SymTypeExpression valueTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(1); - Assertions.assertTrue(valueTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("de.mc.PairB", valueTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, valueTypeArgument); + assertEquals("de.mc.PairB", valueTypeArgument.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBasicGenericRekursiv() throws IOException { Optional type = new MCFullGenericTypesTestParser().parse_StringMCBasicGenericType("de.util.Pair>"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression listSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(listSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("de.util.Pair", ((SymTypeOfGenerics) listSymTypeExpression).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, listSymTypeExpression); + assertEquals("de.util.Pair", ((SymTypeOfGenerics) listSymTypeExpression).getTypeConstructorFullName()); SymTypeExpression keyTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(keyTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("de.mc.PairA", keyTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, keyTypeArgument); + assertEquals("de.mc.PairA", keyTypeArgument.printFullName()); SymTypeExpression valueTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(1); - Assertions.assertTrue(valueTypeArgument instanceof SymTypeOfGenerics); - Assertions.assertEquals("de.util.Pair2", ((SymTypeOfGenerics) valueTypeArgument).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, valueTypeArgument); + assertEquals("de.util.Pair2", ((SymTypeOfGenerics) valueTypeArgument).getTypeConstructorFullName()); SymTypeOfGenerics valueTypeArg = (SymTypeOfGenerics) valueTypeArgument; SymTypeExpression argument1 = valueTypeArg.getArgumentList().get(0); - Assertions.assertEquals("de.mc.PairB", argument1.printFullName()); + assertEquals("de.mc.PairB", argument1.printFullName()); SymTypeExpression argument2 = valueTypeArg.getArgumentList().get(1); - Assertions.assertEquals("de.mc.PairC", argument2.printFullName()); + assertEquals("de.mc.PairC", argument2.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMap() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCMapType("Map"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression listSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(listSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("Map", listSymTypeExpression.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, listSymTypeExpression); + assertEquals("Map", listSymTypeExpression.printFullName()); SymTypeExpression keyTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(keyTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("de.mc.PersonKey", keyTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, keyTypeArgument); + assertEquals("de.mc.PersonKey", keyTypeArgument.printFullName()); SymTypeExpression valueTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(1); - Assertions.assertTrue(valueTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("de.mc.PersonValue", valueTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, valueTypeArgument); + assertEquals("de.mc.PersonValue", valueTypeArgument.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMapUnqualified() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCMapType("Map"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression listSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(listSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("Map", listSymTypeExpression.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, listSymTypeExpression); + assertEquals("Map", listSymTypeExpression.printFullName()); SymTypeExpression keyTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(keyTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("PersonKey", keyTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, keyTypeArgument); + assertEquals("PersonKey", keyTypeArgument.printFullName()); SymTypeExpression valueTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(1); - Assertions.assertTrue(valueTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("PersonValue", valueTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, valueTypeArgument); + assertEquals("PersonValue", valueTypeArgument.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -195,156 +193,156 @@ public void testMapPrimitives() throws IOException { for (String primitiveKey : primitiveTypes) { for (String primitiveValue : primitiveTypes) { Optional type = new MCCollectionTypesTestParser().parse_StringMCMapType("Map<" + primitiveKey + "," + primitiveValue + ">"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression listSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(listSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals(("Map<" + primitiveKey + "," + primitiveValue + ">"), listSymTypeExpression.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, listSymTypeExpression); + assertEquals(("Map<" + primitiveKey + "," + primitiveValue + ">"), listSymTypeExpression.printFullName()); SymTypeExpression keyTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(keyTypeArgument instanceof SymTypePrimitive); - Assertions.assertEquals(primitiveKey, keyTypeArgument.printFullName()); + assertInstanceOf(SymTypePrimitive.class, keyTypeArgument); + assertEquals(primitiveKey, keyTypeArgument.printFullName()); SymTypeExpression valueTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(1); - Assertions.assertTrue(valueTypeArgument instanceof SymTypePrimitive); - Assertions.assertEquals(primitiveValue, valueTypeArgument.printFullName()); + assertInstanceOf(SymTypePrimitive.class, valueTypeArgument); + assertEquals(primitiveValue, valueTypeArgument.printFullName()); } } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testOptional() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCOptionalType("Optional"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression optSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(optSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("Optional", ((SymTypeOfGenerics) optSymTypeExpression).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, optSymTypeExpression); + assertEquals("Optional", ((SymTypeOfGenerics) optSymTypeExpression).getTypeConstructorFullName()); SymTypeExpression listTypeArgument = ((SymTypeOfGenerics) optSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(listTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("de.mc.Person", listTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, listTypeArgument); + assertEquals("de.mc.Person", listTypeArgument.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testOptionalUnqualified() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCOptionalType("Optional"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression optSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(optSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("Optional", ((SymTypeOfGenerics) optSymTypeExpression).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, optSymTypeExpression); + assertEquals("Optional", ((SymTypeOfGenerics) optSymTypeExpression).getTypeConstructorFullName()); SymTypeExpression listTypeArgument = ((SymTypeOfGenerics) optSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(listTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("Person", listTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, listTypeArgument); + assertEquals("Person", listTypeArgument.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testOptionalPrimitive() throws IOException { for (String primitive : primitiveTypes) { Optional type = new MCCollectionTypesTestParser().parse_StringMCOptionalType("Optional<" + primitive + ">"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression optSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(optSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("Optional", ((SymTypeOfGenerics) optSymTypeExpression).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, optSymTypeExpression); + assertEquals("Optional", ((SymTypeOfGenerics) optSymTypeExpression).getTypeConstructorFullName()); SymTypeExpression listTypeArgument = ((SymTypeOfGenerics) optSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(listTypeArgument instanceof SymTypePrimitive); - Assertions.assertEquals(primitive, listTypeArgument.printFullName()); + assertInstanceOf(SymTypePrimitive.class, listTypeArgument); + assertEquals(primitive, listTypeArgument.printFullName()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSet() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCSetType("Set"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression setSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(setSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("Set", ((SymTypeOfGenerics) setSymTypeExpression).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, setSymTypeExpression); + assertEquals("Set", ((SymTypeOfGenerics) setSymTypeExpression).getTypeConstructorFullName()); SymTypeExpression listTypeArgument = ((SymTypeOfGenerics) setSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(listTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("de.mc.Person", listTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, listTypeArgument); + assertEquals("de.mc.Person", listTypeArgument.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSetUnqualified() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCSetType("Set"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression setSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(setSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("Set", ((SymTypeOfGenerics) setSymTypeExpression).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, setSymTypeExpression); + assertEquals("Set", ((SymTypeOfGenerics) setSymTypeExpression).getTypeConstructorFullName()); SymTypeExpression listTypeArgument = ((SymTypeOfGenerics) setSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(listTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("Person", listTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, listTypeArgument); + assertEquals("Person", listTypeArgument.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSetPrimitives() throws IOException { for (String primitive : primitiveTypes) { Optional type = new MCCollectionTypesTestParser().parse_StringMCSetType("Set<" + primitive + ">"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression setSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(setSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("Set", ((SymTypeOfGenerics) setSymTypeExpression).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, setSymTypeExpression); + assertEquals("Set", ((SymTypeOfGenerics) setSymTypeExpression).getTypeConstructorFullName()); SymTypeExpression listTypeArgument = ((SymTypeOfGenerics) setSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(listTypeArgument instanceof SymTypePrimitive); - Assertions.assertEquals(primitive, listTypeArgument.printFullName()); + assertInstanceOf(SymTypePrimitive.class, listTypeArgument); + assertEquals(primitive, listTypeArgument.printFullName()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testList() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCListType("List"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression listSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(listSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("List", ((SymTypeOfGenerics) listSymTypeExpression).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, listSymTypeExpression); + assertEquals("List", ((SymTypeOfGenerics) listSymTypeExpression).getTypeConstructorFullName()); SymTypeExpression listTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(listTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("de.mc.Person", listTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, listTypeArgument); + assertEquals("de.mc.Person", listTypeArgument.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testListUnqualified() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCListType("List"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression listSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(listSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("List", ((SymTypeOfGenerics) listSymTypeExpression).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, listSymTypeExpression); + assertEquals("List", ((SymTypeOfGenerics) listSymTypeExpression).getTypeConstructorFullName()); SymTypeExpression listTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(listTypeArgument instanceof SymTypeOfObject); - Assertions.assertEquals("Person", listTypeArgument.printFullName()); + assertInstanceOf(SymTypeOfObject.class, listTypeArgument); + assertEquals("Person", listTypeArgument.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testListPrimitive() throws IOException { for (String primitive : primitiveTypes) { Optional type = new MCCollectionTypesTestParser().parse_StringMCListType("List<" + primitive + ">"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); SymTypeExpression listSymTypeExpression = mcType2TypeExpression(type.get()); - Assertions.assertTrue(listSymTypeExpression instanceof SymTypeOfGenerics); - Assertions.assertEquals("List", ((SymTypeOfGenerics) listSymTypeExpression).getTypeConstructorFullName()); + assertInstanceOf(SymTypeOfGenerics.class, listSymTypeExpression); + assertEquals("List", ((SymTypeOfGenerics) listSymTypeExpression).getTypeConstructorFullName()); SymTypeExpression listTypeArgument = ((SymTypeOfGenerics) listSymTypeExpression).getArgumentList().get(0); - Assertions.assertTrue(listTypeArgument instanceof SymTypePrimitive); - Assertions.assertEquals(primitive, listTypeArgument.printFullName()); + assertInstanceOf(SymTypePrimitive.class, listTypeArgument); + assertEquals(primitive, listTypeArgument.printFullName()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -352,75 +350,75 @@ public void testListPrimitive() throws IOException { public void testPrimitives() throws IOException { for (String primitive : primitiveTypes) { Optional type = new MCCollectionTypesTestParser().parse_StringMCPrimitiveType(primitive); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); ASTMCPrimitiveType booleanType = type.get(); SymTypeExpression symTypeExpression = mcType2TypeExpression(booleanType); - Assertions.assertTrue(symTypeExpression instanceof SymTypePrimitive); - Assertions.assertEquals(primitive, symTypeExpression.printFullName()); + assertInstanceOf(SymTypePrimitive.class, symTypeExpression); + assertEquals(primitive, symTypeExpression.printFullName()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testVoid() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCVoidType("void"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); ASTMCVoidType booleanType = type.get(); SymTypeExpression symTypeExpression = mcType2TypeExpression(booleanType); - Assertions.assertTrue(symTypeExpression instanceof SymTypeVoid); - Assertions.assertEquals("void", symTypeExpression.printFullName()); + assertInstanceOf(SymTypeVoid.class, symTypeExpression); + assertEquals("void", symTypeExpression.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testQualifiedType() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCQualifiedType("de.mc.Person"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); ASTMCQualifiedType qualifiedType = type.get(); SymTypeExpression symTypeExpression = mcType2TypeExpression(qualifiedType); - Assertions.assertTrue(symTypeExpression instanceof SymTypeOfObject); - Assertions.assertEquals("de.mc.Person", symTypeExpression.printFullName()); + assertInstanceOf(SymTypeOfObject.class, symTypeExpression); + assertEquals("de.mc.Person", symTypeExpression.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testQualifiedTypeUnqualified() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCQualifiedType("Person"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); ASTMCQualifiedType qualifiedType = type.get(); SymTypeExpression symTypeExpression = mcType2TypeExpression(qualifiedType); - Assertions.assertTrue(symTypeExpression instanceof SymTypeOfObject); - Assertions.assertEquals("Person", symTypeExpression.printFullName()); + assertInstanceOf(SymTypeOfObject.class, symTypeExpression); + assertEquals("Person", symTypeExpression.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testQualifiedName() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCQualifiedName("de.mc.Person"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); ASTMCQualifiedName qualifiedName = type.get(); SymTypeExpression symTypeExpression = mcType2TypeExpression(qualifiedName); - Assertions.assertTrue(symTypeExpression instanceof SymTypeOfObject); - Assertions.assertEquals("de.mc.Person", symTypeExpression.printFullName()); + assertInstanceOf(SymTypeOfObject.class, symTypeExpression); + assertEquals("de.mc.Person", symTypeExpression.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testQualifiedNameUnqualified() throws IOException { Optional type = new MCCollectionTypesTestParser().parse_StringMCQualifiedName("Person"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); ASTMCQualifiedName qualifiedName = type.get(); SymTypeExpression symTypeExpression = mcType2TypeExpression(qualifiedName); - Assertions.assertTrue(symTypeExpression instanceof SymTypeOfObject); - Assertions.assertEquals("Person", symTypeExpression.printFullName()); + assertInstanceOf(SymTypeOfObject.class, symTypeExpression); + assertEquals("Person", symTypeExpression.printFullName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/mccollectiontypes/types3/util/MCCollectionSymTypeFactoryTest.java b/monticore-grammar/src/test/java/de/monticore/types/mccollectiontypes/types3/util/MCCollectionSymTypeFactoryTest.java index 74bc4126df..fa8104c0bc 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/mccollectiontypes/types3/util/MCCollectionSymTypeFactoryTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/mccollectiontypes/types3/util/MCCollectionSymTypeFactoryTest.java @@ -7,7 +7,6 @@ import de.monticore.symbols.basicsymbols._symboltable.IBasicSymbolsGlobalScope; import de.monticore.types.check.SymTypeOfGenerics; import de.monticore.types.mccollectiontypes.types3.MCCollectionSymTypeRelations; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -21,6 +20,7 @@ import static de.monticore.types3.util.DefsTypesForTests._unboxedMapSymType; import static de.monticore.types3.util.DefsTypesForTests._unboxedOptionalSymType; import static de.monticore.types3.util.DefsTypesForTests._unboxedSetSymType; +import static org.junit.jupiter.api.Assertions.*; public class MCCollectionSymTypeFactoryTest extends AbstractMCTest { @@ -38,22 +38,22 @@ public void createsList() { IBasicSymbolsGlobalScope gs = BasicSymbolsMill.globalScope(); SymTypeOfGenerics intList = MCCollectionSymTypeFactory.createList(_intSymType); - Assertions.assertTrue(intList.hasTypeInfo()); - Assertions.assertSame(_unboxedListSymType.getTypeInfo(), intList.getTypeInfo()); - Assertions.assertEquals("List", intList.getTypeConstructorFullName()); - Assertions.assertEquals(1, intList.sizeArguments()); - Assertions.assertTrue(_intSymType.deepEquals(intList.getArgument(0))); - Assertions.assertTrue(MCCollectionSymTypeRelations.isList(intList)); + assertTrue(intList.hasTypeInfo()); + assertSame(_unboxedListSymType.getTypeInfo(), intList.getTypeInfo()); + assertEquals("List", intList.getTypeConstructorFullName()); + assertEquals(1, intList.sizeArguments()); + assertTrue(_intSymType.deepEquals(intList.getArgument(0))); + assertTrue(MCCollectionSymTypeRelations.isList(intList)); // again, but with the unboxed "List" not being available gs.remove(gs.resolveType("List").get()); intList = MCCollectionSymTypeFactory.createList(_intSymType); - Assertions.assertTrue(intList.hasTypeInfo()); - Assertions.assertSame(_boxedListSymType.getTypeInfo(), intList.getTypeInfo()); - Assertions.assertEquals("java.util.List", intList.getTypeConstructorFullName()); - Assertions.assertEquals(1, intList.sizeArguments()); - Assertions.assertTrue(_intSymType.deepEquals(intList.getArgument(0))); - Assertions.assertTrue(MCCollectionSymTypeRelations.isList(intList)); + assertTrue(intList.hasTypeInfo()); + assertSame(_boxedListSymType.getTypeInfo(), intList.getTypeInfo()); + assertEquals("java.util.List", intList.getTypeConstructorFullName()); + assertEquals(1, intList.sizeArguments()); + assertTrue(_intSymType.deepEquals(intList.getArgument(0))); + assertTrue(MCCollectionSymTypeRelations.isList(intList)); } @Test @@ -61,22 +61,22 @@ public void createsSet() { IBasicSymbolsGlobalScope gs = BasicSymbolsMill.globalScope(); SymTypeOfGenerics intSet = MCCollectionSymTypeFactory.createSet(_intSymType); - Assertions.assertTrue(intSet.hasTypeInfo()); - Assertions.assertSame(_unboxedSetSymType.getTypeInfo(), intSet.getTypeInfo()); - Assertions.assertEquals("Set", intSet.getTypeConstructorFullName()); - Assertions.assertEquals(1, intSet.sizeArguments()); - Assertions.assertTrue(_intSymType.deepEquals(intSet.getArgument(0))); - Assertions.assertTrue(MCCollectionSymTypeRelations.isSet(intSet)); + assertTrue(intSet.hasTypeInfo()); + assertSame(_unboxedSetSymType.getTypeInfo(), intSet.getTypeInfo()); + assertEquals("Set", intSet.getTypeConstructorFullName()); + assertEquals(1, intSet.sizeArguments()); + assertTrue(_intSymType.deepEquals(intSet.getArgument(0))); + assertTrue(MCCollectionSymTypeRelations.isSet(intSet)); // again, but with the unboxed "Set" not being available gs.remove(gs.resolveType("Set").get()); intSet = MCCollectionSymTypeFactory.createSet(_intSymType); - Assertions.assertTrue(intSet.hasTypeInfo()); - Assertions.assertSame(_boxedSetSymType.getTypeInfo(), intSet.getTypeInfo()); - Assertions.assertEquals("java.util.Set", intSet.getTypeConstructorFullName()); - Assertions.assertEquals(1, intSet.sizeArguments()); - Assertions.assertTrue(_intSymType.deepEquals(intSet.getArgument(0))); - Assertions.assertTrue(MCCollectionSymTypeRelations.isSet(intSet)); + assertTrue(intSet.hasTypeInfo()); + assertSame(_boxedSetSymType.getTypeInfo(), intSet.getTypeInfo()); + assertEquals("java.util.Set", intSet.getTypeConstructorFullName()); + assertEquals(1, intSet.sizeArguments()); + assertTrue(_intSymType.deepEquals(intSet.getArgument(0))); + assertTrue(MCCollectionSymTypeRelations.isSet(intSet)); } @Test @@ -84,22 +84,22 @@ public void createsOptional() { IBasicSymbolsGlobalScope gs = BasicSymbolsMill.globalScope(); SymTypeOfGenerics intOptional = MCCollectionSymTypeFactory.createOptional(_intSymType); - Assertions.assertTrue(intOptional.hasTypeInfo()); - Assertions.assertSame(_unboxedOptionalSymType.getTypeInfo(), intOptional.getTypeInfo()); - Assertions.assertEquals("Optional", intOptional.getTypeConstructorFullName()); - Assertions.assertEquals(1, intOptional.sizeArguments()); - Assertions.assertTrue(_intSymType.deepEquals(intOptional.getArgument(0))); - Assertions.assertTrue(MCCollectionSymTypeRelations.isOptional(intOptional)); + assertTrue(intOptional.hasTypeInfo()); + assertSame(_unboxedOptionalSymType.getTypeInfo(), intOptional.getTypeInfo()); + assertEquals("Optional", intOptional.getTypeConstructorFullName()); + assertEquals(1, intOptional.sizeArguments()); + assertTrue(_intSymType.deepEquals(intOptional.getArgument(0))); + assertTrue(MCCollectionSymTypeRelations.isOptional(intOptional)); // again, but with the unboxed "Optional" not being available gs.remove(gs.resolveType("Optional").get()); intOptional = MCCollectionSymTypeFactory.createOptional(_intSymType); - Assertions.assertTrue(intOptional.hasTypeInfo()); - Assertions.assertSame(_boxedOptionalSymType.getTypeInfo(), intOptional.getTypeInfo()); - Assertions.assertEquals("java.util.Optional", intOptional.getTypeConstructorFullName()); - Assertions.assertEquals(1, intOptional.sizeArguments()); - Assertions.assertTrue(_intSymType.deepEquals(intOptional.getArgument(0))); - Assertions.assertTrue(MCCollectionSymTypeRelations.isOptional(intOptional)); + assertTrue(intOptional.hasTypeInfo()); + assertSame(_boxedOptionalSymType.getTypeInfo(), intOptional.getTypeInfo()); + assertEquals("java.util.Optional", intOptional.getTypeConstructorFullName()); + assertEquals(1, intOptional.sizeArguments()); + assertTrue(_intSymType.deepEquals(intOptional.getArgument(0))); + assertTrue(MCCollectionSymTypeRelations.isOptional(intOptional)); } @Test @@ -108,24 +108,24 @@ public void createsMap() { SymTypeOfGenerics intMap = MCCollectionSymTypeFactory.createMap(_intSymType, _floatSymType); - Assertions.assertTrue(intMap.hasTypeInfo()); - Assertions.assertSame(_unboxedMapSymType.getTypeInfo(), intMap.getTypeInfo()); - Assertions.assertEquals("Map", intMap.getTypeConstructorFullName()); - Assertions.assertEquals(2, intMap.sizeArguments()); - Assertions.assertTrue(_intSymType.deepEquals(intMap.getArgument(0))); - Assertions.assertTrue(_floatSymType.deepEquals(intMap.getArgument(1))); - Assertions.assertTrue(MCCollectionSymTypeRelations.isMap(intMap)); + assertTrue(intMap.hasTypeInfo()); + assertSame(_unboxedMapSymType.getTypeInfo(), intMap.getTypeInfo()); + assertEquals("Map", intMap.getTypeConstructorFullName()); + assertEquals(2, intMap.sizeArguments()); + assertTrue(_intSymType.deepEquals(intMap.getArgument(0))); + assertTrue(_floatSymType.deepEquals(intMap.getArgument(1))); + assertTrue(MCCollectionSymTypeRelations.isMap(intMap)); // again, but with the unboxed "Map" not being available gs.remove(gs.resolveType("Map").get()); intMap = MCCollectionSymTypeFactory.createMap(_intSymType, _floatSymType); - Assertions.assertTrue(intMap.hasTypeInfo()); - Assertions.assertSame(_boxedMapSymType.getTypeInfo(), intMap.getTypeInfo()); - Assertions.assertEquals("java.util.Map", intMap.getTypeConstructorFullName()); - Assertions.assertEquals(2, intMap.sizeArguments()); - Assertions.assertTrue(_intSymType.deepEquals(intMap.getArgument(0))); - Assertions.assertTrue(_floatSymType.deepEquals(intMap.getArgument(1))); - Assertions.assertTrue(MCCollectionSymTypeRelations.isMap(intMap)); + assertTrue(intMap.hasTypeInfo()); + assertSame(_boxedMapSymType.getTypeInfo(), intMap.getTypeInfo()); + assertEquals("java.util.Map", intMap.getTypeConstructorFullName()); + assertEquals(2, intMap.sizeArguments()); + assertTrue(_intSymType.deepEquals(intMap.getArgument(0))); + assertTrue(_floatSymType.deepEquals(intMap.getArgument(1))); + assertTrue(MCCollectionSymTypeRelations.isMap(intMap)); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/mccollectiontypes/types3/util/MCCollectionTypeRelationsTest.java b/monticore-grammar/src/test/java/de/monticore/types/mccollectiontypes/types3/util/MCCollectionTypeRelationsTest.java index a5c9aea2af..7bb3301143 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/mccollectiontypes/types3/util/MCCollectionTypeRelationsTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/mccollectiontypes/types3/util/MCCollectionTypeRelationsTest.java @@ -6,7 +6,6 @@ import de.monticore.symbols.basicsymbols.BasicSymbolsMill; import de.monticore.types.check.SymTypeExpressionFactory; import de.monticore.types.mccollectiontypes.types3.MCCollectionSymTypeRelations; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -25,6 +24,7 @@ import static de.monticore.types3.util.DefsTypesForTests._unboxedOptionalSymType; import static de.monticore.types3.util.DefsTypesForTests._unboxedSetSymType; import static de.monticore.types3.util.DefsTypesForTests._unboxedString; +import static org.junit.jupiter.api.Assertions.*; public class MCCollectionTypeRelationsTest extends AbstractMCTest { @@ -36,174 +36,174 @@ public void init() { @Test public void recognizeUnboxedCollectionTypes() { - Assertions.assertTrue(MCCollectionSymTypeRelations.isMCCollection(_unboxedListSymType)); - Assertions.assertTrue(MCCollectionSymTypeRelations.isMCCollection(_unboxedSetSymType)); - Assertions.assertTrue(MCCollectionSymTypeRelations.isMCCollection(_unboxedOptionalSymType)); - Assertions.assertTrue(MCCollectionSymTypeRelations.isMCCollection(_unboxedMapSymType)); + assertTrue(MCCollectionSymTypeRelations.isMCCollection(_unboxedListSymType)); + assertTrue(MCCollectionSymTypeRelations.isMCCollection(_unboxedSetSymType)); + assertTrue(MCCollectionSymTypeRelations.isMCCollection(_unboxedOptionalSymType)); + assertTrue(MCCollectionSymTypeRelations.isMCCollection(_unboxedMapSymType)); } @Test public void recognizeBoxedCollectionTypes() { - Assertions.assertTrue(MCCollectionSymTypeRelations.isMCCollection(_boxedListSymType)); - Assertions.assertTrue(MCCollectionSymTypeRelations.isMCCollection(_boxedSetSymType)); - Assertions.assertTrue(MCCollectionSymTypeRelations.isMCCollection(_boxedOptionalSymType)); - Assertions.assertTrue(MCCollectionSymTypeRelations.isMCCollection(_boxedMapSymType)); + assertTrue(MCCollectionSymTypeRelations.isMCCollection(_boxedListSymType)); + assertTrue(MCCollectionSymTypeRelations.isMCCollection(_boxedSetSymType)); + assertTrue(MCCollectionSymTypeRelations.isMCCollection(_boxedOptionalSymType)); + assertTrue(MCCollectionSymTypeRelations.isMCCollection(_boxedMapSymType)); } @Test public void recognizeNonCollectionTypes() { - Assertions.assertFalse(MCCollectionSymTypeRelations.isMCCollection(_intSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMCCollection(_personSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMCCollection(_unboxedString)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMCCollection(SymTypeExpressionFactory.createGenerics( + assertFalse(MCCollectionSymTypeRelations.isMCCollection(_intSymType)); + assertFalse(MCCollectionSymTypeRelations.isMCCollection(_personSymType)); + assertFalse(MCCollectionSymTypeRelations.isMCCollection(_unboxedString)); + assertFalse(MCCollectionSymTypeRelations.isMCCollection(SymTypeExpressionFactory.createGenerics( "noList", BasicSymbolsMill.scope(), _intSymType ))); } @Test public void recognizeLists() { - Assertions.assertTrue(MCCollectionSymTypeRelations.isList(_unboxedListSymType)); - Assertions.assertTrue(MCCollectionSymTypeRelations.isList(_boxedListSymType)); + assertTrue(MCCollectionSymTypeRelations.isList(_unboxedListSymType)); + assertTrue(MCCollectionSymTypeRelations.isList(_boxedListSymType)); } @Test public void recognizeNonLists() { - Assertions.assertFalse(MCCollectionSymTypeRelations.isList(_unboxedMapSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isList(_unboxedSetSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isList(_unboxedOptionalSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isList(_boxedMapSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isList(_boxedSetSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isList(_boxedOptionalSymType)); + assertFalse(MCCollectionSymTypeRelations.isList(_unboxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isList(_unboxedSetSymType)); + assertFalse(MCCollectionSymTypeRelations.isList(_unboxedOptionalSymType)); + assertFalse(MCCollectionSymTypeRelations.isList(_boxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isList(_boxedSetSymType)); + assertFalse(MCCollectionSymTypeRelations.isList(_boxedOptionalSymType)); // incorrect number of arguments _unboxedListSymType.setArgumentList(Collections.emptyList()); _boxedListSymType.setArgumentList(Collections.emptyList()); - Assertions.assertFalse(MCCollectionSymTypeRelations.isList(_unboxedListSymType)); + assertFalse(MCCollectionSymTypeRelations.isList(_unboxedListSymType)); assertHasFindingStartingWith("0xFD1C4"); - Assertions.assertFalse(MCCollectionSymTypeRelations.isList(_boxedListSymType)); + assertFalse(MCCollectionSymTypeRelations.isList(_boxedListSymType)); assertHasFindingStartingWith("0xFD1C4"); _unboxedListSymType.setArgumentList(List.of(_intSymType, _intSymType)); _boxedListSymType.setArgumentList(List.of(_intSymType, _intSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isList(_unboxedListSymType)); + assertFalse(MCCollectionSymTypeRelations.isList(_unboxedListSymType)); assertHasFindingStartingWith("0xFD1C4"); - Assertions.assertFalse(MCCollectionSymTypeRelations.isList(_boxedListSymType)); + assertFalse(MCCollectionSymTypeRelations.isList(_boxedListSymType)); assertHasFindingStartingWith("0xFD1C4"); } @Test public void recognizeSets() { - Assertions.assertTrue(MCCollectionSymTypeRelations.isSet(_unboxedSetSymType)); - Assertions.assertTrue(MCCollectionSymTypeRelations.isSet(_boxedSetSymType)); + assertTrue(MCCollectionSymTypeRelations.isSet(_unboxedSetSymType)); + assertTrue(MCCollectionSymTypeRelations.isSet(_boxedSetSymType)); } @Test public void recognizeNonSets() { - Assertions.assertFalse(MCCollectionSymTypeRelations.isSet(_unboxedMapSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isSet(_unboxedListSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isSet(_unboxedOptionalSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isSet(_boxedMapSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isSet(_boxedListSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isSet(_boxedOptionalSymType)); + assertFalse(MCCollectionSymTypeRelations.isSet(_unboxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isSet(_unboxedListSymType)); + assertFalse(MCCollectionSymTypeRelations.isSet(_unboxedOptionalSymType)); + assertFalse(MCCollectionSymTypeRelations.isSet(_boxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isSet(_boxedListSymType)); + assertFalse(MCCollectionSymTypeRelations.isSet(_boxedOptionalSymType)); // incorrect number of arguments _unboxedSetSymType.setArgumentList(Collections.emptyList()); - Assertions.assertFalse(MCCollectionSymTypeRelations.isSet(_unboxedSetSymType)); + assertFalse(MCCollectionSymTypeRelations.isSet(_unboxedSetSymType)); assertHasFindingStartingWith("0xFD1C4"); _boxedSetSymType.setArgumentList(Collections.emptyList()); - Assertions.assertFalse(MCCollectionSymTypeRelations.isSet(_boxedSetSymType)); + assertFalse(MCCollectionSymTypeRelations.isSet(_boxedSetSymType)); assertHasFindingStartingWith("0xFD1C4"); _unboxedSetSymType.setArgumentList(List.of(_intSymType, _intSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isSet(_unboxedSetSymType)); + assertFalse(MCCollectionSymTypeRelations.isSet(_unboxedSetSymType)); assertHasFindingStartingWith("0xFD1C4"); _boxedSetSymType.setArgumentList(List.of(_intSymType, _intSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isSet(_boxedSetSymType)); + assertFalse(MCCollectionSymTypeRelations.isSet(_boxedSetSymType)); assertHasFindingStartingWith("0xFD1C4"); } @Test public void recognizeOptionals() { - Assertions.assertTrue(MCCollectionSymTypeRelations.isOptional(_unboxedOptionalSymType)); - Assertions.assertTrue(MCCollectionSymTypeRelations.isOptional(_boxedOptionalSymType)); + assertTrue(MCCollectionSymTypeRelations.isOptional(_unboxedOptionalSymType)); + assertTrue(MCCollectionSymTypeRelations.isOptional(_boxedOptionalSymType)); } @Test public void recognizeNonOptionals() { - Assertions.assertFalse(MCCollectionSymTypeRelations.isOptional(_unboxedMapSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isOptional(_unboxedListSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isOptional(_unboxedSetSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isOptional(_boxedMapSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isOptional(_boxedListSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isOptional(_boxedSetSymType)); + assertFalse(MCCollectionSymTypeRelations.isOptional(_unboxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isOptional(_unboxedListSymType)); + assertFalse(MCCollectionSymTypeRelations.isOptional(_unboxedSetSymType)); + assertFalse(MCCollectionSymTypeRelations.isOptional(_boxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isOptional(_boxedListSymType)); + assertFalse(MCCollectionSymTypeRelations.isOptional(_boxedSetSymType)); // incorrect number of arguments _unboxedOptionalSymType.setArgumentList(Collections.emptyList()); - Assertions.assertFalse(MCCollectionSymTypeRelations.isOptional(_unboxedOptionalSymType)); + assertFalse(MCCollectionSymTypeRelations.isOptional(_unboxedOptionalSymType)); assertHasFindingStartingWith("0xFD1C4"); _boxedOptionalSymType.setArgumentList(Collections.emptyList()); - Assertions.assertFalse(MCCollectionSymTypeRelations.isOptional(_boxedOptionalSymType)); + assertFalse(MCCollectionSymTypeRelations.isOptional(_boxedOptionalSymType)); assertHasFindingStartingWith("0xFD1C4"); _unboxedOptionalSymType.setArgumentList(List.of(_intSymType, _intSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isOptional(_unboxedOptionalSymType)); + assertFalse(MCCollectionSymTypeRelations.isOptional(_unboxedOptionalSymType)); assertHasFindingStartingWith("0xFD1C4"); _boxedOptionalSymType.setArgumentList(List.of(_intSymType, _intSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isOptional(_boxedOptionalSymType)); + assertFalse(MCCollectionSymTypeRelations.isOptional(_boxedOptionalSymType)); assertHasFindingStartingWith("0xFD1C4"); } @Test public void recognizeMaps() { - Assertions.assertTrue(MCCollectionSymTypeRelations.isMap(_unboxedMapSymType)); - Assertions.assertTrue(MCCollectionSymTypeRelations.isMap(_boxedMapSymType)); + assertTrue(MCCollectionSymTypeRelations.isMap(_unboxedMapSymType)); + assertTrue(MCCollectionSymTypeRelations.isMap(_boxedMapSymType)); } @Test public void recognizeNonMaps() { - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedListSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedSetSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedOptionalSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_boxedListSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_boxedSetSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_boxedOptionalSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedListSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedSetSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedOptionalSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_boxedListSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_boxedSetSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_boxedOptionalSymType)); // incorrect number of arguments _unboxedMapSymType.setArgumentList(Collections.emptyList()); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedMapSymType)); assertHasFindingStartingWith("0xFD1C4"); _boxedMapSymType.setArgumentList(Collections.emptyList()); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_boxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_boxedMapSymType)); assertHasFindingStartingWith("0xFD1C4"); _unboxedMapSymType.setArgumentList(List.of(_intSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedMapSymType)); assertHasFindingStartingWith("0xFD1C4"); _boxedMapSymType.setArgumentList(List.of(_intSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_boxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_boxedMapSymType)); assertHasFindingStartingWith("0xFD1C4"); _unboxedMapSymType.setArgumentList( List.of(_intSymType, _intSymType, _intSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_unboxedMapSymType)); assertHasFindingStartingWith("0xFD1C4"); _boxedMapSymType.setArgumentList( List.of(_intSymType, _intSymType, _intSymType)); - Assertions.assertFalse(MCCollectionSymTypeRelations.isMap(_boxedMapSymType)); + assertFalse(MCCollectionSymTypeRelations.isMap(_boxedMapSymType)); assertHasFindingStartingWith("0xFD1C4"); } @Test public void getCollectionElementTypeTest() { - Assertions.assertSame(_unboxedListSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_unboxedListSymType)); - Assertions.assertSame(_unboxedSetSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_unboxedSetSymType)); - Assertions.assertSame(_unboxedOptionalSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_unboxedOptionalSymType)); - Assertions.assertSame(_unboxedMapSymType.getArgument(1), MCCollectionSymTypeRelations.getCollectionElementType(_unboxedMapSymType)); - Assertions.assertSame(_boxedListSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_boxedListSymType)); - Assertions.assertSame(_boxedSetSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_boxedSetSymType)); - Assertions.assertSame(_boxedOptionalSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_boxedOptionalSymType)); - Assertions.assertSame(_boxedMapSymType.getArgument(1), MCCollectionSymTypeRelations.getCollectionElementType(_boxedMapSymType)); + assertSame(_unboxedListSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_unboxedListSymType)); + assertSame(_unboxedSetSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_unboxedSetSymType)); + assertSame(_unboxedOptionalSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_unboxedOptionalSymType)); + assertSame(_unboxedMapSymType.getArgument(1), MCCollectionSymTypeRelations.getCollectionElementType(_unboxedMapSymType)); + assertSame(_boxedListSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_boxedListSymType)); + assertSame(_boxedSetSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_boxedSetSymType)); + assertSame(_boxedOptionalSymType.getArgument(0), MCCollectionSymTypeRelations.getCollectionElementType(_boxedOptionalSymType)); + assertSame(_boxedMapSymType.getArgument(1), MCCollectionSymTypeRelations.getCollectionElementType(_boxedMapSymType)); } @Test public void getMapKeyTest() { - Assertions.assertSame(_unboxedMapSymType.getArgument(0), MCCollectionSymTypeRelations.getMapKeyType(_unboxedMapSymType)); - Assertions.assertSame(_boxedMapSymType.getArgument(0), MCCollectionSymTypeRelations.getMapKeyType(_boxedMapSymType)); + assertSame(_unboxedMapSymType.getArgument(0), MCCollectionSymTypeRelations.getMapKeyType(_unboxedMapSymType)); + assertSame(_boxedMapSymType.getArgument(0), MCCollectionSymTypeRelations.getMapKeyType(_boxedMapSymType)); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCArrayTypesPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCArrayTypesPrettyPrinterTest.java index fd71403029..ef84d17ecd 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCArrayTypesPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCArrayTypesPrettyPrinterTest.java @@ -9,15 +9,13 @@ import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class MCArrayTypesPrettyPrinterTest { @@ -34,17 +32,17 @@ public void testMCArrayType() throws IOException { //have to use ASTMCType because of left recursion in ASTMCArrayType there is no parse Method MCArrayTypesTestParser parser = new MCArrayTypesTestParser(); Optional ast = parser.parse_StringMCType("String[][]"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.get() instanceof ASTMCArrayType); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertInstanceOf(ASTMCArrayType.class, ast.get()); ASTMCArrayType type = (ASTMCArrayType) ast.get(); MCArrayTypesFullPrettyPrinter printer = new MCArrayTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(type); ast = parser.parse_StringMCType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(type.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(type.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCBasicTypesPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCBasicTypesPrettyPrinterTest.java index 242d349925..f2fbea5613 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCBasicTypesPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCBasicTypesPrettyPrinterTest.java @@ -8,13 +8,14 @@ import de.monticore.types.mcbasictypestest._parser.MCBasicTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCBasicTypesPrettyPrinterTest { @BeforeEach @@ -31,136 +32,136 @@ public void init() { public void testMCQualifiedName() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional ast = parser.parse_StringMCQualifiedName("Name1.Name2.Name3"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCQualifiedName qualifiedName = ast.get(); MCBasicTypesFullPrettyPrinter printer = new MCBasicTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCQualifiedName(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(qualifiedName.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(qualifiedName.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMcImportStatement() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional ast = parser.parse_StringMCImportStatement("import de.monticore.types.*;"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCImportStatement importStatement = ast.get(); MCBasicTypesFullPrettyPrinter printer = new MCBasicTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCImportStatement(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(importStatement.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(importStatement.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMcPrimitiveType() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional ast = parser.parse_StringMCPrimitiveType("long"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCPrimitiveType primitiveType = ast.get(); MCBasicTypesFullPrettyPrinter printer = new MCBasicTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCPrimitiveType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(primitiveType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(primitiveType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCVoidType() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional ast = parser.parse_StringMCVoidType("void"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCVoidType voidType = ast.get(); MCBasicTypesFullPrettyPrinter printer = new MCBasicTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCVoidType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(voidType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(voidType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCReturnTypeVoid() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional ast = parser.parse_StringMCReturnType("void"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCReturnType voidType = ast.get(); MCBasicTypesFullPrettyPrinter printer = new MCBasicTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCReturnType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(voidType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(voidType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCReturnType() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional ast = parser.parse_StringMCReturnType("boolean"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCReturnType voidType = ast.get(); MCBasicTypesFullPrettyPrinter printer = new MCBasicTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCReturnType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(voidType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(voidType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCQualifiedType() throws IOException { MCBasicTypesTestParser parser = new MCBasicTypesTestParser(); Optional ast = parser.parse_StringMCQualifiedType("a.b.c.d"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCQualifiedType qualifiedReferenceType = ast.get(); MCBasicTypesFullPrettyPrinter printer = new MCBasicTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCQualifiedType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(qualifiedReferenceType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(qualifiedReferenceType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCPackageDeclaration() throws IOException { MCBasicTypesTestParser parser = MCBasicTypesTestMill.parser(); Optional ast = parser.parse_StringMCPackageDeclaration("package a.b.c.d;"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCPackageDeclaration packageDeclaration = ast.get(); MCBasicTypesFullPrettyPrinter printer = new MCBasicTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCPackageDeclaration(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(packageDeclaration.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(packageDeclaration.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -177,15 +178,15 @@ public void primitivesTest(){ // .parseType(primitive); Optional type = mcBasicTypesParser.parse_StringMCPrimitiveType(primitive); - Assertions.assertTrue(type.isPresent()); - Assertions.assertEquals(primitive, prettyprinter.prettyprint(type.get())); - Assertions.assertTrue(type.get() instanceof ASTMCPrimitiveType); + assertTrue(type.isPresent()); + assertEquals(primitive, prettyprinter.prettyprint(type.get())); + assertInstanceOf(ASTMCPrimitiveType.class, type.get()); } } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -195,13 +196,13 @@ public void simpleReferenceTest(){ try{ MCBasicTypesTestParser mcBasicTypesParser= new MCBasicTypesTestParser(); Optional type = mcBasicTypesParser.parse_StringMCQualifiedType(simpleReference); - Assertions.assertTrue(type.isPresent()); - Assertions.assertEquals(simpleReference, prettyprinter.prettyprint(type.get())); - Assertions.assertTrue(type.get() instanceof ASTMCQualifiedType); + assertTrue(type.isPresent()); + assertEquals(simpleReference, prettyprinter.prettyprint(type.get())); + assertInstanceOf(ASTMCQualifiedType.class, type.get()); }catch(IOException e){ e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCCollectionTypesPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCCollectionTypesPrettyPrinterTest.java index 98fb1dad5f..dcad861169 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCCollectionTypesPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCCollectionTypesPrettyPrinterTest.java @@ -8,15 +8,14 @@ import de.monticore.types.mccollectiontypes._prettyprint.MCCollectionTypesFullPrettyPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCCollectionTypesPrettyPrinterTest { @@ -31,101 +30,101 @@ public void init() { public void testMCPrimitiveTypeArgument() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional ast = parser.parse_StringMCPrimitiveTypeArgument("boolean"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCPrimitiveTypeArgument typeArgument = ast.get(); MCCollectionTypesFullPrettyPrinter printer = new MCCollectionTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCPrimitiveTypeArgument(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(typeArgument.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(typeArgument.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCBasicTypeArgument() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional ast = parser.parse_StringMCBasicTypeArgument("a.b.c.d"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCBasicTypeArgument typeArgument = ast.get(); MCCollectionTypesFullPrettyPrinter printer = new MCCollectionTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCBasicTypeArgument(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(typeArgument.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(typeArgument.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCListType() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional ast = parser.parse_StringMCListType("List"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCListType listType = ast.get(); MCCollectionTypesFullPrettyPrinter printer = new MCCollectionTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCListType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(listType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(listType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCOptionalType() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional ast = parser.parse_StringMCOptionalType("Optional"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCOptionalType optionalType = ast.get(); MCCollectionTypesFullPrettyPrinter printer = new MCCollectionTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCOptionalType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(optionalType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(optionalType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCMapType() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional ast = parser.parse_StringMCMapType("Map"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCMapType mapType = ast.get(); MCCollectionTypesFullPrettyPrinter printer = new MCCollectionTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCMapType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(mapType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(mapType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCSetType() throws IOException { MCCollectionTypesTestParser parser = new MCCollectionTypesTestParser(); Optional ast = parser.parse_StringMCSetType("Set"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCSetType setType = ast.get(); MCCollectionTypesFullPrettyPrinter printer = new MCCollectionTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCSetType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(setType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(setType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCFullGenericTypesPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCFullGenericTypesPrettyPrinterTest.java index 2972f97f05..72a17975f8 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCFullGenericTypesPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCFullGenericTypesPrettyPrinterTest.java @@ -9,15 +9,14 @@ import de.monticore.types.mcfullgenerictypes._prettyprint.MCFullGenericTypesFullPrettyPrinter; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MCFullGenericTypesPrettyPrinterTest { @@ -33,51 +32,51 @@ public void init() { public void testMCWildcardTypeArgumentExtends() throws IOException { MCFullGenericTypesTestParser parser = new MCFullGenericTypesTestParser(); Optional ast = parser.parse_StringMCWildcardTypeArgument("? extends java.util.List"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCWildcardTypeArgument wildcardType = ast.get(); MCFullGenericTypesFullPrettyPrinter printer = new MCFullGenericTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCWildcardTypeArgument(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(wildcardType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(wildcardType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCWildcardTypeArgumentSuper() throws IOException { MCFullGenericTypesTestParser parser = new MCFullGenericTypesTestParser(); Optional ast = parser.parse_StringMCWildcardTypeArgument("? super de.monticore.ASTNode"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCWildcardTypeArgument wildcardType = ast.get(); MCFullGenericTypesFullPrettyPrinter printer = new MCFullGenericTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCWildcardTypeArgument(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(wildcardType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(wildcardType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCMultipleGenericType() throws IOException { MCFullGenericTypesTestParser parser = new MCFullGenericTypesTestParser(); Optional ast = parser.parse_StringMCMultipleGenericType("java.util.List.some.util.Set.Opt>"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCMultipleGenericType complexReferenceType = ast.get(); MCFullGenericTypesFullPrettyPrinter printer = new MCFullGenericTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCMultipleGenericType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(complexReferenceType.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(complexReferenceType.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCFunctionTypesPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCFunctionTypesPrettyPrinterTest.java index 09114b7834..1174886fc0 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCFunctionTypesPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCFunctionTypesPrettyPrinterTest.java @@ -8,16 +8,13 @@ import de.monticore.types.mcfunctiontypestest._parser.MCFunctionTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class MCFunctionTypesPrettyPrinterTest { @@ -67,9 +64,9 @@ public void testHigherOrderFunction2() throws IOException { protected ASTMCFunctionType parse(String mcTypeStr) throws IOException { MCFunctionTypesTestParser parser = new MCFunctionTypesTestParser(); Optional typeOpt = parser.parse_StringMCFunctionType(mcTypeStr); - Assertions.assertNotNull(typeOpt); - Assertions.assertTrue(typeOpt.isPresent()); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertNotNull(typeOpt); + assertTrue(typeOpt.isPresent()); + assertEquals(0, Log.getFindingsCount()); return typeOpt.get(); } @@ -77,7 +74,7 @@ protected String print(ASTMCFunctionType type) { MCFunctionTypesFullPrettyPrinter printer = new MCFunctionTypesFullPrettyPrinter( new IndentPrinter()); String typeStr = printer.prettyprint(type); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); return typeStr; } @@ -85,8 +82,8 @@ protected void testPrintParseCompare(String typeStr) throws IOException { ASTMCFunctionType type = parse(typeStr); String printed = print(type); ASTMCFunctionType typeOfPrinted = parse(printed); - Assertions.assertTrue(typeOfPrinted.deepEquals(type)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(typeOfPrinted.deepEquals(type)); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCSimpleGenericTypesPrettyPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCSimpleGenericTypesPrettyPrinterTest.java index c1a847213d..e5a16410e4 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCSimpleGenericTypesPrettyPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/MCSimpleGenericTypesPrettyPrinterTest.java @@ -9,13 +9,14 @@ import de.monticore.types.mcsimplegenerictypestest._parser.MCSimpleGenericTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class MCSimpleGenericTypesPrettyPrinterTest { @BeforeEach @@ -32,51 +33,51 @@ public void init() { public void testMCBasicTypeArgument() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional ast = parser.parse_StringMCBasicGenericType("java.util.List>>"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCBasicGenericType typeArgument = ast.get(); MCSimpleGenericTypesFullPrettyPrinter printer = new MCSimpleGenericTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCBasicGenericType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(typeArgument.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(typeArgument.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCBasicTypeArgument2() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional ast = parser.parse_StringMCBasicGenericType("some.randomObject>>>>"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCBasicGenericType typeArgument = ast.get(); MCSimpleGenericTypesFullPrettyPrinter printer = new MCSimpleGenericTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCBasicGenericType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(typeArgument.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(typeArgument.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMCCustomTypeArgument() throws IOException { MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional ast = parser.parse_StringMCCustomTypeArgument("some.randomObject>>>>"); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); ASTMCCustomTypeArgument typeArgument = ast.get(); MCSimpleGenericTypesFullPrettyPrinter printer = new MCSimpleGenericTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); ast = parser.parse_StringMCCustomTypeArgument(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(typeArgument.deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(typeArgument.deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -84,20 +85,20 @@ public void testMultipleMCCustomTypeArgument() throws IOException { String type = "java.util.List,List>"; MCSimpleGenericTypesTestParser parser = new MCSimpleGenericTypesTestParser(); Optional ast = parser.parse_StringMCBasicGenericType(type); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); Optional astBefore = ast; MCSimpleGenericTypesFullPrettyPrinter printer = new MCSimpleGenericTypesFullPrettyPrinter(new IndentPrinter()); String output = printer.prettyprint(ast.get()); - Assertions.assertEquals(type, output); + assertEquals(type, output); ast = parser.parse_StringMCBasicGenericType(output); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(astBefore.get().deepEquals(ast.get())); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(astBefore.get().deepEquals(ast.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/PrintTypeAstExtensionTests.java b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/PrintTypeAstExtensionTests.java index e228b7316e..5e51d2ffec 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/prettyprint/PrintTypeAstExtensionTests.java +++ b/monticore-grammar/src/test/java/de/monticore/types/prettyprint/PrintTypeAstExtensionTests.java @@ -11,15 +11,14 @@ import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class PrintTypeAstExtensionTests { @@ -46,7 +45,7 @@ public void printTypeMethodPrimitiveBooleanTest() { System.out.println(f.getMsg()); } - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { @@ -54,7 +53,7 @@ public void printTypeMethodPrimitiveBooleanTest() { } } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -64,12 +63,12 @@ public void printTypeMethodObjectTypeTest() { String simpleReference = "de.monticore.types.prettyprint"; try { Optional type = mcBasicTypesParser.parse_StringMCObjectType(simpleReference); - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -78,12 +77,12 @@ public void printTypeMethodQualifiedTypeTest() { String simpleReference = "de.monticore.types.prettyprint"; try { Optional type = mcBasicTypesParser.parse_StringMCQualifiedType(simpleReference); - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -93,12 +92,12 @@ public void printTypeMethodReturnTypeTest() { String simpleReference = "de.monticore.types.Prettyprint"; try { Optional type = mcBasicTypesParser.parse_StringMCReturnType(simpleReference); - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -107,12 +106,12 @@ public void printTypeMethodReturnTypeVoidTest() { String simpleReference = "void"; try { Optional type = mcBasicTypesParser.parse_StringMCReturnType(simpleReference); - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -121,14 +120,14 @@ public void printTypeMethodTullGenericTypeTest() { String simpleReference = "de.monticore.types.prettyprint"; try { Optional type = parser.parse_StringMCType(simpleReference); - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -138,14 +137,14 @@ public void printTypeMethodTullGenericType2Test() { String simpleReference = "de.monticore.types.prettyprint"; try { Optional type = parser.parse_StringMCType(simpleReference); - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -155,7 +154,7 @@ public void printTypeMethodTSimpleGenericsArrayTest() { for(String simpleReference:types) { try { Optional type = parser.parse_StringMCType(simpleReference); - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { @@ -163,7 +162,7 @@ public void printTypeMethodTSimpleGenericsArrayTest() { } } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -176,7 +175,7 @@ public void printTypeMethodCollectionTypesTest() { for(String simpleReference:collectionTypes) { try { Optional type = parser.parse_StringMCType(simpleReference); - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { @@ -184,7 +183,7 @@ public void printTypeMethodCollectionTypesTest() { } } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -194,14 +193,14 @@ public void printTypeMethodTullGenericTypeWildcardExtendsTest() { String simpleReference = "de.monticore.types.prettyprint"; try { Optional type = parser.parse_StringMCType(simpleReference); - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -216,14 +215,14 @@ public void printTypeMethodTullGenericTypeExtendsTest() { System.out.println(f.getMsg()); } - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -234,14 +233,14 @@ public void printTypeMethodTullGenericTypeWildcardSuperTest() { try { Optional type = parser.parse_StringMCType(simpleReference); - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -255,14 +254,14 @@ public void printTypeMethodImportStatementTest() { System.out.println(f.getMsg()); } - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -276,14 +275,14 @@ public void printTypeMethodStarImportStatementTest() { System.out.println(f.getMsg()); } - Assertions.assertEquals(simpleReference.trim(), type.get().printType().trim()); + assertEquals(simpleReference.trim(), type.get().printType().trim()); } catch (IOException e) { e.printStackTrace(); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/printer/BasicTypesPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/types/printer/BasicTypesPrinterTest.java index 20084a2265..7e24773833 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/printer/BasicTypesPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/printer/BasicTypesPrinterTest.java @@ -7,13 +7,14 @@ import de.monticore.types.mcbasictypestest._parser.MCBasicTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class BasicTypesPrinterTest { @BeforeEach @@ -35,21 +36,21 @@ public void testPrintType() throws IOException{ Optional astmcPrimitiveType = parser.parse_StringMCPrimitiveType("int"); Optional astmcQualifiedType = parser.parse_StringMCQualifiedType("java.util.List"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astmcImportStatement.isPresent()); - Assertions.assertTrue(astmcImportStatement.isPresent()); - Assertions.assertTrue(astmcImportStatement1.isPresent()); - Assertions.assertTrue(astmcQualifiedName.isPresent()); - Assertions.assertTrue(astmcReturnType.isPresent()); - Assertions.assertTrue(astmcVoidType.isPresent()); - Assertions.assertTrue(astmcPrimitiveType.isPresent()); - Assertions.assertTrue(astmcQualifiedType.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astmcImportStatement.isPresent()); + assertTrue(astmcImportStatement.isPresent()); + assertTrue(astmcImportStatement1.isPresent()); + assertTrue(astmcQualifiedName.isPresent()); + assertTrue(astmcReturnType.isPresent()); + assertTrue(astmcVoidType.isPresent()); + assertTrue(astmcPrimitiveType.isPresent()); + assertTrue(astmcQualifiedType.isPresent()); - Assertions.assertEquals("String", MCBasicTypesMill.prettyPrint(astmcReturnType.get(), true)); - Assertions.assertEquals("void", MCBasicTypesMill.prettyPrint(astmcVoidType.get(), true)); - Assertions.assertEquals("int", MCBasicTypesMill.prettyPrint(astmcPrimitiveType.get(), true)); - Assertions.assertEquals("java.util.List", MCBasicTypesMill.prettyPrint(astmcQualifiedType.get(), true)); + assertEquals("String", MCBasicTypesMill.prettyPrint(astmcReturnType.get(), true)); + assertEquals("void", MCBasicTypesMill.prettyPrint(astmcVoidType.get(), true)); + assertEquals("int", MCBasicTypesMill.prettyPrint(astmcPrimitiveType.get(), true)); + assertEquals("java.util.List", MCBasicTypesMill.prettyPrint(astmcQualifiedType.get(), true)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/printer/CollectionTypesPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/types/printer/CollectionTypesPrinterTest.java index 0cfe3b5885..316a0f117d 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/printer/CollectionTypesPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/printer/CollectionTypesPrinterTest.java @@ -7,13 +7,14 @@ import de.monticore.types.mccollectiontypestest._parser.MCCollectionTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class CollectionTypesPrinterTest { @BeforeEach @@ -34,21 +35,21 @@ public void testPrintType() throws IOException { Optional astmcOptionalType = parser.parse_StringMCOptionalType("Optional"); Optional astmcMapType = parser.parse_StringMCMapType("Map"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astmcBasicTypeArgument.isPresent()); - Assertions.assertTrue(astmcPrimitiveTypeArgument.isPresent()); - Assertions.assertTrue(astmcListType.isPresent()); - Assertions.assertTrue(astmcSetType.isPresent()); - Assertions.assertTrue(astmcOptionalType.isPresent()); - Assertions.assertTrue(astmcMapType.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astmcBasicTypeArgument.isPresent()); + assertTrue(astmcPrimitiveTypeArgument.isPresent()); + assertTrue(astmcListType.isPresent()); + assertTrue(astmcSetType.isPresent()); + assertTrue(astmcOptionalType.isPresent()); + assertTrue(astmcMapType.isPresent()); - Assertions.assertEquals("java.util.List", MCCollectionTypesMill.prettyPrint(astmcBasicTypeArgument.get(), true)); - Assertions.assertEquals("int", MCCollectionTypesMill.prettyPrint(astmcPrimitiveTypeArgument.get(), true)); - Assertions.assertEquals("List", MCCollectionTypesMill.prettyPrint(astmcListType.get(), true)); - Assertions.assertEquals("Set", MCCollectionTypesMill.prettyPrint(astmcSetType.get(), true)); - Assertions.assertEquals("Optional", MCCollectionTypesMill.prettyPrint(astmcOptionalType.get(), true)); - Assertions.assertEquals("Map", MCCollectionTypesMill.prettyPrint(astmcMapType.get(), true)); + assertEquals("java.util.List", MCCollectionTypesMill.prettyPrint(astmcBasicTypeArgument.get(), true)); + assertEquals("int", MCCollectionTypesMill.prettyPrint(astmcPrimitiveTypeArgument.get(), true)); + assertEquals("List", MCCollectionTypesMill.prettyPrint(astmcListType.get(), true)); + assertEquals("Set", MCCollectionTypesMill.prettyPrint(astmcSetType.get(), true)); + assertEquals("Optional", MCCollectionTypesMill.prettyPrint(astmcOptionalType.get(), true)); + assertEquals("Map", MCCollectionTypesMill.prettyPrint(astmcMapType.get(), true)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/printer/FullGenericTypesPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/types/printer/FullGenericTypesPrinterTest.java index c428492ab1..5c476874fa 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/printer/FullGenericTypesPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/printer/FullGenericTypesPrinterTest.java @@ -8,13 +8,14 @@ import de.monticore.types.mcfullgenerictypestest._parser.MCFullGenericTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class FullGenericTypesPrinterTest { @BeforeEach @@ -35,21 +36,21 @@ public void testPrintType() throws IOException { // Optional astmcTypeVariableDeclaration = parser.parse_StringMCTypeVariableDeclaration("a extends b&c&d"); // Optional astmcTypeParameters = parser.parse_StringMCTypeParameters(""); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astmcWildcardTypeArgument.isPresent()); - Assertions.assertTrue(astmcWildcardTypeArgument1.isPresent()); - Assertions.assertTrue(astmcWildcardTypeArgument2.isPresent()); - Assertions.assertTrue(astmcMultipleGenericType.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astmcWildcardTypeArgument.isPresent()); + assertTrue(astmcWildcardTypeArgument1.isPresent()); + assertTrue(astmcWildcardTypeArgument2.isPresent()); + assertTrue(astmcMultipleGenericType.isPresent()); // assertTrue(astmcTypeVariableDeclaration.isPresent()); // assertTrue(astmcTypeParameters.isPresent()); - Assertions.assertEquals("?", MCFullGenericTypesMill.prettyPrint(astmcWildcardTypeArgument.get(), true)); - Assertions.assertEquals("? extends List", MCFullGenericTypesMill.prettyPrint(astmcWildcardTypeArgument1.get(), true)); - Assertions.assertEquals("? super Stream", MCFullGenericTypesMill.prettyPrint(astmcWildcardTypeArgument2.get(), true)); - Assertions.assertEquals("java.util.List>.c.d", MCFullGenericTypesMill.prettyPrint(astmcMultipleGenericType.get(), true)); + assertEquals("?", MCFullGenericTypesMill.prettyPrint(astmcWildcardTypeArgument.get(), true)); + assertEquals("? extends List", MCFullGenericTypesMill.prettyPrint(astmcWildcardTypeArgument1.get(), true)); + assertEquals("? super Stream", MCFullGenericTypesMill.prettyPrint(astmcWildcardTypeArgument2.get(), true)); + assertEquals("java.util.List>.c.d", MCFullGenericTypesMill.prettyPrint(astmcMultipleGenericType.get(), true)); // assertEquals("", FullGenericTypesPrinter.printType(astmcTypeParameters.get())); // assertEquals("a extends b &c &d", FullGenericTypesPrinter.printType(astmcTypeVariableDeclaration.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/printer/SimpleGenericTypesPrinterTest.java b/monticore-grammar/src/test/java/de/monticore/types/printer/SimpleGenericTypesPrinterTest.java index 71a219481a..5c34f9c854 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/printer/SimpleGenericTypesPrinterTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/printer/SimpleGenericTypesPrinterTest.java @@ -8,13 +8,14 @@ import de.monticore.types.mcsimplegenerictypestest._parser.MCSimpleGenericTypesTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class SimpleGenericTypesPrinterTest { @BeforeEach @@ -31,13 +32,13 @@ public void testPrintType() throws IOException { Optional astmcCustomTypeArgument = parser.parse_StringMCCustomTypeArgument("List"); Optional astmcBasicGenericType = parser.parse_StringMCBasicGenericType("java.util.List>"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astmcBasicGenericType.isPresent()); - Assertions.assertTrue(astmcCustomTypeArgument.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astmcBasicGenericType.isPresent()); + assertTrue(astmcCustomTypeArgument.isPresent()); - Assertions.assertEquals("List", MCSimpleGenericTypesMill.prettyPrint(astmcCustomTypeArgument.get(), false)); - Assertions.assertEquals("java.util.List>", MCSimpleGenericTypesMill.prettyPrint(astmcBasicGenericType.get(), false)); + assertEquals("List", MCSimpleGenericTypesMill.prettyPrint(astmcCustomTypeArgument.get(), false)); + assertEquals("java.util.List>", MCSimpleGenericTypesMill.prettyPrint(astmcBasicGenericType.get(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types/typeparameters/cocos/TypeParametersHaveUniqueNamesTest.java b/monticore-grammar/src/test/java/de/monticore/types/typeparameters/cocos/TypeParametersHaveUniqueNamesTest.java index f3b2e77d7c..cd124c093a 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/typeparameters/cocos/TypeParametersHaveUniqueNamesTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/typeparameters/cocos/TypeParametersHaveUniqueNamesTest.java @@ -7,7 +7,6 @@ import de.monticore.types.typeparameterstest._parser.TypeParametersTestParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -15,6 +14,8 @@ import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class TypeParametersHaveUniqueNamesTest { TypeParametersTestCoCoChecker checker; @@ -39,7 +40,7 @@ public void init() { public void testValid(String model) throws IOException { ASTTypeParameters params = parseAndCreateSymTab(model); checker.checkAll(params); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @ParameterizedTest @@ -51,8 +52,8 @@ public void testValid(String model) throws IOException { public void testInvalid(String model) throws IOException { ASTTypeParameters params = parseAndCreateSymTab(model); checker.checkAll(params); - Assertions.assertFalse(Log.getFindings().isEmpty()); - Assertions.assertEquals( + assertFalse(Log.getFindings().isEmpty()); + assertEquals( "0xFDC14", Log.getFindings().get(0).getMsg().substring(0, 7) ); @@ -63,9 +64,9 @@ protected ASTTypeParameters parseAndCreateSymTab(String model) TypeParametersTestParser parser = TypeParametersTestMill.parser(); Optional astOpt = parser.parse_StringTypeParameters(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astOpt.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(parser.hasErrors()); + assertTrue(astOpt.isPresent()); + assertTrue(Log.getFindings().isEmpty()); TypeParametersMill.scopesGenitorDelegator().createFromAST(astOpt.get()); return astOpt.get(); } diff --git a/monticore-grammar/src/test/java/de/monticore/types/typeparameters/cocos/TypeParametersNoCyclicInheritanceTest.java b/monticore-grammar/src/test/java/de/monticore/types/typeparameters/cocos/TypeParametersNoCyclicInheritanceTest.java index 9aef16bba6..566a6a1899 100644 --- a/monticore-grammar/src/test/java/de/monticore/types/typeparameters/cocos/TypeParametersNoCyclicInheritanceTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types/typeparameters/cocos/TypeParametersNoCyclicInheritanceTest.java @@ -16,7 +16,6 @@ import de.monticore.visitor.ITraverser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -24,6 +23,8 @@ import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class TypeParametersNoCyclicInheritanceTest { TypeParametersTestCoCoChecker checker; @@ -47,7 +48,7 @@ public void init() { public void testValid(String model) throws IOException { ASTTypeParameters params = parseAndCreateSymTab(model); checker.checkAll(params); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @ParameterizedTest @@ -58,8 +59,8 @@ public void testValid(String model) throws IOException { public void testInvalid(String model) throws IOException { ASTTypeParameters params = parseAndCreateSymTab(model); checker.checkAll(params); - Assertions.assertFalse(Log.getFindings().isEmpty()); - Assertions.assertEquals( + assertFalse(Log.getFindings().isEmpty()); + assertEquals( "0xFDC12", Log.getFindings().get(0).getMsg().substring(0, 7) ); @@ -70,9 +71,9 @@ protected ASTTypeParameters parseAndCreateSymTab(String model) TypeParametersTestParser parser = TypeParametersTestMill.parser(); Optional astOpt = parser.parse_StringTypeParameters(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astOpt.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(parser.hasErrors()); + assertTrue(astOpt.isPresent()); + assertTrue(Log.getFindings().isEmpty()); ITypeParametersArtifactScope artifactScope = TypeParametersMill .scopesGenitorDelegator().createFromAST(astOpt.get()); artifactScope.setName("aName"); diff --git a/monticore-grammar/src/test/java/de/monticore/types3/AbstractTypeVisitorTest.java b/monticore-grammar/src/test/java/de/monticore/types3/AbstractTypeVisitorTest.java index 9f2dea0038..54beb7b225 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/AbstractTypeVisitorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/AbstractTypeVisitorTest.java @@ -31,7 +31,6 @@ import de.monticore.visitor.ITraverser; import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import java.io.IOException; @@ -52,8 +51,7 @@ import static de.monticore.types3.util.DefsTypesForTests.inScope; import static de.monticore.types3.util.DefsTypesForTests.typeVariable; import static de.monticore.types3.util.DefsTypesForTests.variable; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * used to provide facilities to test type derivers. @@ -178,7 +176,7 @@ protected Optional parseStringExpr(String exprStr) { return parser.parse_StringExpression(exprStr); } catch (IOException e) { - return Assertions.fail(e); + return fail(e); } } @@ -188,7 +186,7 @@ protected Optional parseStringMCType(String mcTypeStr) { return parser.parse_StringMCType(mcTypeStr); } catch (IOException e) { - return Assertions.fail(e); + return fail(e); } } @@ -250,14 +248,14 @@ protected void generateScopes(ASTMCType mcType) { protected ASTExpression parseExpr(String exprStr) { Optional astExpression = parseStringExpr(exprStr); assertNoFindings(); - Assertions.assertTrue(astExpression.isPresent()); + assertTrue(astExpression.isPresent()); return astExpression.get(); } protected ASTMCType parseMCType(String typeStr) { Optional mcType = parseStringMCType(typeStr); assertNoFindings(); - Assertions.assertTrue(mcType.isPresent()); + assertTrue(mcType.isPresent()); return mcType.get(); } @@ -293,7 +291,7 @@ protected void checkExpr( boolean equalsNormalized = expectedType.equals(typeNormalized.printFullName()); if (!allowNormalization || !equalsNormalized) { - Assertions.assertEquals(expectedType, type.printFullName(), "Wrong type for expression " + exprStr); + assertEquals(expectedType, type.printFullName(), "Wrong type for expression " + exprStr); } } @@ -306,7 +304,7 @@ protected void checkType(ASTMCType astType, String expectedType) { generateScopes(astType); SymTypeExpression type = TypeCheck3.symTypeFromAST(astType); assertNoFindings(); - Assertions.assertEquals(expectedType, type.printFullName(), + assertEquals(expectedType, type.printFullName(), "Wrong type for type identifier " + MCBasicTypesMill.prettyPrint(astType, false) ); @@ -345,7 +343,7 @@ protected void checkErrorExpr( "\" but got " + type.printFullName()); // check that the typecheck did something; // if not correctly configured, this will not hold true - Assertions.assertTrue(getType4Ast().hasPartialTypeOfExpression(astExpr)); + assertTrue(getType4Ast().hasPartialTypeOfExpression(astExpr)); assertHasErrorCode(expectedError); Log.getFindings().clear(); } @@ -360,7 +358,7 @@ protected void checkErrorMCType(String typeStr, String expectedError) { + "\" but got " + type.printFullName()); // check that the typecheck did something; // if not correctly configured, this will not hold true - Assertions.assertTrue(getType4Ast().hasPartialTypeOfTypeIdentifier(astType)); + assertTrue(getType4Ast().hasPartialTypeOfTypeIdentifier(astType)); assertHasErrorCode(expectedError); } diff --git a/monticore-grammar/src/test/java/de/monticore/types3/CommonExpressionTypeVisitorTest.java b/monticore-grammar/src/test/java/de/monticore/types3/CommonExpressionTypeVisitorTest.java index d4b6573779..ca6c0d92b8 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/CommonExpressionTypeVisitorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/CommonExpressionTypeVisitorTest.java @@ -27,7 +27,6 @@ import de.monticore.symbols.oosymbols._symboltable.OOTypeSymbol; import de.monticore.types.check.SymTypeExpression; import de.monticore.types.check.SymTypeExpressionFactory; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -45,6 +44,7 @@ import static de.monticore.types.check.SymTypeExpressionFactory.createTypeObject; import static de.monticore.types.check.SymTypeExpressionFactory.createTypeVariable; import static de.monticore.types.check.SymTypeExpressionFactory.createUnion; +import static org.junit.jupiter.api.Assertions.*; public class CommonExpressionTypeVisitorTest extends AbstractTypeVisitorTest { @@ -1166,352 +1166,352 @@ public void deriveFromConditionalExpression() throws IOException { generateScopes(astExpr); assertNoFindings(); SymTypeExpression type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_shortSymType, type)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_byteSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_shortSymType, type)); + assertFalse(SymTypeRelations.isCompatible(_byteSymType, type)); //test with two ints as true and false expression astExpr = parseExpr("3<4?9:10"); generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); // test with boolean and int astExpr = parseExpr("3<4?true:7"); generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertFalse(SymTypeRelations.isCompatible(_booleanSymType, type)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_intSymType, type)); + assertFalse(SymTypeRelations.isCompatible(_booleanSymType, type)); + assertFalse(SymTypeRelations.isCompatible(_intSymType, type)); //test with float and long astExpr = parseExpr("3>4?4.5f:10L"); generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_longSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertFalse(SymTypeRelations.isCompatible(_longSymType, type)); //test without primitive types as true and false expression astExpr = parseExpr("3<9?person1:person2"); generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_personSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_personSymType, type)); //test with two objects in a sub-supertype relation astExpr = parseExpr("3<9?student1:person2"); generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_personSymType, type)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_studentSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_personSymType, type)); + assertFalse(SymTypeRelations.isCompatible(_studentSymType, type)); astExpr = parseExpr("varboolean ? 0 : 1"); // ? applicable to boolean generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); astExpr = parseExpr("varboolean ? varboolean : varboolean"); // ? applicable to boolean, boolean, result is boolean generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_booleanSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_booleanSymType, type)); astExpr = parseExpr("varbyte = varboolean ? varbyte : varbyte"); // ? applicable to byte, byte, result is byte generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_byteSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_byteSymType, type)); astExpr = parseExpr("varshort = varboolean ? varbyte : varshort"); // ? applicable to byte, short, result is short generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_shortSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_shortSymType, type)); astExpr = parseExpr("varshort = varboolean ? varshort : varbyte"); // ? applicable to short, byte, result is short generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_shortSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_shortSymType, type)); astExpr = parseExpr("varshort = varboolean ? varshort : varshort"); // ? applicable to short, short, result is short generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_shortSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_shortSymType, type)); astExpr = parseExpr("varchar = varboolean ? varchar : varchar"); // ? applicable to char, char, result is char generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_charSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_charSymType, type)); astExpr = parseExpr("varint = varboolean ? varchar : varbyte"); // ? applicable to char, byte, result is int generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); astExpr = parseExpr("varint = varboolean ? varbyte : varchar"); // ? applicable to byte, char, result is int generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); astExpr = parseExpr("varint = varboolean ? varchar : varshort"); // ? applicable to char, short, result is int generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); astExpr = parseExpr("varint = varboolean ? varshort : varchar"); // ? applicable to short, char, result is int generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); astExpr = parseExpr("varint = varboolean ? varint : varbyte"); // ? applicable to int, byte, result is int generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); astExpr = parseExpr("varint = varboolean ? varint : varshort"); // ? applicable to int, short, result is int generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); astExpr = parseExpr("varint = varboolean ? varint : varchar"); // ? applicable to int, char, result is int generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); astExpr = parseExpr("varint = varboolean ? varbyte : varint"); // ? applicable to byte, int, result is int generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); astExpr = parseExpr("varint = varboolean ? varshort : varint"); // ? applicable to short, int, result is int generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); astExpr = parseExpr("varint = varboolean ? varchar : varint"); // ? applicable to char, int, result is int generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, type)); astExpr = parseExpr("varint = varboolean ? varint : varint"); // ? applicable to int, int, result is int generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); astExpr = parseExpr("varlong = varboolean ? varlong : varbyte"); // ? applicable to long, byte, result is long generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); astExpr = parseExpr("varlong = varboolean ? varlong : varshort"); // ? applicable to long, short, result is long generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); astExpr = parseExpr("varlong = varboolean ? varlong : varchar"); // ? applicable to long, char, result is long generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); astExpr = parseExpr("varlong = varboolean ? varlong : varint"); // ? applicable to long, int, result is long generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); astExpr = parseExpr("varlong = varboolean ? varbyte : varlong"); // ? applicable to byte, long, result is long generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); astExpr = parseExpr("varlong = varboolean ? varshort : varlong"); // ? applicable to short, long, result is long generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); astExpr = parseExpr("varlong = varboolean ? varchar : varlong"); // ? applicable to char, long, result is long generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); astExpr = parseExpr("varlong = varboolean ? varint : varlong"); // ? applicable to int, long, result is long generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); astExpr = parseExpr("varlong = varboolean ? varlong : varlong"); // ? applicable to long, long, result is long generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, type)); astExpr = parseExpr("varfloat = varboolean ? varfloat : varbyte"); // ? applicable to float, byte, result is float generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); astExpr = parseExpr("varfloat = varboolean ? varfloat : varshort"); // ? applicable to float, short, result is float generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); astExpr = parseExpr("varfloat = varboolean ? varfloat : varchar"); // ? applicable to float, char, result is float generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); astExpr = parseExpr("varfloat = varboolean ? varfloat : varint"); // ? applicable to float, int, result is float generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); astExpr = parseExpr("varfloat = varboolean ? varfloat : varlong"); // ? applicable to float, long, result is float generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); astExpr = parseExpr("varfloat = varboolean ? varbyte : varfloat"); // ? applicable to byte, float, result is float generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); astExpr = parseExpr("varfloat = varboolean ? varshort : varfloat"); // ? applicable to short, float, result is float generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); astExpr = parseExpr("varfloat = varboolean ? varchar : varfloat"); // ? applicable to char, float, result is float generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); astExpr = parseExpr("varfloat = varboolean ? varint : varfloat"); // ? applicable to int, float, result is float generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); astExpr = parseExpr("varfloat = varboolean ? varlong : varfloat"); // ? applicable to long, float, result is float generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); astExpr = parseExpr("varfloat = varboolean ? varfloat : varfloat"); // ? applicable to float, float, result is float generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, type)); astExpr = parseExpr("vardouble = varboolean ? vardouble : varbyte"); // ? applicable to double, byte, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? vardouble : varshort"); // ? applicable to double, short, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? vardouble : varchar"); // ? applicable to double, char, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? vardouble : varint"); // ? applicable to double, int, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? vardouble : varlong"); // ? applicable to double, long, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? vardouble : varfloat"); // ? applicable to double, long, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? varbyte : vardouble"); // ? applicable to byte, double, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? varshort : vardouble"); // ? applicable to short, double, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? varchar : vardouble"); // ? applicable to char, double, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? varint : vardouble"); // ? applicable to int, double, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? varlong : vardouble"); // ? applicable to long, double, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? varfloat : vardouble"); // ? applicable to float, double, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); astExpr = parseExpr("vardouble = varboolean ? vardouble : vardouble"); // ? applicable to double, double, result is double generateScopes(astExpr); assertNoFindings(); type = TypeCheck3.typeOf(astExpr); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, type)); } @Test @@ -1771,19 +1771,19 @@ public void deriveFromFieldAccessExpressionInnerResults() throws IOException { // calculate all the types TypeCheck3.typeOf(astTestVariable); assertNoFindings(); - Assertions.assertTrue(getType4Ast().hasTypeOfExpression(astTestVariable)); - Assertions.assertFalse(getType4Ast().hasTypeOfTypeIdentifierForName(astTestVariable)); - Assertions.assertEquals("short", getType4Ast().getTypeOfExpression(astTestVariable).printFullName()); - Assertions.assertFalse(getType4Ast().hasTypeOfExpression(astTestInnerType)); - Assertions.assertTrue(getType4Ast().hasTypeOfTypeIdentifierForName(astTestInnerType)); - Assertions.assertEquals("types3.types2.Test.TestInnerType", getType4Ast().getPartialTypeOfTypeIdForName(astTestInnerType).printFullName()); - Assertions.assertFalse(getType4Ast().hasTypeOfExpression(astTest)); - Assertions.assertTrue(getType4Ast().hasTypeOfTypeIdentifierForName(astTest)); - Assertions.assertEquals("types3.types2.Test", getType4Ast().getPartialTypeOfTypeIdForName(astTest).printFullName()); - Assertions.assertFalse(getType4Ast().hasTypeOfExpression(astTypes2)); - Assertions.assertFalse(getType4Ast().hasTypeOfTypeIdentifierForName(astTypes2)); - Assertions.assertFalse(getType4Ast().hasTypeOfExpression(astTypes3)); - Assertions.assertFalse(getType4Ast().hasTypeOfTypeIdentifierForName(astTypes3)); + assertTrue(getType4Ast().hasTypeOfExpression(astTestVariable)); + assertFalse(getType4Ast().hasTypeOfTypeIdentifierForName(astTestVariable)); + assertEquals("short", getType4Ast().getTypeOfExpression(astTestVariable).printFullName()); + assertFalse(getType4Ast().hasTypeOfExpression(astTestInnerType)); + assertTrue(getType4Ast().hasTypeOfTypeIdentifierForName(astTestInnerType)); + assertEquals("types3.types2.Test.TestInnerType", getType4Ast().getPartialTypeOfTypeIdForName(astTestInnerType).printFullName()); + assertFalse(getType4Ast().hasTypeOfExpression(astTest)); + assertTrue(getType4Ast().hasTypeOfTypeIdentifierForName(astTest)); + assertEquals("types3.types2.Test", getType4Ast().getPartialTypeOfTypeIdForName(astTest).printFullName()); + assertFalse(getType4Ast().hasTypeOfExpression(astTypes2)); + assertFalse(getType4Ast().hasTypeOfTypeIdentifierForName(astTypes2)); + assertFalse(getType4Ast().hasTypeOfExpression(astTypes3)); + assertFalse(getType4Ast().hasTypeOfTypeIdentifierForName(astTypes3)); assertNoFindings(); } @@ -2510,42 +2510,42 @@ public void visit(ASTExpression node) { // todo https://git.rwth-aachen.de/monticore/monticore/-/issues/4362 // = TypeCheck3.typeOf(astexpr); assertNoFindings(); - //Assertions.assertEquals("void", type.printFullName()); + //assertEquals("void", type.printFullName()); astexpr = parseExpr("myName"); generateScopes(astexpr); astexpr.accept(scopeSetter); type = TypeCheck3.typeOf(astexpr); assertNoFindings(); - Assertions.assertEquals("String", type.printFullName()); + assertEquals("String", type.printFullName()); astexpr = parseExpr("next"); generateScopes(astexpr); astexpr.accept(scopeSetter); type = TypeCheck3.typeOf(astexpr); assertNoFindings(); - Assertions.assertEquals("MySubList.V", type.printFullName()); + assertEquals("MySubList.V", type.printFullName()); astexpr = parseExpr("name"); generateScopes(astexpr); astexpr.accept(scopeSetter); type = TypeCheck3.typeOf(astexpr); assertNoFindings(); - Assertions.assertEquals("String", type.printFullName()); + assertEquals("String", type.printFullName()); astexpr = parseExpr("parameter"); generateScopes(astexpr); astexpr.accept(scopeSetter); type = TypeCheck3.typeOf(astexpr); assertNoFindings(); - Assertions.assertEquals("MySubList.V", type.printFullName()); + assertEquals("MySubList.V", type.printFullName()); astexpr = parseExpr("add(parameter)"); generateScopes(astexpr); astexpr.accept(scopeSetter); type = TypeCheck3.typeOf(astexpr); assertNoFindings(); - Assertions.assertEquals("void", type.printFullName()); + assertEquals("void", type.printFullName()); } public void init_static_example() { diff --git a/monticore-grammar/src/test/java/de/monticore/types3/CommonLiteralsTypeVisitorTest.java b/monticore-grammar/src/test/java/de/monticore/types3/CommonLiteralsTypeVisitorTest.java index 778660dc5b..f06f2559c2 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/CommonLiteralsTypeVisitorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/CommonLiteralsTypeVisitorTest.java @@ -6,13 +6,13 @@ import de.monticore.literals.mcliteralsbasis._ast.ASTLiteral; import de.monticore.types3.util.DefsTypesForTests; import de.monticore.types.check.SymTypeExpression; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import static de.monticore.runtime.junit.MCAssertions.assertNoFindings; +import static org.junit.jupiter.api.Assertions.assertEquals; public class CommonLiteralsTypeVisitorTest extends AbstractTypeVisitorTest { @@ -140,7 +140,7 @@ public void deriveTFromLiteral1BasicDouble() { protected void check(ASTLiteral lit, String expected) { lit.setEnclosingScope(CombineExpressionsWithLiteralsMill.globalScope()); SymTypeExpression type = TypeCheck3.typeOf(lit); - Assertions.assertEquals(expected, type.printFullName()); + assertEquals(expected, type.printFullName()); assertNoFindings(); } diff --git a/monticore-grammar/src/test/java/de/monticore/types3/MCBasicTypesTypeVisitorTest.java b/monticore-grammar/src/test/java/de/monticore/types3/MCBasicTypesTypeVisitorTest.java index a4c3123ed2..a06599f583 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/MCBasicTypesTypeVisitorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/MCBasicTypesTypeVisitorTest.java @@ -5,12 +5,14 @@ import de.monticore.types.mcbasictypes._ast.ASTMCReturnType; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class MCBasicTypesTypeVisitorTest extends AbstractTypeVisitorTest { @@ -44,7 +46,7 @@ public void symTypeFromAST_VoidTest() throws IOException { } else { // if it can be parsed, we expect an error - Assertions.assertTrue(typeOpt.isPresent()); + assertTrue(typeOpt.isPresent()); generateScopes(typeOpt.get()); checkType(typeOpt.get(), "void"); } @@ -54,20 +56,20 @@ public void symTypeFromAST_VoidTest() throws IOException { public void symTypeFromAST_ReturnTest() throws IOException { Optional typeOpt = parser.parse_StringMCReturnType("void"); - Assertions.assertTrue(typeOpt.isPresent()); + assertTrue(typeOpt.isPresent()); SymTypeExpression type = TypeCheck3.symTypeFromAST(typeOpt.get()); - Assertions.assertEquals("void", type.printFullName()); + assertEquals("void", type.printFullName()); } @Test public void symTypeFromAST_ReturnTest2() throws IOException { Optional typeOpt = parser.parse_StringMCReturnType("Person"); - Assertions.assertTrue(typeOpt.isPresent()); - Assertions.assertTrue(typeOpt.get().isPresentMCType()); + assertTrue(typeOpt.isPresent()); + assertTrue(typeOpt.get().isPresentMCType()); generateScopes(typeOpt.get().getMCType()); SymTypeExpression type = TypeCheck3.symTypeFromAST(typeOpt.get()); - Assertions.assertEquals("Person", type.printFullName()); + assertEquals("Person", type.printFullName()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types3/MCCollectionTypesTypeVisitorTest.java b/monticore-grammar/src/test/java/de/monticore/types3/MCCollectionTypesTypeVisitorTest.java index b588f031e4..b81dc4597e 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/MCCollectionTypesTypeVisitorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/MCCollectionTypesTypeVisitorTest.java @@ -10,7 +10,6 @@ import de.monticore.types.check.SymTypeOfGenerics; import de.monticore.types.mcbasictypes._ast.ASTMCType; import de.monticore.types.mccollectiontypes._ast.ASTMCListType; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -19,6 +18,7 @@ import static de.monticore.runtime.junit.MCAssertions.assertNoFindings; import static de.monticore.types3.util.DefsTypesForTests.inScope; import static de.monticore.types3.util.DefsTypesForTests.type; +import static org.junit.jupiter.api.Assertions.*; public class MCCollectionTypesTypeVisitorTest extends AbstractTypeVisitorTest { @@ -50,13 +50,13 @@ public void symTypeFromAST_TestList1() throws IOException { // Then assertNoFindings(); - Assertions.assertEquals(s, result.printFullName()); - Assertions.assertTrue(result instanceof SymTypeOfGenerics); - Assertions.assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0) + assertEquals(s, result.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, result); + assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0) .getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0) + assertFalse(((SymTypeOfGenerics) result).getArgument(0) .getTypeInfo() instanceof OOTypeSymbolSurrogate); } @@ -73,13 +73,13 @@ public void symTypeFromAST_TestSet1() throws IOException { // Then assertNoFindings(); - Assertions.assertEquals(s, result.printFullName()); - Assertions.assertTrue(result instanceof SymTypeOfGenerics); - Assertions.assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0) + assertEquals(s, result.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, result); + assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0) .getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0) + assertFalse(((SymTypeOfGenerics) result).getArgument(0) .getTypeInfo() instanceof OOTypeSymbolSurrogate); } @@ -95,17 +95,17 @@ public void symTypeFromAST_TestMap1() throws IOException { // Then assertNoFindings(); - Assertions.assertEquals(s, result.printFullName()); - Assertions.assertTrue(result instanceof SymTypeOfGenerics); - Assertions.assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0) + assertEquals(s, result.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, result); + assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0) .getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0) + assertFalse(((SymTypeOfGenerics) result).getArgument(0) .getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(1) + assertFalse(((SymTypeOfGenerics) result).getArgument(1) .getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(1) + assertFalse(((SymTypeOfGenerics) result).getArgument(1) .getTypeInfo() instanceof OOTypeSymbolSurrogate); } @@ -121,13 +121,13 @@ public void symTypeFromAST_TestSet2() throws IOException { // Then assertNoFindings(); - Assertions.assertEquals(s, result.printFullName()); - Assertions.assertTrue(result instanceof SymTypeOfGenerics); - Assertions.assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0) + assertEquals(s, result.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, result); + assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0) .getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0) + assertFalse(((SymTypeOfGenerics) result).getArgument(0) .getTypeInfo() instanceof OOTypeSymbolSurrogate); } @@ -143,13 +143,13 @@ public void symTypeFromAST_TestOptional1() throws IOException { // Then assertNoFindings(); - Assertions.assertEquals(s, result.printFullName()); - Assertions.assertTrue(result instanceof SymTypeOfGenerics); - Assertions.assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0) + assertEquals(s, result.printFullName()); + assertInstanceOf(SymTypeOfGenerics.class, result); + assertFalse(result.getTypeInfo() instanceof TypeSymbolSurrogate); + assertFalse(result.getTypeInfo() instanceof OOTypeSymbolSurrogate); + assertFalse(((SymTypeOfGenerics) result).getArgument(0) .getTypeInfo() instanceof TypeSymbolSurrogate); - Assertions.assertFalse(((SymTypeOfGenerics) result).getArgument(0) + assertFalse(((SymTypeOfGenerics) result).getArgument(0) .getTypeInfo() instanceof OOTypeSymbolSurrogate); } diff --git a/monticore-grammar/src/test/java/de/monticore/types3/ResolveTypeIdAsConstructorTest.java b/monticore-grammar/src/test/java/de/monticore/types3/ResolveTypeIdAsConstructorTest.java index 42c8a67e48..e533337965 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/ResolveTypeIdAsConstructorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/ResolveTypeIdAsConstructorTest.java @@ -18,7 +18,6 @@ import de.monticore.types.check.SymTypeOfFunction; import de.monticore.types.check.SymTypeOfIntersection; import de.monticore.types3.util.CombineExpressionsWithLiteralsTypeTraverserFactory; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,6 +33,7 @@ import static de.monticore.types3.util.DefsTypesForTests.oOtype; import static de.monticore.types3.util.DefsTypesForTests.typeVariable; import static de.monticore.types3.util.DefsTypesForTests.variable; +import static org.junit.jupiter.api.Assertions.*; /** * tests whether we can resolve correctly constructors @@ -84,30 +84,30 @@ public void test1() { // do not find the constructor if we find a function SymTypeExpression type = calculateTypeWithinScope("t", oOType.getSpannedScope()); - Assertions.assertEquals("() -> int", type.printFullName()); - Assertions.assertSame(method, ((SymTypeOfFunction) type).getSymbol()); + assertEquals("() -> int", type.printFullName()); + assertSame(method, ((SymTypeOfFunction) type).getSymbol()); // do not find the constructor if we find a function type = calculateTypeWithinScope("t.t", gs); - Assertions.assertEquals("() -> int", type.printFullName()); - Assertions.assertSame(method, ((SymTypeOfFunction) type).getSymbol()); + assertEquals("() -> int", type.printFullName()); + assertSame(method, ((SymTypeOfFunction) type).getSymbol()); // find the constructor based on the type id type = calculateTypeWithinScope("t", gs); - Assertions.assertTrue(type.isIntersectionType()); + assertTrue(type.isIntersectionType()); Collection functions = ((SymTypeOfIntersection) type).getIntersectedTypeSet(); - Assertions.assertTrue(functions.stream().allMatch(f -> f.isFunctionType())); + assertTrue(functions.stream().allMatch(f -> f.isFunctionType())); Collection constructors = functions.stream() .map(f -> (SymTypeOfFunction) f) .collect(Collectors.toSet()); - Assertions.assertEquals(2, constructors.size()); - Assertions.assertTrue(constructors.stream().anyMatch(c -> c.getSymbol() == constructor)); - Assertions.assertTrue(constructors.stream().anyMatch(c -> c.getSymbol() == constructor2)); - Assertions.assertTrue(constructors.stream() + assertEquals(2, constructors.size()); + assertTrue(constructors.stream().anyMatch(c -> c.getSymbol() == constructor)); + assertTrue(constructors.stream().anyMatch(c -> c.getSymbol() == constructor2)); + assertTrue(constructors.stream() .map(SymTypeOfFunction::printFullName) .anyMatch(p -> p.equals("() -> t"))); - Assertions.assertTrue(constructors.stream() + assertTrue(constructors.stream() .map(SymTypeOfFunction::printFullName) .anyMatch(p -> p.equals("t -> t"))); @@ -156,23 +156,23 @@ public void test2() { // find the constructor based on the type id SymTypeExpression type = calculateTypeWithinScope("t", gs); - Assertions.assertTrue(type.isFunctionType()); - Assertions.assertSame(constructor, ((SymTypeOfFunction) type).getSymbol()); + assertTrue(type.isFunctionType()); + assertSame(constructor, ((SymTypeOfFunction) type).getSymbol()); // find the constructor of the inner type, // as the constructor of the outer type is filtered out type = calculateTypeWithinScope("t.t", gs); - Assertions.assertTrue(type.isFunctionType()); - Assertions.assertSame(innerConstructor2, ((SymTypeOfFunction) type).getSymbol()); + assertTrue(type.isFunctionType()); + assertSame(innerConstructor2, ((SymTypeOfFunction) type).getSymbol()); // find the constructor of the inner type, // as the constructor of the outer type is filtered out type = calculateTypeWithinScope("t", oOType.getSpannedScope()); - Assertions.assertTrue(type.isFunctionType()); - Assertions.assertSame(innerConstructor2, ((SymTypeOfFunction) type).getSymbol()); + assertTrue(type.isFunctionType()); + assertSame(innerConstructor2, ((SymTypeOfFunction) type).getSymbol()); type = calculateTypeWithinScope("t", innerOOType.getSpannedScope()); - Assertions.assertEquals("(float -> t.t) & (int -> t.t)", type.printFullName()); + assertEquals("(float -> t.t) & (int -> t.t)", type.printFullName()); assertNoFindings(); } diff --git a/monticore-grammar/src/test/java/de/monticore/types3/ResolveWithinOOTypeTest.java b/monticore-grammar/src/test/java/de/monticore/types3/ResolveWithinOOTypeTest.java index f4ec269698..a75cd9b773 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/ResolveWithinOOTypeTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/ResolveWithinOOTypeTest.java @@ -24,7 +24,6 @@ import de.monticore.types.check.SymTypeOfFunction; import de.monticore.types3.util.CombineExpressionsWithLiteralsTypeTraverserFactory; import de.monticore.types3.util.OOWithinTypeBasicSymbolsResolver; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -40,6 +39,7 @@ import static de.monticore.types3.util.DefsTypesForTests.inScope; import static de.monticore.types3.util.DefsTypesForTests.method; import static de.monticore.types3.util.DefsTypesForTests.oOtype; +import static org.junit.jupiter.api.Assertions.*; /** * tests whether we can resolve correctly constructors within a type. @@ -85,15 +85,15 @@ public void test1() throws IOException { SymTypeExpression type = calculateTypeWithinScope("t", oOType.getSpannedScope()); - Assertions.assertEquals("() -> int", type.printFullName()); - Assertions.assertSame(method, ((SymTypeOfFunction) type).getSymbol()); + assertEquals("() -> int", type.printFullName()); + assertSame(method, ((SymTypeOfFunction) type).getSymbol()); List constructors = calculateConstructorWithinScope( oOType.getSpannedScope(), "t", BasicAccessModifier.PRIVATE ); - Assertions.assertEquals(2, constructors.size()); - Assertions.assertTrue(constructors.contains(constructor)); - Assertions.assertTrue(constructors.contains(constructor2)); + assertEquals(2, constructors.size()); + assertTrue(constructors.contains(constructor)); + assertTrue(constructors.contains(constructor2)); } // class t { @@ -129,15 +129,15 @@ public void test2() throws IOException { List constructors = calculateConstructorWithinScope( oOType.getSpannedScope(), "t", BasicAccessModifier.PRIVATE ); - Assertions.assertEquals(2, constructors.size()); - Assertions.assertTrue(constructors.contains(constructor)); - Assertions.assertTrue(constructors.contains(constructor2)); + assertEquals(2, constructors.size()); + assertTrue(constructors.contains(constructor)); + assertTrue(constructors.contains(constructor2)); constructors = calculateConstructorWithinScope( oOType.getSpannedScope(), "t", BasicAccessModifier.PUBLIC ); - Assertions.assertEquals(1, constructors.size()); - Assertions.assertTrue(constructors.contains(constructor2)); + assertEquals(1, constructors.size()); + assertTrue(constructors.contains(constructor2)); } // test if we get a list of all resolvable elements @@ -194,7 +194,7 @@ public void resolveAllElementsTest() throws IOException { BasicAccessModifier.PUBLIC, t -> true ); - Assertions.assertEquals(Set.of("v", "u"), allTypes.keySet()); + assertEquals(Set.of("v", "u"), allTypes.keySet()); Map> allFunctions = OOWithinTypeBasicSymbolsResolver.getAllFunctions( @@ -203,9 +203,9 @@ public void resolveAllElementsTest() throws IOException { f -> true ); // may not contain constructor - Assertions.assertEquals(Set.of("s", "u"), allFunctions.keySet()); - Assertions.assertEquals(1, allFunctions.get("s").size()); - Assertions.assertEquals(2, allFunctions.get("u").size()); + assertEquals(Set.of("s", "u"), allFunctions.keySet()); + assertEquals(1, allFunctions.get("s").size()); + assertEquals(2, allFunctions.get("u").size()); Map allFields = OOWithinTypeBasicSymbolsResolver.getAllVariables( @@ -214,7 +214,7 @@ public void resolveAllElementsTest() throws IOException { v -> true ); // may not contain the private w - Assertions.assertEquals(Set.of("s", "v"), allFields.keySet()); + assertEquals(Set.of("s", "v"), allFields.keySet()); } // Helper @@ -248,11 +248,11 @@ protected List calculateConstructorWithinScope( scope, name, accessModifier, c -> true ); assertNoFindings(); - Assertions.assertTrue(functions.stream().allMatch(f -> f instanceof MethodSymbol)); + assertTrue(functions.stream().allMatch(f -> f instanceof MethodSymbol)); List constructors = functions.stream() .map(f -> (MethodSymbol) f) .collect(Collectors.toList()); - Assertions.assertTrue(constructors.stream().allMatch(MethodSymbolTOP::isIsConstructor)); + assertTrue(constructors.stream().allMatch(MethodSymbolTOP::isIsConstructor)); return constructors; } diff --git a/monticore-grammar/src/test/java/de/monticore/types3/ResolveWithinTypeTest.java b/monticore-grammar/src/test/java/de/monticore/types3/ResolveWithinTypeTest.java index cefbd97f0f..9636af7027 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/ResolveWithinTypeTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/ResolveWithinTypeTest.java @@ -24,7 +24,6 @@ import de.monticore.types.mcbasictypes._visitor.MCBasicTypesTraverser; import de.monticore.types.mcbasictypes._visitor.MCBasicTypesVisitor2; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,6 +38,7 @@ import static de.monticore.types3.util.DefsTypesForTests.oOtype; import static de.monticore.types3.util.DefsTypesForTests.typeVariable; import static de.monticore.types3.util.DefsTypesForTests.variable; +import static org.junit.jupiter.api.Assertions.*; /** * tests whether we can resolve correctly within a type. @@ -78,21 +78,21 @@ public void test1() throws IOException { SymTypeExpression type = calculateTypeWithinScope("t", oOType.getSpannedScope()); - Assertions.assertEquals("(() -> t) & t", type.printFullName()); - Assertions.assertTrue(type.isIntersectionType()); - Assertions.assertTrue(((SymTypeOfIntersection) type).getIntersectedTypeSet() + assertEquals("(() -> t) & t", type.printFullName()); + assertTrue(type.isIntersectionType()); + assertTrue(((SymTypeOfIntersection) type).getIntersectedTypeSet() .stream() .anyMatch(t -> t.hasTypeInfo() && t.getTypeInfo() == oOType)); type = calculateTypeWithinScope("t()", oOType.getSpannedScope()); assertNoFindings(); - Assertions.assertEquals("t", type.printFullName()); - Assertions.assertSame(type.getTypeInfo(), oOType); + assertEquals("t", type.printFullName()); + assertSame(type.getTypeInfo(), oOType); type = calculateTypeWithinScope("t", method.getSpannedScope()); - Assertions.assertEquals("(() -> t) & t", type.printFullName()); - Assertions.assertTrue(type.isIntersectionType()); - Assertions.assertTrue(((SymTypeOfIntersection) type).getIntersectedTypeSet() + assertEquals("(() -> t) & t", type.printFullName()); + assertTrue(type.isIntersectionType()); + assertTrue(((SymTypeOfIntersection) type).getIntersectedTypeSet() .stream() .anyMatch(t -> t.hasTypeInfo() && t.getTypeInfo() == oOType)); } @@ -200,20 +200,20 @@ public void test4() throws IOException { SymTypeExpression type = calculateTypeWithinScope("t", oOType.getSpannedScope()); - Assertions.assertEquals("(() -> s.t) & s.t", type.printFullName()); - Assertions.assertTrue(type.isIntersectionType()); - Assertions.assertTrue(((SymTypeOfIntersection) type).getIntersectedTypeSet() + assertEquals("(() -> s.t) & s.t", type.printFullName()); + assertTrue(type.isIntersectionType()); + assertTrue(((SymTypeOfIntersection) type).getIntersectedTypeSet() .stream() .anyMatch(t -> t.hasTypeInfo() && t.getTypeInfo() == oOType1)); type = calculateTypeWithinScope("t()", oOType.getSpannedScope()); - Assertions.assertEquals("s.t", type.printFullName()); - Assertions.assertSame(type.getTypeInfo(), oOType1); + assertEquals("s.t", type.printFullName()); + assertSame(type.getTypeInfo(), oOType1); type = calculateTypeWithinScope("t", method.getSpannedScope()); - Assertions.assertEquals("(() -> s.t) & s.t", type.printFullName()); - Assertions.assertTrue(type.isIntersectionType()); - Assertions.assertTrue(((SymTypeOfIntersection) type).getIntersectedTypeSet() + assertEquals("(() -> s.t) & s.t", type.printFullName()); + assertTrue(type.isIntersectionType()); + assertTrue(((SymTypeOfIntersection) type).getIntersectedTypeSet() .stream() .anyMatch(t -> t.hasTypeInfo() && t.getTypeInfo() == oOType1)); } @@ -245,8 +245,8 @@ public void test5() throws IOException { SymTypeExpression type = calculateTypeWithinScope("t", oOType1.getSpannedScope()); - Assertions.assertEquals("t", type.printFullName()); - Assertions.assertSame(oOType, type.getTypeInfo()); + assertEquals("t", type.printFullName()); + assertSame(oOType, type.getTypeInfo()); } // class t {} @@ -280,8 +280,8 @@ public void test6() throws IOException { SymTypeExpression type = calculateTypeWithinScope("t", oOType2.getSpannedScope()); - Assertions.assertEquals("t", type.printFullName()); - Assertions.assertSame(type.getTypeInfo(), oOType); + assertEquals("t", type.printFullName()); + assertSame(type.getTypeInfo(), oOType); } // class t { diff --git a/monticore-grammar/src/test/java/de/monticore/types3/SIUnitTypes4MathTypeVisitorTest.java b/monticore-grammar/src/test/java/de/monticore/types3/SIUnitTypes4MathTypeVisitorTest.java index 6a78b9a6ef..0304dd4f70 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/SIUnitTypes4MathTypeVisitorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/SIUnitTypes4MathTypeVisitorTest.java @@ -3,7 +3,6 @@ import de.monticore.types.check.SymTypeExpression; import de.monticore.types.mcbasictypes._ast.ASTMCType; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -15,6 +14,7 @@ import static de.monticore.types3.util.SIUnitIteratorForTests.get2UnitsGroup; import static de.monticore.types3.util.SIUnitIteratorForTests.getPrefixedUnits; import static de.monticore.types3.util.SIUnitIteratorForTests.getUnits; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SIUnitTypes4MathTypeVisitorTest extends AbstractTypeVisitorTest { @@ -65,7 +65,7 @@ public void synTFromSIUnitTypes4MathAmbiguousUnitsGroups() throws IOException { // But, if the amount decreases, issues have been fixed // and this number can be decreased. // This number should never increase, as it would indicate a new bug. - Assertions.assertEquals(609, ambiguous.size()); + assertEquals(609, ambiguous.size()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types3/SymTypeBoxingVisitorTest.java b/monticore-grammar/src/test/java/de/monticore/types3/SymTypeBoxingVisitorTest.java index 231e1c93e9..37f38bbe02 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/SymTypeBoxingVisitorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/SymTypeBoxingVisitorTest.java @@ -10,7 +10,6 @@ import de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol; import de.monticore.types.check.SymTypeExpression; import de.monticore.types3.util.SymTypeBoxingVisitor; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -23,6 +22,7 @@ import static de.monticore.types.check.SymTypeExpressionFactory.createTypeObject; import static de.monticore.types.check.SymTypeExpressionFactory.createTypeVariable; import static de.monticore.types.check.SymTypeExpressionFactory.createUnion; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SymTypeBoxingVisitorTest extends AbstractMCTest { @@ -111,7 +111,7 @@ public void boxComplexTypes() { public void check(SymTypeExpression unboxed, String expectedBoxedName) { SymTypeExpression boxed = visitor.calculate(unboxed); assertNoFindings(); - Assertions.assertEquals(expectedBoxedName, boxed.printFullName()); + assertEquals(expectedBoxedName, boxed.printFullName()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types3/SymTypeCompatibilityTest.java b/monticore-grammar/src/test/java/de/monticore/types3/SymTypeCompatibilityTest.java index 3065fad1cc..ae29fcf779 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/SymTypeCompatibilityTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/SymTypeCompatibilityTest.java @@ -20,7 +20,6 @@ import de.monticore.types.check.SymTypeOfObject; import de.monticore.types.check.SymTypeOfRegEx; import de.monticore.types.check.SymTypeVariable; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -40,6 +39,8 @@ import static de.monticore.types.check.SymTypeExpressionFactory.createTypeVariable; import static de.monticore.types.check.SymTypeExpressionFactory.createUnion; import static de.monticore.types.check.SymTypeExpressionFactory.createWildcard; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SymTypeCompatibilityTest extends AbstractMCTest { @@ -55,208 +56,208 @@ public void init() { @Test public void isCompatiblePrimitives() { - Assertions.assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _doubleSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _floatSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _longSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _charSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _shortSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _byteSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_booleanSymType, _booleanSymType)); - - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _doubleSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _floatSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _longSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _intSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _charSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _shortSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_doubleSymType, _booleanSymType)); - - Assertions.assertFalse(SymTypeRelations.isCompatible(_floatSymType, _doubleSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, _floatSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, _longSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, _intSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, _charSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, _shortSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_floatSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_floatSymType, _booleanSymType)); - - Assertions.assertFalse(SymTypeRelations.isCompatible(_longSymType, _doubleSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_longSymType, _floatSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, _longSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, _intSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, _charSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, _shortSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_longSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_longSymType, _booleanSymType)); - - Assertions.assertFalse(SymTypeRelations.isCompatible(_intSymType, _doubleSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_intSymType, _floatSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_intSymType, _longSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, _intSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, _charSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, _shortSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_intSymType, _booleanSymType)); - - Assertions.assertFalse(SymTypeRelations.isCompatible(_charSymType, _doubleSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_charSymType, _floatSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_charSymType, _longSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_charSymType, _intSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_charSymType, _charSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_charSymType, _shortSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_charSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_charSymType, _booleanSymType)); - - Assertions.assertFalse(SymTypeRelations.isCompatible(_shortSymType, _doubleSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_shortSymType, _floatSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_shortSymType, _longSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_shortSymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_shortSymType, _charSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_shortSymType, _shortSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_shortSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_shortSymType, _booleanSymType)); - - Assertions.assertFalse(SymTypeRelations.isCompatible(_byteSymType, _doubleSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_byteSymType, _floatSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_byteSymType, _longSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_byteSymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_byteSymType, _charSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_byteSymType, _shortSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_byteSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_byteSymType, _booleanSymType)); - - Assertions.assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _personSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_booleanSymType, _BooleanSymType)); + assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _doubleSymType)); + assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _floatSymType)); + assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _longSymType)); + assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _intSymType)); + assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _charSymType)); + assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _shortSymType)); + assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _byteSymType)); + assertTrue(SymTypeRelations.isCompatible(_booleanSymType, _booleanSymType)); + + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _doubleSymType)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _floatSymType)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _longSymType)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _intSymType)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _charSymType)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _shortSymType)); + assertTrue(SymTypeRelations.isCompatible(_doubleSymType, _byteSymType)); + assertFalse(SymTypeRelations.isCompatible(_doubleSymType, _booleanSymType)); + + assertFalse(SymTypeRelations.isCompatible(_floatSymType, _doubleSymType)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, _floatSymType)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, _longSymType)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, _intSymType)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, _charSymType)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, _shortSymType)); + assertTrue(SymTypeRelations.isCompatible(_floatSymType, _byteSymType)); + assertFalse(SymTypeRelations.isCompatible(_floatSymType, _booleanSymType)); + + assertFalse(SymTypeRelations.isCompatible(_longSymType, _doubleSymType)); + assertFalse(SymTypeRelations.isCompatible(_longSymType, _floatSymType)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, _longSymType)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, _intSymType)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, _charSymType)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, _shortSymType)); + assertTrue(SymTypeRelations.isCompatible(_longSymType, _byteSymType)); + assertFalse(SymTypeRelations.isCompatible(_longSymType, _booleanSymType)); + + assertFalse(SymTypeRelations.isCompatible(_intSymType, _doubleSymType)); + assertFalse(SymTypeRelations.isCompatible(_intSymType, _floatSymType)); + assertFalse(SymTypeRelations.isCompatible(_intSymType, _longSymType)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, _intSymType)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, _charSymType)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, _shortSymType)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, _byteSymType)); + assertFalse(SymTypeRelations.isCompatible(_intSymType, _booleanSymType)); + + assertFalse(SymTypeRelations.isCompatible(_charSymType, _doubleSymType)); + assertFalse(SymTypeRelations.isCompatible(_charSymType, _floatSymType)); + assertFalse(SymTypeRelations.isCompatible(_charSymType, _longSymType)); + assertFalse(SymTypeRelations.isCompatible(_charSymType, _intSymType)); + assertTrue(SymTypeRelations.isCompatible(_charSymType, _charSymType)); + assertFalse(SymTypeRelations.isCompatible(_charSymType, _shortSymType)); + assertFalse(SymTypeRelations.isCompatible(_charSymType, _byteSymType)); + assertFalse(SymTypeRelations.isCompatible(_charSymType, _booleanSymType)); + + assertFalse(SymTypeRelations.isCompatible(_shortSymType, _doubleSymType)); + assertFalse(SymTypeRelations.isCompatible(_shortSymType, _floatSymType)); + assertFalse(SymTypeRelations.isCompatible(_shortSymType, _longSymType)); + assertFalse(SymTypeRelations.isCompatible(_shortSymType, _intSymType)); + assertFalse(SymTypeRelations.isCompatible(_shortSymType, _charSymType)); + assertTrue(SymTypeRelations.isCompatible(_shortSymType, _shortSymType)); + assertTrue(SymTypeRelations.isCompatible(_shortSymType, _byteSymType)); + assertFalse(SymTypeRelations.isCompatible(_shortSymType, _booleanSymType)); + + assertFalse(SymTypeRelations.isCompatible(_byteSymType, _doubleSymType)); + assertFalse(SymTypeRelations.isCompatible(_byteSymType, _floatSymType)); + assertFalse(SymTypeRelations.isCompatible(_byteSymType, _longSymType)); + assertFalse(SymTypeRelations.isCompatible(_byteSymType, _intSymType)); + assertFalse(SymTypeRelations.isCompatible(_byteSymType, _charSymType)); + assertFalse(SymTypeRelations.isCompatible(_byteSymType, _shortSymType)); + assertTrue(SymTypeRelations.isCompatible(_byteSymType, _byteSymType)); + assertFalse(SymTypeRelations.isCompatible(_byteSymType, _booleanSymType)); + + assertFalse(SymTypeRelations.isCompatible(_booleanSymType, _personSymType)); + assertTrue(SymTypeRelations.isCompatible(_booleanSymType, _BooleanSymType)); } @Test public void isSubTypePrimitives() { - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _doubleSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _floatSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _longSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _charSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _shortSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _byteSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_booleanSymType, _booleanSymType)); - - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_doubleSymType, _doubleSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _floatSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _longSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _charSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _shortSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _booleanSymType)); - - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_floatSymType, _doubleSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_floatSymType, _floatSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _longSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _charSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _shortSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _booleanSymType)); - - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_longSymType, _doubleSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_longSymType, _floatSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_longSymType, _longSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_longSymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_longSymType, _charSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_longSymType, _shortSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_longSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_longSymType, _booleanSymType)); - - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_intSymType, _doubleSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_intSymType, _floatSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_intSymType, _longSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_intSymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_intSymType, _charSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_intSymType, _shortSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_intSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_intSymType, _booleanSymType)); - - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_charSymType, _doubleSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_charSymType, _floatSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_charSymType, _longSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_charSymType, _intSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_charSymType, _charSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_charSymType, _shortSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_charSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_charSymType, _booleanSymType)); - - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_shortSymType, _doubleSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_shortSymType, _floatSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_shortSymType, _longSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_shortSymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_shortSymType, _charSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_shortSymType, _shortSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_shortSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_shortSymType, _booleanSymType)); - - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _doubleSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _floatSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _longSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_byteSymType, _charSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _shortSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _byteSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_byteSymType, _booleanSymType)); - - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _personSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _BooleanSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _doubleSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _floatSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _longSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _intSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _charSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _shortSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _byteSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_booleanSymType, _booleanSymType)); + + assertTrue(SymTypeRelations.isSubTypeOf(_doubleSymType, _doubleSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _floatSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _longSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _intSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _charSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _shortSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _byteSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_doubleSymType, _booleanSymType)); + + assertTrue(SymTypeRelations.isSubTypeOf(_floatSymType, _doubleSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_floatSymType, _floatSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _longSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _intSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _charSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _shortSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _byteSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_floatSymType, _booleanSymType)); + + assertTrue(SymTypeRelations.isSubTypeOf(_longSymType, _doubleSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_longSymType, _floatSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_longSymType, _longSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_longSymType, _intSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_longSymType, _charSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_longSymType, _shortSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_longSymType, _byteSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_longSymType, _booleanSymType)); + + assertTrue(SymTypeRelations.isSubTypeOf(_intSymType, _doubleSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_intSymType, _floatSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_intSymType, _longSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_intSymType, _intSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_intSymType, _charSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_intSymType, _shortSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_intSymType, _byteSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_intSymType, _booleanSymType)); + + assertTrue(SymTypeRelations.isSubTypeOf(_charSymType, _doubleSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_charSymType, _floatSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_charSymType, _longSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_charSymType, _intSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_charSymType, _charSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_charSymType, _shortSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_charSymType, _byteSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_charSymType, _booleanSymType)); + + assertTrue(SymTypeRelations.isSubTypeOf(_shortSymType, _doubleSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_shortSymType, _floatSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_shortSymType, _longSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_shortSymType, _intSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_shortSymType, _charSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_shortSymType, _shortSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_shortSymType, _byteSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_shortSymType, _booleanSymType)); + + assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _doubleSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _floatSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _longSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _intSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_byteSymType, _charSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _shortSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_byteSymType, _byteSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_byteSymType, _booleanSymType)); + + assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _personSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _BooleanSymType)); } @Test public void isCompatibleObjects() { - Assertions.assertTrue(SymTypeRelations.isCompatible(_personSymType, _personSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_personSymType, _studentSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_personSymType, _csStudentSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_personSymType, _teacherSymType)); - - Assertions.assertFalse(SymTypeRelations.isCompatible(_studentSymType, _personSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_studentSymType, _studentSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_studentSymType, _csStudentSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_studentSymType, _teacherSymType)); - - Assertions.assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, _personSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, _studentSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_csStudentSymType, _csStudentSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, _teacherSymType)); - - Assertions.assertFalse(SymTypeRelations.isCompatible(_teacherSymType, _personSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_teacherSymType, _studentSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_teacherSymType, _csStudentSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_teacherSymType, _teacherSymType)); + assertTrue(SymTypeRelations.isCompatible(_personSymType, _personSymType)); + assertTrue(SymTypeRelations.isCompatible(_personSymType, _studentSymType)); + assertTrue(SymTypeRelations.isCompatible(_personSymType, _csStudentSymType)); + assertTrue(SymTypeRelations.isCompatible(_personSymType, _teacherSymType)); + + assertFalse(SymTypeRelations.isCompatible(_studentSymType, _personSymType)); + assertTrue(SymTypeRelations.isCompatible(_studentSymType, _studentSymType)); + assertTrue(SymTypeRelations.isCompatible(_studentSymType, _csStudentSymType)); + assertFalse(SymTypeRelations.isCompatible(_studentSymType, _teacherSymType)); + + assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, _personSymType)); + assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, _studentSymType)); + assertTrue(SymTypeRelations.isCompatible(_csStudentSymType, _csStudentSymType)); + assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, _teacherSymType)); + + assertFalse(SymTypeRelations.isCompatible(_teacherSymType, _personSymType)); + assertFalse(SymTypeRelations.isCompatible(_teacherSymType, _studentSymType)); + assertFalse(SymTypeRelations.isCompatible(_teacherSymType, _csStudentSymType)); + assertTrue(SymTypeRelations.isCompatible(_teacherSymType, _teacherSymType)); // String - Assertions.assertTrue(SymTypeRelations.isCompatible(_boxedString, _boxedString)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_boxedString, _unboxedString)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_unboxedString, _boxedString)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_unboxedString, _unboxedString)); + assertTrue(SymTypeRelations.isCompatible(_boxedString, _boxedString)); + assertTrue(SymTypeRelations.isCompatible(_boxedString, _unboxedString)); + assertTrue(SymTypeRelations.isCompatible(_unboxedString, _boxedString)); + assertTrue(SymTypeRelations.isCompatible(_unboxedString, _unboxedString)); // diverse types - Assertions.assertFalse(SymTypeRelations.isCompatible(_personSymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible(_personSymType, _intSymType)); + assertFalse(SymTypeRelations.isCompatible( _personSymType, createTypeArray(_personSymType, 1))); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( _personSymType, createTypeArray(_personSymType, 0))); - Assertions.assertFalse(SymTypeRelations.isCompatible(_personSymType, _unboxedMapSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_personSymType, _BooleanSymType)); + assertFalse(SymTypeRelations.isCompatible(_personSymType, _unboxedMapSymType)); + assertFalse(SymTypeRelations.isCompatible(_personSymType, _BooleanSymType)); } @Test public void isCompatibleRegEx() { SymTypeOfRegEx regEx1 = createTypeRegEx("gr(a|e)y"); SymTypeOfRegEx regEx2 = createTypeRegEx("gr(e|a)y"); - Assertions.assertTrue(SymTypeRelations.isCompatible(regEx1, regEx1)); - Assertions.assertTrue(SymTypeRelations.isCompatible(regEx2, regEx1)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_unboxedString, regEx1)); - Assertions.assertTrue(SymTypeRelations.isCompatible(regEx1, _unboxedString)); + assertTrue(SymTypeRelations.isCompatible(regEx1, regEx1)); + assertTrue(SymTypeRelations.isCompatible(regEx2, regEx1)); + assertTrue(SymTypeRelations.isCompatible(_unboxedString, regEx1)); + assertTrue(SymTypeRelations.isCompatible(regEx1, _unboxedString)); } @Test @@ -265,10 +266,10 @@ public void isCompatibleRegExOnlyJavaLangString() { BasicSymbolsMill.globalScope().remove(_unboxedString.getTypeInfo()); SymTypeOfRegEx regEx1 = createTypeRegEx("gr(a|e)y"); SymTypeOfRegEx regEx2 = createTypeRegEx("gr(e|a)y"); - Assertions.assertTrue(SymTypeRelations.isCompatible(regEx1, regEx1)); - Assertions.assertTrue(SymTypeRelations.isCompatible(regEx2, regEx1)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_boxedString, regEx1)); - Assertions.assertTrue(SymTypeRelations.isCompatible(regEx1, _boxedString)); + assertTrue(SymTypeRelations.isCompatible(regEx1, regEx1)); + assertTrue(SymTypeRelations.isCompatible(regEx2, regEx1)); + assertTrue(SymTypeRelations.isCompatible(_boxedString, regEx1)); + assertTrue(SymTypeRelations.isCompatible(regEx1, _boxedString)); } @Test @@ -277,7 +278,7 @@ public void isCompatibleRegExToStringSuperTypes() { // just to test if String supertypes are taken care of for RegEx _unboxedString.getTypeInfo().addSuperTypes(_personSymType); SymTypeOfRegEx regEx1 = createTypeRegEx("gr(a|e)y"); - Assertions.assertTrue(SymTypeRelations.isCompatible(_personSymType, regEx1)); + assertTrue(SymTypeRelations.isCompatible(_personSymType, regEx1)); } @Test @@ -298,17 +299,17 @@ public void isCompatibleGenerics() { SymTypeOfGenerics linkedListOfPerson = createGenerics(_linkedListSymType.getTypeInfo(), _personSymType); - Assertions.assertTrue(SymTypeRelations.isCompatible(listOfPerson, listOfPerson)); - Assertions.assertTrue(SymTypeRelations.isCompatible(listOfPerson, subPersonList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(listOfPerson, linkedListOfPerson)); - - Assertions.assertFalse(SymTypeRelations.isCompatible(listOfInt, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(listOfInt, listOfBoolean)); - Assertions.assertFalse(SymTypeRelations.isCompatible(listOfBoolean, listOfInt)); - Assertions.assertFalse(SymTypeRelations.isCompatible(listOfBoolean, listOfPerson)); - Assertions.assertFalse(SymTypeRelations.isCompatible(listOfPerson, listOfBoolean)); - Assertions.assertFalse(SymTypeRelations.isCompatible(listOfBoolean, subPersonList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(subPersonList, listOfPerson)); + assertTrue(SymTypeRelations.isCompatible(listOfPerson, listOfPerson)); + assertTrue(SymTypeRelations.isCompatible(listOfPerson, subPersonList)); + assertTrue(SymTypeRelations.isCompatible(listOfPerson, linkedListOfPerson)); + + assertFalse(SymTypeRelations.isCompatible(listOfInt, _intSymType)); + assertFalse(SymTypeRelations.isCompatible(listOfInt, listOfBoolean)); + assertFalse(SymTypeRelations.isCompatible(listOfBoolean, listOfInt)); + assertFalse(SymTypeRelations.isCompatible(listOfBoolean, listOfPerson)); + assertFalse(SymTypeRelations.isCompatible(listOfPerson, listOfBoolean)); + assertFalse(SymTypeRelations.isCompatible(listOfBoolean, subPersonList)); + assertFalse(SymTypeRelations.isCompatible(subPersonList, listOfPerson)); } @Test @@ -325,75 +326,75 @@ public void isSubTypeGenericsDoNotIgnoreTypeArguments() { SymTypeOfGenerics sIHashMap = createGenerics( _hashMapSymType.getTypeInfo(), _boxedString, _IntegerSymType); - Assertions.assertTrue(SymTypeRelations.isCompatible(iSMap, iSHashMap)); - Assertions.assertFalse(SymTypeRelations.isCompatible(iSMap, sIHashMap)); + assertTrue(SymTypeRelations.isCompatible(iSMap, iSHashMap)); + assertFalse(SymTypeRelations.isCompatible(iSMap, sIHashMap)); } @Test public void isCompatibleUnions() { - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createUnion(_personSymType, _carSymType), _personSymType )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createUnion(_personSymType, _carSymType), createUnion(_personSymType, _carSymType) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( _personSymType, createUnion(_studentSymType, _teacherSymType) )); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible( _personSymType, createUnion(_studentSymType, _carSymType) )); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible( createUnion(_studentSymType, _teacherSymType), _personSymType )); } @Test public void IsCompatibleIntersections() { - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createIntersection(_personSymType, _carSymType), createIntersection(_personSymType, _carSymType) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( _personSymType, createIntersection(_studentSymType, _teacherSymType) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( _personSymType, createIntersection(_personSymType, _carSymType) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createIntersection(_teachableSymType, _personSymType), createUnion(_childSymType, _studentSymType) )); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible( createIntersection(_personSymType, _carSymType), _personSymType )); } @Test public void isCompatibleTuples() { - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createTuple(_personSymType, _intSymType), createTuple(_personSymType, _intSymType) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createTuple(_personSymType, _intSymType), createTuple(_studentSymType, _intSymType) )); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible( createTuple(_studentSymType, _intSymType), createTuple(_personSymType, _intSymType) )); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible( createTuple(_carSymType, _intSymType), createTuple(_personSymType, _intSymType) )); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible( createTuple(_personSymType, _intSymType), createTuple(_personSymType, _intSymType, _intSymType) )); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible( createTuple(_personSymType, _intSymType, _intSymType), createTuple(_personSymType, _intSymType) )); @@ -401,49 +402,49 @@ public void isCompatibleTuples() { @Test public void isCompatibleFunctions() { - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createFunction(_personSymType), createFunction(_personSymType) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createFunction(_personSymType, _intSymType), createFunction(_personSymType, _intSymType) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createFunction(_personSymType, List.of(_intSymType), true), createFunction(_personSymType, List.of(_intSymType), true) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createFunction(_personSymType, _intSymType), createFunction(_studentSymType, _intSymType) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createFunction(_personSymType, _intSymType), createFunction(_personSymType, _longSymType) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createFunction(_personSymType, _intSymType), createFunction(_personSymType, List.of(_longSymType), true) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createFunction(_personSymType, _intSymType, _intSymType), createFunction(_personSymType, List.of(_intSymType), true) )); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible( createFunction(_personSymType), createFunction(_personSymType, List.of(_intSymType), true) )); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible( createFunction(_personSymType), createFunction(_carSymType) )); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible( createFunction(_studentSymType, _intSymType), createFunction(_personSymType, _intSymType) )); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible( createFunction(_personSymType, _longSymType), createFunction(_personSymType, _intSymType) )); - Assertions.assertFalse(SymTypeRelations.isCompatible( + assertFalse(SymTypeRelations.isCompatible( createFunction(_personSymType, List.of(_intSymType), true), createFunction(_personSymType, _intSymType) )); @@ -451,8 +452,8 @@ public void isCompatibleFunctions() { @Test public void isCompatibleNumericsAndSIUnits() { - Assertions.assertFalse(SymTypeRelations.isCompatible(_s_SISymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_intSymType, _s_SISymType)); + assertFalse(SymTypeRelations.isCompatible(_s_SISymType, _intSymType)); + assertFalse(SymTypeRelations.isCompatible(_intSymType, _s_SISymType)); // TBD: SIUnit of dimension one } @@ -460,12 +461,12 @@ public void isCompatibleNumericsAndSIUnits() { public void isCompatibleNumericsAndNumericsWithSIUnits() { SymTypeOfNumericWithSIUnit deg_float_SISymType = createNumericWithSIUnit(_deg_SISymType, _floatSymType); - Assertions.assertFalse(SymTypeRelations.isCompatible(_s_int_SISymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_intSymType, _s_int_SISymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_deg_int_SISymType, _intSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_intSymType, _deg_int_SISymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(deg_float_SISymType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_intSymType, deg_float_SISymType)); + assertFalse(SymTypeRelations.isCompatible(_s_int_SISymType, _intSymType)); + assertFalse(SymTypeRelations.isCompatible(_intSymType, _s_int_SISymType)); + assertTrue(SymTypeRelations.isCompatible(_deg_int_SISymType, _intSymType)); + assertTrue(SymTypeRelations.isCompatible(_intSymType, _deg_int_SISymType)); + assertTrue(SymTypeRelations.isCompatible(deg_float_SISymType, _intSymType)); + assertFalse(SymTypeRelations.isCompatible(_intSymType, deg_float_SISymType)); } @Test @@ -475,80 +476,80 @@ public void isCompatibleNumericWithSIUnits() { SymTypeOfNumericWithSIUnit deg_float_SISymType = createNumericWithSIUnit(_deg_SISymType, _floatSymType); - Assertions.assertTrue(SymTypeRelations.isCompatible(_s_int_SISymType, _s_int_SISymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_Ohm_int_SISymType, _Ohm_int_SISymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_s_int_SISymType, _A_int_SISymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_A_int_SISymType, _s_int_SISymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_deg_int_SISymType, _rad_int_SISymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_rad_int_SISymType, _deg_int_SISymType)); - - Assertions.assertTrue(SymTypeRelations.isCompatible(s_float_SISymType, _s_int_SISymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_s_int_SISymType, s_float_SISymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(deg_float_SISymType, _rad_int_SISymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_rad_int_SISymType, deg_float_SISymType)); + assertTrue(SymTypeRelations.isCompatible(_s_int_SISymType, _s_int_SISymType)); + assertTrue(SymTypeRelations.isCompatible(_Ohm_int_SISymType, _Ohm_int_SISymType)); + assertFalse(SymTypeRelations.isCompatible(_s_int_SISymType, _A_int_SISymType)); + assertFalse(SymTypeRelations.isCompatible(_A_int_SISymType, _s_int_SISymType)); + assertTrue(SymTypeRelations.isCompatible(_deg_int_SISymType, _rad_int_SISymType)); + assertTrue(SymTypeRelations.isCompatible(_rad_int_SISymType, _deg_int_SISymType)); + + assertTrue(SymTypeRelations.isCompatible(s_float_SISymType, _s_int_SISymType)); + assertFalse(SymTypeRelations.isCompatible(_s_int_SISymType, s_float_SISymType)); + assertTrue(SymTypeRelations.isCompatible(deg_float_SISymType, _rad_int_SISymType)); + assertFalse(SymTypeRelations.isCompatible(_rad_int_SISymType, deg_float_SISymType)); } @Test public void isCompatibleSIUnits() { - Assertions.assertTrue(SymTypeRelations.isCompatible(_s_SISymType, _s_SISymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_Ohm_SISymType, _Ohm_SISymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_s_SISymType, _A_SISymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_A_SISymType, _s_SISymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_deg_SISymType, _rad_SISymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_rad_SISymType, _deg_SISymType)); + assertTrue(SymTypeRelations.isCompatible(_s_SISymType, _s_SISymType)); + assertTrue(SymTypeRelations.isCompatible(_Ohm_SISymType, _Ohm_SISymType)); + assertFalse(SymTypeRelations.isCompatible(_s_SISymType, _A_SISymType)); + assertFalse(SymTypeRelations.isCompatible(_A_SISymType, _s_SISymType)); + assertTrue(SymTypeRelations.isCompatible(_deg_SISymType, _rad_SISymType)); + assertTrue(SymTypeRelations.isCompatible(_rad_SISymType, _deg_SISymType)); // cannot combine SIUnits with NumericWithSIUnits - Assertions.assertFalse(SymTypeRelations.isCompatible(_s_SISymType, _s_int_SISymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_s_int_SISymType, _s_SISymType)); + assertFalse(SymTypeRelations.isCompatible(_s_SISymType, _s_int_SISymType)); + assertFalse(SymTypeRelations.isCompatible(_s_int_SISymType, _s_SISymType)); } @Test public void isSubTypeBottom() { // bottom is subType of EVERY other type - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _bottomType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _topType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _intSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _booleanSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _IntegerSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _personSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _nullSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _unboxedListSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _unboxedListSymType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _linkedListSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _bottomType)); + assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _topType)); + assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _intSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _booleanSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _IntegerSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _personSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _nullSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _unboxedListSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _unboxedListSymType)); + assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _linkedListSymType)); // bottom is never the superType except for bottom itself - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_topType, _bottomType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_intSymType, _bottomType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _bottomType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_IntegerSymType, _bottomType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_personSymType, _bottomType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_nullSymType, _bottomType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_unboxedListSymType, _bottomType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_unboxedListSymType, _bottomType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_linkedListSymType, _bottomType)); + assertFalse(SymTypeRelations.isSubTypeOf(_topType, _bottomType)); + assertFalse(SymTypeRelations.isSubTypeOf(_intSymType, _bottomType)); + assertFalse(SymTypeRelations.isSubTypeOf(_booleanSymType, _bottomType)); + assertFalse(SymTypeRelations.isSubTypeOf(_IntegerSymType, _bottomType)); + assertFalse(SymTypeRelations.isSubTypeOf(_personSymType, _bottomType)); + assertFalse(SymTypeRelations.isSubTypeOf(_nullSymType, _bottomType)); + assertFalse(SymTypeRelations.isSubTypeOf(_unboxedListSymType, _bottomType)); + assertFalse(SymTypeRelations.isSubTypeOf(_unboxedListSymType, _bottomType)); + assertFalse(SymTypeRelations.isSubTypeOf(_linkedListSymType, _bottomType)); } @Test public void isSubTypeTop() { // top is superType of EVERY other type - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _topType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_topType, _topType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_intSymType, _topType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_booleanSymType, _topType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_IntegerSymType, _topType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_personSymType, _topType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_nullSymType, _topType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_unboxedListSymType, _topType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_unboxedListSymType, _topType)); - Assertions.assertTrue(SymTypeRelations.isSubTypeOf(_linkedListSymType, _topType)); + assertTrue(SymTypeRelations.isSubTypeOf(_bottomType, _topType)); + assertTrue(SymTypeRelations.isSubTypeOf(_topType, _topType)); + assertTrue(SymTypeRelations.isSubTypeOf(_intSymType, _topType)); + assertTrue(SymTypeRelations.isSubTypeOf(_booleanSymType, _topType)); + assertTrue(SymTypeRelations.isSubTypeOf(_IntegerSymType, _topType)); + assertTrue(SymTypeRelations.isSubTypeOf(_personSymType, _topType)); + assertTrue(SymTypeRelations.isSubTypeOf(_nullSymType, _topType)); + assertTrue(SymTypeRelations.isSubTypeOf(_unboxedListSymType, _topType)); + assertTrue(SymTypeRelations.isSubTypeOf(_unboxedListSymType, _topType)); + assertTrue(SymTypeRelations.isSubTypeOf(_linkedListSymType, _topType)); // top is never the subType except for top itself - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_topType, _bottomType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_topType, _intSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_topType, _booleanSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_topType, _IntegerSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_topType, _personSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_topType, _nullSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_topType, _unboxedListSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_topType, _unboxedListSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_topType, _linkedListSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_topType, _bottomType)); + assertFalse(SymTypeRelations.isSubTypeOf(_topType, _intSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_topType, _booleanSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_topType, _IntegerSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_topType, _personSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_topType, _nullSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_topType, _unboxedListSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_topType, _unboxedListSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_topType, _linkedListSymType)); } @Test @@ -580,58 +581,58 @@ public void isCompatibleTypeVariable() { // unbounded type variable are like existential types: // we don't know enough to do pretty much anything with it - Assertions.assertTrue(SymTypeRelations.isCompatible(unboundedTVar, unboundedTVar)); - Assertions.assertFalse(SymTypeRelations.isCompatible(unboundedTVar, unbounded2TVar)); - Assertions.assertFalse(SymTypeRelations.isCompatible(unboundedTVar, _personSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_personSymType, unboundedTVar)); + assertTrue(SymTypeRelations.isCompatible(unboundedTVar, unboundedTVar)); + assertFalse(SymTypeRelations.isCompatible(unboundedTVar, unbounded2TVar)); + assertFalse(SymTypeRelations.isCompatible(unboundedTVar, _personSymType)); + assertFalse(SymTypeRelations.isCompatible(_personSymType, unboundedTVar)); // we can assign variables if we know their upper bound - Assertions.assertTrue(SymTypeRelations.isCompatible(_personSymType, subStudentTVar)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_studentSymType, subStudentTVar)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, subStudentTVar)); + assertTrue(SymTypeRelations.isCompatible(_personSymType, subStudentTVar)); + assertTrue(SymTypeRelations.isCompatible(_studentSymType, subStudentTVar)); + assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, subStudentTVar)); // we cannot really assign to variable if we only know their upper bounds - Assertions.assertFalse(SymTypeRelations.isCompatible(subStudentTVar, _personSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(subStudentTVar, _studentSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(subStudentTVar, _csStudentSymType)); + assertFalse(SymTypeRelations.isCompatible(subStudentTVar, _personSymType)); + assertFalse(SymTypeRelations.isCompatible(subStudentTVar, _studentSymType)); + assertFalse(SymTypeRelations.isCompatible(subStudentTVar, _csStudentSymType)); // we can assign to variables if we know their lower bound - Assertions.assertFalse(SymTypeRelations.isCompatible(superStudentTVar, _personSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(superStudentTVar, _studentSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(superStudentTVar, _csStudentSymType)); + assertFalse(SymTypeRelations.isCompatible(superStudentTVar, _personSymType)); + assertTrue(SymTypeRelations.isCompatible(superStudentTVar, _studentSymType)); + assertTrue(SymTypeRelations.isCompatible(superStudentTVar, _csStudentSymType)); // we cannot really assign variables if we only know their lower bounds - Assertions.assertFalse(SymTypeRelations.isCompatible(_personSymType, superStudentTVar)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_studentSymType, superStudentTVar)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, superStudentTVar)); + assertFalse(SymTypeRelations.isCompatible(_personSymType, superStudentTVar)); + assertFalse(SymTypeRelations.isCompatible(_studentSymType, superStudentTVar)); + assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, superStudentTVar)); // two single bounded variables - Assertions.assertTrue(SymTypeRelations.isCompatible(superStudentTVar, subStudentTVar)); - Assertions.assertTrue(SymTypeRelations.isCompatible(superPersonTVar, subStudentTVar)); - Assertions.assertFalse(SymTypeRelations.isCompatible(superStudentTVar, subPersonTVar)); - Assertions.assertFalse(SymTypeRelations.isCompatible(subPersonTVar, subStudentTVar)); - Assertions.assertFalse(SymTypeRelations.isCompatible(subStudentTVar, subPersonTVar)); + assertTrue(SymTypeRelations.isCompatible(superStudentTVar, subStudentTVar)); + assertTrue(SymTypeRelations.isCompatible(superPersonTVar, subStudentTVar)); + assertFalse(SymTypeRelations.isCompatible(superStudentTVar, subPersonTVar)); + assertFalse(SymTypeRelations.isCompatible(subPersonTVar, subStudentTVar)); + assertFalse(SymTypeRelations.isCompatible(subStudentTVar, subPersonTVar)); // in case of upper AND lower bound set, // we can assign and assign to the type variable // assign to: - Assertions.assertFalse(SymTypeRelations.isCompatible(superSSubCsSTVar, _personSymType)); - Assertions.assertFalse(SymTypeRelations.isCompatible(superSSubCsSTVar, _studentSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(superSSubCsSTVar, _csStudentSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(superSSubCsSTVar, _firstSemesterCsStudentSymType)); + assertFalse(SymTypeRelations.isCompatible(superSSubCsSTVar, _personSymType)); + assertFalse(SymTypeRelations.isCompatible(superSSubCsSTVar, _studentSymType)); + assertTrue(SymTypeRelations.isCompatible(superSSubCsSTVar, _csStudentSymType)); + assertTrue(SymTypeRelations.isCompatible(superSSubCsSTVar, _firstSemesterCsStudentSymType)); // assign: - Assertions.assertTrue(SymTypeRelations.isCompatible(_personSymType, superSSubCsSTVar)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_studentSymType, superSSubCsSTVar)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, superSSubCsSTVar)); - Assertions.assertFalse(SymTypeRelations.isCompatible(_firstSemesterCsStudentSymType, superSSubCsSTVar)); + assertTrue(SymTypeRelations.isCompatible(_personSymType, superSSubCsSTVar)); + assertTrue(SymTypeRelations.isCompatible(_studentSymType, superSSubCsSTVar)); + assertFalse(SymTypeRelations.isCompatible(_csStudentSymType, superSSubCsSTVar)); + assertFalse(SymTypeRelations.isCompatible(_firstSemesterCsStudentSymType, superSSubCsSTVar)); } @Test public void isCompatibleTypeVariableRecursive() { // check that we can handle recursively defined generics, // e.g., A> - Assertions.assertTrue(SymTypeRelations.isCompatible(_simpleCrtSymType, _simpleCrtSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_graphSymType, _graphSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_graphNodeSymType, _graphNodeSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible(_graphEdgeSymType, _graphEdgeSymType)); + assertTrue(SymTypeRelations.isCompatible(_simpleCrtSymType, _simpleCrtSymType)); + assertTrue(SymTypeRelations.isCompatible(_graphSymType, _graphSymType)); + assertTrue(SymTypeRelations.isCompatible(_graphNodeSymType, _graphNodeSymType)); + assertTrue(SymTypeRelations.isCompatible(_graphEdgeSymType, _graphEdgeSymType)); } @Test @@ -665,24 +666,24 @@ public void isCompatibleUpperBoundedGenerics() { createWildcard(true, _personSymType) ); - Assertions.assertFalse(SymTypeRelations.isCompatible(pList, sList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(sList, pList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(pList, sSubList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(sList, sSubList)); - - Assertions.assertTrue(SymTypeRelations.isCompatible(pSubList, pList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(pSubList, sList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(pSubList, pSubList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(pSubList, sSubList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(sSubList, pList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(sSubList, sList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(sSubList, pSubList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(sSubList, sSubList)); - - Assertions.assertTrue(SymTypeRelations.isCompatible(pSubList, pSubLinkedList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(pSubList, sSubLinkedList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(sSubList, pSubLinkedList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(sSubList, sSubLinkedList)); + assertFalse(SymTypeRelations.isCompatible(pList, sList)); + assertFalse(SymTypeRelations.isCompatible(sList, pList)); + assertFalse(SymTypeRelations.isCompatible(pList, sSubList)); + assertFalse(SymTypeRelations.isCompatible(sList, sSubList)); + + assertTrue(SymTypeRelations.isCompatible(pSubList, pList)); + assertTrue(SymTypeRelations.isCompatible(pSubList, sList)); + assertTrue(SymTypeRelations.isCompatible(pSubList, pSubList)); + assertTrue(SymTypeRelations.isCompatible(pSubList, sSubList)); + assertFalse(SymTypeRelations.isCompatible(sSubList, pList)); + assertTrue(SymTypeRelations.isCompatible(sSubList, sList)); + assertFalse(SymTypeRelations.isCompatible(sSubList, pSubList)); + assertTrue(SymTypeRelations.isCompatible(sSubList, sSubList)); + + assertTrue(SymTypeRelations.isCompatible(pSubList, pSubLinkedList)); + assertTrue(SymTypeRelations.isCompatible(pSubList, sSubLinkedList)); + assertFalse(SymTypeRelations.isCompatible(sSubList, pSubLinkedList)); + assertTrue(SymTypeRelations.isCompatible(sSubList, sSubLinkedList)); } @Test @@ -716,34 +717,34 @@ public void isCompatibleLowerBoundedGenerics() { createWildcard(false, _personSymType) ); - Assertions.assertFalse(SymTypeRelations.isCompatible(pList, sList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(sList, pList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(pList, sSuperList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(sList, sSuperList)); - - Assertions.assertTrue(SymTypeRelations.isCompatible(pSuperList, pList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(pSuperList, sList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(pSuperList, pSuperList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(pSuperList, sSuperList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(sSuperList, pList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(sSuperList, sList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(sSuperList, pSuperList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(sSuperList, sSuperList)); - - Assertions.assertTrue(SymTypeRelations.isCompatible(pSuperList, pSuperLinkedList)); - Assertions.assertFalse(SymTypeRelations.isCompatible(pSuperList, sSuperLinkedList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(sSuperList, pSuperLinkedList)); - Assertions.assertTrue(SymTypeRelations.isCompatible(sSuperList, sSuperLinkedList)); + assertFalse(SymTypeRelations.isCompatible(pList, sList)); + assertFalse(SymTypeRelations.isCompatible(sList, pList)); + assertFalse(SymTypeRelations.isCompatible(pList, sSuperList)); + assertFalse(SymTypeRelations.isCompatible(sList, sSuperList)); + + assertTrue(SymTypeRelations.isCompatible(pSuperList, pList)); + assertFalse(SymTypeRelations.isCompatible(pSuperList, sList)); + assertTrue(SymTypeRelations.isCompatible(pSuperList, pSuperList)); + assertFalse(SymTypeRelations.isCompatible(pSuperList, sSuperList)); + assertTrue(SymTypeRelations.isCompatible(sSuperList, pList)); + assertTrue(SymTypeRelations.isCompatible(sSuperList, sList)); + assertTrue(SymTypeRelations.isCompatible(sSuperList, pSuperList)); + assertTrue(SymTypeRelations.isCompatible(sSuperList, sSuperList)); + + assertTrue(SymTypeRelations.isCompatible(pSuperList, pSuperLinkedList)); + assertFalse(SymTypeRelations.isCompatible(pSuperList, sSuperLinkedList)); + assertTrue(SymTypeRelations.isCompatible(sSuperList, pSuperLinkedList)); + assertTrue(SymTypeRelations.isCompatible(sSuperList, sSuperLinkedList)); } @Test public void nullCompatibilityAndSubTyping() { - Assertions.assertFalse(SymTypeRelations.isCompatible(_intSymType, createTypeOfNull())); - Assertions.assertTrue(SymTypeRelations.isCompatible(_IntegerSymType, createTypeOfNull())); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(createTypeOfNull(), _personSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_personSymType, createTypeOfNull())); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_s_SISymType, _nullSymType)); - Assertions.assertFalse(SymTypeRelations.isSubTypeOf(_s_int_SISymType, _nullSymType)); + assertFalse(SymTypeRelations.isCompatible(_intSymType, createTypeOfNull())); + assertTrue(SymTypeRelations.isCompatible(_IntegerSymType, createTypeOfNull())); + assertFalse(SymTypeRelations.isSubTypeOf(createTypeOfNull(), _personSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_personSymType, createTypeOfNull())); + assertFalse(SymTypeRelations.isSubTypeOf(_s_SISymType, _nullSymType)); + assertFalse(SymTypeRelations.isSubTypeOf(_s_int_SISymType, _nullSymType)); } /** @@ -771,8 +772,8 @@ public void isCompatibleSuperTypeOfBoxed() { createGenerics(iterableSym, _boxedListSymType.getArgument(0)) )); - Assertions.assertTrue(SymTypeRelations.isCompatible(comparableInteger, _IntegerSymType)); - Assertions.assertTrue(SymTypeRelations.isCompatible( + assertTrue(SymTypeRelations.isCompatible(comparableInteger, _IntegerSymType)); + assertTrue(SymTypeRelations.isCompatible( createGenerics(iterableSym, _IntegerSymType), createGenerics(_unboxedListSymType.getTypeInfo(), _intSymType) )); diff --git a/monticore-grammar/src/test/java/de/monticore/types3/SymTypeLeastUpperBoundTest.java b/monticore-grammar/src/test/java/de/monticore/types3/SymTypeLeastUpperBoundTest.java index 7ab0adc305..6042aad884 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/SymTypeLeastUpperBoundTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/SymTypeLeastUpperBoundTest.java @@ -7,7 +7,6 @@ import de.monticore.runtime.junit.AbstractMCTest; import de.monticore.types3.util.DefsTypesForTests; import de.monticore.types.check.SymTypeExpression; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -25,6 +24,7 @@ import static de.monticore.types.check.SymTypeExpressionFactory.createIntersection; import static de.monticore.types.check.SymTypeExpressionFactory.createTypeArray; import static de.monticore.types.check.SymTypeExpressionFactory.createUnion; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SymTypeLeastUpperBoundTest extends AbstractMCTest { @@ -65,6 +65,6 @@ protected void checkLub(SymTypeExpression type, String expectedPrint) { Optional lubOpt = SymTypeRelations.leastUpperBound(type); String printed = lubOpt.map(SymTypeExpression::printFullName).orElse(""); assertNoFindings(); - Assertions.assertEquals(expectedPrint, printed); + assertEquals(expectedPrint, printed); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types3/SymTypeNormalizeVisitorTest.java b/monticore-grammar/src/test/java/de/monticore/types3/SymTypeNormalizeVisitorTest.java index 068cb87597..8ead0cf963 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/SymTypeNormalizeVisitorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/SymTypeNormalizeVisitorTest.java @@ -8,7 +8,6 @@ import de.monticore.types.check.SymTypeOfIntersection; import de.monticore.types.check.SymTypeOfUnion; import de.monticore.types3.util.SymTypeNormalizeVisitor; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -27,6 +26,7 @@ import static de.monticore.types.check.SymTypeExpressionFactory.createTypeArray; import static de.monticore.types.check.SymTypeExpressionFactory.createTypeObject; import static de.monticore.types.check.SymTypeExpressionFactory.createUnion; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SymTypeNormalizeVisitorTest extends AbstractMCTest { @@ -344,7 +344,7 @@ public void normalizeNumericWithSIUnits() { public void check(SymTypeExpression type, String expectedPrint) { SymTypeExpression normalized = visitor.calculate(type); assertNoFindings(); - Assertions.assertEquals(expectedPrint, normalized.printFullName()); + assertEquals(expectedPrint, normalized.printFullName()); } public void check(SymTypeExpression type, SymTypeExpression expectedType) { diff --git a/monticore-grammar/src/test/java/de/monticore/types3/SymTypeUnboxingVisitorTest.java b/monticore-grammar/src/test/java/de/monticore/types3/SymTypeUnboxingVisitorTest.java index 4f2256bf1c..c8b6c38352 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/SymTypeUnboxingVisitorTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/SymTypeUnboxingVisitorTest.java @@ -9,7 +9,6 @@ import de.monticore.symbols.basicsymbols._symboltable.TypeVarSymbol; import de.monticore.types.check.SymTypeExpression; import de.monticore.types3.util.SymTypeUnboxingVisitor; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -21,6 +20,7 @@ import static de.monticore.types.check.SymTypeExpressionFactory.createTypeObject; import static de.monticore.types.check.SymTypeExpressionFactory.createTypeVariable; import static de.monticore.types.check.SymTypeExpressionFactory.createUnion; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SymTypeUnboxingVisitorTest extends AbstractMCTest { @@ -109,7 +109,7 @@ public void unboxComplexTypes() { public void check(SymTypeExpression boxed, String expectedUnboxedName) { SymTypeExpression unboxed = visitor.calculate(boxed); assertNoFindings(); - Assertions.assertEquals(expectedUnboxedName, unboxed.printFullName()); + assertEquals(expectedUnboxedName, unboxed.printFullName()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/types3/streams/StreamSymTypeFactoryTest.java b/monticore-grammar/src/test/java/de/monticore/types3/streams/StreamSymTypeFactoryTest.java index 39bee94ffe..1b4a5925f4 100644 --- a/monticore-grammar/src/test/java/de/monticore/types3/streams/StreamSymTypeFactoryTest.java +++ b/monticore-grammar/src/test/java/de/monticore/types3/streams/StreamSymTypeFactoryTest.java @@ -17,9 +17,7 @@ import static de.monticore.types3.util.DefsTypesForTests._unboxedListSymType; import static de.monticore.types3.util.DefsTypesForTests._unboxedOptionalSymType; import static de.monticore.types3.util.DefsTypesForTests._unboxedSetSymType; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class StreamSymTypeFactoryTest extends AbstractMCTest { diff --git a/monticore-grammar/src/test/java/de/monticore/umlmodifier/ModifierBuilderTest.java b/monticore-grammar/src/test/java/de/monticore/umlmodifier/ModifierBuilderTest.java index cf36817e5f..e0f47cada4 100644 --- a/monticore-grammar/src/test/java/de/monticore/umlmodifier/ModifierBuilderTest.java +++ b/monticore-grammar/src/test/java/de/monticore/umlmodifier/ModifierBuilderTest.java @@ -5,11 +5,10 @@ import de.monticore.umlmodifier._ast.ASTModifierBuilder; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ModifierBuilderTest { @@ -21,16 +20,16 @@ public void before() { @Test public void checkAllOptions() { - Assertions.assertTrue(new ASTModifierBuilder().PUBLIC().build().isPublic()); - Assertions.assertTrue(new ASTModifierBuilder().PRIVATE().build().isPrivate()); - Assertions.assertTrue(new ASTModifierBuilder().PROTECTED().build().isProtected()); - Assertions.assertTrue(new ASTModifierBuilder().FINAL().build().isFinal()); - Assertions.assertTrue(new ASTModifierBuilder().ABSTRACT().build().isAbstract()); - Assertions.assertTrue(new ASTModifierBuilder().LOCAL().build().isLocal()); - Assertions.assertTrue(new ASTModifierBuilder().DERIVED().build().isDerived()); - Assertions.assertTrue(new ASTModifierBuilder().READONLY().build().isReadonly()); - Assertions.assertTrue(new ASTModifierBuilder().STATIC().build().isStatic()); + assertTrue(new ASTModifierBuilder().PUBLIC().build().isPublic()); + assertTrue(new ASTModifierBuilder().PRIVATE().build().isPrivate()); + assertTrue(new ASTModifierBuilder().PROTECTED().build().isProtected()); + assertTrue(new ASTModifierBuilder().FINAL().build().isFinal()); + assertTrue(new ASTModifierBuilder().ABSTRACT().build().isAbstract()); + assertTrue(new ASTModifierBuilder().LOCAL().build().isLocal()); + assertTrue(new ASTModifierBuilder().DERIVED().build().isDerived()); + assertTrue(new ASTModifierBuilder().READONLY().build().isReadonly()); + assertTrue(new ASTModifierBuilder().STATIC().build().isStatic()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/umlmodifier/ModifierPrettyPrintTest.java b/monticore-grammar/src/test/java/de/monticore/umlmodifier/ModifierPrettyPrintTest.java index 3c00dc3cc2..f2d4a2cdda 100644 --- a/monticore-grammar/src/test/java/de/monticore/umlmodifier/ModifierPrettyPrintTest.java +++ b/monticore-grammar/src/test/java/de/monticore/umlmodifier/ModifierPrettyPrintTest.java @@ -4,12 +4,11 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ModifierPrettyPrintTest { @@ -24,24 +23,24 @@ public void before() { @Test public void testLongFormsIndividual() { - Assertions.assertEquals("public", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().PUBLIC().build(), false)); - Assertions.assertEquals("private", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().PRIVATE().build(), false)); - Assertions.assertEquals("protected", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().PROTECTED().build(), false)); - Assertions.assertEquals("final", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().FINAL().build(), false)); - Assertions.assertEquals("abstract", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().ABSTRACT().build(), false)); - Assertions.assertEquals("local", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().LOCAL().build(), false)); - Assertions.assertEquals("derived", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().DERIVED().build(), false)); - Assertions.assertEquals("readonly", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().READONLY().build(), false)); - Assertions.assertEquals("static", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().STATIC().build(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("public", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().PUBLIC().build(), false)); + assertEquals("private", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().PRIVATE().build(), false)); + assertEquals("protected", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().PROTECTED().build(), false)); + assertEquals("final", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().FINAL().build(), false)); + assertEquals("abstract", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().ABSTRACT().build(), false)); + assertEquals("local", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().LOCAL().build(), false)); + assertEquals("derived", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().DERIVED().build(), false)); + assertEquals("readonly", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().READONLY().build(), false)); + assertEquals("static", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().STATIC().build(), false)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLong() { - Assertions.assertEquals("public static", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().PUBLIC().STATIC().build(), false)); - Assertions.assertEquals("abstract readonly", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().ABSTRACT().READONLY().build(), false)); - Assertions.assertEquals("protected static", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().PROTECTED().STATIC().build(), false)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("public static", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().PUBLIC().STATIC().build(), false)); + assertEquals("abstract readonly", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().ABSTRACT().READONLY().build(), false)); + assertEquals("protected static", UMLModifierMill.prettyPrint(UMLModifierMill.modifierBuilder().PROTECTED().STATIC().build(), false)); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/umlstereotype/StereoValueContentTest.java b/monticore-grammar/src/test/java/de/monticore/umlstereotype/StereoValueContentTest.java index f5893f8135..ca481af753 100644 --- a/monticore-grammar/src/test/java/de/monticore/umlstereotype/StereoValueContentTest.java +++ b/monticore-grammar/src/test/java/de/monticore/umlstereotype/StereoValueContentTest.java @@ -6,10 +6,12 @@ import de.se_rwth.commons.logging.LogStub; import org.apache.commons.lang3.StringEscapeUtils; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class StereoValueContentTest { @BeforeEach public void init() { @@ -20,7 +22,7 @@ public void init() { @AfterEach public void postCheck() { - Assertions.assertTrue(LogStub.getFindings().isEmpty()); + assertTrue(LogStub.getFindings().isEmpty()); } @Test @@ -28,7 +30,7 @@ public void testSimpleBuilder() { String input = "Hello world"; var sv = TestMCCommonMill.stereoValueBuilder().setName("Stereo") .setContent(input).build(); - Assertions.assertEquals(input, sv.getContent()); + assertEquals(input, sv.getContent()); } @Test @@ -36,7 +38,7 @@ public void testSimple() { String input = "Hello world"; var sv = TestMCCommonMill.stereoValueBuilder().setName("Stereo").build(); sv.setContent(input); - Assertions.assertEquals(input, sv.getContent()); + assertEquals(input, sv.getContent()); } @Test @@ -44,7 +46,7 @@ public void testQuotationBuilder() { String input = "Hello \"world\""; var sv = TestMCCommonMill.stereoValueBuilder().setName("Stereo") .setContent(input).build(); - Assertions.assertEquals(input, sv.getContent()); + assertEquals(input, sv.getContent()); } @Test @@ -52,7 +54,7 @@ public void testQuotation() { String input = "Hello \"world\""; var sv = TestMCCommonMill.stereoValueBuilder().setName("Stereo").build(); sv.setContent(input); - Assertions.assertEquals(input, sv.getContent()); + assertEquals(input, sv.getContent()); } @Test @@ -60,7 +62,7 @@ public void testBackslashBuilder() { String input = "Hello \\ world,\n hello\\people"; var sv = TestMCCommonMill.stereoValueBuilder().setName("Stereo") .setContent(input).build(); - Assertions.assertEquals(input, sv.getContent()); + assertEquals(input, sv.getContent()); } @Test @@ -68,7 +70,7 @@ public void testBackslash() { String input = "Hello \\ world,\n hello\\people"; var sv = TestMCCommonMill.stereoValueBuilder().setName("Stereo").build(); sv.setContent(input); - Assertions.assertEquals(input, sv.getContent()); + assertEquals(input, sv.getContent()); } @@ -79,7 +81,7 @@ public void testSetTextBuilder() { .setText(MCCommonLiteralsMill.stringLiteralBuilder() .setSource(StringEscapeUtils.escapeJava(input)).build()) .build(); - Assertions.assertEquals(input, sv.getContent()); + assertEquals(input, sv.getContent()); } } diff --git a/monticore-grammar/src/test/java/de/monticore/umlstereotype/cocos/StereoValueIsStringLiteralTest.java b/monticore-grammar/src/test/java/de/monticore/umlstereotype/cocos/StereoValueIsStringLiteralTest.java index fdd5b58629..82d56bb304 100644 --- a/monticore-grammar/src/test/java/de/monticore/umlstereotype/cocos/StereoValueIsStringLiteralTest.java +++ b/monticore-grammar/src/test/java/de/monticore/umlstereotype/cocos/StereoValueIsStringLiteralTest.java @@ -5,13 +5,15 @@ import de.monticore.umlstereotype._ast.ASTStereotype; import de.monticore.umlstereotype._cocos.UMLStereotypeCoCoChecker; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Holds tests for {@link StereoValueIsStringLiteral} */ @@ -29,19 +31,19 @@ public void init() { public void checkValid(String expressionString) throws IOException { Optional optAST = parser.parse_StringStereotype(expressionString); - Assertions.assertTrue(optAST.isPresent()); + assertTrue(optAST.isPresent()); Log.getFindings().clear(); checker.checkAll(optAST.get()); - Assertions.assertTrue(Log.getFindings().isEmpty(), Log.getFindings().toString()); + assertTrue(Log.getFindings().isEmpty(), Log.getFindings().toString()); } public void checkInvalid(String expressionString) throws IOException { Optional optAST = parser.parse_StringStereotype(expressionString); - Assertions.assertTrue(optAST.isPresent()); + assertTrue(optAST.isPresent()); Log.getFindings().clear(); Log.enableFailQuick(false); checker.checkAll(optAST.get()); - Assertions.assertFalse(Log.getFindings().isEmpty()); + assertFalse(Log.getFindings().isEmpty()); } @Test diff --git a/monticore-libraries/stream-symbols-it/build.gradle b/monticore-libraries/stream-symbols-it/build.gradle index c529c535d7..a5adb3f4f1 100644 --- a/monticore-libraries/stream-symbols-it/build.gradle +++ b/monticore-libraries/stream-symbols-it/build.gradle @@ -14,8 +14,8 @@ dependencies { testImplementation 'de.se_rwth.commons:se-commons-logging:' + se_commons_version testImplementation 'de.se_rwth.commons:se-commons-utilities:' + se_commons_version testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" - testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" } test { diff --git a/monticore-libraries/stream-symbols-it/src/test/java/de/monticore/symbols/library/StreamTypeTest.java b/monticore-libraries/stream-symbols-it/src/test/java/de/monticore/symbols/library/StreamTypeTest.java index 18456acc2a..7c961efdbb 100644 --- a/monticore-libraries/stream-symbols-it/src/test/java/de/monticore/symbols/library/StreamTypeTest.java +++ b/monticore-libraries/stream-symbols-it/src/test/java/de/monticore/symbols/library/StreamTypeTest.java @@ -13,7 +13,6 @@ import de.monticore.types3.util.WithinScopeBasicSymbolsResolver; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -25,6 +24,8 @@ import java.util.Optional; import java.util.jar.JarFile; +import static org.junit.jupiter.api.Assertions.*; + public class StreamTypeTest { @BeforeEach @@ -38,9 +39,9 @@ public void init() throws IOException { // workaround to get library path working (in emf) URL streamURL = StreamTypeTest.class.getClassLoader().getResource("Stream.symtabdefinitionsym"); - Assertions.assertNotNull(streamURL); + assertNotNull(streamURL); // need to be expanded if ever false (could be a folder?) - Assertions.assertEquals("jar", streamURL.getProtocol()); + assertEquals("jar", streamURL.getProtocol()); JarURLConnection urlConnection = (JarURLConnection) streamURL.openConnection(); JarFile jar = urlConnection.getJarFile(); Path jarPath = Path.of(jar.getName()); @@ -55,40 +56,40 @@ public void init() throws IOException { public void resolveStreamType() { Optional streamOpt = OOSymbolsMill.globalScope() .resolveType("Stream"); - Assertions.assertTrue(streamOpt.isPresent()); + assertTrue(streamOpt.isPresent()); TypeSymbol stream = streamOpt.get(); - Assertions.assertNotNull(stream.getSpannedScope()); - Assertions.assertEquals(1, stream.getSpannedScope().getTypeVarSymbols().size()); - Assertions.assertEquals(0, Log.getErrorCount()); + assertNotNull(stream.getSpannedScope()); + assertEquals(1, stream.getSpannedScope().getTypeVarSymbols().size()); + assertEquals(0, Log.getErrorCount()); } @Test public void resolveStaticRepeat() { MethodSymbol method = getMethodSymbol("Stream.repeat"); - Assertions.assertEquals(2, method.getParameterList().size()); + assertEquals(2, method.getParameterList().size()); assertIsStreamWithTypeVar(method.getType()); - Assertions.assertTrue(method.isIsStatic()); + assertTrue(method.isIsStatic()); List typeVars = method.getSpannedScope().getLocalTypeVarSymbols(); - Assertions.assertEquals(1, typeVars.size()); - Assertions.assertNotEquals(typeVars.get(0).getName(), "T"); + assertEquals(1, typeVars.size()); + assertNotEquals("T", typeVars.get(0).getName()); } @Test public void resolveStreamMethodLen() { MethodSymbol method = getMethodSymbol("Stream.len"); - Assertions.assertEquals(0, method.getParameterList().size()); - Assertions.assertTrue(method.getEnclosingScope().getSpanningSymbol() instanceof TypeSymbol); - Assertions.assertEquals("Stream", method.getEnclosingScope().getSpanningSymbol().getName()); - Assertions.assertEquals(BasicSymbolsMill.LONG, method.getType().getTypeInfo().getName()); + assertEquals(0, method.getParameterList().size()); + assertInstanceOf(TypeSymbol.class, method.getEnclosingScope().getSpanningSymbol()); + assertEquals("Stream", method.getEnclosingScope().getSpanningSymbol().getName()); + assertEquals(BasicSymbolsMill.LONG, method.getType().getTypeInfo().getName()); } @Test public void resolveStreamMethodIsEmpty() { MethodSymbol method = getMethodSymbol("Stream.isEmpty"); - Assertions.assertEquals(0, method.getParameterList().size()); - Assertions.assertTrue(method.getEnclosingScope().getSpanningSymbol() instanceof TypeSymbol); - Assertions.assertEquals("Stream", method.getEnclosingScope().getSpanningSymbol().getName()); - Assertions.assertEquals(BasicSymbolsMill.BOOLEAN, method.getType().getTypeInfo().getName()); + assertEquals(0, method.getParameterList().size()); + assertInstanceOf(TypeSymbol.class, method.getEnclosingScope().getSpanningSymbol()); + assertEquals("Stream", method.getEnclosingScope().getSpanningSymbol().getName()); + assertEquals(BasicSymbolsMill.BOOLEAN, method.getType().getTypeInfo().getName()); } @Test @@ -145,17 +146,17 @@ public void isTypeVarResolvableFromReturn() { } protected void assertIsStreamWithTypeVar(SymTypeExpression type) { - Assertions.assertNotNull(type); - Assertions.assertTrue(type.isGenericType()); - Assertions.assertEquals("Stream", type.getTypeInfo().getName()); - Assertions.assertEquals(1, ((SymTypeOfGenerics) type).getArgumentList().size()); - Assertions.assertTrue(((SymTypeOfGenerics) type).getArgument(0).isTypeVariable()); + assertNotNull(type); + assertTrue(type.isGenericType()); + assertEquals("Stream", type.getTypeInfo().getName()); + assertEquals(1, ((SymTypeOfGenerics) type).getArgumentList().size()); + assertTrue(((SymTypeOfGenerics) type).getArgument(0).isTypeVariable()); } protected void testResolveMethod(String name) { Optional methodType = WithinScopeBasicSymbolsResolver.resolveNameAsExpr(BasicSymbolsMill.globalScope(), name); - Assertions.assertTrue(methodType.isPresent(), name); - Assertions.assertTrue(methodType.get().isFunctionType() + assertTrue(methodType.isPresent(), name); + assertTrue(methodType.get().isFunctionType() || methodType.get().isIntersectionType() ); } diff --git a/monticore-runtime-emf/build.gradle b/monticore-runtime-emf/build.gradle index 2cb5148a5f..1d66d1b0e2 100644 --- a/monticore-runtime-emf/build.gradle +++ b/monticore-runtime-emf/build.gradle @@ -10,8 +10,8 @@ dependencies { implementation 'org.eclipse.emf:org.eclipse.emf.compare.match:' + emf_compare_version implementation 'org.eclipse.emf:org.eclipse.emf.compare.diff:' + emf_compare_version testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" - testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" testImplementation 'org.apache.groovy:groovy:4.0.2' } diff --git a/monticore-runtime/build.gradle b/monticore-runtime/build.gradle index a62d6925fd..b4ccbac6aa 100644 --- a/monticore-runtime/build.gradle +++ b/monticore-runtime/build.gradle @@ -35,9 +35,14 @@ dependencies { testFixturesImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version" - testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" +} + +test { + useJUnitPlatform() } diff --git a/monticore-runtime/src/test/java/de/monticore/ast/CommentBuilderTest.java b/monticore-runtime/src/test/java/de/monticore/ast/CommentBuilderTest.java index efa290f7bf..49b2221a19 100644 --- a/monticore-runtime/src/test/java/de/monticore/ast/CommentBuilderTest.java +++ b/monticore-runtime/src/test/java/de/monticore/ast/CommentBuilderTest.java @@ -3,15 +3,14 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class CommentBuilderTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -23,11 +22,12 @@ public void positiveTest() { assertTrue(Log.getFindings().isEmpty()); } - @Test(expected=IllegalStateException.class) + @Test public void negativeTest() { final CommentBuilder commentBuilder = new CommentBuilder(); assertFalse(commentBuilder.isValid()); - commentBuilder.build(); - assertTrue(Log.getFindings().isEmpty()); + assertThrows(IllegalStateException.class, commentBuilder::build); + assertEquals(1L, Log.getFindingsCount()); + assertEquals("0xA4322 text of type String must not be null", Log.getFindings().get(0).getMsg()); } } diff --git a/monticore-runtime/src/test/java/de/monticore/cocos/helper/Assert.java b/monticore-runtime/src/test/java/de/monticore/cocos/helper/Assert.java index 64b388e0d2..d0deeaac2d 100644 --- a/monticore-runtime/src/test/java/de/monticore/cocos/helper/Assert.java +++ b/monticore-runtime/src/test/java/de/monticore/cocos/helper/Assert.java @@ -2,15 +2,15 @@ package de.monticore.cocos.helper; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.util.Collection; import com.google.common.base.Joiner; import de.se_rwth.commons.logging.Finding; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Helper for testing CoCos. * @@ -30,8 +30,8 @@ public static void assertErrors(Collection expectedErrors, for (Finding expectedError : expectedErrors) { boolean found = actualErrors.stream() .filter(s -> s.buildMsg().contains(expectedError.buildMsg())).count() >= 1; - assertTrue("The following expected error was not found: " + expectedError - + actualErrorsJoined, found); + assertTrue(found, + "The following expected error was not found: " + expectedError + actualErrorsJoined); } } @@ -50,8 +50,8 @@ public static void assertErrorMsg(Collection expectedErrors, boolean found = actualErrors.stream().filter( f -> f.getMsg().equals(expectedError.getMsg()) ).count() >= 1; - assertTrue("The following expected error was not found: " + expectedError - + actualErrorsJoined, found); + assertTrue(found, + "The following expected error was not found: " + expectedError + actualErrorsJoined); } } @@ -66,10 +66,9 @@ public static void assertEqualErrorCounts(Collection expectedErrors, String actualErrorsJoined = "\nactual Errors: \n\t" + Joiner.on("\n\t").join(actualErrors); String expectedErrorsJoined = "\nexpected Errors: \n\t" + Joiner.on("\n\t").join(expectedErrors); - assertEquals( + assertEquals(expectedErrors.size(), actualErrors.size(), "Expected " + expectedErrors.size() + " errors, but found " + actualErrors.size() - + "." + expectedErrorsJoined + actualErrorsJoined, expectedErrors.size(), - actualErrors.size()); + + "." + expectedErrorsJoined + actualErrorsJoined); } } diff --git a/monticore-runtime/src/test/java/de/monticore/generating/GeneratorEngineTest.java b/monticore-runtime/src/test/java/de/monticore/generating/GeneratorEngineTest.java index c1f72a1b04..5987eee079 100644 --- a/monticore-runtime/src/test/java/de/monticore/generating/GeneratorEngineTest.java +++ b/monticore-runtime/src/test/java/de/monticore/generating/GeneratorEngineTest.java @@ -12,7 +12,6 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -20,6 +19,7 @@ import java.nio.file.Paths; import static de.monticore.generating.GeneratorEngine.existsHandwrittenClass; +import static org.junit.jupiter.api.Assertions.*; /** * Tests for {@link de.monticore.generating.GeneratorEngine}. @@ -48,15 +48,15 @@ public void testGenerateInFile() { generatorEngine.generate("the.Template", Paths.get("a/GenerateInFile.test"), node); - Assertions.assertEquals(1, freeMarkerTemplateEngine.getProcessedTemplates().size()); + assertEquals(1, freeMarkerTemplateEngine.getProcessedTemplates().size()); FreeMarkerTemplateMock template = freeMarkerTemplateEngine.getProcessedTemplates().iterator().next(); - Assertions.assertTrue(template.isProcessed()); - Assertions.assertEquals("the.Template", template.getName()); + assertTrue(template.isProcessed()); + assertEquals("the.Template", template.getName()); - Assertions.assertEquals(1, fileHandler.getStoredFilesAndContents().size()); - Assertions.assertTrue(fileHandler.getStoredFilesAndContents().containsKey(Paths.get + assertEquals(1, fileHandler.getStoredFilesAndContents().size()); + assertTrue(fileHandler.getStoredFilesAndContents().containsKey(Paths.get (new File("target1/a/GenerateInFile.test").getAbsolutePath()))); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @AfterAll @@ -75,15 +75,15 @@ public void testGenerateStringBuilder() { GeneratorEngineMock generatorEngine = new GeneratorEngineMock(setup); StringBuilder sb = generatorEngine.generateNoA("the.Template"); - Assertions.assertTrue(sb.length()>0); + assertTrue(sb.length()>0); - Assertions.assertEquals(1, freeMarkerTemplateEngine.getProcessedTemplates().size()); + assertEquals(1, freeMarkerTemplateEngine.getProcessedTemplates().size()); FreeMarkerTemplateMock template = freeMarkerTemplateEngine.getProcessedTemplates().iterator().next(); - Assertions.assertTrue(template.isProcessed()); - Assertions.assertEquals("the.Template", template.getName()); + assertTrue(template.isProcessed()); + assertEquals("the.Template", template.getName()); - Assertions.assertEquals(0, fileHandler.getStoredFilesAndContents().size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(0, fileHandler.getStoredFilesAndContents().size()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -94,8 +94,8 @@ public void testWrongPath() { setup.setAdditionalTemplatePaths(Lists.newArrayList(file)); setup.setFileHandler(fileHandler); FreeMarkerTemplateEngineMock freeMarkerTemplateEngine = new FreeMarkerTemplateEngineMock(setup.getConfig()); - Assertions.assertEquals(1, Log.getFindingsCount()); - Assertions.assertEquals("0xA1020 Unable to load templates from non-existent path doesnotexist", Log.getFindings().get(0).getMsg()); + assertEquals(1, Log.getFindingsCount()); + assertEquals("0xA1020 Unable to load templates from non-existent path doesnotexist", Log.getFindings().get(0).getMsg()); } @Test @@ -103,8 +103,8 @@ public void testExistHWC() { String classname = "test.A"; String notExistName = "test.B"; - Assertions.assertTrue(existsHandwrittenClass(new MCPath("src/test/resources/hwc"), classname)); - Assertions.assertFalse(existsHandwrittenClass(new MCPath("src/test/resources/hwc"), notExistName)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(existsHandwrittenClass(new MCPath("src/test/resources/hwc"), classname)); + assertFalse(existsHandwrittenClass(new MCPath("src/test/resources/hwc"), notExistName)); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/GlobalExtensionManagementGlobalVarsTest.java b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/GlobalExtensionManagementGlobalVarsTest.java index d3be5f9904..9dd1ade79f 100644 --- a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/GlobalExtensionManagementGlobalVarsTest.java +++ b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/GlobalExtensionManagementGlobalVarsTest.java @@ -10,7 +10,6 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,8 +17,8 @@ import java.util.ArrayList; import static de.monticore.generating.templateengine.TestConstants.TEMPLATE_PACKAGE; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests for {@link GlobalExtensionManagement}. @@ -47,7 +46,7 @@ public void setup() { config.setOutputDirectory(new File("dummy")); config.setTracing(false); tc = new TemplateControllerMock(config, ""); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @AfterAll @@ -61,19 +60,19 @@ public void testGlobalVars() { glex.defineGlobalVar("asd", new String("asd")); StringBuilder output = tc.include(TEMPLATE_PACKAGE + "GlobalVars"); - Assertions.assertEquals("testasd", output.toString().replaceAll("\\s+", "")); + assertEquals("testasd", output.toString().replaceAll("\\s+", "")); glex.changeGlobalVar("asd", new String("aaa")); output = tc.include(TEMPLATE_PACKAGE + "GlobalVars"); - Assertions.assertEquals("testaaa", output.toString().replaceAll("\\s+", "")); + assertEquals("testaaa", output.toString().replaceAll("\\s+", "")); glex.defineGlobalVar("liste", new ArrayList<>()); glex.addToGlobalVar("liste", new String("a")); glex.addToGlobalVar("liste", new String("b")); glex.addToGlobalVar("liste", new String("c")); output = tc.include(TEMPLATE_PACKAGE + "GlobalListVars"); - Assertions.assertEquals("abc", output.toString().replaceAll("\\s+", "")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("abc", output.toString().replaceAll("\\s+", "")); + assertTrue(Log.getFindings().isEmpty()); } @@ -87,8 +86,8 @@ public void testVariables4() { // override same variable String res = ge.generate(TEMPLATE_PACKAGE + "TestVariables4", ast).toString(); - Assertions.assertEquals("A:16B:38C:555", res.replaceAll("\\r\\n|\\r|\\n", "")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("A:16B:38C:555", res.replaceAll("\\r\\n|\\r|\\n", "")); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/ObjectFactoryTest.java b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/ObjectFactoryTest.java index 500b339b8f..d47a546f49 100644 --- a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/ObjectFactoryTest.java +++ b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/ObjectFactoryTest.java @@ -7,10 +7,11 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class ObjectFactoryTest { @BeforeEach @@ -22,9 +23,9 @@ public void before() { @Test public void testInstanciationWithDefaultConstructor() { Object obj = ObjectFactory.createObject("java.lang.String"); - Assertions.assertNotNull(obj); - Assertions.assertEquals(String.class, obj.getClass()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertNotNull(obj); + assertEquals(String.class, obj.getClass()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -32,10 +33,10 @@ public void testInstanciationWithParams() { List params = new ArrayList(); params.add("myContent"); Object obj = ObjectFactory.createObject("java.lang.String", params); - Assertions.assertNotNull(obj); - Assertions.assertEquals(String.class, obj.getClass()); - Assertions.assertEquals(obj, "myContent"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertNotNull(obj); + assertEquals(String.class, obj.getClass()); + assertEquals(obj, "myContent"); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -51,10 +52,10 @@ public void testInstanciationWithTypesAndParams() { params.add(3); Object obj = ObjectFactory.createObject("java.lang.String", paramTypes, params); - Assertions.assertNotNull(obj); - Assertions.assertEquals(obj.getClass(), (new String()).getClass()); - Assertions.assertEquals(obj, "yes"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertNotNull(obj); + assertEquals(obj.getClass(), (new String()).getClass()); + assertEquals(obj, "yes"); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateAliasingTest.java b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateAliasingTest.java index 08b8793aea..1555eff0cb 100644 --- a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateAliasingTest.java +++ b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateAliasingTest.java @@ -14,7 +14,6 @@ import de.se_rwth.commons.logging.LogStub; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -22,6 +21,8 @@ import java.io.IOException; import java.util.*; +import static org.junit.jupiter.api.Assertions.*; + public class TemplateAliasingTest { private static final File TARGET_DIR = new File("target"); @@ -59,8 +60,8 @@ public static void resetFileReaderWriter() { public void testIncludeAlias() { StringBuilder templateOutput = tc.include(ALIASES_PACKAGE + "IncludeAlias"); - Assertions.assertEquals("Plain is included.", templateOutput.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("Plain is included.", templateOutput.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -69,14 +70,14 @@ public void testIncludeDispatching(){ StringBuilder templateOutput = tc.include(ALIASES_PACKAGE + "IncludeDispatching"); - Assertions.assertEquals("String argument\n" + + assertEquals("String argument\n" + "Plain is included.\n" + "Plain is included.\n" + "\n" + "List argument\n" + "Plain is included.Plain is included.\n" + "Plain is included.Plain is included.", templateOutput.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -84,8 +85,8 @@ public void testInclude2Alias() { String content = "Content of ast"; StringBuilder templateOutput = tc.include(ALIASES_PACKAGE + "Include2Alias", new AliasTestASTNodeMock(content)); - Assertions.assertEquals(content, templateOutput.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(content, templateOutput.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -93,8 +94,8 @@ public void testIncludeArgsAndSignatureAlias(){ StringBuilder templateOut = tc.include(ALIASES_PACKAGE + "IncludeArgsAndSignatureAlias"); - Assertions.assertEquals("Name is Charly, age is 30, city is Aachen", templateOut.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("Name is Charly, age is 30, city is Aachen", templateOut.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -102,8 +103,8 @@ public void testSignature(){ StringBuilder templateOut = tc.includeArgs(ALIASES_PACKAGE + "SignatureAliasWithThreeParameters", "Max Mustermann", "45", "Berlin"); - Assertions.assertEquals("Name is Max Mustermann, age is 45, city is Berlin", templateOut.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("Name is Max Mustermann, age is 45, city is Berlin", templateOut.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -117,7 +118,7 @@ public void testSimpleDefineHookPoint() throws IOException { StringBuilder templateOut = tc.includeArgs(templateName, ast, Collections.singletonList(alternativeAst)); - Assertions.assertEquals("/* generated by template de.monticore.generating.templateengine.templates.aliases.DefineHookPointAlias*/\n" + + assertEquals("/* generated by template de.monticore.generating.templateengine.templates.aliases.DefineHookPointAlias*/\n" + "/* Hookpoint: WithoutAst */\n" + "/* Hookpoint: WithAst */\n" + "/* Hookpoint: WithAlternativeAst */", templateOut.toString()); @@ -127,7 +128,7 @@ public void testSimpleDefineHookPoint() throws IOException { glex.bindHookPoint("WithoutAst", new StringHookPoint("a1")); templateOut = tc.includeArgs(templateName, ast, Collections.singletonList(alternativeAst)); - Assertions.assertEquals("/* generated by template de.monticore.generating.templateengine.templates.aliases.DefineHookPointAlias*/\n" + + assertEquals("/* generated by template de.monticore.generating.templateengine.templates.aliases.DefineHookPointAlias*/\n" + "a1\n" + "/* Hookpoint: WithAst */\n" + "/* Hookpoint: WithAlternativeAst */", templateOut.toString()); @@ -136,7 +137,7 @@ public void testSimpleDefineHookPoint() throws IOException { glex.bindHookPoint("WithAst", new TemplateStringHookPoint("${ast.content}")); templateOut = tc.includeArgs(templateName, ast, Collections.singletonList(alternativeAst)); - Assertions.assertEquals("/* generated by template de.monticore.generating.templateengine.templates.aliases.DefineHookPointAlias*/\n" + + assertEquals("/* generated by template de.monticore.generating.templateengine.templates.aliases.DefineHookPointAlias*/\n" + "a1\n" + "/* generated by template template*/\n" + "c1\n" + @@ -146,10 +147,10 @@ public void testSimpleDefineHookPoint() throws IOException { glex.bindHookPoint("WithAlternativeAst", new TemplateStringHookPoint("${ast.content}")); templateOut = tc.includeArgs(templateName, ast, Collections.singletonList(alternativeAst)); - Assertions.assertEquals("a1\n" + + assertEquals("a1\n" + "c1\n" + "c2", templateOut.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -161,7 +162,7 @@ public void testDefineHookPointWithDefaultAlias() throws IOException { StringBuilder templateOut = tc.includeArgs(templateName, ast, Collections.singletonList(alternativeAst)); - Assertions.assertEquals("default text 1\n" + + assertEquals("default text 1\n" + "default text 2\n" + "default text 3", templateOut.toString().replaceAll("\r", "")); @@ -170,7 +171,7 @@ public void testDefineHookPointWithDefaultAlias() throws IOException { glex.bindHookPoint("WithoutAst", new StringHookPoint("a1")); templateOut = tc.includeArgs(templateName, ast, Collections.singletonList(alternativeAst)); - Assertions.assertEquals("a1\n" + + assertEquals("a1\n" + "default text 2\n" + "default text 3", templateOut.toString().replaceAll("\r", "")); @@ -178,17 +179,17 @@ public void testDefineHookPointWithDefaultAlias() throws IOException { glex.bindHookPoint("WithAst", new TemplateStringHookPoint("${ast.content}")); templateOut = tc.includeArgs(templateName, ast, Collections.singletonList(alternativeAst)); - Assertions.assertEquals("a1\n" + + assertEquals("a1\n" + "c1\n" + "default text 3", templateOut.toString().replaceAll("\r", "")); glex.bindHookPoint("WithAlternativeAst", new TemplateStringHookPoint("${ast.content}")); templateOut = tc.includeArgs(templateName, ast, Collections.singletonList(alternativeAst)); - Assertions.assertEquals("a1\n" + + assertEquals("a1\n" + "c1\n" + "c2", templateOut.toString().replaceAll("\r", "")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -203,12 +204,12 @@ public void testBindHookPointAlias(){ StringBuilder templateOut = tc.includeArgs(templateName, ast, Arrays.asList(alternativeAst)); - Assertions.assertEquals("/* generated by template de.monticore.generating.templateengine.templates.aliases.BindHookPointAlias*/\n" + + assertEquals("/* generated by template de.monticore.generating.templateengine.templates.aliases.BindHookPointAlias*/\n" + "/* generated by template de.monticore.generating.templateengine.templates.aliases.DefineHookPointAlias*/\n" + "bound\n" + "/* Hookpoint: WithAst */\n" + "/* Hookpoint: WithAlternativeAst */", templateOut.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -222,14 +223,14 @@ public void testRequiredGlobalVarValid() { glex.getGlobalData().remove("a"); } - Assertions.assertTrue(LogStub.getPrints().isEmpty(), "Log not empty!\n" + LogStub.getPrints()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(LogStub.getPrints().isEmpty(), "Log not empty!\n" + LogStub.getPrints()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testRequiredGlobalVarInvalid() { tc.include(ALIASES_PACKAGE + "RequiredGlobalVarAlias"); - Assertions.assertFalse(LogStub.getPrints().isEmpty(), "Log is empty but error was expected!"); + assertFalse(LogStub.getPrints().isEmpty(), "Log is empty but error was expected!"); } @@ -248,8 +249,8 @@ public void testRequiredGlobalVarsValid() { glex.getGlobalData().remove("c"); } - Assertions.assertTrue(LogStub.getPrints().isEmpty(), "Log not empty!\n" + LogStub.getPrints()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(LogStub.getPrints().isEmpty(), "Log not empty!\n" + LogStub.getPrints()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -257,12 +258,12 @@ public void testRequiredGlobalVarsInvalid() { StringBuilder templateOut = tc.include(ALIASES_PACKAGE + "RequiredGlobalVarsAlias"); - Assertions.assertFalse(LogStub.getPrints().isEmpty(), "Log empty, expected error"); + assertFalse(LogStub.getPrints().isEmpty(), "Log empty, expected error"); } @Test public void testLogAliases() { - Assertions.assertTrue(config.getAliases().isEmpty()); + assertTrue(config.getAliases().isEmpty()); tc.include(ALIASES_PACKAGE + "LogAliases"); assertAliases(tc, NUMBER_ALIASES); @@ -272,7 +273,7 @@ public void testLogAliases() { "Error Message" ); - Assertions.assertEquals(3, LogStub.getPrints().size()); + assertEquals(3, LogStub.getPrints().size()); assertErrors(expectedLogs, LogStub.getPrints()); } @@ -282,24 +283,24 @@ public void testLogAliases() { public void testExistsHookPoint(){ StringBuilder templateOut = tc.include(ALIASES_PACKAGE + "ExistsHookPointAlias"); - Assertions.assertEquals("false\nfalse", templateOut.toString()); + assertEquals("false\nfalse", templateOut.toString()); config.getGlex().bindHookPoint("hp1", new StringHookPoint("a")); templateOut = tc.include(ALIASES_PACKAGE + "ExistsHookPointAlias"); - Assertions.assertEquals("true\nfalse", templateOut.toString()); + assertEquals("true\nfalse", templateOut.toString()); config.getGlex().bindHookPoint("hp2", new StringHookPoint("a")); templateOut = tc.include(ALIASES_PACKAGE + "ExistsHookPointAlias"); - Assertions.assertEquals("true\ntrue", templateOut.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("true\ntrue", templateOut.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testAddToGlobalVarsAliasUndefinedVariable(){ tc.include(ALIASES_PACKAGE + "AddToGlobalVarAlias"); - Assertions.assertTrue(LogStub.getPrints().stream().anyMatch(s -> s.contains("0xA8124"))); + assertTrue(LogStub.getPrints().stream().anyMatch(s -> s.contains("0xA8124"))); } @Test @@ -310,18 +311,18 @@ public void testAddToGlobalVarsAliasValid(){ tc.include(ALIASES_PACKAGE + "AddToGlobalVarAlias"); - Assertions.assertTrue(LogStub.getPrints().isEmpty()); + assertTrue(LogStub.getPrints().isEmpty()); List aList = (List) glex.getGlobalVar("a"); List bList = (List) glex.getGlobalVar("b"); - Assertions.assertEquals(2, aList.size()); - Assertions.assertEquals(1, bList.size()); + assertEquals(2, aList.size()); + assertEquals(1, bList.size()); - Assertions.assertEquals("item 1", aList.get(0)); - Assertions.assertEquals("item 2", aList.get(1)); - Assertions.assertEquals("item 3", bList.get(0)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("item 1", aList.get(0)); + assertEquals("item 2", aList.get(1)); + assertEquals("item 3", bList.get(0)); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -331,8 +332,8 @@ public void testChangeGlobalVarAlias(){ tc.include(ALIASES_PACKAGE + "ChangeGlobalVarAlias"); - Assertions.assertEquals("changed", glex.getGlobalVar("a")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("changed", glex.getGlobalVar("a")); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -343,8 +344,8 @@ public void testDefineGlobalVarAliasValid(){ glex.requiredGlobalVar("a"); - Assertions.assertTrue(LogStub.getPrints().isEmpty(), "Log is not empty, messages: " + LogStub.getPrints()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(LogStub.getPrints().isEmpty(), "Log is not empty, messages: " + LogStub.getPrints()); + assertTrue(Log.getFindings().isEmpty()); } @@ -354,7 +355,7 @@ public void testDefineGlobalVarAliasExistsAlready(){ glex.defineGlobalVar("a", "?"); tc.include(ALIASES_PACKAGE + "DefineGlobalVarAlias"); - Assertions.assertFalse(LogStub.getPrints().isEmpty()); + assertFalse(LogStub.getPrints().isEmpty()); } @Test @@ -364,9 +365,9 @@ public void testGetGlobalVarAliasValid(){ StringBuilder templateOut = tc.include(ALIASES_PACKAGE + "GetGlobalVarAlias"); - Assertions.assertEquals("value", templateOut.toString()); - Assertions.assertTrue(LogStub.getPrints().isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("value", templateOut.toString()); + assertTrue(LogStub.getPrints().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -374,8 +375,8 @@ public void testGetGlobalVarAliasInvalid(){ StringBuilder templateOut = tc.include(ALIASES_PACKAGE + "GetGlobalVarAlias"); - Assertions.assertEquals("unset", templateOut.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("unset", templateOut.toString()); + assertTrue(Log.getFindings().isEmpty()); } @@ -392,15 +393,15 @@ private static void assertErrors(Collection expectedErrors, String actualErrorsJoined = "\nactual Errors: \n\t" + Joiner.on("\n\t").join(actualErrors); for (String expectedError : expectedErrors) { boolean found = actualErrors.stream().filter(s -> s.contains(expectedError)).count() >= 1; - Assertions.assertTrue(found, "The following expected error was not found: " + expectedError + assertTrue(found, "The following expected error was not found: " + expectedError + actualErrorsJoined); } } private void assertAliases(TemplateController tc, int expectedNumberAliases) { List aliases = config.getAliases(); - Assertions.assertNotNull(aliases); - Assertions.assertEquals(expectedNumberAliases, aliases.size()); + assertNotNull(aliases); + assertEquals(expectedNumberAliases, aliases.size()); } public static class AliasTestASTNodeMock extends ASTCNode { diff --git a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerHookPointsTest.java b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerHookPointsTest.java index 735b737307..7d5ce22051 100644 --- a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerHookPointsTest.java +++ b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerHookPointsTest.java @@ -3,6 +3,7 @@ package de.monticore.generating.templateengine; import static de.monticore.generating.templateengine.TestConstants.TEMPLATE_PACKAGE; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.io.IOException; @@ -15,7 +16,6 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -58,8 +58,8 @@ public static void resetFileReaderWriter() { @Test public void testUndefinedHook() { tc.getGeneratorSetup().setTracing(true); - Assertions.assertEquals("/* Hookpoint: hp1 */", glex.defineHookPoint(tc, "hp1")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("/* Hookpoint: hp1 */", glex.defineHookPoint(tc, "hp1")); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -67,11 +67,11 @@ public void testDefaultHook() { tc.getGeneratorSetup().setTracing(false); String hpValue; hpValue = glex.defineHookPointWithDefault(tc, "hp1", "default"); - Assertions.assertEquals("default", hpValue); + assertEquals("default", hpValue); glex.bindHookPoint("hp1", new StringHookPoint("value of hp1")); hpValue = glex.defineHookPointWithDefault(tc, "hp1", "default"); - Assertions.assertEquals("value of hp1", hpValue); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("value of hp1", hpValue); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -82,22 +82,22 @@ public void testSetStringHook() { // define new hook point hp1 glex.bindHookPoint("hp1", new StringHookPoint("value of hp1")); hpValue = glex.defineHookPoint(tc, "hp1"); - Assertions.assertNotNull(hpValue); - Assertions.assertEquals("value of hp1", hpValue); + assertNotNull(hpValue); + assertEquals("value of hp1", hpValue); // overwrite value of hook point hp1 glex.bindHookPoint("hp1", new StringHookPoint("new value of hp1")); hpValue = glex.defineHookPoint(tc, "hp1"); - Assertions.assertNotNull(hpValue); - Assertions.assertEquals("new value of hp1", hpValue); + assertNotNull(hpValue); + assertEquals("new value of hp1", hpValue); // define new hook point hp2 glex.bindHookPoint("hp2", new StringHookPoint("value of hp2")); hpValue = glex.defineHookPoint(tc, "hp2"); - Assertions.assertNotNull(hpValue); - Assertions.assertEquals("value of hp2", hpValue); + assertNotNull(hpValue); + assertEquals("value of hp2", hpValue); // hp1 still exists - Assertions.assertEquals("new value of hp1", glex.defineHookPoint(tc, "hp1")); + assertEquals("new value of hp1", glex.defineHookPoint(tc, "hp1")); } @@ -108,22 +108,22 @@ public void testSetTemplateHook() { // define new hook point hp1 glex.bindHookPoint("hp1", new TemplateHookPoint(TEMPLATE_PACKAGE + "HelloWorld")); hpValue = glex.defineHookPoint(tc, "hp1"); - Assertions.assertNotNull(hpValue); - Assertions.assertEquals("Hello World!", hpValue); + assertNotNull(hpValue); + assertEquals("Hello World!", hpValue); // overwrite value of hook point hp1 glex.bindHookPoint("hp1", new TemplateHookPoint(TEMPLATE_PACKAGE + "HowAreYou")); hpValue = glex.defineHookPoint(tc, "hp1"); - Assertions.assertNotNull(hpValue); - Assertions.assertEquals("How Are You?", hpValue); + assertNotNull(hpValue); + assertEquals("How Are You?", hpValue); // define new hook point hp2 glex.bindHookPoint("hp2", new TemplateHookPoint(TEMPLATE_PACKAGE + "HelloWorld")); hpValue = glex.defineHookPoint(tc, "hp2"); - Assertions.assertNotNull(hpValue); - Assertions.assertEquals("Hello World!", hpValue); + assertNotNull(hpValue); + assertEquals("Hello World!", hpValue); // hp1 still exists - Assertions.assertEquals("How Are You?", glex.defineHookPoint(tc, "hp1")); + assertEquals("How Are You?", glex.defineHookPoint(tc, "hp1")); } @Test @@ -134,24 +134,24 @@ public void testSetCodeHook() { CodeHookPointMock command = new CodeHookPointMock("command1"); glex.bindHookPoint("hp1", command); hpValue = glex.defineHookPoint(tc, "hp1"); - Assertions.assertNotNull(hpValue); - Assertions.assertEquals("command1", hpValue); + assertNotNull(hpValue); + assertEquals("command1", hpValue); // overwrite value of hook point hp1 command = new CodeHookPointMock("command2"); glex.bindHookPoint("hp1", command); hpValue = glex.defineHookPoint(tc, "hp1"); - Assertions.assertNotNull(hpValue); - Assertions.assertEquals("command2", hpValue); + assertNotNull(hpValue); + assertEquals("command2", hpValue); // overwrite value of hook point hp1 command = new CodeHookPointMock("command3"); glex.bindHookPoint("hp2", command); hpValue = glex.defineHookPoint(tc, "hp2"); - Assertions.assertNotNull(hpValue); - Assertions.assertEquals("command3", hpValue); + assertNotNull(hpValue); + assertEquals("command3", hpValue); // hp1 still exists - Assertions.assertEquals("command2", glex.defineHookPoint(tc, "hp1")); + assertEquals("command2", glex.defineHookPoint(tc, "hp1")); } @Test @@ -159,51 +159,51 @@ public void testStringTemplateCodeHookCombinations() { final String hp = "hp"; glex.bindHookPoint(hp, new StringHookPoint("StringHook")); - Assertions.assertEquals("StringHook", glex.defineHookPoint(tc, hp)); + assertEquals("StringHook", glex.defineHookPoint(tc, hp)); glex.bindHookPoint(hp, new TemplateHookPoint(TEMPLATE_PACKAGE + "A")); - Assertions.assertEquals("A", glex.defineHookPoint(tc, hp)); + assertEquals("A", glex.defineHookPoint(tc, hp)); CodeHookPointMock command = new CodeHookPointMock("command"); glex.bindHookPoint(hp, command); - Assertions.assertEquals("command", glex.defineHookPoint(tc, hp)); + assertEquals("command", glex.defineHookPoint(tc, hp)); glex.bindHookPoint(hp, new TemplateHookPoint(TEMPLATE_PACKAGE + "A")); - Assertions.assertEquals("A", glex.defineHookPoint(tc, hp)); + assertEquals("A", glex.defineHookPoint(tc, hp)); glex.bindHookPoint(hp, new StringHookPoint("StringHook")); - Assertions.assertEquals("StringHook", glex.defineHookPoint(tc, hp)); + assertEquals("StringHook", glex.defineHookPoint(tc, hp)); } @Test public void testStringHookInSubtemplate() { - Assertions.assertEquals("TopStringHook Hello Brave New World!", tc.include(TEMPLATE_PACKAGE + "TopStringHook").toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("TopStringHook Hello Brave New World!", tc.include(TEMPLATE_PACKAGE + "TopStringHook").toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testTemplateHookInSubtemplate() { - Assertions.assertEquals("TopTemplateHook A", tc.include(TEMPLATE_PACKAGE + "TopTemplateHook").toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("TopTemplateHook A", tc.include(TEMPLATE_PACKAGE + "TopTemplateHook").toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBeforeTemplates() { - Assertions.assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A").toString()); glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); - Assertions.assertEquals("BA", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("BA", tc.include(TEMPLATE_PACKAGE + "A").toString()); // previously set template is overwritten glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A").toString()); // pass a list of templates glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", Arrays.asList( new TemplateHookPoint(TEMPLATE_PACKAGE + "B"), new TemplateHookPoint(TEMPLATE_PACKAGE + "C"))); - Assertions.assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A").toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -211,21 +211,21 @@ public void testSpecificBeforeTemplates() { ASTNode ast1 = new ASTNodeMock(); ASTNode ast2 = new ASTNodeMock(); - Assertions.assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); - Assertions.assertEquals("BA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); - Assertions.assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A", ast2).toString()); + assertEquals("BA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A", ast2).toString()); // previously set template is overwritten glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); - Assertions.assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A", ast2).toString()); + assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A", ast2).toString()); // add a new template glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); - Assertions.assertEquals("CBA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); - Assertions.assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A", ast2).toString()); + assertEquals("CBA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A", ast2).toString()); } @@ -236,7 +236,7 @@ public void testOrderOfBeforeTemplates() { // Add specific template glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Reset glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -245,7 +245,7 @@ public void testOrderOfBeforeTemplates() { // set specific template glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Reset glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -254,7 +254,7 @@ public void testOrderOfBeforeTemplates() { // Add general template glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A").toString()); // Reset glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -263,7 +263,7 @@ public void testOrderOfBeforeTemplates() { // set general template glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A").toString()); // Reset glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -272,7 +272,7 @@ public void testOrderOfBeforeTemplates() { // Add and set specific template glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Reset glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -281,7 +281,7 @@ public void testOrderOfBeforeTemplates() { // Set and add specific template glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Reset glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -290,7 +290,7 @@ public void testOrderOfBeforeTemplates() { // Add and set general template glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("CA", tc.include(TEMPLATE_PACKAGE + "A").toString()); // Reset glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -299,7 +299,7 @@ public void testOrderOfBeforeTemplates() { // Set and add general template glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A").toString()); // Reset glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -308,7 +308,7 @@ public void testOrderOfBeforeTemplates() { // Add specific and general template glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Reset glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -317,17 +317,17 @@ public void testOrderOfBeforeTemplates() { // Add general and specific template glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("CBA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("CBA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Set specific and general template glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("BCA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Set general and specific template glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("CBA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("CBA", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); } @Test @@ -337,7 +337,7 @@ public void testOrderOfAfterTemplates() { // Add specific template glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Reset glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -346,7 +346,7 @@ public void testOrderOfAfterTemplates() { // set specific template glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("AC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("AC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Reset glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -355,7 +355,7 @@ public void testOrderOfAfterTemplates() { // Add general template glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A").toString()); // Reset glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -364,7 +364,7 @@ public void testOrderOfAfterTemplates() { // set general template glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("AC", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("AC", tc.include(TEMPLATE_PACKAGE + "A").toString()); // Reset glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -373,7 +373,7 @@ public void testOrderOfAfterTemplates() { // Add and set specific template glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("AC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("AC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Reset glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -382,7 +382,7 @@ public void testOrderOfAfterTemplates() { // Set and add specific template glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Reset glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -391,7 +391,7 @@ public void testOrderOfAfterTemplates() { // Add and set general template glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("AC", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("AC", tc.include(TEMPLATE_PACKAGE + "A").toString()); // Reset glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -400,7 +400,7 @@ public void testOrderOfAfterTemplates() { // Set and add general template glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A").toString()); // Reset glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -409,7 +409,7 @@ public void testOrderOfAfterTemplates() { // Add specific and general template glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Reset glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, Lists.newArrayList()); @@ -418,131 +418,131 @@ public void testOrderOfAfterTemplates() { // Add general and specific template glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("ACB", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("ACB", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Set specific and general template glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); // Set general and specific template glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("ACB", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); + assertEquals("ACB", tc.include(TEMPLATE_PACKAGE + "A", ast1).toString()); } @Test public void testAfterTemplates() { - Assertions.assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A").toString()); glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); - Assertions.assertEquals("AB", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("AB", tc.include(TEMPLATE_PACKAGE + "A").toString()); // previously set template is overwritten glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("AC", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("AC", tc.include(TEMPLATE_PACKAGE + "A").toString()); // pass a list of templates glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", Arrays.asList( new TemplateHookPoint(TEMPLATE_PACKAGE + "B"), new TemplateHookPoint(TEMPLATE_PACKAGE + "C"))); - Assertions.assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A").toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testAddAfterTemplates() { - Assertions.assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A").toString()); glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); - Assertions.assertEquals("AB", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("AB", tc.include(TEMPLATE_PACKAGE + "A").toString()); // previously set template is not overwritten glex.addAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("ABC", tc.include(TEMPLATE_PACKAGE + "A").toString()); } @Test public void testReplaceTemplate() { StringBuilder r = tc.include(TEMPLATE_PACKAGE + "A"); - Assertions.assertEquals("A", r.toString()); + assertEquals("A", r.toString()); // self-replacement glex.replaceTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "A")); r = tc.include(TEMPLATE_PACKAGE + "A"); - Assertions.assertEquals("A", r.toString()); + assertEquals("A", r.toString()); glex.replaceTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); r = tc.include(TEMPLATE_PACKAGE + "A"); - Assertions.assertEquals("B", r.toString()); + assertEquals("B", r.toString()); // previously set template is overwritten glex.replaceTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); r = tc.include(TEMPLATE_PACKAGE + "A"); - Assertions.assertEquals("C", r.toString()); + assertEquals("C", r.toString()); // pass a list of templates glex.replaceTemplate(TEMPLATE_PACKAGE + "A", Arrays.asList( new TemplateHookPoint(TEMPLATE_PACKAGE + "B"), new TemplateHookPoint(TEMPLATE_PACKAGE + "C"))); r = tc.include(TEMPLATE_PACKAGE + "A"); - Assertions.assertEquals("BC", r.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("BC", r.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBeforeReplaceAfterCombinations() { - Assertions.assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("A", tc.include(TEMPLATE_PACKAGE + "A").toString()); glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); - Assertions.assertEquals("BA", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("BA", tc.include(TEMPLATE_PACKAGE + "A").toString()); glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("BAC", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("BAC", tc.include(TEMPLATE_PACKAGE + "A").toString()); glex.replaceTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("BCC", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("BCC", tc.include(TEMPLATE_PACKAGE + "A").toString()); glex.replaceTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); - Assertions.assertEquals("BBC", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertEquals("BBC", tc.include(TEMPLATE_PACKAGE + "A").toString()); // replacing B has no effect on A glex.replaceTemplate(TEMPLATE_PACKAGE + "B", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("BBC", tc.include(TEMPLATE_PACKAGE + "A").toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("BBC", tc.include(TEMPLATE_PACKAGE + "A").toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBeforeReplaceAfterInSubtemplates() { - Assertions.assertEquals("TopA A", tc.include(TEMPLATE_PACKAGE + "TopA").toString()); + assertEquals("TopA A", tc.include(TEMPLATE_PACKAGE + "TopA").toString()); glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); - Assertions.assertEquals("TopA BA", tc.include(TEMPLATE_PACKAGE + "TopA").toString()); + assertEquals("TopA BA", tc.include(TEMPLATE_PACKAGE + "TopA").toString()); glex.replaceTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("TopA BC", tc.include(TEMPLATE_PACKAGE + "TopA").toString()); + assertEquals("TopA BC", tc.include(TEMPLATE_PACKAGE + "TopA").toString()); glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); - Assertions.assertEquals("TopA BCB", tc.include(TEMPLATE_PACKAGE + "TopA").toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("TopA BCB", tc.include(TEMPLATE_PACKAGE + "TopA").toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSpecificBeforeReplaceAfterInSubtemplates() { ASTNode ast1 = new ASTNodeMock(); - Assertions.assertEquals("TopA A", tc.include(TEMPLATE_PACKAGE + "TopA").toString()); + assertEquals("TopA A", tc.include(TEMPLATE_PACKAGE + "TopA").toString()); glex.setBeforeTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); - Assertions.assertEquals("TopA BA", tc.include(TEMPLATE_PACKAGE + "TopA", ast1).toString()); + assertEquals("TopA BA", tc.include(TEMPLATE_PACKAGE + "TopA", ast1).toString()); glex.replaceTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "C")); - Assertions.assertEquals("TopA BC", tc.include(TEMPLATE_PACKAGE + "TopA", ast1).toString()); + assertEquals("TopA BC", tc.include(TEMPLATE_PACKAGE + "TopA", ast1).toString()); glex.setAfterTemplate(TEMPLATE_PACKAGE + "A", ast1, new TemplateHookPoint(TEMPLATE_PACKAGE + "B")); - Assertions.assertEquals("TopA BCB", tc.include(TEMPLATE_PACKAGE + "TopA", ast1).toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("TopA BCB", tc.include(TEMPLATE_PACKAGE + "TopA", ast1).toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -550,20 +550,20 @@ public void testTemplateStringHook() throws IOException{ // define new hook point hp1 glex.bindHookPoint("hp1", new TemplateStringHookPoint("<#if true>true")); String hpValue = glex.defineHookPoint(tc, "hp1"); - Assertions.assertNotNull(hpValue); - Assertions.assertEquals("true", hpValue); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertNotNull(hpValue); + assertEquals("true", hpValue); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testDefineHookPointWithArgs() { glex.bindHookPoint("hp1", new TemplateHookPoint(TEMPLATE_PACKAGE + "SignatureWithOneParameter")); String hpValue = glex.defineHookPoint(tc, "hp1", "A"); - Assertions.assertEquals("Name is A", hpValue); + assertEquals("Name is A", hpValue); glex.bindHookPoint("hp1", new TemplateHookPoint(TEMPLATE_PACKAGE + "SignatureWithThreeParameters")); hpValue = glex.defineHookPoint(tc, "hp1", "B", 42, "LA"); - Assertions.assertEquals("Name is B, age is 42, city is LA", hpValue); + assertEquals("Name is B, age is 42, city is LA", hpValue); } @Test @@ -572,11 +572,11 @@ public void testBeforeHookpoint() { // without binding glex.setBeforeTemplate( "hp", ast1, new StringHookPoint("Before Hookpoint")); - Assertions.assertEquals("Before Hookpoint", tc.include(TEMPLATE_PACKAGE + "HookCall", ast1).toString()); + assertEquals("Before Hookpoint", tc.include(TEMPLATE_PACKAGE + "HookCall", ast1).toString()); // with binding glex.bindHookPoint("hp", new StringHookPoint(":Bind Hookpoint")); - Assertions.assertEquals("Before Hookpoint:Bind Hookpoint", tc.include(TEMPLATE_PACKAGE + "HookCall", ast1).toString()); + assertEquals("Before Hookpoint:Bind Hookpoint", tc.include(TEMPLATE_PACKAGE + "HookCall", ast1).toString()); } @@ -585,7 +585,7 @@ public void testAfterHookpoint() { ASTNode ast1 = new ASTNodeMock(); glex.setAfterTemplate( "hp", ast1, new StringHookPoint("After Hookpoint")); - Assertions.assertEquals("After Hookpoint", tc.include(TEMPLATE_PACKAGE + "HookCall", ast1).toString()); + assertEquals("After Hookpoint", tc.include(TEMPLATE_PACKAGE + "HookCall", ast1).toString()); } } diff --git a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerSignatureUsageTest.java b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerSignatureUsageTest.java index e61a108c7f..bd23f7da18 100644 --- a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerSignatureUsageTest.java +++ b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerSignatureUsageTest.java @@ -3,10 +3,7 @@ package de.monticore.generating.templateengine; import static de.monticore.generating.templateengine.TestConstants.TEMPLATE_PACKAGE; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; @@ -20,7 +17,6 @@ import de.monticore.generating.templateengine.freemarker.MontiCoreFreeMarkerException; import de.monticore.io.FileReaderWriterMock; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -67,8 +63,8 @@ public static void resetFileReaderWriter() { public void testSignatureWithOneParameter() { StringBuilder output = tc.includeArgs(TEMPLATE_PACKAGE + "SignatureWithOneParameter", Lists.newArrayList("Charly")); - Assertions.assertTrue(Log.getFindings().isEmpty()); - Assertions.assertEquals("Name is Charly", output.toString()); + assertTrue(Log.getFindings().isEmpty()); + assertEquals("Name is Charly", output.toString()); } @Test @@ -76,8 +72,8 @@ public void testSignatureWithThreeParameters() { StringBuilder output = tc.includeArgs(TEMPLATE_PACKAGE + "SignatureWithThreeParameters", Lists.newArrayList("Charly", "30", "Aachen")); - Assertions.assertEquals("Name is Charly, age is 30, city is Aachen", output.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("Name is Charly, age is 30, city is Aachen", output.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -85,8 +81,8 @@ public void testSignatureWithManyParameters() { StringBuilder output = tc.includeArgs(TEMPLATE_PACKAGE + "SignatureWithManyParameters", Lists.newArrayList("Charly", "30", "Aachen", "52062", "Engineer", "No friends")); - Assertions.assertEquals("Name=Charly, age=30, city=Aachen, zip=52062, job=Engineer, friends=No friends", output.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("Name=Charly, age=30, city=Aachen, zip=52062, job=Engineer, friends=No friends", output.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -94,8 +90,8 @@ public void testNestedSignatureCalls() { StringBuilder output = tc.includeArgs(TEMPLATE_PACKAGE + "NestedSignatureCalls", Lists.newArrayList("T1")); - Assertions.assertEquals("T1 -> Name is T2", output.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("T1 -> Name is T2", output.toString()); + assertTrue(Log.getFindings().isEmpty()); } @@ -104,11 +100,11 @@ public void testWrongNumberOfArguments() { try { tc.includeArgs(TEMPLATE_PACKAGE + "SignatureWithOneParameter", Lists.newArrayList("Charly", "tooMuch")); - Assertions.fail("Argument list is too long."); + fail("Argument list is too long."); } catch (MontiCoreFreeMarkerException e) { - Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + assertTrue(e.getCause() instanceof IllegalArgumentException); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Disabled @@ -117,8 +113,8 @@ public void testArgumentsAreOnlyVisibleInIncludedTemplate() { StringBuilder templateOutput = tc.includeArgs(TEMPLATE_PACKAGE + "ArgumentsAreOnlyVisibleInIncludedTemplate", Lists.newArrayList("Charly")); - Assertions.assertEquals("Hello Charly\nSorry, what was your name?", templateOutput.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("Hello Charly\nSorry, what was your name?", templateOutput.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -126,9 +122,9 @@ public void testArgumentsAreOnlyVisibleInIncludedTemplate() { public void testParameterizedInclusionUsage() { StringBuilder templateOutput = tc.include(TEMPLATE_PACKAGE + "ParameterizedInclusionUsage"); - Assertions.assertEquals("Name is Charly\n" + + assertEquals("Name is Charly\n" + "Name is Charly, age is 30, city is Aachen\n" + "Name=Charly, age=30, city=Aachen, zip=52062, job=Engineer, friends=No friends", templateOutput.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } \ No newline at end of file diff --git a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerTest.java b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerTest.java index fe6b043150..751a9b1079 100644 --- a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerTest.java +++ b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateControllerTest.java @@ -13,7 +13,6 @@ import de.se_rwth.commons.logging.LogStub; import freemarker.template.Template; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -26,6 +25,7 @@ import java.util.List; import static de.monticore.generating.templateengine.TestConstants.TEMPLATE_PACKAGE; +import static org.junit.jupiter.api.Assertions.*; /** * Tests for {@link TemplateController}. @@ -73,17 +73,17 @@ public static void resetFileReaderWriter() { @Disabled @Test public void testImplicitAstPassing() { - Assertions.assertNull(tc.getAST()); + assertNull(tc.getAST()); tc.include(TEMPLATE_PACKAGE + "A"); - Assertions.assertNull(tc.getAST()); + assertNull(tc.getAST()); // pass ast explicit tc.include(TEMPLATE_PACKAGE + "A", ASTNodeMock.INSTANCE); - Assertions.assertNotNull(tc.getAST()); - Assertions.assertSame(ASTNodeMock.INSTANCE, tc.getAST()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertNotNull(tc.getAST()); + assertSame(ASTNodeMock.INSTANCE, tc.getAST()); + assertTrue(Log.getFindings().isEmpty()); } @@ -92,19 +92,19 @@ public void testWriteArgs() { String TEMPLATE_NAME = "the.Template"; tc.writeArgs(TEMPLATE_NAME, "path.to.file", ".ext", ASTNodeMock.INSTANCE, new ArrayList<>()); - Assertions.assertEquals(1, freeMarkerTemplateEngine.getProcessedTemplates().size()); + assertEquals(1, freeMarkerTemplateEngine.getProcessedTemplates().size()); FreeMarkerTemplateMock template = freeMarkerTemplateEngine.getProcessedTemplates().iterator() .next(); - Assertions.assertTrue(template.isProcessed()); - Assertions.assertEquals(TEMPLATE_NAME, template.getName()); - Assertions.assertNotNull(template.getData()); + assertTrue(template.isProcessed()); + assertEquals(TEMPLATE_NAME, template.getName()); + assertNotNull(template.getData()); - Assertions.assertEquals(1, fileHandler.getStoredFilesAndContents().size()); + assertEquals(1, fileHandler.getStoredFilesAndContents().size()); Path writtenFilePath = Paths.get(TARGET_DIR.getAbsolutePath(), "path/to/file.ext"); - Assertions.assertTrue(fileHandler.getStoredFilesAndContents().containsKey(writtenFilePath)); - Assertions.assertEquals("Content of template: " + TEMPLATE_NAME, fileHandler.getContentForFile(writtenFilePath.toString()).get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(fileHandler.getStoredFilesAndContents().containsKey(writtenFilePath)); + assertEquals("Content of template: " + TEMPLATE_NAME, fileHandler.getContentForFile(writtenFilePath.toString()).get()); + assertTrue(Log.getFindings().isEmpty()); } @@ -123,10 +123,10 @@ public void testDefaultMethods() { DefaultImpl def = new DefaultImpl(); StringBuilder result = tc .includeArgs(TEMPLATE_PACKAGE + "DefaultMethodCall", Lists.newArrayList(def)); - Assertions.assertNotNull(result); - Assertions.assertEquals("A", result.toString().trim()); + assertNotNull(result); + assertEquals("A", result.toString().trim()); FileReaderWriter.init(); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -150,11 +150,11 @@ public void testBlacklisteTemplatesI() throws IOException { // configure Template Controller with black list tc.setTemplateBlackList(blackList); - Assertions.assertEquals(1, tc.getTemplateBlackList().size()); - Assertions.assertFalse(tc.isTemplateNoteGenerated(templateI)); - Assertions.assertTrue(tc.isTemplateNoteGenerated(templateII)); + assertEquals(1, tc.getTemplateBlackList().size()); + assertFalse(tc.isTemplateNoteGenerated(templateI)); + assertTrue(tc.isTemplateNoteGenerated(templateII)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -176,10 +176,10 @@ public void testBlacklistTemplatesII() throws IOException { Template templateII = new Template(templateNameII, "", null); - Assertions.assertEquals(1, tc.getTemplateBlackList().size()); - Assertions.assertFalse(tc.isTemplateNoteGenerated(templateI)); - Assertions.assertTrue(tc.isTemplateNoteGenerated(templateII)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(1, tc.getTemplateBlackList().size()); + assertFalse(tc.isTemplateNoteGenerated(templateI)); + assertTrue(tc.isTemplateNoteGenerated(templateII)); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -189,7 +189,7 @@ public void testIncludeArgsDoesNotOverrideParameters() { String result = controller.includeArgs("de.monticore.generating.templateengine.IncludeArgsDoesntOverride1", "a", "b").toString(); - Assertions.assertEquals("aba", result.strip() + assertEquals("aba", result.strip() .replaceAll("\n", "") .replaceAll(" ", "") .replaceAll("/\\*(.)*?\\*/", "")); @@ -207,7 +207,7 @@ public void testParametersOfOuterTemplateNotVisible() { "OuterParametersNotVisible1", "A"); } catch (MontiCoreFreeMarkerException e) { - Assertions.assertTrue(e.getMessage().contains( + assertTrue(e.getMessage().contains( "The following has evaluated to null or missing:\n==> A [in " + "template \"de.monticore.generating.templateengine." + "OuterParametersNotVisible2\" at line 2, column 3]")); @@ -228,7 +228,7 @@ public void testInnerParametersNotVisible() { "A"); } catch (MontiCoreFreeMarkerException e) { - Assertions.assertTrue(e.getMessage().contains("The following has evaluated to " + + assertTrue(e.getMessage().contains("The following has evaluated to " + "null or missing:\n==> B [in template \"de.monticore.generating." + "templateengine.InnerParametersNotVisible1\" at line 4, column 3]")); } diff --git a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateLoggerTest.java b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateLoggerTest.java index 68c4bb7d54..89f6861438 100644 --- a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateLoggerTest.java +++ b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/TemplateLoggerTest.java @@ -3,6 +3,8 @@ package de.monticore.generating.templateengine; import static de.monticore.generating.templateengine.TestConstants.TEMPLATE_PACKAGE; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.File; @@ -10,7 +12,6 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import de.monticore.generating.GeneratorSetup; @@ -70,8 +71,8 @@ public static void resetFileReaderWriter() { @Test public void demonstrateTemplateLogging() { StringBuilder result = tc.include(TEMPLATE_PACKAGE + "Log"); - Assertions.assertNotNull(result); - Assertions.assertEquals("A", result.toString().trim()); + assertNotNull(result); + assertEquals("A", result.toString().trim()); } } diff --git a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/reporting/commons/ReportingStringHelperTest.java b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/reporting/commons/ReportingStringHelperTest.java index 5a50816ba8..c9c2a8ba73 100644 --- a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/reporting/commons/ReportingStringHelperTest.java +++ b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/reporting/commons/ReportingStringHelperTest.java @@ -3,12 +3,13 @@ package de.monticore.generating.templateengine.reporting.commons; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import de.se_rwth.commons.logging.Log; +import static org.junit.jupiter.api.Assertions.*; + public class ReportingStringHelperTest { @BeforeEach @@ -19,25 +20,25 @@ public void before() { @Test public void testReportingStringHelper() { - Assertions.assertFalse(ReportingHelper + assertFalse(ReportingHelper .formatStringToReportingString( "{this.height \n\t= builder.getHeight();this.width = builder.getWidth();addAllPhotoMessages(builder.getPhotoMessages());addAllTags(builder.getTags());}", 60).contains("\t")); - Assertions.assertEquals(60, ReportingHelper + assertEquals(60, ReportingHelper .formatStringToReportingString( "{this.height \n\t= builder.getHeight();this.width = builder.getWidth();addAllPhotoMessages(builder.getPhotoMessages());addAllTags(builder.getTags());}", 60).length()); - Assertions.assertEquals(6, ReportingHelper + assertEquals(6, ReportingHelper .formatStringToReportingString( "abcd", 60).length()); - Assertions.assertEquals(7, ReportingHelper + assertEquals(7, ReportingHelper .formatStringToReportingString( "{this.height \n\t= builder.getHeight();this.width = builder.getWidth();addAllPhotoMessages(builder.getPhotoMessages());addAllTags(builder.getTags());}", 5).length()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/reporting/commons/StatisticsHandlerTest.java b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/reporting/commons/StatisticsHandlerTest.java index e4c0c2c5bd..99a78083d4 100644 --- a/monticore-runtime/src/test/java/de/monticore/generating/templateengine/reporting/commons/StatisticsHandlerTest.java +++ b/monticore-runtime/src/test/java/de/monticore/generating/templateengine/reporting/commons/StatisticsHandlerTest.java @@ -1,10 +1,9 @@ package de.monticore.generating.templateengine.reporting.commons; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class StatisticsHandlerTest { @Test @@ -12,7 +11,7 @@ public void validSHash() { String content = "SomeString with many characters? + ?+._ü1^^"; String SHASH = StatisticsHandler.getSHASH(content); - Assertions.assertTrue(StatisticsHandler.isValidSHASH(SHASH, content)); + assertTrue(StatisticsHandler.isValidSHASH(SHASH, content)); } @Test public void invalidSHash() { @@ -20,7 +19,7 @@ public void invalidSHash() { String SHASH = StatisticsHandler.getSHASH(content); String differentContent = "AnotjherString"; - Assertions.assertFalse(StatisticsHandler.isValidSHASH(SHASH, differentContent)); + assertFalse(StatisticsHandler.isValidSHASH(SHASH, differentContent)); } } \ No newline at end of file diff --git a/monticore-runtime/src/test/java/de/monticore/io/FileFinderTest.java b/monticore-runtime/src/test/java/de/monticore/io/FileFinderTest.java index 6575d7bb80..fe9df9a93e 100644 --- a/monticore-runtime/src/test/java/de/monticore/io/FileFinderTest.java +++ b/monticore-runtime/src/test/java/de/monticore/io/FileFinderTest.java @@ -6,7 +6,6 @@ import de.se_rwth.commons.Names; import de.se_rwth.commons.logging.Log; import org.apache.commons.io.filefilter.RegexFileFilter; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -21,8 +20,8 @@ import java.util.Optional; import java.util.stream.Collectors; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class FileFinderTest { @@ -47,9 +46,9 @@ public void testGetFiles1() { entries.add(Paths.get("src","test","resources")); MCPath mp = new MCPath(entries); List files = find(mp, qualifiedModelName, fileExt); - Assertions.assertEquals(4, files.size()); + assertEquals(4, files.size()); List absolutePath = files.stream().map(f ->f.toString()).collect(Collectors.toList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -62,9 +61,9 @@ public void testGetFiles2() { entries.add(Paths.get("src", "test", "resources")); MCPath mp = new MCPath(entries); Optional file = mp.find(qualifiedModelName, fileExt); - Assertions.assertTrue(file.isPresent()); - Assertions.assertTrue(file.get().toString().endsWith("de/monticore/io/Model2.mc4")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(file.isPresent()); + assertTrue(file.get().toString().endsWith("de/monticore/io/Model2.mc4")); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -78,7 +77,7 @@ public void testGetFiles3() { MCPath mp = new MCPath(entries); Optional url = mp.find(qualifiedModelName, fileExt); assertFalse(url.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private void assertFalse(boolean present) { @@ -94,11 +93,11 @@ public void testGetFiles4() { entries.add(Paths.get("src","test","resources")); MCPath mp = new MCPath(entries); List files = find(mp, qualifiedModelName, fileExt); - Assertions.assertEquals(2, files.size()); + assertEquals(2, files.size()); List absolutePath = files.stream().map(f ->f.toString()).collect(Collectors.toList()); - Assertions.assertTrue(absolutePath.get(0).endsWith("de/monticore/io/Model1.cdsym")); - Assertions.assertTrue(absolutePath.get(1).endsWith("de/monticore/io/Model1.cdsym")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(absolutePath.get(0).endsWith("de/monticore/io/Model1.cdsym")); + assertTrue(absolutePath.get(1).endsWith("de/monticore/io/Model1.cdsym")); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -112,7 +111,7 @@ public void testGetFiles5() { MCPath mp = new MCPath(entries); Optional url = mp.find(qualifiedModelName, fileExt); assertFalse(url.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -125,9 +124,9 @@ public void testGetFiles6(){ entries.add(Paths.get("src","test","resources")); MCPath mp = new MCPath(entries); List files = find(mp, qualifiedModelName, fileExt); - Assertions.assertEquals(4, files.size()); + assertEquals(4, files.size()); List absolutePath = files.stream().map(f ->f.toString()).collect(Collectors.toList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -141,7 +140,7 @@ public void testGetFiles7() { MCPath mp = new MCPath(entries); Optional url = mp.find(qualifiedModelName, fileExt); assertFalse(url.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -154,8 +153,8 @@ public void testGetFiles8() { entries.add(Paths.get("src","test","resources")); MCPath mp = new MCPath(entries); List files = find(mp, qualifiedModelName, fileExt); - Assertions.assertEquals(0, files.size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(0, files.size()); + assertTrue(Log.getFindings().isEmpty()); } @@ -169,7 +168,7 @@ public void testFindFiles1() { entries.add(Paths.get("src","test","resources")); MCPath mp = new MCPath(entries); Optional files = mp.find(qualifiedModelName, fileExt); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith("0xA1294")); + assertTrue(Log.getFindings().get(0).getMsg().startsWith("0xA1294")); } @@ -183,8 +182,8 @@ public void testFindFiles2() { entries.add(Paths.get("src","test","resources")); MCPath mp = new MCPath(entries); Optional files = mp.find(qualifiedModelName, fileExt); - Assertions.assertTrue(files.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(files.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -198,7 +197,7 @@ public void testFindFiles3() { MCPath mp = new MCPath(entries); Optional files = mp.find(qualifiedModelName, fileExt); assertFalse(files.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -212,7 +211,7 @@ public void testFindFiles4() { MCPath mp = new MCPath(entries); Optional files = mp.find(qualifiedModelName, fileExt); assertFalse(files.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @@ -226,8 +225,8 @@ public void testFindFiles5() { entries.add(Paths.get("src","test","resources")); MCPath mp = new MCPath(entries); List files = find(mp, qualifiedModelName, fileExt); - Assertions.assertEquals(2, files.size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(2, files.size()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -240,7 +239,7 @@ public void testFindFile1() { entries.add(Paths.get("src","test","resources")); MCPath mp = new MCPath(entries); Optional files = mp.find(qualifiedModelName, fileExt); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith("0xA1294")); + assertTrue(Log.getFindings().get(0).getMsg().startsWith("0xA1294")); } @Test @@ -253,8 +252,8 @@ public void testFindFile2() { entries.add(Paths.get("src","test","resources")); MCPath mp = new MCPath(entries); Optional files = mp.find(qualifiedModelName, fileExt); - Assertions.assertTrue(files.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(files.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -268,7 +267,7 @@ public void testFindFile3() { MCPath mp = new MCPath(entries); Optional files = mp.find(qualifiedModelName, fileExt); assertFalse(files.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -282,7 +281,7 @@ public void testFindFile4() { MCPath mp = new MCPath(entries); Optional files = mp.find(qualifiedModelName, fileExt); assertFalse(files.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } public List find(MCPath mp, String qualifiedName, String fileExtRegEx) { diff --git a/monticore-runtime/src/test/java/de/monticore/io/FileReaderWriterTest.java b/monticore-runtime/src/test/java/de/monticore/io/FileReaderWriterTest.java index e5f2240e83..f796ec25f3 100644 --- a/monticore-runtime/src/test/java/de/monticore/io/FileReaderWriterTest.java +++ b/monticore-runtime/src/test/java/de/monticore/io/FileReaderWriterTest.java @@ -2,9 +2,6 @@ package de.monticore.io; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -13,10 +10,12 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class FileReaderWriterTest { Path testPath = Paths.get("target/test/FileHandlertest.txt"); @@ -46,8 +45,8 @@ public void tearDown() { public void testFileHandler() { FileReaderWriter.init(); FileReaderWriter.storeInFile(testPath, testContent); - Assertions.assertEquals(testContent, FileReaderWriter.readFromFile(testPath)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(testContent, FileReaderWriter.readFromFile(testPath)); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-runtime/src/test/java/de/monticore/io/paths/MCPathTest.java b/monticore-runtime/src/test/java/de/monticore/io/paths/MCPathTest.java index d20209787c..509e442d07 100644 --- a/monticore-runtime/src/test/java/de/monticore/io/paths/MCPathTest.java +++ b/monticore-runtime/src/test/java/de/monticore/io/paths/MCPathTest.java @@ -3,7 +3,6 @@ import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -25,6 +24,8 @@ import java.util.stream.Collectors; import java.util.zip.ZipEntry; +import static org.junit.jupiter.api.Assertions.*; + public class MCPathTest { @BeforeEach @@ -43,11 +44,11 @@ public void testFindWithOneArgument(){ mp.addEntry(Paths.get("src/test/resources/jar/Test.jar")); Optional fileInJar = mp.find("de/monticore/MCBasics.mc4"); - Assertions.assertTrue(logback.isPresent()); - Assertions.assertTrue(grammar.isPresent()); - Assertions.assertTrue(fileInJar.isPresent()); - Assertions.assertFalse(nonExistent.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(logback.isPresent()); + assertTrue(grammar.isPresent()); + assertTrue(fileInJar.isPresent()); + assertFalse(nonExistent.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -61,22 +62,22 @@ public void testFindWithTwoArguments(){ Optional grammar2 = mp.find("de.monticore.io.Model3", ".*4"); Optional nonExistent2 = mp.find("Test", "m.4"); - Assertions.assertTrue(logback.isPresent()); - Assertions.assertTrue(grammar.isPresent()); - Assertions.assertFalse(nonExistent.isPresent()); + assertTrue(logback.isPresent()); + assertTrue(grammar.isPresent()); + assertFalse(nonExistent.isPresent()); - Assertions.assertTrue(logback2.isPresent()); - Assertions.assertTrue(grammar2.isPresent()); - Assertions.assertFalse(nonExistent2.isPresent()); + assertTrue(logback2.isPresent()); + assertTrue(grammar2.isPresent()); + assertFalse(nonExistent2.isPresent()); mp.addEntry(Paths.get("src/test/resources/jar/Test.jar")); Optional fileInJar = mp.find("de.monticore.MCBasics", "mc4"); Optional fileInJar2 = mp.find("de.monticore.MCBasics", "m.4"); Optional fileNotInJar = mp.find("MCBasics", "m.4"); - Assertions.assertTrue(fileInJar.isPresent()); - Assertions.assertTrue(fileInJar2.isPresent()); - Assertions.assertFalse(fileNotInJar.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(fileInJar.isPresent()); + assertTrue(fileInJar2.isPresent()); + assertFalse(fileNotInJar.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -85,10 +86,10 @@ public void testAddEntry(){ Path resources = Paths.get("src/test/resources"); Path models = Paths.get("src/test/models"); mp.addEntry(resources); - Assertions.assertEquals(1, mp.getEntries().size()); + assertEquals(1, mp.getEntries().size()); mp.addEntry(models); - Assertions.assertEquals(2, mp.getEntries().size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(2, mp.getEntries().size()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -96,10 +97,10 @@ public void testRemoveEntry(){ MCPath mp = new MCPath(); Path resources = Paths.get("src/test/resources"); mp.addEntry(resources); - Assertions.assertEquals(1, mp.getEntries().size()); + assertEquals(1, mp.getEntries().size()); mp.removeEntry(resources); - Assertions.assertTrue(mp.isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(mp.isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -112,23 +113,23 @@ public void testGetEntries(){ mp.addEntry(models); mp.addEntry(java); Collection paths = mp.getEntries(); - Assertions.assertEquals(3, paths.size()); - Assertions.assertTrue(paths.contains(resources.toAbsolutePath())); - Assertions.assertTrue(paths.contains(models.toAbsolutePath())); - Assertions.assertTrue(paths.contains(java.toAbsolutePath())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(3, paths.size()); + assertTrue(paths.contains(resources.toAbsolutePath())); + assertTrue(paths.contains(models.toAbsolutePath())); + assertTrue(paths.contains(java.toAbsolutePath())); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testIsEmpty(){ MCPath mp = new MCPath(); - Assertions.assertTrue(mp.isEmpty()); + assertTrue(mp.isEmpty()); Path resources = Paths.get("src/test/resources"); mp.addEntry(resources); - Assertions.assertFalse(mp.isEmpty()); + assertFalse(mp.isEmpty()); mp.removeEntry(resources); - Assertions.assertTrue(mp.isEmpty()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(mp.isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -138,9 +139,9 @@ public void testToString() throws MalformedURLException { Path models = Paths.get("src/test/models"); mp.addEntry(resources); mp.addEntry(models); - Assertions.assertEquals("[" + resources.toUri().toURL().toString() + ", " + assertEquals("[" + resources.toUri().toURL().toString() + ", " + models.toUri().toURL().toString() + "]", mp.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -148,18 +149,18 @@ public void testToPath() throws MalformedURLException { Path resources = Paths.get("src/test/resources"); URL url = resources.toUri().toURL(); Optional result = MCPath.toPath(url); - Assertions.assertTrue(result.isPresent()); - Assertions.assertEquals(result.get(), resources.toAbsolutePath()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(result.isPresent()); + assertEquals(result.get(), resources.toAbsolutePath()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testToURL() throws URISyntaxException { Path resources = Paths.get("src/test/resources"); Optional result = MCPath.toURL(resources); - Assertions.assertTrue(result.isPresent()); - Assertions.assertEquals(result.get().toURI(), resources.toUri()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(result.isPresent()); + assertEquals(result.get().toURI(), resources.toUri()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -170,8 +171,8 @@ public void testReportAmbiguity() throws MalformedURLException { urlList.add(resources); MCPath.reportAmbiguity(urlList, "src/test/resources"); List findings = Log.getFindings().stream().filter(f -> f.getMsg().startsWith("0xA1294")).collect(Collectors.toList()); - Assertions.assertEquals(1, findings.size()); - Assertions.assertEquals("0xA1294 The following entries for the file `" + "src/test/resources" + "` are ambiguous:" + assertEquals(1, findings.size()); + assertEquals("0xA1294 The following entries for the file `" + "src/test/resources" + "` are ambiguous:" + "\n" + "{" + resources.toString() + ",\n" + resources.toString() + "}", findings.get(0).getMsg()); } @Test @@ -180,22 +181,22 @@ public void testReportAmbiguity() throws MalformedURLException { public void testShouldFind(){ String jdk = System.getenv("JAVA_HOME").replaceAll("\\\\", "/") + "/jre/lib/rt.jar"; MCPath mp = new MCPath(jdk); - Assertions.assertTrue(mp.find("java/util/List.class").isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(mp.find("java/util/List.class").isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testShouldNotFind(){ MCPath mp = new MCPath(""); - Assertions.assertFalse(mp.find("java/util/List.class").isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(mp.find("java/util/List.class").isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testShouldNotFind2(){ MCPath mp = new MCPath("this/is/a/test"); - Assertions.assertFalse(mp.find("java/util/List.class").isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(mp.find("java/util/List.class").isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -204,13 +205,13 @@ public void testCachedAmbiguous() { Log.clearFindings(); MCPath path = new MCPath(); path.addEntry(Paths.get("src/test/resources/paths/1/a")); - Assertions.assertTrue(path.find("AFile", "txt").isPresent()); - Assertions.assertEquals(0, Log.getErrorCount()); + assertTrue(path.find("AFile", "txt").isPresent()); + assertEquals(0, Log.getErrorCount()); path.addEntry(Paths.get("src/test/resources/paths/2/a")); - Assertions.assertTrue(path.find("AFile", "txt").isEmpty()); + assertTrue(path.find("AFile", "txt").isEmpty()); List findings = Log.getFindings().stream().filter(f -> f.getMsg().startsWith("0xA1294")).collect(Collectors.toList()); - Assertions.assertEquals(1, findings.size()); - Assertions.assertEquals("0xA1294 The following entries for the file `" + "AFile\\.txt" + "` are ambiguous:" + assertEquals(1, findings.size()); + assertEquals("0xA1294 The following entries for the file `" + "AFile\\.txt" + "` are ambiguous:" + "\n" + "{" + Paths.get("src/test/resources/paths/1/a/AFile.txt").toUri().toString().replaceAll("///","/") + ",\n" + Paths.get("src/test/resources/paths/2/a/AFile.txt").toUri().toString().replaceAll("///","/") + "}", findings.get(0).getMsg()); } @@ -235,10 +236,10 @@ public void testCachedSym(@TempDir File tempF) throws IOException { MCPath path = new MCPath(); path.addEntry(jar.toPath()); - Assertions.assertTrue(path.find("de.mc.A", ".*sym").isPresent(), "Finding a qualified file failed"); - Assertions.assertTrue(path.find("B", ".*sym").isPresent(), "Finding an unqualified file failed"); + assertTrue(path.find("de.mc.A", ".*sym").isPresent(), "Finding a qualified file failed"); + assertTrue(path.find("B", ".*sym").isPresent(), "Finding an unqualified file failed"); path.removeEntry(jar.toPath()); - Assertions.assertFalse(path.find("de.mc.A", ".*sym").isPresent(), "removeEntry was not completed"); + assertFalse(path.find("de.mc.A", ".*sym").isPresent(), "removeEntry was not completed"); } diff --git a/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonLexerTest.java b/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonLexerTest.java index 739a8fffae..b08f50786d 100644 --- a/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonLexerTest.java +++ b/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonLexerTest.java @@ -3,13 +3,11 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static de.monticore.symboltable.serialization.JsonTokenKind.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class JsonLexerTest { @@ -22,68 +20,68 @@ public void before() { @Test public void testNumberWhitespaces() { JsonLexer lexer = new JsonLexer("12.5 3e9"); - Assertions.assertEquals("12.5", lexer.poll().getValue()); - Assertions.assertEquals(WHITESPACE, lexer.poll().getKind()); - Assertions.assertEquals("3e9", lexer.poll().getValue()); - Assertions.assertEquals(false, lexer.hasNext()); + assertEquals("12.5", lexer.poll().getValue()); + assertEquals(WHITESPACE, lexer.poll().getKind()); + assertEquals("3e9", lexer.poll().getValue()); + assertFalse(lexer.hasNext()); lexer = new JsonLexer("1\t2.5"); - Assertions.assertEquals("1", lexer.poll().getValue()); - Assertions.assertEquals(WHITESPACE, lexer.poll().getKind()); - Assertions.assertEquals("2.5", lexer.poll().getValue()); - Assertions.assertEquals(false, lexer.hasNext()); + assertEquals("1", lexer.poll().getValue()); + assertEquals(WHITESPACE, lexer.poll().getKind()); + assertEquals("2.5", lexer.poll().getValue()); + assertFalse(lexer.hasNext()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testJsonObjects() { JsonLexer lexer = new JsonLexer("{\"foo\":\"b a r\"}"); - Assertions.assertEquals(BEGIN_OBJECT, lexer.poll().getKind()); - Assertions.assertEquals(STRING, lexer.poll().getKind()); - Assertions.assertEquals(COLON, lexer.poll().getKind()); - Assertions.assertEquals(STRING, lexer.poll().getKind()); - Assertions.assertEquals(END_OBJECT, lexer.poll().getKind()); - Assertions.assertEquals(false, lexer.hasNext()); + assertEquals(BEGIN_OBJECT, lexer.poll().getKind()); + assertEquals(STRING, lexer.poll().getKind()); + assertEquals(COLON, lexer.poll().getKind()); + assertEquals(STRING, lexer.poll().getKind()); + assertEquals(END_OBJECT, lexer.poll().getKind()); + assertFalse(lexer.hasNext()); lexer = new JsonLexer("{\"a\":2,\"b\":false}"); - Assertions.assertEquals(BEGIN_OBJECT, lexer.poll().getKind()); - Assertions.assertEquals(STRING, lexer.poll().getKind()); - Assertions.assertEquals(COLON, lexer.poll().getKind()); - Assertions.assertEquals(NUMBER, lexer.poll().getKind()); - Assertions.assertEquals(COMMA, lexer.poll().getKind()); - Assertions.assertEquals(STRING, lexer.poll().getKind()); - Assertions.assertEquals(COLON, lexer.poll().getKind()); - Assertions.assertEquals(BOOLEAN, lexer.poll().getKind()); - Assertions.assertEquals(END_OBJECT, lexer.poll().getKind()); - Assertions.assertEquals(false, lexer.hasNext()); + assertEquals(BEGIN_OBJECT, lexer.poll().getKind()); + assertEquals(STRING, lexer.poll().getKind()); + assertEquals(COLON, lexer.poll().getKind()); + assertEquals(NUMBER, lexer.poll().getKind()); + assertEquals(COMMA, lexer.poll().getKind()); + assertEquals(STRING, lexer.poll().getKind()); + assertEquals(COLON, lexer.poll().getKind()); + assertEquals(BOOLEAN, lexer.poll().getKind()); + assertEquals(END_OBJECT, lexer.poll().getKind()); + assertFalse(lexer.hasNext()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testJsonArray() { JsonLexer lexer = new JsonLexer("[\"fo\\\"o\",\"\\b\\\\ar\"]"); - Assertions.assertEquals(BEGIN_ARRAY, lexer.poll().getKind()); - Assertions.assertEquals(STRING, lexer.poll().getKind()); - Assertions.assertEquals(COMMA, lexer.poll().getKind()); - Assertions.assertEquals(STRING, lexer.poll().getKind()); - Assertions.assertEquals(END_ARRAY, lexer.poll().getKind()); - Assertions.assertEquals(false, lexer.hasNext()); + assertEquals(BEGIN_ARRAY, lexer.poll().getKind()); + assertEquals(STRING, lexer.poll().getKind()); + assertEquals(COMMA, lexer.poll().getKind()); + assertEquals(STRING, lexer.poll().getKind()); + assertEquals(END_ARRAY, lexer.poll().getKind()); + assertFalse(lexer.hasNext()); lexer = new JsonLexer("[\"\\\"a\",-2.4e-5,\"b\",null]"); - Assertions.assertEquals(BEGIN_ARRAY, lexer.poll().getKind()); - Assertions.assertEquals(STRING, lexer.poll().getKind()); - Assertions.assertEquals(COMMA, lexer.poll().getKind()); - Assertions.assertEquals(NUMBER, lexer.poll().getKind()); - Assertions.assertEquals(COMMA, lexer.poll().getKind()); - Assertions.assertEquals(STRING, lexer.poll().getKind()); - Assertions.assertEquals(COMMA, lexer.poll().getKind()); - Assertions.assertEquals(NULL, lexer.poll().getKind()); - Assertions.assertEquals(END_ARRAY, lexer.poll().getKind()); - Assertions.assertEquals(false, lexer.hasNext()); + assertEquals(BEGIN_ARRAY, lexer.poll().getKind()); + assertEquals(STRING, lexer.poll().getKind()); + assertEquals(COMMA, lexer.poll().getKind()); + assertEquals(NUMBER, lexer.poll().getKind()); + assertEquals(COMMA, lexer.poll().getKind()); + assertEquals(STRING, lexer.poll().getKind()); + assertEquals(COMMA, lexer.poll().getKind()); + assertEquals(NULL, lexer.poll().getKind()); + assertEquals(END_ARRAY, lexer.poll().getKind()); + assertFalse(lexer.hasNext()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -124,18 +122,18 @@ public void testSinglelexer() { checkSingleToken("\"\\\"\"", "\"",STRING); checkSingleToken("\"foo \\b\\f\\r\\n\\t\\\" foo \"", "foo \b\f\r\n\t\" foo ", STRING); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } protected void checkSingleToken(String json, String expectedContent, JsonTokenKind expectedTokenKind){ JsonLexer lexer = new JsonLexer(json); JsonToken actual = lexer.poll(); - Assertions.assertEquals(expectedTokenKind, actual.getKind()); + assertEquals(expectedTokenKind, actual.getKind()); if (actual.getKind().hasValue()) { String value = actual.getValue(); - Assertions.assertEquals(expectedContent, value); + assertEquals(expectedContent, value); } - Assertions.assertEquals(false, lexer.hasNext()); + assertFalse(lexer.hasNext()); } protected void checkSingleToken(String json, JsonTokenKind expectedTokenKind) { diff --git a/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonParserTest.java b/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonParserTest.java index c2663739d8..9a6082172c 100644 --- a/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonParserTest.java +++ b/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonParserTest.java @@ -1,12 +1,8 @@ /* (c) https://github.com/MontiCore/monticore */ package de.monticore.symboltable.serialization; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -14,6 +10,8 @@ import java.util.function.Function; +import static org.junit.jupiter.api.Assertions.*; + public class JsonParserTest { @BeforeEach @@ -57,33 +55,33 @@ protected void testParseErroneousJson(Function f, String json){ catch (RuntimeException e){ //Ignore exceptions that occur because fail quick is disabled } - Assertions.assertTrue(Log.getErrorCount()>0); + assertTrue(Log.getErrorCount()>0); } @Test public void testSimpleObject() { JsonObject result = JsonParser.parseJsonObject("{\"foo\":false,\"bar\":3,\"bla\":\"yes\",\"blub\":3.4}"); - Assertions.assertTrue(result.getMember("foo").isJsonBoolean()); - Assertions.assertEquals(false, result.getMember("foo").getAsJsonBoolean().getValue()); + assertTrue(result.getMember("foo").isJsonBoolean()); + assertFalse(result.getMember("foo").getAsJsonBoolean().getValue()); - Assertions.assertTrue(result.getMember("bar").isJsonNumber()); - Assertions.assertEquals(3, result.getMember("bar").getAsJsonNumber().getNumberAsInteger()); + assertTrue(result.getMember("bar").isJsonNumber()); + assertEquals(3, result.getMember("bar").getAsJsonNumber().getNumberAsInteger()); - Assertions.assertTrue(result.getMember("bla").isJsonString()); - Assertions.assertEquals("yes", result.getMember("bla").getAsJsonString().getValue()); + assertTrue(result.getMember("bla").isJsonString()); + assertEquals("yes", result.getMember("bla").getAsJsonString().getValue()); - Assertions.assertTrue(result.getMember("blub").isJsonNumber()); - Assertions.assertEquals(3.4, result.getMember("blub").getAsJsonNumber().getNumberAsDouble(), 0.1); + assertTrue(result.getMember("blub").isJsonNumber()); + assertEquals(3.4, result.getMember("blub").getAsJsonNumber().getNumberAsDouble(), 0.1); - Assertions.assertTrue(JsonParser.parseJsonObject("{}").isJsonObject()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(JsonParser.parseJsonObject("{}").isJsonObject()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testStringEscapes(){ JsonObject result = JsonParser.parseJsonObject("{\"foo\":\"\\n\"}"); - Assertions.assertTrue(result.getMember("foo").isJsonString()); - Assertions.assertEquals("\n", result.getMember("foo").getAsJsonString().getValue()); + assertTrue(result.getMember("foo").isJsonString()); + assertEquals("\n", result.getMember("foo").getAsJsonString().getValue()); } } diff --git a/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonPrinterSecurityTest.java b/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonPrinterSecurityTest.java index db8173d0a4..08a576fb64 100644 --- a/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonPrinterSecurityTest.java +++ b/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonPrinterSecurityTest.java @@ -1,21 +1,19 @@ /* (c) https://github.com/MontiCore/monticore */ package de.monticore.symboltable.serialization; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.util.ArrayList; import java.util.List; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import de.monticore.symboltable.serialization.json.JsonArray; import de.monticore.symboltable.serialization.json.JsonObject; +import static org.junit.jupiter.api.Assertions.*; + /** * This test checks whether injection of objects into serialization and deserialization is avoided * correctly. @@ -55,33 +53,33 @@ public void test() { String s = printFoo(bar); JsonObject o = JsonParser.parseJsonObject(s); - Assertions.assertEquals("Bar", getName(o)); - Assertions.assertEquals(2, getChildren(o).size()); + assertEquals("Bar", getName(o)); + assertEquals(2, getChildren(o).size()); JsonObject b1 = getChildren(o).get(0).getAsJsonObject(); - Assertions.assertEquals("Bar1", getName(b1)); - Assertions.assertEquals(1, getChildren(b1).size()); + assertEquals("Bar1", getName(b1)); + assertEquals(1, getChildren(b1).size()); JsonObject b11 = getChildren(b1).get(0).getAsJsonObject(); - Assertions.assertEquals("Bar1.1", getName(b11)); - Assertions.assertEquals(false, b11.hasMember("children")); + assertEquals("Bar1.1", getName(b11)); + assertFalse(b11.hasMember("children")); JsonObject b2 = getChildren(o).get(1).getAsJsonObject(); - Assertions.assertTrue(getName(b2).startsWith("Bar2")); + assertTrue(getName(b2).startsWith("Bar2")); // without escaping, Bar2 would contain the injected child Bar2.1 - Assertions.assertEquals(false, b2.hasMember("children")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(b2.hasMember("children")); + assertTrue(Log.getFindings().isEmpty()); } protected JsonArray getChildren(JsonObject foo) { - Assertions.assertEquals(true, foo.hasMember("children")); - Assertions.assertEquals(true, foo.getMember("children").isJsonArray()); + assertTrue(foo.hasMember("children")); + assertTrue(foo.getMember("children").isJsonArray()); return foo.getMember("children").getAsJsonArray(); } protected String getName(JsonObject foo) { - Assertions.assertEquals(true, foo.hasMember("name")); - Assertions.assertEquals(true, foo.getMember("name").isJsonString()); + assertTrue(foo.hasMember("name")); + assertTrue(foo.getMember("name").isJsonString()); return foo.getMember("name").getAsJsonString().getValue(); } diff --git a/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonPrinterTest.java b/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonPrinterTest.java index 5bb82c7b3b..1b5f1ed4a0 100644 --- a/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonPrinterTest.java +++ b/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonPrinterTest.java @@ -4,15 +4,14 @@ import com.google.common.collect.Lists; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests the JsonPrinter @@ -43,17 +42,17 @@ public void testOmitEmptyArray() { printer.endObject(); String serialized = printer.getContent(); - Assertions.assertTrue(null != JsonParser.parseJsonObject(serialized)); - Assertions.assertTrue(!serialized.contains("kindHierarchy")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(null != JsonParser.parseJsonObject(serialized)); + assertTrue(!serialized.contains("kindHierarchy")); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testEscapeSequences() { JsonPrinter printer = new JsonPrinter(); printer.value("\"\t\\\n'"); - Assertions.assertEquals("\"\\\"\\t\\\\\\n'\"", printer.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("\"\\\"\\t\\\\\\n'\"", printer.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -61,13 +60,13 @@ public void testEmptyObject() { JsonPrinter printer = new JsonPrinter(true); printer.beginObject(); printer.endObject(); - Assertions.assertEquals("{}", printer.toString()); + assertEquals("{}", printer.toString()); printer = new JsonPrinter(false); printer.beginObject(); printer.endObject(); - Assertions.assertEquals("", printer.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("", printer.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -76,14 +75,14 @@ public void testDefaultString() { printer.beginObject(); printer.member("s", ""); printer.endObject(); - Assertions.assertEquals("", printer.toString()); + assertEquals("", printer.toString()); printer = new JsonPrinter(true); printer.beginObject(); printer.member("s", ""); printer.endObject(); - Assertions.assertEquals("{\"s\":\"\"}", printer.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("{\"s\":\"\"}", printer.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -92,14 +91,14 @@ public void testDefaultInt() { printer.beginObject(); printer.member("i", 0); printer.endObject(); - Assertions.assertEquals("", printer.toString()); + assertEquals("", printer.toString()); printer = new JsonPrinter(true); printer.beginObject(); printer.member("i", 0); printer.endObject(); - Assertions.assertEquals("{\"i\":0}", printer.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("{\"i\":0}", printer.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -108,14 +107,14 @@ public void testDefaultBoolean() { printer.beginObject(); printer.member("b", false); printer.endObject(); - Assertions.assertEquals("", printer.toString()); + assertEquals("", printer.toString()); printer = new JsonPrinter(true); printer.beginObject(); printer.member("b", false); printer.endObject(); - Assertions.assertEquals("{\"b\":false}", printer.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("{\"b\":false}", printer.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -123,27 +122,27 @@ public void testEmptyList() { JsonPrinter printer = new JsonPrinter(true); printer.beginArray(); printer.endArray(); - Assertions.assertEquals("[]", printer.toString()); + assertEquals("[]", printer.toString()); printer = new JsonPrinter(true); printer.beginObject(); printer.beginArray("emptyList"); printer.endArray(); printer.endObject(); - Assertions.assertEquals("{\"emptyList\":[]}", printer.toString()); + assertEquals("{\"emptyList\":[]}", printer.toString()); printer = new JsonPrinter(false); printer.beginArray(); printer.endArray(); - Assertions.assertEquals("", printer.toString()); + assertEquals("", printer.toString()); printer = new JsonPrinter(false); printer.beginObject(); printer.beginArray("emptyList"); printer.endArray(); printer.endObject(); - Assertions.assertEquals("", printer.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("", printer.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -152,32 +151,32 @@ public void testBasicTypeAttributes() { printer.beginObject(); printer.member("booleanAttribute", true); printer.endObject(); - Assertions.assertEquals("{\"booleanAttribute\":true}", printer.toString()); + assertEquals("{\"booleanAttribute\":true}", printer.toString()); printer = new JsonPrinter(); printer.beginObject(); printer.member("intAttribute", -1); printer.endObject(); - Assertions.assertEquals("{\"intAttribute\":-1}", printer.toString()); + assertEquals("{\"intAttribute\":-1}", printer.toString()); printer = new JsonPrinter(); printer.beginObject(); printer.member("floatAttribute", 47.11f); printer.endObject(); - Assertions.assertEquals("{\"floatAttribute\":47.11}", printer.toString()); + assertEquals("{\"floatAttribute\":47.11}", printer.toString()); printer = new JsonPrinter(); printer.beginObject(); printer.member("doubleAttribute", 47.11); printer.endObject(); - Assertions.assertEquals("{\"doubleAttribute\":47.11}", printer.toString()); + assertEquals("{\"doubleAttribute\":47.11}", printer.toString()); printer = new JsonPrinter(); printer.beginObject(); printer.member("longAttribute", 123456789L); printer.endObject(); - Assertions.assertEquals("{\"longAttribute\":123456789}", printer.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("{\"longAttribute\":123456789}", printer.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -186,50 +185,50 @@ public void testOptionalAndList() { printer.beginObject(); printer.member("optionalAttribute", Optional.of("presentOptional")); printer.endObject(); - Assertions.assertEquals("{\"optionalAttribute\":\"presentOptional\"}", printer.toString()); + assertEquals("{\"optionalAttribute\":\"presentOptional\"}", printer.toString()); printer = new JsonPrinter(false); printer.beginObject(); printer.member("optionalAttribute", Optional.of("presentOptional")); printer.endObject(); - Assertions.assertEquals("{\"optionalAttribute\":\"presentOptional\"}", printer.toString()); + assertEquals("{\"optionalAttribute\":\"presentOptional\"}", printer.toString()); printer = new JsonPrinter(true); printer.beginObject(); printer.member("optionalAttribute", Optional.empty()); printer.endObject(); - Assertions.assertEquals("{\"optionalAttribute\":null}", printer.toString()); + assertEquals("{\"optionalAttribute\":null}", printer.toString()); printer = new JsonPrinter(false); printer.beginObject(); printer.member("optionalAttribute", Optional.empty()); printer.endObject(); - Assertions.assertEquals("", printer.toString()); + assertEquals("", printer.toString()); printer = new JsonPrinter(true); printer.beginObject(); printer.member("listAttribute", new ArrayList<>()); printer.endObject(); - Assertions.assertEquals("{\"listAttribute\":[]}", printer.toString()); + assertEquals("{\"listAttribute\":[]}", printer.toString()); printer = new JsonPrinter(false); printer.beginObject(); printer.member("listAttribute", new ArrayList<>()); printer.endObject(); - Assertions.assertEquals("", printer.toString()); + assertEquals("", printer.toString()); printer = new JsonPrinter(true); printer.beginObject(); printer.member("listAttribute", Lists.newArrayList("first", "second")); printer.endObject(); - Assertions.assertEquals("{\"listAttribute\":[\"first\",\"second\"]}", printer.toString()); + assertEquals("{\"listAttribute\":[\"first\",\"second\"]}", printer.toString()); printer = new JsonPrinter(false); printer.beginObject(); printer.member("listAttribute", Lists.newArrayList("first", "second")); printer.endObject(); - Assertions.assertEquals("{\"listAttribute\":[\"first\",\"second\"]}", printer.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("{\"listAttribute\":[\"first\",\"second\"]}", printer.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -241,7 +240,7 @@ public void testInvalidNestings() { printer.beginObject(); printer.endObject(); printer.getContent(); - Assertions.assertEquals(1, Log.getFindings().size()); + assertEquals(1, Log.getFindings().size()); Log.clearFindings(); printer = new JsonPrinter(); @@ -249,7 +248,7 @@ public void testInvalidNestings() { printer.endObject(); printer.endObject(); printer.getContent(); - Assertions.assertEquals(1, Log.getFindings().size()); + assertEquals(1, Log.getFindings().size()); Log.clearFindings(); printer = new JsonPrinter(); @@ -257,7 +256,7 @@ public void testInvalidNestings() { printer.beginArray(); printer.endArray(); printer.getContent(); - Assertions.assertEquals(1, Log.getFindings().size()); + assertEquals(1, Log.getFindings().size()); Log.clearFindings(); printer = new JsonPrinter(); @@ -265,7 +264,7 @@ public void testInvalidNestings() { printer.endArray(); printer.endArray(); printer.getContent(); - Assertions.assertEquals(1, Log.getFindings().size()); + assertEquals(1, Log.getFindings().size()); Log.clearFindings(); printer = new JsonPrinter(); @@ -275,7 +274,7 @@ public void testInvalidNestings() { printer.endArray(); printer.endObject(); printer.getContent(); - Assertions.assertEquals(3, Log.getFindings().size()); + assertEquals(3, Log.getFindings().size()); } } diff --git a/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonStringEscapeTest.java b/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonStringEscapeTest.java index f13b8921de..c52d76f780 100644 --- a/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonStringEscapeTest.java +++ b/monticore-runtime/src/test/java/de/monticore/symboltable/serialization/JsonStringEscapeTest.java @@ -1,11 +1,10 @@ package de.monticore.symboltable.serialization; import de.monticore.symboltable.serialization.json.JsonElement; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class JsonStringEscapeTest { @@ -15,7 +14,7 @@ public void testSingleQuoteNotEscaped(){ printer.value("'"); String content = printer.getContent(); - Assertions.assertEquals("\"'\"", content); + assertEquals("\"'\"", content); } @Test @@ -24,7 +23,7 @@ public void testUtf8Escaped(){ printer.value("✔"); String content = printer.getContent(); - Assertions.assertEquals("\"\\u2714\"", content); + assertEquals("\"\\u2714\"", content); } @Test @@ -89,9 +88,9 @@ protected void testRoundtrip(String input) { String content = printer.getContent(); JsonElement e = JsonParser.parse(content); - Assertions.assertTrue(e.isJsonString()); + assertTrue(e.isJsonString()); - Assertions.assertEquals(input, e.getAsJsonString().getValue()); + assertEquals(input, e.getAsJsonString().getValue()); } } diff --git a/monticore-runtime/src/test/java/de/monticore/templateEnginePerformance/TemplateEngineBenchmark.java b/monticore-runtime/src/test/java/de/monticore/templateEnginePerformance/TemplateEngineBenchmark.java index 51b0655555..0e9b3d29be 100644 --- a/monticore-runtime/src/test/java/de/monticore/templateEnginePerformance/TemplateEngineBenchmark.java +++ b/monticore-runtime/src/test/java/de/monticore/templateEnginePerformance/TemplateEngineBenchmark.java @@ -4,8 +4,8 @@ import de.monticore.generating.GeneratorSetup; import de.monticore.generating.templateengine.TemplateController; import de.monticore.generating.templateengine.TemplateHookPoint; -import org.junit.Test; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.concurrent.TimeUnit; diff --git a/monticore-runtime/src/testFixtures/java/de/monticore/runtime/junit/MCAssertions.java b/monticore-runtime/src/testFixtures/java/de/monticore/runtime/junit/MCAssertions.java index fd774c94ed..d1b4a0423f 100644 --- a/monticore-runtime/src/testFixtures/java/de/monticore/runtime/junit/MCAssertions.java +++ b/monticore-runtime/src/testFixtures/java/de/monticore/runtime/junit/MCAssertions.java @@ -12,6 +12,8 @@ import java.util.function.Predicate; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.fail; + /** * MCAssertions is a collection of utility methods that support asserting * conditions in MontiCore tests. @@ -226,7 +228,7 @@ public static V failAndPrintFindings(String message) { .collect(Collectors.joining(System.lineSeparator())) ); } - return Assertions.fail(messageWithFindings.toString()); + return fail(messageWithFindings.toString()); } } diff --git a/monticore-runtime/src/testFixtures/java/de/monticore/runtime/junit/PrettyPrinterTester.java b/monticore-runtime/src/testFixtures/java/de/monticore/runtime/junit/PrettyPrinterTester.java index 93d262851f..c4367769c7 100644 --- a/monticore-runtime/src/testFixtures/java/de/monticore/runtime/junit/PrettyPrinterTester.java +++ b/monticore-runtime/src/testFixtures/java/de/monticore/runtime/junit/PrettyPrinterTester.java @@ -2,7 +2,6 @@ import de.monticore.antlr4.MCConcreteParser; import de.monticore.ast.ASTNode; -import org.junit.jupiter.api.Assertions; import java.io.IOException; import java.util.Optional; @@ -11,6 +10,8 @@ import static de.monticore.runtime.junit.MCAssertions.assertNoFindings; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; /** * Offers functions to test pretty printers @@ -44,7 +45,7 @@ public static void testPrettyPrinter( Optional astOpt = parseFunc.apply(model); MCAssertions.assertNoFindings(); assertTrue(astOpt.isPresent(), "Failed to parse input"); - Assertions.assertFalse(parser.hasErrors(), "Parser has Errors"); + assertFalse(parser.hasErrors(), "Parser has Errors"); N ast = astOpt.get(); // pretty print the model String prettyPrinted = prettyPrintFunc.apply(ast); @@ -52,7 +53,7 @@ public static void testPrettyPrinter( // parse the pretty printed model Optional prettyPrintedAstOpt = parseFunc.apply(prettyPrinted); MCAssertions.assertNoFindings(); - Assertions.assertFalse(parser.hasErrors()); + assertFalse(parser.hasErrors()); assertTrue(prettyPrintedAstOpt.isPresent()); // compare both ASTs assertTrue(ast.deepEquals(prettyPrintedAstOpt.get()), @@ -60,7 +61,7 @@ public static void testPrettyPrinter( ); // run an additional check if (!additionalCheck.test(prettyPrinted)) { - Assertions.fail("Pretty Printer test: failed during additional check"); + fail("Pretty Printer test: failed during additional check"); } } diff --git a/monticore-test/01.experiments/build.gradle b/monticore-test/01.experiments/build.gradle index 9cce8f048c..5789ca6add 100644 --- a/monticore-test/01.experiments/build.gradle +++ b/monticore-test/01.experiments/build.gradle @@ -14,7 +14,8 @@ subprojects { dependencies { implementation "de.se_rwth.commons:se-commons-utilities:$se_commons_version" testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" } tasks.named('generateMCGrammars') { @@ -38,6 +39,8 @@ configure(subprojects.findAll {it.name != 'forParser' && it.name != 'runtimeOnly } testImplementation testFixtures(project(":monticore-runtime")) } + + test {useJUnitPlatform()} } clean.dependsOn(subprojects.collect{it.getTasksByName("clean", false)}) diff --git a/monticore-test/01.experiments/demonstrator/build.gradle b/monticore-test/01.experiments/demonstrator/build.gradle index 4f5455a778..8b50c3d46a 100644 --- a/monticore-test/01.experiments/demonstrator/build.gradle +++ b/monticore-test/01.experiments/demonstrator/build.gradle @@ -13,13 +13,14 @@ description = 'Experiments: automata' testing { suites { test { - useJUnitJupiter() + useJUnitJupiter(junit_version) } productTest(JvmTestSuite) { dependencies { implementation project() implementation testFixtures(project(":monticore-runtime")) + runtimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" } sources { java.srcDirs += ["$buildDir/statepattern" , "$projectDir/src/product/java"] diff --git a/monticore-test/01.experiments/forParser/build.gradle b/monticore-test/01.experiments/forParser/build.gradle index f0669a6036..59efeb1aa2 100644 --- a/monticore-test/01.experiments/forParser/build.gradle +++ b/monticore-test/01.experiments/forParser/build.gradle @@ -12,6 +12,10 @@ dependencies { implementation project(path: ':monticore-runtime') } +test { + useJUnitPlatform() +} + sourceSets { main.java.srcDirs = [ "$projectDir/src/main/java" ] } diff --git a/monticore-test/01.experiments/hooks/build.gradle b/monticore-test/01.experiments/hooks/build.gradle index 3658f69601..af902c2aa2 100644 --- a/monticore-test/01.experiments/hooks/build.gradle +++ b/monticore-test/01.experiments/hooks/build.gradle @@ -14,13 +14,14 @@ dependencies { testing { suites { test { - useJUnitJupiter() + useJUnitJupiter(junit_version) } productTest(JvmTestSuite) { dependencies { implementation project() implementation testFixtures(project(":monticore-runtime")) + runtimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" } sources { java.srcDirs += ["$buildDir/statepattern" , "$projectDir/src/product/java"] diff --git a/monticore-test/01.experiments/tagging/build.gradle b/monticore-test/01.experiments/tagging/build.gradle index c635a726e5..8e54409a78 100644 --- a/monticore-test/01.experiments/tagging/build.gradle +++ b/monticore-test/01.experiments/tagging/build.gradle @@ -54,8 +54,9 @@ if (("true").equals(getProperty('genTagging'))) { dependencies { withGenImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" - withGenImplementation "org.junit.vintage:junit-vintage-engine:$junit_version" - withGenRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + withGenImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + withGenRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" + // monticore-grammar-tagging withGenImplementation files(project(":monticore-grammar").sourceSets.tagging.output.classesDirs) withGenImplementation project(project.path) @@ -63,6 +64,10 @@ if (("true").equals(getProperty('genTagging'))) { withGenGrammarSymbolDependencies files(project(":monticore-grammar").sourceSets.main.grammars.getSourceDirectories()) } + test { + useJUnitPlatform() + } + // Register a jUnit platform tasks.register('withGenTest', Test) { description = 'Runs tests with tagGen.' diff --git a/monticore-test/01.experiments/tagging/src/test/java/GrammarTagTest.java b/monticore-test/01.experiments/tagging/src/test/java/GrammarTagTest.java index 2c04f6cc65..173bb3ccbe 100644 --- a/monticore-test/01.experiments/tagging/src/test/java/GrammarTagTest.java +++ b/monticore-test/01.experiments/tagging/src/test/java/GrammarTagTest.java @@ -11,7 +11,6 @@ import de.monticore.tagging.tags._ast.ASTValuedTag; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -19,6 +18,8 @@ import java.util.List; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + // Also test the SimpleSymbolTagger on a more complex language with scopes and package names public class GrammarTagTest { @@ -36,7 +37,7 @@ public static void init() throws Exception { // Load all relevant models Optional opt = TagRepository.loadTagModel(new File("src/test/resources/models/SimpleGrammar.tags")); if (opt.isEmpty()) - Assertions.fail("Failed to load Simple.tags"); + fail("Failed to load Simple.tags"); tagger = new SimpleSymbolTagger(TagRepository::getLoadedTagUnits); @@ -52,14 +53,14 @@ public static void init() throws Exception { @Test public void testAutomaton() { List tags = tagger.getTags(automata.getSymbol()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "Grammar"); } @Test public void testAutomatonProdSymbol() { List tags = tagger.getTags(automata.getSpannedScope().resolveProd("Automaton").get()); - Assertions.assertEquals(2, tags.size()); + assertEquals(2, tags.size()); assertValuedTag(tags.get(0), "SymbolProd", "within"); assertValuedTag(tags.get(1), "SymbolProd", "fqn"); } @@ -67,14 +68,14 @@ public void testAutomatonProdSymbol() { @Test public void testFQNAutomaton() { List tags = tagger.getTags(fqnAutomata.getSymbol()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "FQNGrammar"); } @Test public void testFQNAutomatonProdSymbol() { List tags = tagger.getTags(fqnAutomata.getSpannedScope().resolveProd("Automaton").get()); - Assertions.assertEquals(2, tags.size()); + assertEquals(2, tags.size()); assertValuedTag(tags.get(0), "SymbolProd", "within"); assertValuedTag(tags.get(1), "SymbolProd", "fqn"); } @@ -83,34 +84,34 @@ public void testFQNAutomatonProdSymbol() { @Test public void testAddRemove() { List tags = tagger.getTags(fqnAutomata.getSpannedScope().resolveProd("Automaton").get()); - Assertions.assertEquals(2, tags.size()); + assertEquals(2, tags.size()); tagger.addTag(fqnAutomata.getSpannedScope().resolveProd("Automaton").get(), TagsMill.simpleTagBuilder().setName("newTag").build()); tags = tagger.getTags(fqnAutomata.getSpannedScope().resolveProd("Automaton").get()); - Assertions.assertEquals(3, tags.size(), "Add on FQN.Automaton"); + assertEquals(3, tags.size(), "Add on FQN.Automaton"); tagger.removeTag(fqnAutomata.getSpannedScope().resolveProd("Automaton").get(), tags.get(2)); tags = tagger.getTags(fqnAutomata.getSpannedScope().resolveProd("Automaton").get()); - Assertions.assertEquals(2, tags.size(), "Remove on FQN.Automaton"); + assertEquals(2, tags.size(), "Remove on FQN.Automaton"); tagger.addTag(fqnAutomata.getSpannedScope().resolveProd("State").get(), TagsMill.simpleTagBuilder().setName("newTag").build()); tags = tagger.getTags(fqnAutomata.getSpannedScope().resolveProd("State").get()); - Assertions.assertEquals(1, tags.size(), "Add on (freshly tagged) FQN.State"); + assertEquals(1, tags.size(), "Add on (freshly tagged) FQN.State"); } protected void assertValuedTag(ASTTag tag, String name, String value) { - Assertions.assertInstanceOf(ASTValuedTag.class, tag); + assertInstanceOf(ASTValuedTag.class, tag); ASTValuedTag valuedTag = (ASTValuedTag) tag; - Assertions.assertEquals(name, valuedTag.getName()); - Assertions.assertEquals(value, valuedTag.getValue()); + assertEquals(name, valuedTag.getName()); + assertEquals(value, valuedTag.getValue()); } protected void assertSimpleTag(ASTTag tag, String name) { - Assertions.assertInstanceOf(ASTSimpleTag.class, tag); + assertInstanceOf(ASTSimpleTag.class, tag); ASTSimpleTag simpleTag = (ASTSimpleTag) tag; - Assertions.assertEquals(name, simpleTag.getName()); + assertEquals(name, simpleTag.getName()); } } diff --git a/monticore-test/01.experiments/tagging/src/test/java/TagTest.java b/monticore-test/01.experiments/tagging/src/test/java/TagTest.java index dd2667901b..699f6c4670 100644 --- a/monticore-test/01.experiments/tagging/src/test/java/TagTest.java +++ b/monticore-test/01.experiments/tagging/src/test/java/TagTest.java @@ -16,7 +16,6 @@ import de.monticore.tagging.tags._ast.ASTValuedTag; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -26,6 +25,8 @@ import java.util.Map; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + public class TagTest { static ASTAutomaton model; @@ -42,11 +43,11 @@ public static void init() throws Exception { // Load all relevant models var emptyTagsOpt1 = TagRepository.loadTagModel(new File("src/test/resources/models/Empty.tags")); - Assertions.assertTrue(emptyTagsOpt1.isPresent(), "Failed to load Empty.tags"); + assertTrue(emptyTagsOpt1.isPresent(), "Failed to load Empty.tags"); var opt = TagRepository.loadTagModel(new File("src/test/resources/models/Simple.tags")); - Assertions.assertTrue(opt.isPresent(), "Failed to load Simple.tags"); + assertTrue(opt.isPresent(), "Failed to load Simple.tags"); var emptyTagsOpt2 = TagRepository.loadTagModel(new File("src/test/resources/models/Empty.tags")); - Assertions.assertTrue(emptyTagsOpt2.isPresent(), "Failed to load Empty.tags"); + assertTrue(emptyTagsOpt2.isPresent(), "Failed to load Empty.tags"); tagger = new SimpleSymbolTagger(TagRepository::getLoadedTagUnits); @@ -68,7 +69,7 @@ public void visit(ASTState node) { @Test public void testAutomaton() { List tags = tagger.getTags(model.getSymbol()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertValuedTag(tags.get(0), "Method", "App.call()"); } @@ -76,7 +77,7 @@ public void testAutomaton() { @Test public void testStateA() { List tags = tagger.getTags(states.get("A").getSymbol()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "Monitored"); } @@ -84,20 +85,20 @@ public void testStateA() { @Test public void testStateBSymbol() { List tags = tagger.getTags(states.get("B").getSymbol()); - Assertions.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); } @Test public void testStateBASymbol() { List tags = tagger.getTags(states.get("BA").getSymbol()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag1"); } @Test public void testStateBBSymbol() { List tags = tagger.getTags(states.get("BB").getSymbol()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag2"); } @@ -105,44 +106,44 @@ public void testStateBBSymbol() { @Test public void testSomeScopeCSymbol() { List tags = tagger.getTags(model.getEnclosingScope().resolveScopedState("C").get()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertValuedTag(tags.get(0), "VerboseLog", "doLogC"); } @Test public void testStateC_CASymbol() { List tags = tagger.getTags(states.get("C.CA").getSymbol()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag1"); } @Test public void testStateC_CBSymbol() { List tags = tagger.getTags(states.get("C.CB").getSymbol()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag2"); } @Test public void testStateDSymbol() { List tags = tagger.getTags(states.get("D").getSymbol()); - Assertions.assertEquals(2, tags.size()); + assertEquals(2, tags.size()); assertSimpleTag(tags.get(0), "WildcardedTag"); } @Test public void testDupSymbols() { Optional stateSymbolOpt = model.getEnclosingScope().resolveState("Dup"); - Assertions.assertTrue(stateSymbolOpt.isPresent()); + assertTrue(stateSymbolOpt.isPresent()); Optional scopedStateSymbolOpt = model.getEnclosingScope().resolveScopedState("Dup"); - Assertions.assertTrue(scopedStateSymbolOpt.isPresent()); + assertTrue(scopedStateSymbolOpt.isPresent()); // Discuss if this type-unaware duplication is desired? List tags = tagger.getTags(stateSymbolOpt.get()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "WildcardedTag"); tags = tagger.getTags(scopedStateSymbolOpt.get()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "WildcardedTag"); } @@ -150,30 +151,30 @@ public void testDupSymbols() { public void testAddStateE() { ASTState stateE = states.get("E"); List tags = tagger.getTags(stateE.getSymbol()); - Assertions.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); // Add new Tag ASTTag tag = TagsMill.simpleTagBuilder().setName("TestTag").build(); tagger.addTag(stateE.getSymbol(), tag); tags = tagger.getTags(stateE.getSymbol()); - Assertions.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "TestTag"); // Remove tag again tagger.removeTag(stateE.getSymbol(), tag); tags = tagger.getTags(stateE.getSymbol()); - Assertions.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); } protected void assertValuedTag(ASTTag tag, String name, String value) { - Assertions.assertInstanceOf(ASTValuedTag.class, tag); + assertInstanceOf(ASTValuedTag.class, tag); ASTValuedTag valuedTag = (ASTValuedTag) tag; - Assertions.assertEquals(name, valuedTag.getName()); - Assertions.assertEquals(value, valuedTag.getValue()); + assertEquals(name, valuedTag.getName()); + assertEquals(value, valuedTag.getValue()); } protected void assertSimpleTag(ASTTag tag, String name) { - Assertions.assertInstanceOf(ASTSimpleTag.class, tag); + assertInstanceOf(ASTSimpleTag.class, tag); ASTSimpleTag simpleTag = (ASTSimpleTag) tag; - Assertions.assertEquals(name, simpleTag.getName()); + assertEquals(name, simpleTag.getName()); } } diff --git a/monticore-test/01.experiments/tagging/src/withGen/java/AutomataSchemaTest.java b/monticore-test/01.experiments/tagging/src/withGen/java/AutomataSchemaTest.java index 8b0d82710b..1b7729d1c6 100644 --- a/monticore-test/01.experiments/tagging/src/withGen/java/AutomataSchemaTest.java +++ b/monticore-test/01.experiments/tagging/src/withGen/java/AutomataSchemaTest.java @@ -8,29 +8,35 @@ import automatatagschema.AutomataTagSchemaMill; import automatatagschema._symboltable.AutomataTagSchemaSymbols2Json; import automatatagschema._symboltable.IAutomataTagSchemaArtifactScope; +import com.google.common.base.Preconditions; import com.google.common.io.Files; import de.monticore.tagging.tags._ast.ASTTagUnit; import de.monticore.tagging.tagschema._ast.ASTTagSchema; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import org.apache.commons.io.FileUtils; -import org.junit.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import java.io.File; import java.io.IOException; import java.util.Objects; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class AutomataSchemaTest { protected static ASTAutomaton model; + @TempDir static File tempDir; - @BeforeClass + @BeforeAll public static void prepare() throws Exception { - tempDir = java.nio.file.Files.createTempDirectory("AutomataSchemaTest").toFile(); - if (!tempDir.exists()) - tempDir.mkdirs(); LogStub.init(); Log.enableFailQuick(false); @@ -53,7 +59,7 @@ public static void prepare() throws Exception { IAutomataTagSchemaArtifactScope artifactScope = AutomataTagSchemaMill.scopesGenitorDelegator().createFromAST(schemaOpt.get()); String symFile = new File(new File(tempDir, "schema"), Files.getNameWithoutExtension(f.getName()) + ".sym").toString(); symbols2Json.store(artifactScope, symFile); - Assert.assertEquals("TagSchema " + f + " logged errors",0, Log.getErrorCount()); + assertEquals(0, Log.getErrorCount(), "TagSchema " + f + " logged errors"); } else { Log.clearFindings(); Log.warn("Failed to load TagSchema " + f); @@ -66,133 +72,133 @@ public static void prepare() throws Exception { // Finally, switch to the TagDef language AutomataTagDefinitionMill.init(); - Assert.assertEquals(0, Log.getErrorCount()); + assertEquals(0, Log.getErrorCount()); } - @Before + @BeforeEach public void beforeEach() { Log.clearFindings(); } @Test public void testResolve() throws IOException { - Assert.assertTrue(AutomataTagSchemaMill.globalScope().resolveTagSchema("AutomataSchema").isPresent()); - Assert.assertEquals(0, Log.getErrorCount()); + assertTrue(AutomataTagSchemaMill.globalScope().resolveTagSchema("AutomataSchema").isPresent()); + assertEquals(0, Log.getErrorCount()); } @Test public void testValidTags1() throws IOException { testTagDefCoCoChecker("src/test/resources/models/Simple.tags"); - Assert.assertEquals(0, Log.getErrorCount()); + assertEquals(0, Log.getErrorCount()); } @Test public void testSpotRootWithSimpleInsteadOfValued() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidTags1.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNWithInvalidSimpleTag() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidTags2.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNHWithInvalidSimpleTag() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidTags3.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNHWithInvalidValuedTag() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidTags4.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNWithinWithInvalidSimpleTag() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidTags5.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testComplexMissing() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidTags7.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testComplexTooMany() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidTags8.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNWithinWithInvalidPrivateTag() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidTagsPrivate.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNComplexMissingInner() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidComplexTags1.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNComplexTooManyInner() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidComplexTags2.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNComplexTypoInner() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidComplexTags3.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNComplexNotANumber() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidComplexTags4.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNComplexNotABoolean() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidComplexTags5.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNComplexUnknownInnerComplex() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidComplexTags6.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNComplexInvalidInnerComplex() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidComplexTags7.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNPattern() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidPatternTags1.tags"); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } @Test public void testFQNPatternWithin() throws IOException { testTagDefCoCoChecker("src/test/resources/models/InvalidPatternTags2.tags"); - Assert.assertEquals(2, Log.getErrorCount()); + assertEquals(2, Log.getErrorCount()); } @Test public void testFQNNonConformingTags() throws IOException { testTagDefCoCoChecker("src/test/resources/models/NonConformingTags.tags"); - Assert.assertEquals(0, Log.getErrorCount()); + assertEquals(0, Log.getErrorCount()); } protected void testTagDefCoCoChecker(String file) throws IOException { @@ -204,11 +210,4 @@ protected void testTagDefCoCoChecker(String file) throws IOException { coCoChecker.checkAll(n.get()); } - - @AfterClass - public static void cleanUp() throws IOException { - if (tempDir.exists()) { - FileUtils.deleteDirectory(tempDir); - } - } } diff --git a/monticore-test/01.experiments/tagging/src/withGen/java/CDTest.java b/monticore-test/01.experiments/tagging/src/withGen/java/CDTest.java index daf0a9e466..d7abf31b22 100644 --- a/monticore-test/01.experiments/tagging/src/withGen/java/CDTest.java +++ b/monticore-test/01.experiments/tagging/src/withGen/java/CDTest.java @@ -12,17 +12,20 @@ import de.monticore.umlstereotype.UMLStereotypeMill; import de.monticore.umlstereotype._ast.ASTStereoValue; import de.monticore.umlstereotype._ast.ASTStereoValueBuilder; -import org.junit.jupiter.api.Assertions; -import org.junit.BeforeClass; -import org.junit.Test; import de.monticore.tagging.TagRepository; import de.monticore.tagtest.cdbasis4tags._tagging.CDBasis4TagsTagger; import de.monticore.tagtest.cdbasis4tags._visitor.CDBasis4TagsVisitor2; import de.monticore.tagtest.cdbasis4tags._visitor.CDBasis4TagsTraverser; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + import java.io.File; import java.util.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * This test aims to replicate parts of CD4A to test the tagging infrastucture * in regards to interface usage (such as types) @@ -30,7 +33,7 @@ * In addition, we demonstrate the interaction between tags and stereotypes */ public class CDTest { - @BeforeClass + @BeforeAll public static void init() { CDBasis4TagsTagDefinitionMill.init(); } @@ -38,23 +41,23 @@ public static void init() { @Test public void test() throws Exception{ Optional ast = CDBasis4TagsMill.parser().parse(new File("src/test/resources/models/Door.cd").toString()); - Assert.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); CDBasis4TagsMill.scopesGenitorDelegator().createFromAST(ast.get()); Optional doorsThatAreOpenableTags = TagRepository.loadTagModel(new File("src/test/resources/models/DoorsThatAreOpenable.tags")); - Assert.assertTrue(doorsThatAreOpenableTags.isPresent()); + assertTrue(doorsThatAreOpenableTags.isPresent()); Optional theDoorSymbol = ast.get().getEnclosingScope().resolveCDType("TheDoor"); Optional aSingleDoorSymbol = ast.get().getEnclosingScope().resolveCDType("ASingleDoor"); - Assert.assertTrue(theDoorSymbol.isPresent()); - Assert.assertTrue(aSingleDoorSymbol.isPresent()); + assertTrue(theDoorSymbol.isPresent()); + assertTrue(aSingleDoorSymbol.isPresent()); List tagsForTheDoor = new ArrayList<>(CDBasis4TagsTagger.getInstance().getTags(theDoorSymbol.get())); - Assert.assertEquals(1, tagsForTheDoor.size()); + assertEquals(1, tagsForTheDoor.size()); List tagsForASingleDoor = new ArrayList<>(CDBasis4TagsTagger.getInstance().getTags(aSingleDoorSymbol.get())); - Assert.assertEquals(1, tagsForASingleDoor.size()); + assertEquals(1, tagsForASingleDoor.size()); // Turn stereos into tags @@ -62,7 +65,7 @@ public void test() throws Exception{ tagsFromStereo(ast.get(), tempTagUnit); tagsForASingleDoor.addAll(CDBasis4TagsTagger.getInstance().getTags(aSingleDoorSymbol.get())); - Assert.assertEquals(2, tagsForASingleDoor.size()); + assertEquals(2, tagsForASingleDoor.size()); stereoFromTags(ast.get(), Collections.singleton(doorsThatAreOpenableTags.get())); diff --git a/monticore-test/01.experiments/tagging/src/withGen/java/FQNEnhancedAutomataSchemaTest.java b/monticore-test/01.experiments/tagging/src/withGen/java/FQNEnhancedAutomataSchemaTest.java index 4fa718d7e5..562620f605 100644 --- a/monticore-test/01.experiments/tagging/src/withGen/java/FQNEnhancedAutomataSchemaTest.java +++ b/monticore-test/01.experiments/tagging/src/withGen/java/FQNEnhancedAutomataSchemaTest.java @@ -1,5 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ +import com.google.common.base.Preconditions; import de.monticore.fqn.fqnautomata._ast.ASTAutomaton; import de.monticore.fqn.fqnautomata._tagging.FQNAutomataTagConformsToSchemaCoCo; import de.monticore.fqn.fqnenhancedautomata.FQNEnhancedAutomataMill; @@ -11,20 +12,21 @@ import de.monticore.tagging.tagschema._ast.ASTTagSchema; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.util.Objects; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class FQNEnhancedAutomataSchemaTest { protected static ASTAutomaton model; - @BeforeClass + @BeforeAll public static void prepare() throws Exception { LogStub.init(); Log.enableFailQuick(false); @@ -50,7 +52,7 @@ public static void prepare() throws Exception { FQNEnhancedAutomataTagDefinitionMill.init(); } - @Before + @BeforeEach public void beforeEach() { Log.clearFindings(); } @@ -58,49 +60,49 @@ public void beforeEach() { @Test public void testValidTags1() throws IOException { testCoCo("src/test/resources/models/Simple.tags"); - Assert.assertEquals(0, Log.getErrorCount()); + assertEquals(0, Log.getErrorCount()); } @Test public void testSpotRootWithSimpleInsteadOfValued() throws IOException { testCoCo("src/test/resources/models/InvalidTags1.tags"); - Assert.assertEquals(2, Log.getErrorCount()); + assertEquals(2, Log.getErrorCount()); } @Test public void testFQNWithInvalidSimpleTag() throws IOException { testCoCo("src/test/resources/models/InvalidTags2.tags"); - Assert.assertEquals(2, Log.getErrorCount()); + assertEquals(2, Log.getErrorCount()); } @Test public void testFQNHWithInvalidSimpleTag() throws IOException { testCoCo("src/test/resources/models/InvalidTags3.tags"); - Assert.assertEquals(2, Log.getErrorCount()); + assertEquals(2, Log.getErrorCount()); } @Test public void testFQNHWithInvalidValuedTag() throws IOException { testCoCo("src/test/resources/models/InvalidTags4.tags"); - Assert.assertEquals(2, Log.getErrorCount()); + assertEquals(2, Log.getErrorCount()); } @Test public void testFQNWithinWithInvalidSimpleTag() throws IOException { testCoCo("src/test/resources/models/InvalidTags5.tags"); - Assert.assertEquals(2, Log.getErrorCount()); + assertEquals(2, Log.getErrorCount()); } @Test public void testFQNWithinWithInvalidPrivateTag() throws IOException { testCoCo("src/test/resources/models/InvalidTagsPrivate.tags"); - Assert.assertEquals(2, Log.getErrorCount()); + assertEquals(2, Log.getErrorCount()); } @Test public void testEnhancedFQNNonExtendedTag() throws IOException { testCoCo("src/test/resources/models/InvalidEnhancedTags1.tags"); - Assert.assertEquals(2, Log.getErrorCount()); + assertEquals(2, Log.getErrorCount()); } protected void testCoCo(String file) throws IOException { diff --git a/monticore-test/01.experiments/tagging/src/withGen/java/FQNInheritedTagTest.java b/monticore-test/01.experiments/tagging/src/withGen/java/FQNInheritedTagTest.java index d4623c8103..016418fa04 100644 --- a/monticore-test/01.experiments/tagging/src/withGen/java/FQNInheritedTagTest.java +++ b/monticore-test/01.experiments/tagging/src/withGen/java/FQNInheritedTagTest.java @@ -22,9 +22,8 @@ import de.monticore.tagging.tags._ast.ASTValuedTag; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import util.TestUtil; import java.util.Collections; @@ -32,6 +31,8 @@ import java.util.List; import java.util.Map; +import static org.junit.jupiter.api.Assertions.*; + // Copy of TagTest, just with a grammar in a package // Also tests inheritance public class FQNInheritedTagTest { @@ -44,7 +45,7 @@ public class FQNInheritedTagTest { protected IFQNEnhancedAutomataTagger fqnAutomataTagger = FQNEnhancedAutomataTagger.getInstance(); - @BeforeClass + @BeforeAll public static void init() throws Exception { LogStub.init(); Log.enableFailQuick(false); @@ -78,55 +79,55 @@ public void visit(ASTRedState node) { @Test public void testAutomaton() { List tags = fqnAutomataTagger.getTags(model, Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertValuedTag(tags.get(0), "Method", "App.call()"); } @Test public void testStateA() { List tags = fqnAutomataTagger.getTags(states.get("A"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "Monitored"); } @Test public void testStateB() { List tags = fqnAutomataTagger.getTags(states.get("B"), Collections.singleton(tagDefinition)); - Assert.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); } @Test public void testStateBA() { List tags = fqnAutomataTagger.getTags(states.get("BA"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag1"); } @Test public void testStateBB() { List tags = fqnAutomataTagger.getTags(states.get("BB"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag2"); } @Test public void testSomeScopeC() { List tags = fqnAutomataTagger.getTags(model.getEnclosingScope().resolveScopedState("C").get().getAstNode(), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertValuedTag(tags.get(0), "Log", "doLogC"); } @Test public void testStateC_CA() { List tags = fqnAutomataTagger.getTags(states.get("C.CA"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag1"); } @Test public void testStateC_CB() { List tags = fqnAutomataTagger.getTags(states.get("C.CB"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag2"); } @@ -134,14 +135,14 @@ public void testStateC_CB() { public void testSomeScopeC_Transition() { List tags = fqnAutomataTagger.getTags((ASTTransition) model.getEnclosingScope().resolveScopedState("C").get().getAstNode() .getScopedStateElement(2), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertValuedTag(tags.get(0), "Log", "timestamp"); } @Test public void testStateD() { List tags = fqnAutomataTagger.getTags(states.get("D"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "WildcardedTag"); } @@ -149,47 +150,47 @@ public void testStateD() { public void testAddStateE() { ASTState stateE = states.get("E"); List tags = fqnAutomataTagger.getTags(stateE, Collections.singleton(tagDefinition)); - Assert.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); // Add new Tag ASTTag tag = TagsMill.simpleTagBuilder().setName("TestTag").build(); fqnAutomataTagger.addTag(stateE, tagDefinition, tag); tags = fqnAutomataTagger.getTags(stateE, Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "TestTag"); // Remove tag again fqnAutomataTagger.removeTag(stateE, tagDefinition, tag); tags = fqnAutomataTagger.getTags(stateE, Collections.singleton(tagDefinition)); - Assert.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); } @Test public void testAddTransition() { ASTTransition transition = TestUtil.getTransition(model).stream().filter(e->e.getFrom().equals("E") && e.getTo().equals("E")).findAny().get(); List tags = fqnAutomataTagger.getTags(transition, Collections.singleton(tagDefinition)); - Assert.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); // Add new Tag ASTTag tag = TagsMill.simpleTagBuilder().setName("TestTag").build(); fqnAutomataTagger.addTag(transition, tagDefinition, tag); tags = fqnAutomataTagger.getTags(transition, Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "TestTag"); // Remove tag again fqnAutomataTagger.removeTag(transition, tagDefinition, tag); tags = fqnAutomataTagger.getTags(transition, Collections.singleton(tagDefinition)); - Assert.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); } @Test public void testStateRC_CA() { List tags = fqnAutomataTagger.getTags(states.get("RC.CA"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag1"); } @Test public void testStateRC_RCB() { List tags = fqnAutomataTagger.getTags(red_states.get("RC.RCB"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag2"); } @@ -198,21 +199,21 @@ public void testSomeScopeRC_Transition() { List tags = fqnAutomataTagger.getTags((ASTTransition) ((IFQNEnhancedAutomataScope) model.getEnclosingScope()) .resolveRedScopedState("RC").get().getAstNode() .getScopedStateElement(2), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertValuedTag(tags.get(0), "Log", "timestamp"); } protected void assertValuedTag(ASTTag tag, String name, String value) { - Assert.assertTrue(tag instanceof ASTValuedTag); + assertInstanceOf(ASTValuedTag.class, tag); ASTValuedTag valuedTag = (ASTValuedTag) tag; - Assert.assertEquals(name, valuedTag.getName()); - Assert.assertEquals(value, valuedTag.getValue()); + assertEquals(name, valuedTag.getName()); + assertEquals(value, valuedTag.getValue()); } protected void assertSimpleTag(ASTTag tag, String name) { - Assert.assertTrue(tag instanceof ASTSimpleTag); + assertInstanceOf(ASTSimpleTag.class, tag); ASTSimpleTag simpleTag = (ASTSimpleTag) tag; - Assert.assertEquals(name, simpleTag.getName()); + assertEquals(name, simpleTag.getName()); } } diff --git a/monticore-test/01.experiments/tagging/src/withGen/java/FQNTagTest.java b/monticore-test/01.experiments/tagging/src/withGen/java/FQNTagTest.java index c57586ef13..ef6b1d6430 100644 --- a/monticore-test/01.experiments/tagging/src/withGen/java/FQNTagTest.java +++ b/monticore-test/01.experiments/tagging/src/withGen/java/FQNTagTest.java @@ -16,10 +16,9 @@ import de.monticore.tagging.tags._ast.ASTValuedTag; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.Ignore; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import util.TestUtil; import java.util.Collections; @@ -27,6 +26,8 @@ import java.util.List; import java.util.Map; +import static org.junit.jupiter.api.Assertions.*; + // Copy of TagTest, just with a grammar in a package public class FQNTagTest { @@ -37,7 +38,7 @@ public class FQNTagTest { protected IFQNAutomataTagger fqnAutomataTagger = FQNAutomataTagger.getInstance(); - @BeforeClass + @BeforeAll public static void init() throws Exception { LogStub.init(); Log.enableFailQuick(false); @@ -65,71 +66,71 @@ public void visit(ASTState node) { @Test public void testAutomaton() { List tags = fqnAutomataTagger.getTags(model, Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertValuedTag(tags.get(0), "Method", "App.call()"); } @Test public void testStateA() { List tags = fqnAutomataTagger.getTags(states.get("A"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "Monitored"); } @Test public void testStateB() { List tags = fqnAutomataTagger.getTags(states.get("B"), Collections.singleton(tagDefinition)); - Assert.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); } @Test public void testStateBA() { List tags = fqnAutomataTagger.getTags(states.get("BA"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag1"); } @Test public void testStateBB() { List tags = fqnAutomataTagger.getTags(states.get("BB"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag2"); } @Test public void testSomeScopeC() { List tags = fqnAutomataTagger.getTags(model.getEnclosingScope().resolveScopedState("C").get().getAstNode(), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertValuedTag(tags.get(0), "VerboseLog", "doLogC"); } @Test public void testStateC_CA() { List tags = fqnAutomataTagger.getTags(states.get("C.CA"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag1"); } @Test public void testStateC_CB() { List tags = fqnAutomataTagger.getTags(states.get("C.CB"), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "StateTag2"); } @Test - @Ignore // concrete syntax matching is WIP + @Disabled // concrete syntax matching is WIP public void testSomeScopeC_Transition() { List tags = fqnAutomataTagger.getTags((ASTTransition) model.getEnclosingScope().resolveScopedState("C").get().getAstNode() .getScopedStateElement(2), Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertValuedTag(tags.get(0), "Log", "timestamp"); } @Test public void testStateD() { List tags = fqnAutomataTagger.getTags(states.get("D"), Collections.singleton(tagDefinition)); - Assert.assertEquals(2, tags.size()); + assertEquals(2, tags.size()); assertSimpleTag(tags.get(0), "WildcardedTag"); } @@ -137,47 +138,47 @@ public void testStateD() { public void testAddStateE() { ASTState stateE = states.get("E"); List tags = fqnAutomataTagger.getTags(stateE, Collections.singleton(tagDefinition)); - Assert.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); // Add new Tag ASTTag tag = TagsMill.simpleTagBuilder().setName("TestTag").build(); fqnAutomataTagger.addTag(stateE, tagDefinition, tag); tags = fqnAutomataTagger.getTags(stateE, Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "TestTag"); // Remove tag again fqnAutomataTagger.removeTag(stateE, tagDefinition, tag); tags = fqnAutomataTagger.getTags(stateE, Collections.singleton(tagDefinition)); - Assert.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); } @Test public void testAddTransition() { ASTTransition transition = TestUtil.getTransition(model).stream().filter(e->e.getFrom().equals("E") && e.getTo().equals("E")).findAny().get(); List tags = fqnAutomataTagger.getTags(transition, Collections.singleton(tagDefinition)); - Assert.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); // Add new Tag ASTTag tag = TagsMill.simpleTagBuilder().setName("TestTag").build(); fqnAutomataTagger.addTag(transition, tagDefinition, tag); tags = fqnAutomataTagger.getTags(transition, Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), "TestTag"); // Remove tag again fqnAutomataTagger.removeTag(transition, tagDefinition, tag); tags = fqnAutomataTagger.getTags(transition, Collections.singleton(tagDefinition)); - Assert.assertEquals(0, tags.size()); + assertEquals(0, tags.size()); } protected void assertValuedTag(ASTTag tag, String name, String value) { - Assert.assertTrue(tag instanceof ASTValuedTag); + assertInstanceOf(ASTValuedTag.class, tag); ASTValuedTag valuedTag = (ASTValuedTag) tag; - Assert.assertEquals(name, valuedTag.getName()); - Assert.assertEquals(value, valuedTag.getValue()); + assertEquals(name, valuedTag.getName()); + assertEquals(value, valuedTag.getValue()); } protected void assertSimpleTag(ASTTag tag, String name) { - Assert.assertTrue(tag instanceof ASTSimpleTag); + assertInstanceOf(ASTSimpleTag.class, tag); ASTSimpleTag simpleTag = (ASTSimpleTag) tag; - Assert.assertEquals(name, simpleTag.getName()); + assertEquals(name, simpleTag.getName()); } } diff --git a/monticore-test/01.experiments/tagging/src/withGen/java/InvalidTagSchemaTest.java b/monticore-test/01.experiments/tagging/src/withGen/java/InvalidTagSchemaTest.java index 7305f2c7da..d9142184cb 100644 --- a/monticore-test/01.experiments/tagging/src/withGen/java/InvalidTagSchemaTest.java +++ b/monticore-test/01.experiments/tagging/src/withGen/java/InvalidTagSchemaTest.java @@ -4,17 +4,19 @@ import de.monticore.tagging.tagschema._ast.ASTTagSchema; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class InvalidTagSchemaTest { - @BeforeClass + @BeforeAll public static void prepare() { LogStub.init(); Log.enableFailQuick(false); @@ -22,7 +24,7 @@ public static void prepare() { AutomataTagSchemaMill.init(); } - @Before + @BeforeEach public void beforeEach() { Log.clearFindings(); } @@ -30,9 +32,9 @@ public void beforeEach() { @Test public void test() throws IOException { Optional astOpt = AutomataTagSchemaMill.parser().parse("src/test/resources/schema/invalid/InvalidTagSchema.tagschema"); - Assert.assertTrue(astOpt.isPresent()); + assertTrue(astOpt.isPresent()); new de.monticore.tagging.tagschema.TagSchemaAfterParseTrafo().transform(astOpt.get()); - Assert.assertEquals(1, Log.getErrorCount()); + assertEquals(1, Log.getErrorCount()); } } diff --git a/monticore-test/01.experiments/tagging/src/withGen/java/NotQuiteAutomataTest.java b/monticore-test/01.experiments/tagging/src/withGen/java/NotQuiteAutomataTest.java index e8fb4dd07a..55bdaa779d 100644 --- a/monticore-test/01.experiments/tagging/src/withGen/java/NotQuiteAutomataTest.java +++ b/monticore-test/01.experiments/tagging/src/withGen/java/NotQuiteAutomataTest.java @@ -11,9 +11,8 @@ import de.monticore.tagging.tags._ast.ASTTagUnit; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.Collections; import java.util.LinkedHashMap; @@ -21,6 +20,8 @@ import java.util.Map; import java.util.function.BiFunction; +import static org.junit.jupiter.api.Assertions.*; + public class NotQuiteAutomataTest { static ASTAutomaton model; @@ -32,7 +33,7 @@ public class NotQuiteAutomataTest { protected static Map nodes = new LinkedHashMap<>(); - @BeforeClass + @BeforeAll public static void init() throws Exception { LogStub.init(); Log.enableFailQuick(false); @@ -62,8 +63,8 @@ public static void init() throws Exception { @Test public void testParseCorrect() { - Assert.assertTrue(model.isPresentNotQuiteAutomataProductions()); - Assert.assertEquals(8, nodes.size()); + assertTrue(model.isPresentNotQuiteAutomataProductions()); + assertEquals(8, nodes.size()); } @Test @@ -123,15 +124,15 @@ public void testYetAnotherSymbolProdCS() { } protected void doTest(A ast, BiFunction, List> getTags, String name) { - Assert.assertNotNull(ast); + assertNotNull(ast); List tags = getTags.apply(ast, Collections.singleton(tagDefinition)); - Assert.assertEquals(1, tags.size()); + assertEquals(1, tags.size()); assertSimpleTag(tags.get(0), name); } protected void assertSimpleTag(ASTTag tag, String name) { - Assert.assertTrue(tag instanceof ASTSimpleTag); + assertInstanceOf(ASTSimpleTag.class, tag); ASTSimpleTag simpleTag = (ASTSimpleTag) tag; - Assert.assertEquals(name, simpleTag.getName()); + assertEquals(name, simpleTag.getName()); } } diff --git a/monticore-test/01.experiments/tagging/src/withGen/java/TagSchemaSerializationTest.java b/monticore-test/01.experiments/tagging/src/withGen/java/TagSchemaSerializationTest.java index acd4419575..c694952fa9 100644 --- a/monticore-test/01.experiments/tagging/src/withGen/java/TagSchemaSerializationTest.java +++ b/monticore-test/01.experiments/tagging/src/withGen/java/TagSchemaSerializationTest.java @@ -6,6 +6,7 @@ import automatatagdefinition._cocos.AutomataTagDefinitionCoCoChecker; import automatatagschema._symboltable.AutomataTagSchemaSymbols2Json; import automatatagschema._symboltable.IAutomataTagSchemaArtifactScope; +import com.google.common.base.Preconditions; import de.monticore.fqn.fqnenhancedautomata._symboltable.IFQNEnhancedAutomataArtifactScope; import de.monticore.fqn.fqnenhancedautomatatagschema.FQNEnhancedAutomataTagSchemaMill; import de.monticore.fqn.fqnenhancedautomatatagschema._symboltable.FQNEnhancedAutomataTagSchemaSymbols2Json; @@ -15,20 +16,21 @@ import de.monticore.tagging.tagschema._ast.ASTTagSchema; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; import java.util.Objects; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class TagSchemaSerializationTest { protected static ASTAutomaton model; - @BeforeClass + @BeforeAll public static void prepare() throws Exception { LogStub.init(); Log.enableFailQuick(false); @@ -47,7 +49,7 @@ public static void prepare() throws Exception { } - @Before + @BeforeEach public void beforeEach() { Log.clearFindings(); } @@ -71,7 +73,7 @@ public void test() throws IOException { String serializedCopy = schemaSymbols2Json.serialize(copy); - Assert.assertEquals(serialized, serializedCopy); + assertEquals(serialized, serializedCopy); } } diff --git a/monticore-test/01.experiments/templates/build.gradle b/monticore-test/01.experiments/templates/build.gradle index e7ac78571b..09dd9e5646 100644 --- a/monticore-test/01.experiments/templates/build.gradle +++ b/monticore-test/01.experiments/templates/build.gradle @@ -13,13 +13,14 @@ dependencies { testing { suites { test { - useJUnitJupiter() + useJUnitJupiter(junit_version) } productTest(JvmTestSuite) { dependencies { implementation project() implementation testFixtures(project(":monticore-runtime")) + runtimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" } sources { java.srcDirs += ["$buildDir/statepattern" , "$projectDir/src/product/java"] diff --git a/monticore-test/02.experiments/build.gradle b/monticore-test/02.experiments/build.gradle index e59fa1dcfe..730996f504 100644 --- a/monticore-test/02.experiments/build.gradle +++ b/monticore-test/02.experiments/build.gradle @@ -23,8 +23,12 @@ subprojects { } } testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" - testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" + } + + test { + useJUnitPlatform() } } diff --git a/monticore-test/02.experiments/configTemplate/src/test/java/CustomTemplateTest.java b/monticore-test/02.experiments/configTemplate/src/test/java/CustomTemplateTest.java index 5f5318ae50..8aef893340 100644 --- a/monticore-test/02.experiments/configTemplate/src/test/java/CustomTemplateTest.java +++ b/monticore-test/02.experiments/configTemplate/src/test/java/CustomTemplateTest.java @@ -1,8 +1,5 @@ /* (c) https://github.com/MontiCore/monticore */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.util.List; @@ -11,10 +8,11 @@ import de.se_rwth.commons.logging.Finding; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Main class for the some Demonstration to Parse */ @@ -44,18 +42,18 @@ public void testParseMethods() throws IOException { // expecting two warnings of the same type, once for instantiating the mill // and once for instantiating the ASTAutomaton node List findings = Log.getFindings(); - Assertions.assertEquals(2, findings.size()); - Assertions.assertEquals(MSG, findings.get(0).getMsg()); - Assertions.assertEquals(MSG, findings.get(1).getMsg()); + assertEquals(2, findings.size()); + assertEquals(MSG, findings.get(0).getMsg()); + assertEquals(MSG, findings.get(1).getMsg()); // the config template additionally configures overriding the specific // "sizeStates" method of the automaton to always return 10. // Thus, we expect the corresponding method to return 10, while the // actual state list is empty - Assertions.assertEquals(0, aut.getStateList().size()); // actual state list size - Assertions.assertEquals(10, aut.sizeStates()); // modified state list size + assertEquals(0, aut.getStateList().size()); // actual state list size + assertEquals(10, aut.sizeStates()); // modified state list size - Assertions.assertEquals(0, aut.count()); + assertEquals(0, aut.count()); } } diff --git a/monticore-test/02.experiments/dispatcher/src/test/java/GetDispatcherFromMillTest.java b/monticore-test/02.experiments/dispatcher/src/test/java/GetDispatcherFromMillTest.java index 31f35e0bfa..3d7793f962 100644 --- a/monticore-test/02.experiments/dispatcher/src/test/java/GetDispatcherFromMillTest.java +++ b/monticore-test/02.experiments/dispatcher/src/test/java/GetDispatcherFromMillTest.java @@ -1,11 +1,10 @@ /* (c) https://github.com/MontiCore/monticore */ -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import simpleinterfaces.SimpleInterfacesMill; import simpleinterfaces._util.ISimpleInterfacesTypeDispatcher; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; public class GetDispatcherFromMillTest { @@ -13,7 +12,7 @@ public class GetDispatcherFromMillTest { public void testGetterInMill() { ISimpleInterfacesTypeDispatcher dispatcher1 = SimpleInterfacesMill.typeDispatcher(); ISimpleInterfacesTypeDispatcher dispatcher2 = SimpleInterfacesMill.typeDispatcher(); - Assertions.assertSame(dispatcher1, dispatcher2); + assertSame(dispatcher1, dispatcher2); } } diff --git a/monticore-test/02.experiments/forGrammarOps/src/test/java/AutomataParseTest.java b/monticore-test/02.experiments/forGrammarOps/src/test/java/AutomataParseTest.java index 91e3c90b42..71aa3ca7e5 100644 --- a/monticore-test/02.experiments/forGrammarOps/src/test/java/AutomataParseTest.java +++ b/monticore-test/02.experiments/forGrammarOps/src/test/java/AutomataParseTest.java @@ -1,5 +1,4 @@ /* (c) https://github.com/MontiCore/monticore */ -import static org.junit.Assert.assertTrue; import java.io.IOException; import java.io.StringReader; @@ -10,10 +9,11 @@ import automata._parser.AutomataParser; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Main class for the some Demonstration to Parse */ @@ -37,24 +37,24 @@ public void testParseMethods() throws IOException { // parse from a file Optional at = p.parse(filename); - Assertions.assertTrue(at.isPresent()); + assertTrue(at.isPresent()); // parse from a Reader object String aut = "automaton PingPong {" + "state Ping;" + "}"; at = p.parse(new StringReader(aut)); - Assertions.assertTrue(at.isPresent()); + assertTrue(at.isPresent()); // another parse from a String at = p.parse_String(aut); - Assertions.assertTrue(at.isPresent()); + assertTrue(at.isPresent()); // parse for a sublanguage, here: a State Optional s = p.parse_StringState("state Ping;"); - Assertions.assertTrue(s.isPresent()); + assertTrue(s.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/02.experiments/forGrammarOps/src/test/java/AutomataToolTest.java b/monticore-test/02.experiments/forGrammarOps/src/test/java/AutomataToolTest.java index 44de5bd800..e1d16370f3 100644 --- a/monticore-test/02.experiments/forGrammarOps/src/test/java/AutomataToolTest.java +++ b/monticore-test/02.experiments/forGrammarOps/src/test/java/AutomataToolTest.java @@ -5,12 +5,11 @@ import java.util.*; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class AutomataToolTest { @@ -27,11 +26,11 @@ public void init() { public void executeSimple12() { AutomataTool.main(new String[] { "-i", "src/test/resources/example/Simple12.aut" }); Log.printFindings(); - Assertions.assertEquals(0, Log.getFindings().size()); + assertEquals(0, Log.getFindings().size()); // LogStub.printPrints(); List p = LogStub.getPrints(); - Assertions.assertEquals(6, p.size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(6, p.size()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/02.experiments/resolving/src/test/java/de/monticore/simplecd/ResolvingTest.java b/monticore-test/02.experiments/resolving/src/test/java/de/monticore/simplecd/ResolvingTest.java index 5ef3232821..93af938bd3 100644 --- a/monticore-test/02.experiments/resolving/src/test/java/de/monticore/simplecd/ResolvingTest.java +++ b/monticore-test/02.experiments/resolving/src/test/java/de/monticore/simplecd/ResolvingTest.java @@ -12,15 +12,14 @@ import de.monticore.symboltable.resolving.ResolvedSeveralEntriesForSymbolException; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ResolvingTest { @@ -60,38 +59,38 @@ public void testValidExample(){ Optional a = parseAndTransform("src/test/resources/de/monticore/simplecd/valid/A.cd"); Optional b = parseAndTransform("src/test/resources/de/monticore/simplecd/valid/B.cd"); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ISimpleCDArtifactScope asB = buildSymbolTable(b.get()); ISimpleCDArtifactScope asA = buildSymbolTable(a.get()); Optional fooSymbol = asA.resolveCDClass("Foo"); - Assertions.assertTrue(fooSymbol.isPresent()); + assertTrue(fooSymbol.isPresent()); ISimpleCDScope fooScope = fooSymbol.get().getSpannedScope(); Optional type = fooScope.resolveCDClass("B.Bar"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); } @Test public void testSimpleInvalid(){ Optional c = parseAndTransform("src/test/resources/de/monticore/simplecd/invalid/C.cd"); - Assertions.assertTrue(c.isPresent()); + assertTrue(c.isPresent()); ISimpleCDArtifactScope asC = buildSymbolTable(c.get()); Optional fooSymbol = asC.resolveCDClass("Foo"); - Assertions.assertTrue(fooSymbol.isPresent()); + assertTrue(fooSymbol.isPresent()); ISimpleCDScope fooScope = fooSymbol.get().getSpannedScope(); try { Optional type = fooScope.resolveCDClass("Bar"); //if a type could be resolved: Test fails because Bar should be ambiguous - Assertions.assertFalse(type.isPresent()); + assertFalse(type.isPresent()); } catch(ResolvedSeveralEntriesForSymbolException e) { - Assertions.assertTrue(e.getMessage().startsWith("0xA4095")); + assertTrue(e.getMessage().startsWith("0xA4095")); } } @@ -100,22 +99,22 @@ public void testInterModelInvalid(){ Optional a = parseAndTransform("src/test/resources/de/monticore/simplecd/invalid/A.cd"); Optional b = parseAndTransform("src/test/resources/de/monticore/simplecd/invalid/B.cd"); - Assertions.assertTrue(a.isPresent()); - Assertions.assertTrue(b.isPresent()); + assertTrue(a.isPresent()); + assertTrue(b.isPresent()); ISimpleCDArtifactScope asB = buildSymbolTable(b.get()); ISimpleCDArtifactScope asA = buildSymbolTable(a.get()); Optional fooSymbol = asA.resolveCDClass("Foo"); - Assertions.assertTrue(fooSymbol.isPresent()); + assertTrue(fooSymbol.isPresent()); ISimpleCDScope fooScope = fooSymbol.get().getSpannedScope(); try { Optional type = fooScope.resolveCDClass("B.Bar"); //if a type could be resolved: Test fails because B.Bar should be ambiguous - Assertions.assertFalse(type.isPresent()); + assertFalse(type.isPresent()); } catch(ResolvedSeveralEntriesForSymbolException e) { - Assertions.assertTrue(e.getMessage().startsWith("0xA4095")); + assertTrue(e.getMessage().startsWith("0xA4095")); } } diff --git a/monticore-test/02.experiments/scopes/src/test/java/GlobalScopeTest.java b/monticore-test/02.experiments/scopes/src/test/java/GlobalScopeTest.java index 4092d2178e..9e845557d0 100644 --- a/monticore-test/02.experiments/scopes/src/test/java/GlobalScopeTest.java +++ b/monticore-test/02.experiments/scopes/src/test/java/GlobalScopeTest.java @@ -6,13 +6,12 @@ import de.monticore.io.paths.MCPath; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.nio.file.Paths; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class GlobalScopeTest { @@ -33,6 +32,6 @@ public void testGS() { gs.putSymbolDeSer("automata._symboltable.StateSymbol", new MyStateDeSer()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/02.experiments/traverser/src/test/java/TreesTest.java b/monticore-test/02.experiments/traverser/src/test/java/TreesTest.java index b9341ed356..40fde3e6ea 100644 --- a/monticore-test/02.experiments/traverser/src/test/java/TreesTest.java +++ b/monticore-test/02.experiments/traverser/src/test/java/TreesTest.java @@ -1,15 +1,10 @@ /* (c) https://github.com/MontiCore/monticore */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -21,6 +16,8 @@ import trees._parser.TreesParser; import trees._visitor.TreesTraverser; +import static org.junit.jupiter.api.Assertions.*; + public class TreesTest { @BeforeEach @@ -36,12 +33,12 @@ public void testTrees() throws IOException { TreesParser parser = new TreesParser(); Optional tree = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(tree.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(tree.isPresent()); // compute and check result - Assertions.assertEquals(3, leafCount(tree.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(3, leafCount(tree.get())); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -51,12 +48,12 @@ public void testBranches() throws IOException { SubTreesParser parser = new SubTreesParser(); Optional tree = parser.parse(model); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(tree.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(tree.isPresent()); // compute and check result - Assertions.assertEquals(6, leafCount(tree.get())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(6, leafCount(tree.get())); + assertTrue(Log.getFindings().isEmpty()); } /** diff --git a/monticore-test/02.experiments/typecheck/src/test/java/MyLangTest.java b/monticore-test/02.experiments/typecheck/src/test/java/MyLangTest.java index 6421992022..1efe9f686c 100644 --- a/monticore-test/02.experiments/typecheck/src/test/java/MyLangTest.java +++ b/monticore-test/02.experiments/typecheck/src/test/java/MyLangTest.java @@ -1,9 +1,5 @@ /* (c) https://github.com/MontiCore/monticore */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.util.Optional; @@ -20,10 +16,10 @@ import mylang.FullSynthesizeFromMyLang; import mylang._ast.ASTMyVar; import mylang._parser.MyLangParser; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; public class MyLangTest { @@ -40,8 +36,8 @@ public void testMyLang() throws IOException { MyLangParser parser = MyLangMill.parser(); Optional varOpt = parser.parse_String("boolean x = 3 > 4"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(varOpt.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(varOpt.isPresent()); MyLangMill.scopesGenitorDelegator().createFromAST(varOpt.get()); @@ -60,20 +56,20 @@ public void testMyLang() throws IOException { SymTypeExpression symType2 = tc.typeOf(exp); // check whether the type is boolean - Assertions.assertEquals("boolean", symType1.getTypeInfo().getName()); - Assertions.assertTrue(TypeCheck.isBoolean(symType1)); + assertEquals("boolean", symType1.getTypeInfo().getName()); + assertTrue(TypeCheck.isBoolean(symType1)); - Assertions.assertEquals("boolean", symType2.getTypeInfo().getName()); + assertEquals("boolean", symType2.getTypeInfo().getName()); - Assertions.assertTrue(TypeCheck.isBoolean(symType2)); + assertTrue(TypeCheck.isBoolean(symType2)); // check whether both types are compatible - Assertions.assertTrue(TypeCheck.compatible(symType1,symType2)); + assertTrue(TypeCheck.compatible(symType1,symType2)); // check whether the expression is of assignable type - Assertions.assertTrue(tc.isOfTypeForAssign(symType1,exp)); + assertTrue(tc.isOfTypeForAssign(symType1,exp)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-test/02.experiments/unknownScopes/src/test/java/UnknownScopeDeSerTests.java b/monticore-test/02.experiments/unknownScopes/src/test/java/UnknownScopeDeSerTests.java index 73495dab43..c44867d3b9 100644 --- a/monticore-test/02.experiments/unknownScopes/src/test/java/UnknownScopeDeSerTests.java +++ b/monticore-test/02.experiments/unknownScopes/src/test/java/UnknownScopeDeSerTests.java @@ -1,8 +1,5 @@ /* (c) https://github.com/MontiCore/monticore */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import bar.BarMill; import bar._symboltable.BarArtifactScope; import bar._symboltable.IBarGlobalScope; @@ -15,7 +12,6 @@ import foo._parser.FooParser; import foo._symboltable.FooSymbols2Json; import foo._symboltable.IFooArtifactScope; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import java.io.IOException; @@ -24,6 +20,9 @@ import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class UnknownScopeDeSerTests { @BeforeEach @@ -42,7 +41,7 @@ public void test() throws IOException { "}\n" ); - Assertions.assertTrue(parsedFooArtifact.isPresent()); + assertTrue(parsedFooArtifact.isPresent()); ASTFooArtifact fooArtifact = parsedFooArtifact.get(); @@ -55,14 +54,14 @@ public void test() throws IOException { IBarGlobalScope barGlobalScope = BarMill.globalScope(); BarArtifactScope scope = (BarArtifactScope) barGlobalScope.getDeSer().deserializeArtifactScope(jsonFoo); - Assertions.assertTrue(scope.getUnknownSymbols().containsKey("TestNest")); - Assertions.assertEquals(1, scope.getUnknownSymbols().get("TestNest").size()); + assertTrue(scope.getUnknownSymbols().containsKey("TestNest")); + assertEquals(1, scope.getUnknownSymbols().get("TestNest").size()); IBarScope unknownNestScope = (IBarScope) scope.getUnknownSymbols().get("TestNest").get(0).getSpannedScope(); - Assertions.assertEquals(2, unknownNestScope.getSubScopes().size()); + assertEquals(2, unknownNestScope.getSubScopes().size()); - Assertions.assertTrue(unknownNestScope.getSubScopes().stream().anyMatch(it -> Objects.equals(it.getName(), "testFunction"))); - Assertions.assertTrue(unknownNestScope.getSubScopes().stream().anyMatch(it -> Objects.equals(it.getName(), "testFunction2"))); + assertTrue(unknownNestScope.getSubScopes().stream().anyMatch(it -> Objects.equals(it.getName(), "testFunction"))); + assertTrue(unknownNestScope.getSubScopes().stream().anyMatch(it -> Objects.equals(it.getName(), "testFunction2"))); } } diff --git a/monticore-test/it/build.gradle b/monticore-test/it/build.gradle index 5310f4cb5a..3f6e97adde 100644 --- a/monticore-test/it/build.gradle +++ b/monticore-test/it/build.gradle @@ -7,7 +7,6 @@ plugins { description = 'MontiCore Generator Main Integration Test' ext.grammarDir = 'src/main/grammars' -ext.junit_version = '5.10.3' configurations {grammar} @@ -22,8 +21,9 @@ dependencies { // implementation project (':monticore-generator') testImplementation testFixtures(project(':monticore-runtime')) testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" - testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" grammar (project(path: ':monticore-grammar')){ capabilities { requireCapability("de.monticore:monticore-grammar-grammars") @@ -54,6 +54,7 @@ java { } test { + useJUnitPlatform() testLogging { showStandardStreams = true } diff --git a/monticore-test/it/src/test/java/mc/examples/automaton/TestAutomaton.java b/monticore-test/it/src/test/java/mc/examples/automaton/TestAutomaton.java index 73525af124..073a00b598 100644 --- a/monticore-test/it/src/test/java/mc/examples/automaton/TestAutomaton.java +++ b/monticore-test/it/src/test/java/mc/examples/automaton/TestAutomaton.java @@ -13,7 +13,6 @@ import mc.examples.automaton.automaton._od.Automaton2OD; import mc.examples.automaton.automaton._parser.AutomatonParser; import mc.examples.automaton.automaton._visitor.AutomatonTraverser; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -24,8 +23,8 @@ import java.nio.file.Paths; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestAutomaton extends GeneratorIntegrationsTest { @@ -39,8 +38,8 @@ private ASTAutomaton parse() throws IOException { AutomatonParser parser = new AutomatonParser(); Optional optAutomaton; optAutomaton = parser.parseAutomaton("src/test/resources/examples/automaton/Testautomat.aut"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(optAutomaton.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(optAutomaton.isPresent()); AutomatonMill.globalScope().clear(); AutomatonMill.scopesGenitorDelegator().createFromAST(optAutomaton.get()); return optAutomaton.get(); @@ -55,15 +54,15 @@ private void printOD(ASTAutomaton ast, String symbolName) throws IOException { traverser.add4Automaton(odCreator); traverser.setAutomatonHandler(odCreator); odCreator.printObjectDiagram(symbolName, ast); - Assertions.assertTrue(printer.getContent().length()>0); - Assertions.assertTrue(readFile("src/test/resources/examples/automaton/Output.od", StandardCharsets.UTF_8).endsWith(printer.getContent())); + assertTrue(printer.getContent().length()>0); + assertTrue(readFile("src/test/resources/examples/automaton/Output.od", StandardCharsets.UTF_8).endsWith(printer.getContent())); } @Test public void test() throws IOException { ASTAutomaton ast = parse(); printOD(ast, "Testautomat"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } protected String readFile(String path, Charset encoding) diff --git a/monticore-test/it/src/test/java/mc/examples/coord/TestCoordinates.java b/monticore-test/it/src/test/java/mc/examples/coord/TestCoordinates.java index 8e252286eb..f51404673a 100644 --- a/monticore-test/it/src/test/java/mc/examples/coord/TestCoordinates.java +++ b/monticore-test/it/src/test/java/mc/examples/coord/TestCoordinates.java @@ -2,17 +2,12 @@ package mc.examples.coord; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -30,6 +25,8 @@ import mc.examples.polar.coordpolar._parser.CoordpolarParser; import mc.examples.polar.coordpolar._visitor.CoordpolarTraverser; +import static org.junit.jupiter.api.Assertions.*; + public class TestCoordinates extends GeneratorIntegrationsTest { private static final double DELTA = 1e-5; @@ -47,21 +44,21 @@ public void testCoordcartesianParser() throws IOException { .parseCoordinateFile("src/test/resources/examples/coord/coordinates.cart"); // (2,4) // (5,2) // (1,7) - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astCartesian.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astCartesian.isPresent()); - Assertions.assertEquals(astCartesian.get().getCoordinateList().size(), 3); + assertEquals(3, astCartesian.get().getCoordinateList().size()); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(0).getX(), 2); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(0).getY(), 4); + assertEquals(2, astCartesian.get().getCoordinateList().get(0).getX()); + assertEquals(4, astCartesian.get().getCoordinateList().get(0).getY()); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(1).getX(), 5); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(1).getY(), 2); + assertEquals(5, astCartesian.get().getCoordinateList().get(1).getX()); + assertEquals(2, astCartesian.get().getCoordinateList().get(1).getY()); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(2).getX(), 1); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(2).getY(), 7); + assertEquals(1, astCartesian.get().getCoordinateList().get(2).getX()); + assertEquals(7, astCartesian.get().getCoordinateList().get(2).getY()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -72,22 +69,22 @@ public void testCoordpolarParser() throws IOException { // [1,0;0,5] // [2,5;1,3] // [47,11;0,815] - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astPolar.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astPolar.isPresent()); - Assertions.assertEquals(astPolar.get().getCoordinateList().size(), 3); + assertEquals(3, astPolar.get().getCoordinateList().size()); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(0).getD(), 1.0, DELTA); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(0).getPhi(), 0.5, DELTA); + assertEquals(1.0, astPolar.get().getCoordinateList().get(0).getD(), DELTA); + assertEquals(0.5, astPolar.get().getCoordinateList().get(0).getPhi(), DELTA); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(1).getD(), 2.5, DELTA); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(1).getPhi(), 1.3, DELTA); + assertEquals(2.5, astPolar.get().getCoordinateList().get(1).getD(), DELTA); + assertEquals(1.3, astPolar.get().getCoordinateList().get(1).getPhi(), DELTA); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(2).getD(), 47.11, DELTA); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(2).getPhi(), 0.815, DELTA); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(47.11, astPolar.get().getCoordinateList().get(2).getD(), DELTA); + assertEquals(0.815, astPolar.get().getCoordinateList().get(2).getPhi(), DELTA); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -95,8 +92,8 @@ public void cartesian2Polar() throws IOException { CoordcartesianParser parser = new CoordcartesianParser(); Optional astCartesian = parser .parseCoordinateFile("src/test/resources/examples/coord/coordinates.cart"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astCartesian.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astCartesian.isPresent()); // Transform cartesian to polar coordinates CoordcartesianTraverser t1 = CoordcartesianMill.traverser(); @@ -116,21 +113,21 @@ public void cartesian2Polar() throws IOException { mc.examples.polar.coordpolar._parser.CoordpolarParser polarParser = new CoordpolarParser(); Optional astPolar = polarParser .parseCoordinateFile(new StringReader(ip.getContent())); - Assertions.assertFalse(polarParser.hasErrors()); - Assertions.assertTrue(astPolar.isPresent()); + assertFalse(polarParser.hasErrors()); + assertTrue(astPolar.isPresent()); - Assertions.assertEquals(astPolar.get().getCoordinateList().size(), 3); + assertEquals(3, astPolar.get().getCoordinateList().size()); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(0).getD(), 4.47213, DELTA); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(0).getPhi(), 1.10714, DELTA); + assertEquals(4.47213, astPolar.get().getCoordinateList().get(0).getD(), DELTA); + assertEquals(1.10714, astPolar.get().getCoordinateList().get(0).getPhi(), DELTA); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(1).getD(), 5.38516, DELTA); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(1).getPhi(), 0.380506, DELTA); + assertEquals(5.38516, astPolar.get().getCoordinateList().get(1).getD(), DELTA); + assertEquals(0.380506, astPolar.get().getCoordinateList().get(1).getPhi(), DELTA); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(2).getD(), 7.07106, DELTA); - Assertions.assertEquals(astPolar.get().getCoordinateList().get(2).getPhi(), 1.428899, DELTA); + assertEquals(7.07106, astPolar.get().getCoordinateList().get(2).getD(), DELTA); + assertEquals(1.428899, astPolar.get().getCoordinateList().get(2).getPhi(), DELTA); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -138,19 +135,19 @@ public void mirrorTransformation() throws IOException { CoordcartesianParser parser = new CoordcartesianParser(); Optional astCartesian = parser .parseCoordinateFile("src/test/resources/examples/coord/coordinates.cart"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astCartesian.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astCartesian.isPresent()); - Assertions.assertEquals(astCartesian.get().getCoordinateList().size(), 3); + assertEquals(3, astCartesian.get().getCoordinateList().size()); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(0).getX(), 2); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(0).getY(), 4); + assertEquals(2, astCartesian.get().getCoordinateList().get(0).getX()); + assertEquals(4, astCartesian.get().getCoordinateList().get(0).getY()); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(1).getX(), 5); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(1).getY(), 2); + assertEquals(5, astCartesian.get().getCoordinateList().get(1).getX()); + assertEquals(2, astCartesian.get().getCoordinateList().get(1).getY()); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(2).getX(), 1); - Assertions.assertEquals(astCartesian.get().getCoordinateList().get(2).getY(), 7); + assertEquals(1, astCartesian.get().getCoordinateList().get(2).getX()); + assertEquals(7, astCartesian.get().getCoordinateList().get(2).getY()); // Transform cartesian to polar coordinates CoordcartesianTraverser t1 = CoordcartesianMill.traverser(); @@ -168,21 +165,21 @@ public void mirrorTransformation() throws IOException { astCartesian.get().accept(t2); Optional astTransformed = parser.parseCoordinateFile(new StringReader(ip.getContent())); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astTransformed.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astTransformed.isPresent()); - Assertions.assertEquals(astTransformed.get().getCoordinateList().size(), 3); + assertEquals(3, astTransformed.get().getCoordinateList().size()); - Assertions.assertEquals(astTransformed.get().getCoordinateList().get(0).getX(), 4); - Assertions.assertEquals(astTransformed.get().getCoordinateList().get(0).getY(), 2); + assertEquals(4, astTransformed.get().getCoordinateList().get(0).getX()); + assertEquals(2, astTransformed.get().getCoordinateList().get(0).getY()); - Assertions.assertEquals(astTransformed.get().getCoordinateList().get(1).getX(), 2); - Assertions.assertEquals(astTransformed.get().getCoordinateList().get(1).getY(), 5); + assertEquals(2, astTransformed.get().getCoordinateList().get(1).getX()); + assertEquals(5, astTransformed.get().getCoordinateList().get(1).getY()); - Assertions.assertEquals(astTransformed.get().getCoordinateList().get(2).getX(), 7); - Assertions.assertEquals(astTransformed.get().getCoordinateList().get(2).getY(), 1); + assertEquals(7, astTransformed.get().getCoordinateList().get(2).getX()); + assertEquals(1, astTransformed.get().getCoordinateList().get(2).getY()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/examples/lwc/TestEDL.java b/monticore-test/it/src/test/java/mc/examples/lwc/TestEDL.java index cc0e34dde4..287de6b182 100644 --- a/monticore-test/it/src/test/java/mc/examples/lwc/TestEDL.java +++ b/monticore-test/it/src/test/java/mc/examples/lwc/TestEDL.java @@ -2,18 +2,12 @@ package mc.examples.lwc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import mc.examples.lwc.edl.edl.EDLMill; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import com.google.common.collect.Lists; @@ -24,6 +18,8 @@ import mc.examples.lwc.edl.edl._parser.EDLParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class TestEDL extends GeneratorIntegrationsTest { @BeforeEach @@ -37,37 +33,37 @@ public void testParser() throws IOException { EDLParser parser = new EDLParser(); Optional ast = parser .parseEDLCompilationUnit("src/test/resources/examples/lwc/edl/Car.edl"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertNotNull(ast.get().getEntity()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertNotNull(ast.get().getEntity()); ASTEntity entity = ast.get().getEntity(); - Assertions.assertEquals(entity.getName(), "Car"); - Assertions.assertEquals(entity.getPropertyList().size(), 7); + assertEquals("Car", entity.getName()); + assertEquals(7, entity.getPropertyList().size()); - Assertions.assertEquals(entity.getPropertyList().get(0).getName(), "brand"); - Assertions.assertTrue(entity.getPropertyList().get(0).getType() + assertEquals("brand", entity.getPropertyList().get(0).getName()); + assertTrue(entity.getPropertyList().get(0).getType() .deepEquals(EDLMill.stringLiteralBuilder().build())); - Assertions.assertEquals(entity.getPropertyList().get(1).getName(), "model"); - Assertions.assertTrue(entity.getPropertyList().get(1).getType() + assertEquals("model", entity.getPropertyList().get(1).getName()); + assertTrue(entity.getPropertyList().get(1).getType() .deepEquals(EDLMill.stringLiteralBuilder().build())); - Assertions.assertEquals(entity.getPropertyList().get(2).getName(), "price"); - Assertions.assertTrue(entity.getPropertyList().get(2).getType() + assertEquals("price", entity.getPropertyList().get(2).getName()); + assertTrue(entity.getPropertyList().get(2).getType() .deepEquals(EDLMill.intLiteralBuilder().build())); - Assertions.assertEquals(entity.getPropertyList().get(3).getName(), "age"); - Assertions.assertTrue(entity.getPropertyList().get(3).getType() + assertEquals("age", entity.getPropertyList().get(3).getName()); + assertTrue(entity.getPropertyList().get(3).getType() .deepEquals(EDLMill.intLiteralBuilder().build())); - Assertions.assertEquals(entity.getPropertyList().get(4).getName(), "doors"); - Assertions.assertTrue(entity.getPropertyList().get(4).getType() + assertEquals("doors", entity.getPropertyList().get(4).getName()); + assertTrue(entity.getPropertyList().get(4).getType() .deepEquals(EDLMill.intLiteralBuilder().build())); - Assertions.assertEquals(entity.getPropertyList().get(5).getName(), "myself"); - Assertions.assertTrue(entity + assertEquals("myself", entity.getPropertyList().get(5).getName()); + assertTrue(entity .getPropertyList() .get(5) .getType() @@ -76,8 +72,8 @@ public void testParser() throws IOException { .setQualifiedName( EDLMill.qualifiedNameBuilder().setNamesList(Lists.newArrayList("Car")).build()).build())); - Assertions.assertEquals(entity.getPropertyList().get(6).getName(), "owner"); - Assertions.assertTrue(entity + assertEquals("owner", entity.getPropertyList().get(6).getName()); + assertTrue(entity .getPropertyList() .get(6) .getType() @@ -87,7 +83,7 @@ public void testParser() throws IOException { EDLMill.qualifiedNameBuilder().setNamesList(Lists.newArrayList("lwc", "edl", "Person")) .build()).build())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/examples/lwc/TestODL.java b/monticore-test/it/src/test/java/mc/examples/lwc/TestODL.java index 8ed33d47a4..22e5e6163e 100644 --- a/monticore-test/it/src/test/java/mc/examples/lwc/TestODL.java +++ b/monticore-test/it/src/test/java/mc/examples/lwc/TestODL.java @@ -2,18 +2,12 @@ package mc.examples.lwc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import mc.examples.lwc.odl.odl.ODLMill; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import com.google.common.collect.Lists; @@ -24,6 +18,8 @@ import mc.examples.lwc.odl.odl._parser.ODLParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class TestODL extends GeneratorIntegrationsTest { @BeforeEach @@ -37,22 +33,22 @@ public void testParser() throws IOException { ODLParser parser = new ODLParser(); Optional ast = parser .parseODLCompilationUnit("src/test/resources/examples/lwc/odl/MyWorld.odl"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTInstances instances = ast.get().getInstances(); - Assertions.assertNotNull(instances); + assertNotNull(instances); - Assertions.assertEquals(instances.getName(), "MyWorld"); - Assertions.assertEquals(instances.getObjectList().size(), 2); + assertEquals("MyWorld", instances.getName()); + assertEquals(2, instances.getObjectList().size()); - Assertions.assertEquals(instances.getObjectList().get(0).getName(), "person"); - Assertions.assertTrue(instances.getObjectList().get(0).getType().deepEquals( + assertEquals("person", instances.getObjectList().get(0).getName()); + assertTrue(instances.getObjectList().get(0).getType().deepEquals( ODLMill.qualifiedNameBuilder().setNamesList(Lists.newArrayList("Person")).build())); - Assertions.assertEquals(instances.getObjectList().get(0).getAssignmentList().size(), 4); - Assertions.assertEquals(instances.getObjectList().get(0).getAssignmentList().get(0).getName(), "birthday"); - Assertions.assertTrue(instances + assertEquals(4, instances.getObjectList().get(0).getAssignmentList().size()); + assertEquals("birthday", instances.getObjectList().get(0).getAssignmentList().get(0).getName()); + assertTrue(instances .getObjectList() .get(0) .getAssignmentList() @@ -62,8 +58,8 @@ public void testParser() throws IOException { ODLMill.dateValueBuilder() .setDate(ODLMill.dateBuilder().setDay("01").setMonth("01").setYear("1999").build()).build())); - Assertions.assertEquals(instances.getObjectList().get(0).getAssignmentList().get(1).getName(), "name"); - Assertions.assertTrue(instances + assertEquals("name", instances.getObjectList().get(0).getAssignmentList().get(1).getName()); + assertTrue(instances .getObjectList() .get(0) .getAssignmentList() @@ -73,8 +69,8 @@ public void testParser() throws IOException { ODLMill.stringValueBuilder() .setSTRING("alice").build())); - Assertions.assertEquals(instances.getObjectList().get(0).getAssignmentList().get(2).getName(), "id"); - Assertions.assertTrue(instances + assertEquals("id", instances.getObjectList().get(0).getAssignmentList().get(2).getName()); + assertTrue(instances .getObjectList() .get(0) .getAssignmentList() @@ -84,8 +80,8 @@ public void testParser() throws IOException { ODLMill.intValueBuilder() .setINT("1").build())); - Assertions.assertEquals(instances.getObjectList().get(0).getAssignmentList().get(3).getName(), "car"); - Assertions.assertTrue(instances + assertEquals("car", instances.getObjectList().get(0).getAssignmentList().get(3).getName()); + assertTrue(instances .getObjectList() .get(0) .getAssignmentList() @@ -95,10 +91,10 @@ public void testParser() throws IOException { ODLMill.referenceValueBuilder() .setName("car").build())); - Assertions.assertEquals(instances.getObjectList().get(1).getName(), "car"); - Assertions.assertTrue(instances.getObjectList().get(1).getType().deepEquals( + assertEquals("car", instances.getObjectList().get(1).getName()); + assertTrue(instances.getObjectList().get(1).getType().deepEquals( ODLMill.qualifiedNameBuilder().setNamesList(Lists.newArrayList("lwc", "edl", "Car")).build())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/abc/EmbedTest.java b/monticore-test/it/src/test/java/mc/feature/abc/EmbedTest.java index d72543cdcb..1bdefbfca4 100644 --- a/monticore-test/it/src/test/java/mc/feature/abc/EmbedTest.java +++ b/monticore-test/it/src/test/java/mc/feature/abc/EmbedTest.java @@ -2,21 +2,19 @@ package mc.feature.abc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import mc.GeneratorIntegrationsTest; import mc.feature.abc.realabc._parser.RealABCParser; +import static org.junit.jupiter.api.Assertions.*; + public class EmbedTest extends GeneratorIntegrationsTest { @BeforeEach @@ -30,8 +28,8 @@ public void test() throws IOException { RealABCParser p = parse("a b c"); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -39,8 +37,8 @@ public void testb() throws IOException { RealABCParser p = parse("a b"); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -48,8 +46,8 @@ public void testc() throws IOException { RealABCParser p = parse("a a a b b b c c c"); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -57,8 +55,8 @@ public void testd() throws IOException { RealABCParser p = parse("a b c c"); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } private RealABCParser parse(String in) throws IOException { diff --git a/monticore-test/it/src/test/java/mc/feature/abstractgrammar/AbstractGrammarTest.java b/monticore-test/it/src/test/java/mc/feature/abstractgrammar/AbstractGrammarTest.java index 15f97c74ec..7370b19bb3 100644 --- a/monticore-test/it/src/test/java/mc/feature/abstractgrammar/AbstractGrammarTest.java +++ b/monticore-test/it/src/test/java/mc/feature/abstractgrammar/AbstractGrammarTest.java @@ -2,15 +2,11 @@ package mc.feature.abstractgrammar; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; @@ -21,6 +17,8 @@ import mc.feature.abstractgrammar.implementation._parser.ImplementationParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class AbstractGrammarTest extends GeneratorIntegrationsTest { @BeforeEach @@ -35,10 +33,10 @@ public void testRefInterface() throws IOException { ImplementationParser p = new ImplementationParser(); java.util.Optional ast = p.parseUseUnterface(new StringReader("use impl myimplinterface")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(p.hasErrors()); - Assertions.assertTrue(ast.get().getII() instanceof ASTB); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(ast.isPresent()); + assertFalse(p.hasErrors()); + assertInstanceOf(ASTB.class, ast.get().getII()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -47,9 +45,9 @@ public void testRefAbstractRule() throws IOException { ImplementationParser p = new ImplementationParser(); java.util.Optional ast = p.parseUseAbstract(new StringReader("use ext myextabstract")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(p.hasErrors()); - Assertions.assertTrue(ast.get().getAA() instanceof ASTC); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(ast.isPresent()); + assertFalse(p.hasErrors()); + assertInstanceOf(ASTC.class, ast.get().getAA()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/abstractprod/AbstractProdTest.java b/monticore-test/it/src/test/java/mc/feature/abstractprod/AbstractProdTest.java index 5044c0ac81..f3367a3f6e 100644 --- a/monticore-test/it/src/test/java/mc/feature/abstractprod/AbstractProdTest.java +++ b/monticore-test/it/src/test/java/mc/feature/abstractprod/AbstractProdTest.java @@ -2,15 +2,11 @@ package mc.feature.abstractprod; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; @@ -20,6 +16,8 @@ import mc.feature.abstractprod.abstractprod._parser.AbstractProdParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class AbstractProdTest extends GeneratorIntegrationsTest { @BeforeEach @@ -34,11 +32,11 @@ public void testb() throws IOException { AbstractProdParser p = new AbstractProdParser(); java.util.Optional ast = p.parseA(new StringReader("b")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(ast.get() instanceof ASTB); - Assertions.assertFalse(p.hasErrors()); + assertTrue(ast.isPresent()); + assertInstanceOf(ASTB.class, ast.get()); + assertFalse(p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -47,10 +45,10 @@ public void testc() throws IOException { AbstractProdParser p = new AbstractProdParser(); java.util.Optional ast = p.parseA(new StringReader("c")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(ast.get() instanceof ASTC); - Assertions.assertFalse(p.hasErrors()); + assertTrue(ast.isPresent()); + assertInstanceOf(ASTC.class, ast.get()); + assertFalse(p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/addkeywords/AddKeywordsTest.java b/monticore-test/it/src/test/java/mc/feature/addkeywords/AddKeywordsTest.java index 239c9cab3c..07bf7eca5c 100644 --- a/monticore-test/it/src/test/java/mc/feature/addkeywords/AddKeywordsTest.java +++ b/monticore-test/it/src/test/java/mc/feature/addkeywords/AddKeywordsTest.java @@ -2,17 +2,12 @@ package mc.feature.addkeywords; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -21,6 +16,8 @@ import mc.feature.addkeywords.addkeywords._ast.ASTE; import mc.feature.addkeywords.addkeywords._parser.AddKeywordsParser; +import static org.junit.jupiter.api.Assertions.*; + public class AddKeywordsTest extends GeneratorIntegrationsTest { @BeforeEach @@ -36,15 +33,15 @@ public void testB() throws IOException { helperb("keyword"); helperb("key2"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private void helperb(String in) throws IOException { AddKeywordsParser b = new AddKeywordsParser(); b.parseB(new StringReader(in)); - Assertions.assertFalse(b.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(b.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -54,13 +51,13 @@ public void testC() throws IOException { helperc("keyword"); helperc("key2"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private void helperc(String in) throws IOException { AddKeywordsParser b = new AddKeywordsParser(); b.parseC(new StringReader(in)); - Assertions.assertFalse(b.hasErrors()); + assertFalse(b.hasErrors()); } @Test @@ -70,18 +67,18 @@ public void testD() throws IOException { helperd("keyword"); helperd("key2"); - Assertions.assertEquals(3, helperd("10 keyword 2").getNameList().size()); - Assertions.assertEquals(3, helperd("2 2 3").getNameList().size()); - Assertions.assertEquals(3, helperd("48 keyword key2").getNameList().size()); + assertEquals(3, helperd("10 keyword 2").getNameList().size()); + assertEquals(3, helperd("2 2 3").getNameList().size()); + assertEquals(3, helperd("48 keyword key2").getNameList().size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private ASTD helperd(String in) throws IOException { AddKeywordsParser createSimpleParser = new AddKeywordsParser(); Optional parse = createSimpleParser.parseD(new StringReader(in)); - Assertions.assertTrue(parse.isPresent()); - Assertions.assertFalse(createSimpleParser.hasErrors()); + assertTrue(parse.isPresent()); + assertFalse(createSimpleParser.hasErrors()); return parse.get(); } @@ -93,18 +90,18 @@ public void testE() throws IOException { helpere("keyword"); helpere("key2"); - Assertions.assertEquals(3, helpere("10 keyword 2").getINTList().size()); - Assertions.assertEquals(3, helpere("2 2 3").getINTList().size()); - Assertions.assertEquals(3, helpere("48 keyword key2").getINTList().size()); + assertEquals(3, helpere("10 keyword 2").getINTList().size()); + assertEquals(3, helpere("2 2 3").getINTList().size()); + assertEquals(3, helpere("48 keyword key2").getINTList().size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private ASTE helpere(String in) throws IOException { AddKeywordsParser createSimpleParser = new AddKeywordsParser(); Optional parse = createSimpleParser.parseE(new StringReader(in)); - Assertions.assertTrue(parse.isPresent()); - Assertions.assertFalse(createSimpleParser.hasErrors()); + assertTrue(parse.isPresent()); + assertFalse(createSimpleParser.hasErrors()); return parse.get(); } diff --git a/monticore-test/it/src/test/java/mc/feature/ast/ParserForInterfaceTest.java b/monticore-test/it/src/test/java/mc/feature/ast/ParserForInterfaceTest.java index 17de12e6c1..6a65d13895 100644 --- a/monticore-test/it/src/test/java/mc/feature/ast/ParserForInterfaceTest.java +++ b/monticore-test/it/src/test/java/mc/feature/ast/ParserForInterfaceTest.java @@ -2,21 +2,19 @@ package mc.feature.ast; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; import mc.feature.featuredsl._parser.FeatureDSLParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class ParserForInterfaceTest extends GeneratorIntegrationsTest { @BeforeEach @@ -32,9 +30,9 @@ public void testExtraComponent() throws IOException { FeatureDSLParser p = new FeatureDSLParser(); p.parseExtraComponent(s); - Assertions.assertEquals(false, p.hasErrors()); + assertFalse(p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/ast/ParserTest.java b/monticore-test/it/src/test/java/mc/feature/ast/ParserTest.java index ad07fa49a0..06ff5b4966 100644 --- a/monticore-test/it/src/test/java/mc/feature/ast/ParserTest.java +++ b/monticore-test/it/src/test/java/mc/feature/ast/ParserTest.java @@ -2,10 +2,6 @@ package mc.feature.ast; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; @@ -31,6 +27,8 @@ import mc.feature.featuredsl._ast.ASTSpices2; import mc.feature.featuredsl._parser.FeatureDSLParser; +import static org.junit.jupiter.api.Assertions.*; + public class ParserTest extends GeneratorIntegrationsTest { @BeforeEach @@ -46,27 +44,27 @@ public void testConstants() throws IOException { FeatureDSLParser p = new FeatureDSLParser(); Optional opt = p.parseAutomaton(s); - Assertions.assertTrue(opt.isPresent()); + assertTrue(opt.isPresent()); ASTAutomaton ast = opt.get(); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertEquals("a", ast.getName()); + assertFalse(p.hasErrors()); + assertEquals("a", ast.getName()); - Assertions.assertEquals(true, ((ASTConstants) ast.getWiredList().get(0)).isPubblic()); - Assertions.assertEquals(false, ((ASTConstants) ast.getWiredList().get(0)).isPrivate()); + assertTrue(((ASTConstants) ast.getWiredList().get(0)).isPubblic()); + assertFalse(((ASTConstants) ast.getWiredList().get(0)).isPrivate()); - Assertions.assertEquals(true, ((ASTConstants) ast.getWiredList().get(1)).isPubblic()); - Assertions.assertEquals(false, ((ASTConstants) ast.getWiredList().get(1)).isPrivate()); + assertTrue(((ASTConstants) ast.getWiredList().get(1)).isPubblic()); + assertFalse(((ASTConstants) ast.getWiredList().get(1)).isPrivate()); - Assertions.assertEquals(false, ((ASTConstants) ast.getWiredList().get(2)).isPubblic()); - Assertions.assertEquals(true, ((ASTConstants) ast.getWiredList().get(2)).isPrivate()); + assertFalse(((ASTConstants) ast.getWiredList().get(2)).isPubblic()); + assertTrue(((ASTConstants) ast.getWiredList().get(2)).isPrivate()); - Assertions.assertEquals(true, ((ASTSpices1) ast.getWiredList().get(3)).isCarlique()); - Assertions.assertEquals(true, ((ASTSpices1) ast.getWiredList().get(3)).isPepper()); + assertTrue(((ASTSpices1) ast.getWiredList().get(3)).isCarlique()); + assertTrue(((ASTSpices1) ast.getWiredList().get(3)).isPepper()); - Assertions.assertEquals(ASTConstantsFeatureDSL.NONE, ((ASTSpices2) ((ASTAutomaton) ast).getWiredList().get(4)).getSpicelevel()); + assertEquals(ASTConstantsFeatureDSL.NONE, ((ASTSpices2) ((ASTAutomaton) ast).getWiredList().get(4)).getSpicelevel()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -80,7 +78,7 @@ public void testConstantsParseError() throws IOException { FeatureDSLParser p = new FeatureDSLParser(); p.parseAutomaton(s); - Assertions.assertEquals(true, p.hasErrors()); + assertTrue(p.hasErrors()); } /* Grammar: B: A:A (B:A)*; @@ -99,12 +97,12 @@ public void testListError() throws IOException { FeatureDSLParser p = new FeatureDSLParser(); Optional ast = p.parseB(s); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals(true, ast.get().getA() instanceof ASTA); - Assertions.assertEquals(true, ast.get().getBList() instanceof List); + assertFalse(p.hasErrors()); + assertTrue(ast.isPresent()); + assertInstanceOf(ASTA.class, ast.get().getA()); + assertInstanceOf(List.class, ast.get().getBList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /* Grammar: B: A:A (A:A)*; @@ -123,11 +121,11 @@ public void testListError2() throws IOException { FeatureDSLParser p = new FeatureDSLParser(); Optional ast = p.parseC(s); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertEquals(true, ast.get().getAList() instanceof List); + assertTrue(ast.isPresent()); + assertFalse(p.hasErrors()); + assertInstanceOf(List.class, ast.get().getAList()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } /* Grammar: @@ -146,7 +144,7 @@ public void testListError3() throws IOException { FeatureDSLParser p = new FeatureDSLParser(); Optional ast = p.parseComplexname(s); - Assertions.assertFalse(ast.isPresent()); + assertFalse(ast.isPresent()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/astident/TestASTIdent.java b/monticore-test/it/src/test/java/mc/feature/astident/TestASTIdent.java index bf59b7e9cc..7b775665f2 100644 --- a/monticore-test/it/src/test/java/mc/feature/astident/TestASTIdent.java +++ b/monticore-test/it/src/test/java/mc/feature/astident/TestASTIdent.java @@ -2,15 +2,11 @@ package mc.feature.astident; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; @@ -18,6 +14,8 @@ import mc.feature.astident.astident._parser.AstIdentParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class TestASTIdent extends GeneratorIntegrationsTest { @BeforeEach @@ -34,13 +32,13 @@ public void testParser() throws IOException { AstIdentParser p = new AstIdentParser(); java.util.Optional ast = p.parseA(s); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals(false, p.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(p.hasErrors()); // Test parsing - Assertions.assertEquals("Otto", ast.get().getName()); + assertEquals("Otto", ast.get().getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/astlist/CollectionTest.java b/monticore-test/it/src/test/java/mc/feature/astlist/CollectionTest.java index 50e57e1e6b..f991e232fe 100644 --- a/monticore-test/it/src/test/java/mc/feature/astlist/CollectionTest.java +++ b/monticore-test/it/src/test/java/mc/feature/astlist/CollectionTest.java @@ -8,12 +8,11 @@ import mc.feature.list.lists.ListsMill; import mc.feature.list.lists._ast.ASTParent; import mc.feature.list.lists._ast.ASTSon; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CollectionTest { @@ -38,16 +37,16 @@ public void testDeepEquals1() { p2.getSonsList().add(s3); p2.getSonsList().add(s4); - Assertions.assertTrue(p1.deepEquals(p1, true)); - Assertions.assertTrue(p2.deepEquals(p2, true)); - Assertions.assertTrue(p1.deepEquals(p2, true)); - Assertions.assertTrue(p2.deepEquals(p1, true)); + assertTrue(p1.deepEquals(p1, true)); + assertTrue(p2.deepEquals(p2, true)); + assertTrue(p1.deepEquals(p2, true)); + assertTrue(p2.deepEquals(p1, true)); p1.getSonsList().remove(s1); - Assertions.assertFalse(p1.deepEquals(p2, true)); - Assertions.assertFalse(p2.deepEquals(p1, true)); + assertFalse(p1.deepEquals(p2, true)); + assertFalse(p2.deepEquals(p1, true)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -69,14 +68,14 @@ public void testDeepEquals2() { p2.getSonsList().add(s3); p2.getSonsList().add(s4); - Assertions.assertTrue(p1.deepEquals(p1)); - Assertions.assertFalse(p1.deepEquals(p2)); - Assertions.assertTrue(p1.deepEquals(p2, false)); - Assertions.assertTrue(p2.deepEquals(p1, false)); - Assertions.assertFalse(p1.deepEquals(p2, true)); - Assertions.assertFalse(p2.deepEquals(p1, true)); + assertTrue(p1.deepEquals(p1)); + assertFalse(p1.deepEquals(p2)); + assertTrue(p1.deepEquals(p2, false)); + assertTrue(p2.deepEquals(p1, false)); + assertFalse(p1.deepEquals(p2, true)); + assertFalse(p2.deepEquals(p1, true)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -94,16 +93,16 @@ public void testDeepEqualsWithComments1() { p2.getSonsList().add(s3); p2.getSonsList().add(s4); - Assertions.assertTrue(p1.deepEqualsWithComments(p1)); - Assertions.assertTrue(p2.deepEqualsWithComments(p2)); - Assertions.assertTrue(p1.deepEqualsWithComments(p2)); - Assertions.assertTrue(p2.deepEqualsWithComments(p1)); + assertTrue(p1.deepEqualsWithComments(p1)); + assertTrue(p2.deepEqualsWithComments(p2)); + assertTrue(p1.deepEqualsWithComments(p2)); + assertTrue(p2.deepEqualsWithComments(p1)); p1.getSonsList().remove(s1); - Assertions.assertFalse(p1.deepEqualsWithComments(p2)); - Assertions.assertFalse(p2.deepEqualsWithComments(p1)); + assertFalse(p1.deepEqualsWithComments(p2)); + assertFalse(p2.deepEqualsWithComments(p1)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -125,10 +124,10 @@ public void testDeepEqualsWithComments2() { p2.getSonsList().add(s3); p2.getSonsList().add(s4); - Assertions.assertFalse(p1.deepEqualsWithComments(p2)); - Assertions.assertFalse(p2.deepEqualsWithComments(p1)); + assertFalse(p1.deepEqualsWithComments(p2)); + assertFalse(p2.deepEqualsWithComments(p1)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -152,15 +151,15 @@ public void deepEqualsWithComments3() { p2.getSonsList().add(s3); p2.getSonsList().add(s4); - Assertions.assertTrue(p1.deepEqualsWithComments(p2)); - Assertions.assertTrue(p2.deepEqualsWithComments(p1)); + assertTrue(p1.deepEqualsWithComments(p2)); + assertTrue(p2.deepEqualsWithComments(p1)); c1.setText("different comment"); - Assertions.assertFalse(p1.deepEqualsWithComments(p2)); - Assertions.assertFalse(p2.deepEqualsWithComments(p1)); + assertFalse(p1.deepEqualsWithComments(p2)); + assertFalse(p2.deepEqualsWithComments(p1)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -180,9 +179,9 @@ public void testDeepClone() { ASTParent p2 = p1.deepClone(); - Assertions.assertTrue(p1.deepEqualsWithComments(p2)); + assertTrue(p1.deepEqualsWithComments(p2)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -203,9 +202,9 @@ public void testClone() { ASTParent p2 = p1.deepClone(); - Assertions.assertTrue(p1.deepEquals(p2)); + assertTrue(p1.deepEquals(p2)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/astlist/TestLists.java b/monticore-test/it/src/test/java/mc/feature/astlist/TestLists.java index 92b161c596..13ad7c9c42 100644 --- a/monticore-test/it/src/test/java/mc/feature/astlist/TestLists.java +++ b/monticore-test/it/src/test/java/mc/feature/astlist/TestLists.java @@ -13,8 +13,8 @@ import java.util.ArrayList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestLists extends GeneratorIntegrationsTest { @@ -45,10 +45,10 @@ public void testLists() { list.add(f); list.add(g); - Assertions.assertEquals(6, list.indexOf(g)); + assertEquals(6, list.indexOf(g)); list.remove(g); - Assertions.assertEquals(-1, list.indexOf(g)); + assertEquals(-1, list.indexOf(g)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/aststring/ASTStringParserTest.java b/monticore-test/it/src/test/java/mc/feature/aststring/ASTStringParserTest.java index 633acac71d..d861398f3f 100644 --- a/monticore-test/it/src/test/java/mc/feature/aststring/ASTStringParserTest.java +++ b/monticore-test/it/src/test/java/mc/feature/aststring/ASTStringParserTest.java @@ -1,8 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ package mc.feature.aststring; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.io.IOException; import java.io.StringReader; @@ -12,7 +10,6 @@ import de.se_rwth.commons.logging.LogStub; import mc.feature.aststring.aststring.AststringMill; import mc.feature.aststring.aststring._ast.ASTTestSingleQuote; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; @@ -20,6 +17,8 @@ import mc.feature.aststring.aststring._parser.AststringParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class ASTStringParserTest extends GeneratorIntegrationsTest { @BeforeEach @@ -36,34 +35,34 @@ public void testParser() throws IOException { AststringParser p = new AststringParser(); java.util.Optional opt = p.parseStart(s); - Assertions.assertTrue(opt.isPresent()); + assertTrue(opt.isPresent()); ASTStart ast = opt.get(); - Assertions.assertEquals(false, p.hasErrors()); + assertFalse(p.hasErrors()); // Test parsing - Assertions.assertEquals("ah", ast.getAList().get(0)); - Assertions.assertEquals("be", ast.getAList().get(1)); - Assertions.assertEquals("ce", ast.getAList().get(2)); - Assertions.assertEquals("oh", ast.getBList().get(0)); - Assertions.assertEquals("pe", ast.getBList().get(1)); - Assertions.assertEquals("qu", ast.getBList().get(2)); - Assertions.assertEquals("x", ast.getCList().get(0)); - Assertions.assertEquals("y", ast.getCList().get(1)); - Assertions.assertEquals("z", ast.getCList().get(2)); - Assertions.assertEquals("de", ast.getDList().get(0)); - Assertions.assertEquals("eh", ast.getDList().get(1)); + assertEquals("ah", ast.getAList().get(0)); + assertEquals("be", ast.getAList().get(1)); + assertEquals("ce", ast.getAList().get(2)); + assertEquals("oh", ast.getBList().get(0)); + assertEquals("pe", ast.getBList().get(1)); + assertEquals("qu", ast.getBList().get(2)); + assertEquals("x", ast.getCList().get(0)); + assertEquals("y", ast.getCList().get(1)); + assertEquals("z", ast.getCList().get(2)); + assertEquals("de", ast.getDList().get(0)); + assertEquals("eh", ast.getDList().get(1)); // Test toString method - Assertions.assertEquals("ef", ast.getDList().get(2).toString()); + assertEquals("ef", ast.getDList().get(2).toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSingleQuote() throws IOException { Optional ast = AststringMill.parser().parse_StringTestSingleQuote("Alex's Parser probleme"); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/automaton/SubclassParsingTest.java b/monticore-test/it/src/test/java/mc/feature/automaton/SubclassParsingTest.java index 565c1e1d2b..3cf61e47c9 100644 --- a/monticore-test/it/src/test/java/mc/feature/automaton/SubclassParsingTest.java +++ b/monticore-test/it/src/test/java/mc/feature/automaton/SubclassParsingTest.java @@ -2,15 +2,12 @@ package mc.feature.automaton; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; @@ -19,6 +16,9 @@ import mc.feature.automaton.automaton._ast.ASTTransition; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class SubclassParsingTest extends GeneratorIntegrationsTest { @BeforeEach @@ -33,9 +33,9 @@ public void testSubtypeParsing() throws IOException { AutomatonParser parser = new AutomatonParser(); Optional ast = parser.parseTransition(new StringReader("sub a -x> b;")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(ast.get() instanceof ASTSubTransition); + assertTrue(ast.isPresent()); + assertInstanceOf(ASTSubTransition.class, ast.get()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/classgenwithingrammar/ParserTest.java b/monticore-test/it/src/test/java/mc/feature/classgenwithingrammar/ParserTest.java index a7461e5293..dcbc981511 100644 --- a/monticore-test/it/src/test/java/mc/feature/classgenwithingrammar/ParserTest.java +++ b/monticore-test/it/src/test/java/mc/feature/classgenwithingrammar/ParserTest.java @@ -2,21 +2,20 @@ package mc.feature.classgenwithingrammar; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import mc.GeneratorIntegrationsTest; import mc.feature.classgenwithingrammar.type._parser.TypeParser; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class ParserTest extends GeneratorIntegrationsTest { @BeforeEach @@ -30,7 +29,7 @@ public void before() { public void test() throws IOException { boolean hasError = parse("Hallo Hallo Hallo Welt "); - Assertions.assertTrue(hasError); + assertTrue(hasError); } // Test that the last Hallo is too much @@ -38,7 +37,7 @@ public void test() throws IOException { public void test2() throws IOException { boolean hasError = parse("Hallo Hallo Hallo Hallo "); - Assertions.assertTrue(hasError); + assertTrue(hasError); } // Tests that String is ok @@ -47,9 +46,9 @@ public void test3() throws IOException { boolean hasError = parse("Hallo Hallo Hallo "); - Assertions.assertFalse(hasError); + assertFalse(hasError); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } // Tests that one hallo is issing @@ -58,7 +57,7 @@ public void test4() throws IOException { boolean hasError = parse("Hallo "); - Assertions.assertTrue(hasError); + assertTrue(hasError); } // Test that one Welt is too much @@ -67,7 +66,7 @@ public void testl() throws IOException { boolean hasError = parse2("Hall Hall Hall \"Wel\" "); - Assertions.assertTrue(hasError); + assertTrue(hasError); } // Test that too many Hallo and Welt are detected in one go @@ -76,7 +75,7 @@ public void testl2() throws IOException { boolean hasError = parse2("Hall Hall Hall Hall \"Wel\" "); - Assertions.assertTrue(hasError); + assertTrue(hasError); } // Tests that String is ok @@ -85,9 +84,9 @@ public void testl3() throws IOException { boolean hasError = parse2("Hall Hall Hall "); - Assertions.assertFalse(hasError); + assertFalse(hasError); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private boolean parse( String input) throws IOException { diff --git a/monticore-test/it/src/test/java/mc/feature/cocochecker/CoCoCheckerTest.java b/monticore-test/it/src/test/java/mc/feature/cocochecker/CoCoCheckerTest.java index 0bd9f4f18b..f3c0bbf6f5 100644 --- a/monticore-test/it/src/test/java/mc/feature/cocochecker/CoCoCheckerTest.java +++ b/monticore-test/it/src/test/java/mc/feature/cocochecker/CoCoCheckerTest.java @@ -2,17 +2,12 @@ package mc.feature.cocochecker; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -29,6 +24,8 @@ import mc.feature.cocochecker.c._cocos.CASTZCoCo; import mc.feature.cocochecker.c._cocos.CCoCoChecker; +import static org.junit.jupiter.api.Assertions.*; + /** * Tests adding cocos of super languages to a checker of a sublanguage.
*
@@ -97,9 +94,9 @@ public void setUp() { } catch (IOException e) { e.printStackTrace(); - Assertions.fail("Parser Error."); + fail("Parser Error."); } - Assertions.assertTrue(astOpt.isPresent()); + assertTrue(astOpt.isPresent()); ast = astOpt.get(); checked.setLength(0); } @@ -114,8 +111,8 @@ public void testCoCoComposition() { checker.addCoCo(cocoZ); checker.checkAll(ast); - Assertions.assertEquals("BAYZ", checked.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("BAYZ", checked.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -137,8 +134,8 @@ public void testCheckerComposition() { checkerA.addChecker(checkerC); checkerA.checkAll(ast); - Assertions.assertEquals("BAYZ", checked.toString()); + assertEquals("BAYZ", checked.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/comments/CommentTest.java b/monticore-test/it/src/test/java/mc/feature/comments/CommentTest.java index b0e1c20396..8bfea3fced 100644 --- a/monticore-test/it/src/test/java/mc/feature/comments/CommentTest.java +++ b/monticore-test/it/src/test/java/mc/feature/comments/CommentTest.java @@ -2,15 +2,11 @@ package mc.feature.comments; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; @@ -22,6 +18,8 @@ import mc.feature.featuredsl._parser.FeatureDSLParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class CommentTest extends GeneratorIntegrationsTest { @BeforeEach @@ -41,30 +39,30 @@ public void testConstants() throws IOException { ASTAutomaton ast = optAst.get(); // Parsing - Assertions.assertEquals(false, cp.hasErrors()); - Assertions.assertEquals("a", ast.getName()); + assertFalse(cp.hasErrors()); + assertEquals("a", ast.getName()); - Assertions.assertEquals(true, ((ASTConstants) ast.getWiredList().get(0)).isPubblic()); - Assertions.assertEquals(false, ((ASTConstants) ast.getWiredList().get(0)).isPrivate()); + assertTrue(((ASTConstants) ast.getWiredList().get(0)).isPubblic()); + assertFalse(((ASTConstants) ast.getWiredList().get(0)).isPrivate()); - Assertions.assertEquals(true, ((ASTConstants) ast.getWiredList().get(1)).isPubblic()); - Assertions.assertEquals(false, ((ASTConstants) ast.getWiredList().get(1)).isPrivate()); + assertTrue(((ASTConstants) ast.getWiredList().get(1)).isPubblic()); + assertFalse(((ASTConstants) ast.getWiredList().get(1)).isPrivate()); - Assertions.assertEquals(false, ((ASTConstants) ast.getWiredList().get(2)).isPubblic()); - Assertions.assertEquals(true, ((ASTConstants) ast.getWiredList().get(2)).isPrivate()); + assertFalse(((ASTConstants) ast.getWiredList().get(2)).isPubblic()); + assertTrue(((ASTConstants) ast.getWiredList().get(2)).isPrivate()); - Assertions.assertEquals(true, ((ASTSpices1) ast.getWiredList().get(3)).isCarlique()); - Assertions.assertEquals(true, ((ASTSpices1) ast.getWiredList().get(3)).isPepper()); + assertTrue(((ASTSpices1) ast.getWiredList().get(3)).isCarlique()); + assertTrue(((ASTSpices1) ast.getWiredList().get(3)).isPepper()); - Assertions.assertEquals(ASTConstantsFeatureDSL.NONE, ((ASTSpices2) ((ASTAutomaton) ast).getWiredList().get(4)).getSpicelevel()); + assertEquals(ASTConstantsFeatureDSL.NONE, ((ASTSpices2) ((ASTAutomaton) ast).getWiredList().get(4)).getSpicelevel()); - Assertions.assertEquals("// Test ", ast.get_PreCommentList().get(0).getText()); - Assertions.assertEquals("/*Second*/", ast.get_PreCommentList().get(1).getText()); - Assertions.assertEquals("// First Constant 1", ast.getWiredList().get(0).get_PreCommentList().get(0).getText()); - Assertions.assertEquals("// First Constant 2", ast.getWiredList().get(0).get_PostCommentList().get(0).getText()); - Assertions.assertEquals("/*Second Constant*/", ast.getWiredList().get(1).get_PreCommentList().get(0).getText()); + assertEquals("// Test ", ast.get_PreCommentList().get(0).getText()); + assertEquals("/*Second*/", ast.get_PreCommentList().get(1).getText()); + assertEquals("// First Constant 1", ast.getWiredList().get(0).get_PreCommentList().get(0).getText()); + assertEquals("// First Constant 2", ast.getWiredList().get(0).get_PostCommentList().get(0).getText()); + assertEquals("/*Second Constant*/", ast.getWiredList().get(1).get_PreCommentList().get(0).getText()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/comments/CommentTypesTest.java b/monticore-test/it/src/test/java/mc/feature/comments/CommentTypesTest.java index cb65e9f2d3..87bbcc68fa 100644 --- a/monticore-test/it/src/test/java/mc/feature/comments/CommentTypesTest.java +++ b/monticore-test/it/src/test/java/mc/feature/comments/CommentTypesTest.java @@ -2,21 +2,19 @@ package mc.feature.comments; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import mc.GeneratorIntegrationsTest; import mc.feature.comments.commenttypestest._parser.CommentTypesTestParser; +import static org.junit.jupiter.api.Assertions.*; + public class CommentTypesTest extends GeneratorIntegrationsTest { @BeforeEach @@ -37,8 +35,8 @@ public void testXMLComment() throws IOException { CommentTypesTestParser p = new CommentTypesTestParser(); p.parseCStart(r); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -52,8 +50,8 @@ public void testCComment_With__() throws IOException { CommentTypesTestParser p = new CommentTypesTestParser(); p.parseCStart(r); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -67,8 +65,8 @@ public void testTexComment() throws IOException { CommentTypesTestParser p = new CommentTypesTestParser(); p.parseCStart(r); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -82,8 +80,8 @@ public void testFreeMarkerComment() throws IOException { CommentTypesTestParser p = new CommentTypesTestParser(); p.parseCStart(r); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } /** @@ -97,8 +95,8 @@ public void testHashComment() throws IOException { CommentTypesTestParser p = new CommentTypesTestParser(); p.parseCStart(r); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/comments/CommentsTest.java b/monticore-test/it/src/test/java/mc/feature/comments/CommentsTest.java index ba30faaf90..d32579a524 100644 --- a/monticore-test/it/src/test/java/mc/feature/comments/CommentsTest.java +++ b/monticore-test/it/src/test/java/mc/feature/comments/CommentsTest.java @@ -2,15 +2,11 @@ package mc.feature.comments; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import de.monticore.ast.ASTNode; @@ -19,6 +15,8 @@ import mc.feature.comments.commenttest._parser.CommentTestParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class CommentsTest extends GeneratorIntegrationsTest { @BeforeEach @@ -38,14 +36,14 @@ public void testComment() throws IOException { CommentTestParser p = new CommentTestParser(); java.util.Optional optAst = p.parseStart(r); - Assertions.assertTrue(optAst.isPresent()); + assertTrue(optAst.isPresent()); ASTStart ast = optAst.get(); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertEquals(1, ast.getAList().size()); - Assertions.assertEquals(1, ast.getBList().size()); - Assertions.assertEquals(1, ((ASTNode) ast.getAList().get(0)).get_PreCommentList().size()); - Assertions.assertEquals(1, ((ASTNode) ast.getAList().get(0)).get_PostCommentList().size()); - Assertions.assertEquals(0, ((ASTNode) ast.getBList().get(0)).get_PreCommentList().size()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertEquals(1, ast.getAList().size()); + assertEquals(1, ast.getBList().size()); + assertEquals(1, ((ASTNode) ast.getAList().get(0)).get_PreCommentList().size()); + assertEquals(1, ((ASTNode) ast.getAList().get(0)).get_PostCommentList().size()); + assertEquals(0, ((ASTNode) ast.getBList().get(0)).get_PreCommentList().size()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/compilationunit/ParserTest.java b/monticore-test/it/src/test/java/mc/feature/compilationunit/ParserTest.java index 85c8acc647..560d1acadf 100644 --- a/monticore-test/it/src/test/java/mc/feature/compilationunit/ParserTest.java +++ b/monticore-test/it/src/test/java/mc/feature/compilationunit/ParserTest.java @@ -2,16 +2,12 @@ package mc.feature.compilationunit; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -21,6 +17,8 @@ import mc.feature.compilationunit.compunit._ast.ASTCuFoo; import mc.feature.compilationunit.compunit._parser.CompunitParser; +import static org.junit.jupiter.api.Assertions.*; + public class ParserTest extends GeneratorIntegrationsTest { @BeforeEach @@ -34,10 +32,10 @@ public void testFoo() throws IOException { CompunitParser p = new CompunitParser(); Optional cUnit = p.parseCu(new StringReader("foo a")); - Assertions.assertFalse(p.hasErrors()); - Assertions.assertTrue(cUnit.isPresent()); - Assertions.assertTrue(cUnit.get() instanceof ASTCuFoo); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(cUnit.isPresent()); + assertInstanceOf(ASTCuFoo.class, cUnit.get()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -45,10 +43,10 @@ public void testBar() throws IOException { CompunitParser p = new CompunitParser(); Optional cUnit = p.parseCu(new StringReader("bar a")); - Assertions.assertFalse(p.hasErrors()); - Assertions.assertTrue(cUnit.isPresent()); - Assertions.assertTrue(cUnit.get() instanceof ASTCuBar); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(cUnit.isPresent()); + assertInstanceOf(ASTCuBar.class, cUnit.get()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/constantsshortform/ConstantsShortFormTest.java b/monticore-test/it/src/test/java/mc/feature/constantsshortform/ConstantsShortFormTest.java index 3c728f2b0a..c0b43f2886 100644 --- a/monticore-test/it/src/test/java/mc/feature/constantsshortform/ConstantsShortFormTest.java +++ b/monticore-test/it/src/test/java/mc/feature/constantsshortform/ConstantsShortFormTest.java @@ -8,12 +8,10 @@ import mc.feature.constantsshortform.constantsshortform.ConstantsShortFormMill; import mc.feature.constantsshortform.constantsshortform._ast.ASTA; import mc.feature.constantsshortform.constantsshortform._ast.ASTB; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ConstantsShortFormTest extends GeneratorIntegrationsTest { @@ -26,15 +24,15 @@ public void before() { @Test public void test() { ASTA a = ConstantsShortFormMill.aBuilder().build(); - Assertions.assertEquals(a.isMyConst(), false); + assertFalse(a.isMyConst()); a.setMyConst(true); - Assertions.assertEquals(a.isMyConst(), true); + assertTrue(a.isMyConst()); ASTB b = ConstantsShortFormMill.bBuilder().build(); - Assertions.assertEquals(b.isConst(), false); + assertFalse(b.isConst()); b.setConst(true); - Assertions.assertEquals(b.isConst(), true); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(b.isConst()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/deepclone/DeepCloneNotEqualTest.java b/monticore-test/it/src/test/java/mc/feature/deepclone/DeepCloneNotEqualTest.java index 0128e67ce0..de357fa050 100644 --- a/monticore-test/it/src/test/java/mc/feature/deepclone/DeepCloneNotEqualTest.java +++ b/monticore-test/it/src/test/java/mc/feature/deepclone/DeepCloneNotEqualTest.java @@ -8,15 +8,14 @@ import mc.feature.deepclone.deepclone._parser.DeepCloneParser; import mc.grammar.literals.ittestliterals._ast.ASTStringLiteral; import mc.grammar.literals.ittestliterals._ast.ASTIntLiteral; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DeepCloneNotEqualTest { @@ -30,64 +29,64 @@ public void before() { public void TestName() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneName("Name"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneName astClone = ast.get().deepClone(); astClone.setName("NewName"); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestNameList() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneNameList("Name1 Name2 Name3"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneNameList astClone = ast.get().deepClone(); astClone.setName(1, "NewName"); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestNameOptionalPresent() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneNameOptional("opt Name"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(ast.get().isPresentName()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(ast.get().isPresentName()); ASTCloneNameOptional astClone = ast.get().deepClone(); astClone.setNameAbsent(); - Assertions.assertFalse(astClone.isPresentName()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(astClone.isPresentName()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestNameOptionalAbsent() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneNameOptional("opt"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(ast.get().isPresentName()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(ast.get().isPresentName()); ASTCloneNameOptional astClone = ast.get().deepClone(); astClone.setName("NewName"); - Assertions.assertTrue(astClone.isPresentName()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(astClone.isPresentName()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestAST() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneAST("clone Name1 Name2 Name3"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneAST astClone = ast.get().deepClone(); astClone.getCloneNameList().setName(1, "NewName"); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -95,12 +94,12 @@ public void TestASTList() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser .parse_StringCloneASTList("clone Name1 Name2 clone Name3 Name4 Name5"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneASTList astClone = ast.get().deepClone(); astClone.getCloneAST(1).getCloneNameList().setName(1, "NewName"); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -108,244 +107,244 @@ public void TestASTOptionalPresent() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser .parse_StringCloneASTOptional("opt clone Name1 Name2 Name3"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(ast.get().isPresentCloneAST()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(ast.get().isPresentCloneAST()); ASTCloneASTOptional astClone = ast.get().deepClone(); astClone.setCloneASTAbsent(); - Assertions.assertFalse(astClone.isPresentCloneAST()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(astClone.isPresentCloneAST()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestASTOptionalAbsent() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneASTOptional("opt"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(ast.get().isPresentCloneAST()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(ast.get().isPresentCloneAST()); ASTCloneASTOptional astClone = ast.get().deepClone(); ASTCloneAST newast = parser.parse_StringCloneAST("clone Name1 Name2").get(); astClone.setCloneAST(newast); - Assertions.assertTrue(astClone.isPresentCloneAST()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(astClone.isPresentCloneAST()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestString() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneString("\"String\""); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneString astClone = ast.get().deepClone(); ASTStringLiteral string = parser.parse_StringCloneString("\"NewString\"").get().getStringLiteral(); astClone.setStringLiteral(string); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestStringList() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneStringList("\"String1\" \"String2\" \"String3\""); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneStringList astClone = ast.get().deepClone(); ASTStringLiteral string = parser.parse_StringCloneString("\"NewString\"").get().getStringLiteral(); astClone.getStringLiteralList().set(1, string); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestStringOptionalPresent() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneStringOptional("opt \"String\""); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(ast.get().isPresentStringLiteral()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(ast.get().isPresentStringLiteral()); ASTCloneStringOptional astClone = ast.get().deepClone(); astClone.setStringLiteralAbsent(); - Assertions.assertFalse(astClone.isPresentStringLiteral()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(astClone.isPresentStringLiteral()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestStringOptionalAbsent() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneStringOptional("opt"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(ast.get().isPresentStringLiteral()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(ast.get().isPresentStringLiteral()); ASTCloneStringOptional astClone = ast.get().deepClone(); ASTStringLiteral string = parser.parse_StringCloneString("\"NewString\"").get().getStringLiteral(); astClone.setStringLiteral(string); - Assertions.assertTrue(astClone.isPresentStringLiteral()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(astClone.isPresentStringLiteral()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestInt() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneInt("1234"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneInt astClone = ast.get().deepClone(); ASTIntLiteral i= parser.parse_StringCloneInt("4567").get().getIntLiteral(); astClone.setIntLiteral(i); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestIntList() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneIntList("12 34 56"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneIntList astClone = ast.get().deepClone(); ASTIntLiteral i= parser.parse_StringCloneInt("4567").get().getIntLiteral(); astClone.setIntLiteral(1, i); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestIntOptionalPresent() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneIntOptional("opt 234"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(ast.get().isPresentIntLiteral()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(ast.get().isPresentIntLiteral()); ASTCloneIntOptional astClone = ast.get().deepClone(); astClone.setIntLiteralAbsent(); - Assertions.assertFalse(astClone.isPresentIntLiteral()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(astClone.isPresentIntLiteral()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestIntOptionalAbsent() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneIntOptional("opt"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(ast.get().isPresentIntLiteral()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(ast.get().isPresentIntLiteral()); ASTCloneIntOptional astClone = ast.get().deepClone(); ASTIntLiteral i= parser.parse_StringCloneInt("4567").get().getIntLiteral(); astClone.setIntLiteral(i); - Assertions.assertTrue(astClone.isPresentIntLiteral()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(astClone.isPresentIntLiteral()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestString2() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneString2("\"String\""); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneString2 astClone = ast.get().deepClone(); astClone.setString("NewString"); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestStringList2() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneStringList2("\"String1\" \"String2\" \"String3\""); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneStringList2 astClone = ast.get().deepClone(); astClone.setString(1,"NewString"); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestStringOptionalPresent2() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneStringOptional2("opt \"String\""); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(ast.get().isPresentString()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(ast.get().isPresentString()); ASTCloneStringOptional2 astClone = ast.get().deepClone(); astClone.setStringAbsent(); - Assertions.assertFalse(astClone.isPresentString()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(astClone.isPresentString()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestStringOptionalAbsent2() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneStringOptional2("opt"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(ast.get().isPresentString()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(ast.get().isPresentString()); ASTCloneStringOptional2 astClone = ast.get().deepClone(); astClone.setString("NewString"); - Assertions.assertTrue(astClone.isPresentString()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(astClone.isPresentString()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestInt2() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneInt2("1234"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneInt2 astClone = ast.get().deepClone(); astClone.setNum_Int("4567"); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestIntList2() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneIntList2("12 34 56"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); ASTCloneIntList2 astClone = ast.get().deepClone(); astClone.setNum_Int(1, "2345"); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestIntOptionalPresent2() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneIntOptional2("opt 234"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(ast.get().isPresentNum_Int()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(ast.get().isPresentNum_Int()); ASTCloneIntOptional2 astClone = ast.get().deepClone(); astClone.setNum_IntAbsent(); - Assertions.assertFalse(astClone.isPresentNum_Int()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(astClone.isPresentNum_Int()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } @Test public void TestIntOptionalAbsent2() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneIntOptional2("opt"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertFalse(ast.get().isPresentNum_Int()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(ast.get().isPresentNum_Int()); ASTCloneIntOptional2 astClone = ast.get().deepClone(); astClone.setNum_Int("1234"); - Assertions.assertTrue(astClone.isPresentNum_Int()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(astClone.isPresentNum_Int()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } /* @Test @@ -362,14 +361,14 @@ public void TestEnumList() throws IOException { public void TestEnumOptionalPresent() throws IOException { DeepCloneParser parser = new DeepCloneParser(); Optional ast = parser.parse_StringCloneEnumOptional("opt enum"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(ast.get().isPresentCloneEnum()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(ast.get().isPresentCloneEnum()); ASTCloneEnumOptional astClone = ast.get().deepClone(); astClone.setCloneEnumAbsent(); - Assertions.assertFalse(astClone.isPresentCloneEnum()); - Assertions.assertFalse(ast.get().deepEquals(astClone)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(astClone.isPresentCloneEnum()); + assertFalse(ast.get().deepEquals(astClone)); + assertTrue(Log.getFindings().isEmpty()); } /* @Test diff --git a/monticore-test/it/src/test/java/mc/feature/deepclone/NoDoubleAddingTest.java b/monticore-test/it/src/test/java/mc/feature/deepclone/NoDoubleAddingTest.java index 11bba20458..360a345f13 100644 --- a/monticore-test/it/src/test/java/mc/feature/deepclone/NoDoubleAddingTest.java +++ b/monticore-test/it/src/test/java/mc/feature/deepclone/NoDoubleAddingTest.java @@ -5,15 +5,14 @@ import de.se_rwth.commons.logging.LogStub; import mc.feature.deepclone.nodoubleadding._ast.ASTSupProd; import mc.feature.deepclone.nodoubleadding._parser.NoDoubleAddingParser; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class NoDoubleAddingTest { @@ -28,14 +27,14 @@ public void testNoDoubleListElements() throws IOException { //test that deepClone does not copy list elements twice NoDoubleAddingParser parser = new NoDoubleAddingParser(); Optional astSupProd = parser.parse_StringSupProd("Foo foo Name1 Name2 Name3"); - Assertions.assertTrue(astSupProd.isPresent()); + assertTrue(astSupProd.isPresent()); ASTSupProd clonedProd = astSupProd.get().deepClone(); - Assertions.assertEquals(3, clonedProd.sizeNames()); - Assertions.assertEquals("Name1", clonedProd.getName(0)); - Assertions.assertEquals("Name2", clonedProd.getName(1)); - Assertions.assertEquals("Name3", clonedProd.getName(2)); + assertEquals(3, clonedProd.sizeNames()); + assertEquals("Name1", clonedProd.getName(0)); + assertEquals("Name2", clonedProd.getName(1)); + assertEquals("Name3", clonedProd.getName(2)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/embedding/EmbedTest.java b/monticore-test/it/src/test/java/mc/feature/embedding/EmbedTest.java index 3950de6227..b1dca0ad4b 100644 --- a/monticore-test/it/src/test/java/mc/feature/embedding/EmbedTest.java +++ b/monticore-test/it/src/test/java/mc/feature/embedding/EmbedTest.java @@ -2,21 +2,19 @@ package mc.feature.embedding; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import mc.GeneratorIntegrationsTest; import mc.feature.embedding.outer.embedded._parser.EmbeddedParser; +import static org.junit.jupiter.api.Assertions.*; + public class EmbedTest extends GeneratorIntegrationsTest { @BeforeEach @@ -32,8 +30,8 @@ public void test() throws IOException { EmbeddedParser parser = new EmbeddedParser(); parser.parseStart(new StringReader("a a a")); - Assertions.assertEquals(false, parser.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(false, parser.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -42,8 +40,8 @@ public void test2_a() throws IOException { EmbeddedParser parser = new EmbeddedParser(); parser.parseStart(new StringReader("a x a")); - Assertions.assertEquals(false, parser.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(parser.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -52,8 +50,8 @@ public void test2_b() throws IOException { EmbeddedParser parser = new EmbeddedParser(); parser.parseStart2(new StringReader("a x a")); - Assertions.assertEquals(false, parser.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(parser.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -62,7 +60,7 @@ public void test3() throws IOException { EmbeddedParser parser = new EmbeddedParser(); parser.parseStart2(new StringReader("a a x a a")); - Assertions.assertEquals(true, parser.hasErrors()); + assertTrue(parser.hasErrors()); } @Test @@ -71,8 +69,8 @@ public void test4() throws IOException { EmbeddedParser parser = new EmbeddedParser(); parser.parseStart3(new StringReader("b x")); - Assertions.assertEquals(false, parser.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(parser.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/embedding/EmbeddingTest.java b/monticore-test/it/src/test/java/mc/feature/embedding/EmbeddingTest.java index 13564562da..a3d1df9e74 100644 --- a/monticore-test/it/src/test/java/mc/feature/embedding/EmbeddingTest.java +++ b/monticore-test/it/src/test/java/mc/feature/embedding/EmbeddingTest.java @@ -2,9 +2,6 @@ package mc.feature.embedding; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.Reader; import java.io.StringReader; @@ -12,7 +9,6 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -22,6 +18,9 @@ import mc.feature.embedding.outer.featureouterdsl._ast.ASTOuter; import mc.feature.embedding.outer.featureouterdsl._ast.ASTOuter3; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class EmbeddingTest extends GeneratorIntegrationsTest { @BeforeEach @@ -59,9 +58,9 @@ public void testEmbedding() throws IOException { ASTOuter ast = createAST("hihi", s); - Assertions.assertEquals("test", ((ASTExt) ast.getInner()).getInner().getName()); + assertEquals("test", ((ASTExt) ast.getInner()).getInner().getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -71,7 +70,7 @@ public void testEmbedding3() throws IOException { createAST3("Embedded - optional taken", s); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -81,7 +80,7 @@ public void testEmbedding4() throws IOException { createAST3("Embedded - optional not taken", s); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/expression/Expression3Test.java b/monticore-test/it/src/test/java/mc/feature/expression/Expression3Test.java index d84bc7425d..c7235a368d 100644 --- a/monticore-test/it/src/test/java/mc/feature/expression/Expression3Test.java +++ b/monticore-test/it/src/test/java/mc/feature/expression/Expression3Test.java @@ -2,16 +2,11 @@ package mc.feature.expression; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -25,6 +20,8 @@ import mc.feature.expression.expression3._ast.ASTPrimaryExpr; import mc.feature.expression.expression3._parser.Expression3Parser; +import static org.junit.jupiter.api.Assertions.*; + public class Expression3Test extends GeneratorIntegrationsTest { @BeforeEach @@ -43,113 +40,113 @@ public Optional parse(String input) throws IOException { public void testPlus() { try { Optional res = parse("1+2"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTAddExpr); + assertInstanceOf(ASTAddExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLiteral() { try { Optional res = parse("1"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTPrimaryExpr); + assertInstanceOf(ASTPrimaryExpr.class, ast); - Assertions.assertEquals("1", ((ASTPrimaryExpr) ast).getNumericLiteral()); + assertEquals("1", ((ASTPrimaryExpr) ast).getNumericLiteral()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testStar() { try { Optional res = parse("1*2"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTMultExpr); + assertInstanceOf(ASTMultExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBracket() { try { Optional res = parse("(1*2)"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTBracketExpr); + assertInstanceOf(ASTBracketExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpr1() { try { Optional res = parse("1*2+3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTAddExpr); + assertInstanceOf(ASTAddExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpr2() { try { Optional res = parse("1+2*3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTAddExpr); + assertInstanceOf(ASTAddExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpr3() { try { Optional res = parse("1-2-3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTAddExpr); + assertInstanceOf(ASTAddExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPowerWithRightAssoc() { try { Optional res = parse("2^3^4"); - Assertions.assertTrue(res.isPresent()); - Assertions.assertTrue(res.get()instanceof ASTPowerExpr); + assertTrue(res.isPresent()); + assertInstanceOf(ASTPowerExpr.class, res.get()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/expression/Expression4Test.java b/monticore-test/it/src/test/java/mc/feature/expression/Expression4Test.java index e763a2850e..df40446cee 100644 --- a/monticore-test/it/src/test/java/mc/feature/expression/Expression4Test.java +++ b/monticore-test/it/src/test/java/mc/feature/expression/Expression4Test.java @@ -2,16 +2,11 @@ package mc.feature.expression; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -25,6 +20,8 @@ import mc.feature.expression.expression4._ast.ASTPrimaryExpr; import mc.feature.expression.expression4._parser.Expression4Parser; +import static org.junit.jupiter.api.Assertions.*; + public class Expression4Test extends GeneratorIntegrationsTest { @BeforeEach @@ -43,113 +40,113 @@ public Optional parse(String input) throws IOException { public void testPlus() { try { Optional res = parse("1+2"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTAddExpr); + assertInstanceOf(ASTAddExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLiteral() { try { Optional res = parse("1"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTPrimaryExpr); + assertInstanceOf(ASTPrimaryExpr.class, ast); - Assertions.assertEquals("1", ((ASTPrimaryExpr) ast).getNumericLiteral()); + assertEquals("1", ((ASTPrimaryExpr) ast).getNumericLiteral()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testStar() { try { Optional res = parse("1*2"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTMultExpr); + assertInstanceOf(ASTMultExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBracket() { try { Optional res = parse("(1*2)"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTBracketExpr); + assertInstanceOf(ASTBracketExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpr1() { try { Optional res = parse("1*2+3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTAddExpr); + assertInstanceOf(ASTAddExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpr2() { try { Optional res = parse("1+2*3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTAddExpr); + assertInstanceOf(ASTAddExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpr3() { try { Optional res = parse("1-2-3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTAddExpr); + assertInstanceOf(ASTAddExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPowerWithRightAssoc() { try { Optional res = parse("2^3^4"); - Assertions.assertTrue(res.isPresent()); - Assertions.assertTrue(res.get()instanceof ASTPowerExpr); + assertTrue(res.isPresent()); + assertInstanceOf(ASTPowerExpr.class, res.get()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/expression/Expression5Test.java b/monticore-test/it/src/test/java/mc/feature/expression/Expression5Test.java index e0a2a8a2ec..0cdf75e4bc 100644 --- a/monticore-test/it/src/test/java/mc/feature/expression/Expression5Test.java +++ b/monticore-test/it/src/test/java/mc/feature/expression/Expression5Test.java @@ -2,16 +2,11 @@ package mc.feature.expression; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -21,6 +16,8 @@ import mc.feature.expression.expression5._ast.ASTMultExpr; import mc.feature.expression.expression5._parser.Expression5Parser; +import static org.junit.jupiter.api.Assertions.*; + public class Expression5Test extends GeneratorIntegrationsTest { @BeforeEach @@ -40,42 +37,42 @@ public Optional parse(String input) throws IOException { public void testExpr1() { try { Optional res = parse("1*2+3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTMultExpr); + assertInstanceOf(ASTMultExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpr2() { try { Optional res = parse("1+2*3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTMultExpr); + assertInstanceOf(ASTMultExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpr3() { try { Optional res = parse("1*2*3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast instanceof ASTMultExpr); + assertInstanceOf(ASTMultExpr.class, ast); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-test/it/src/test/java/mc/feature/expression/ExpressionTest.java b/monticore-test/it/src/test/java/mc/feature/expression/ExpressionTest.java index b545783fec..116ff811e1 100644 --- a/monticore-test/it/src/test/java/mc/feature/expression/ExpressionTest.java +++ b/monticore-test/it/src/test/java/mc/feature/expression/ExpressionTest.java @@ -2,16 +2,11 @@ package mc.feature.expression; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import de.se_rwth.commons.logging.Log; @@ -21,6 +16,8 @@ import mc.feature.expression.expression._parser.ExpressionParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class ExpressionTest extends GeneratorIntegrationsTest { @BeforeEach @@ -39,113 +36,113 @@ public Optional parse(String input) throws IOException { public void testPlus() { try { Optional res = parse("1+2"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertEquals(ASTConstantsExpression.PLUS, ast.getOp()); + assertEquals(ASTConstantsExpression.PLUS, ast.getOp()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testLiteral() { try { Optional res = parse("1"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast.isPresentNumericLiteral()); - Assertions.assertEquals("1", ast.getNumericLiteral()); + assertTrue(ast.isPresentNumericLiteral()); + assertEquals("1", ast.getNumericLiteral()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testStar() { try { Optional res = parse("1*2"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertEquals(ASTConstantsExpression.STAR, ast.getOp()); + assertEquals(ASTConstantsExpression.STAR, ast.getOp()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testBracket() { try { Optional res = parse("(1*2)"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertTrue(ast.isPresentExpr()); + assertTrue(ast.isPresentExpr()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpr1() { try { Optional res = parse("1*2+3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertEquals(ASTConstantsExpression.PLUS, ast.getOp()); + assertEquals(ASTConstantsExpression.PLUS, ast.getOp()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpr2() { try { Optional res = parse("1+2*3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertEquals(ASTConstantsExpression.PLUS, ast.getOp()); + assertEquals(ASTConstantsExpression.PLUS, ast.getOp()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExpr3() { try { Optional res = parse("1-2-3"); - Assertions.assertTrue(res.isPresent()); + assertTrue(res.isPresent()); ASTExpr ast = res.get(); - Assertions.assertEquals(ASTConstantsExpression.MINUS, ast.getOp()); + assertEquals(ASTConstantsExpression.MINUS, ast.getOp()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testPowerWithRightAssoc() { try { Optional res = parse("2^3^4"); - Assertions.assertTrue(res.isPresent()); - Assertions.assertTrue(res.get().isPresentLeft()); - Assertions.assertTrue(res.get().getLeft().isPresentNumericLiteral()); + assertTrue(res.isPresent()); + assertTrue(res.get().isPresentLeft()); + assertTrue(res.get().getLeft().isPresentNumericLiteral()); } catch (Exception e) { - Assertions.fail(e.getMessage()); + fail(e.getMessage()); } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/filefindertest/FileFinderTest.java b/monticore-test/it/src/test/java/mc/feature/filefindertest/FileFinderTest.java index c6e91fdbc2..3094da8b41 100644 --- a/monticore-test/it/src/test/java/mc/feature/filefindertest/FileFinderTest.java +++ b/monticore-test/it/src/test/java/mc/feature/filefindertest/FileFinderTest.java @@ -9,7 +9,6 @@ import mc.feature.filefindertest.filefindertest._ast.ASTSCArtifact; import mc.feature.filefindertest.filefindertest._parser.FileFinderTestParser; import mc.feature.filefindertest.filefindertest._symboltable.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -17,8 +16,8 @@ import java.nio.file.Paths; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class FileFinderTest { @@ -37,8 +36,8 @@ public void setUp() throws IOException { Optional artifactII = parser.parse("src/test/resources/mc/feature/filefindertest/Model2.sc"); FileFinderTestScopesGenitorDelegator delegator = FileFinderTestMill.scopesGenitorDelegator(); FileFinderTestScopesGenitorDelegator delegatorII = FileFinderTestMill.scopesGenitorDelegator(); - Assertions.assertTrue(artifact.isPresent()); - Assertions.assertTrue(artifactII.isPresent()); + assertTrue(artifact.isPresent()); + assertTrue(artifactII.isPresent()); IFileFinderTestArtifactScope scope = delegator.createFromAST(artifact.get()); scope.setPackageName("mc.feature.filefindertest"); IFileFinderTestArtifactScope scopeII = delegatorII.createFromAST(artifactII.get()); @@ -58,8 +57,8 @@ public void testFileFinder1() { gs.clear(); gs.setSymbolPath(new MCPath(Paths.get(SYMBOL_PATH))); Optional statechartSymbol = gs.resolveStatechart("mc.feature.filefindertest.Model1"); - Assertions.assertTrue(statechartSymbol.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(statechartSymbol.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -70,8 +69,8 @@ public void testFileFinder2() { gs.setFileExt("scsym"); gs.setSymbolPath(new MCPath(Paths.get(SYMBOL_PATH))); Optional statechartSymbol = gs.resolveStatechart("mc.feature.filefindertest.Model1"); - Assertions.assertTrue(statechartSymbol.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(statechartSymbol.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -82,8 +81,8 @@ public void testFileFinder3() { gs.setFileExt("ym"); gs.setSymbolPath(new MCPath(Paths.get(SYMBOL_PATH))); Optional statechartSymbol = gs.resolveStatechart("mc.feature.filefindertest.Model1"); - Assertions.assertFalse(statechartSymbol.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(statechartSymbol.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -93,8 +92,8 @@ public void testFileFinder4() { gs.clear(); gs.setSymbolPath(new MCPath(Paths.get("src/test"))); Optional statechartSymbol = gs.resolveStatechart("mc.feature.filefindertest.Model1"); - Assertions.assertFalse(statechartSymbol.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(statechartSymbol.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -104,8 +103,8 @@ public void testFileFinder5() { gs.clear(); gs.setSymbolPath(new MCPath()); Optional statechartSymbol = gs.resolveStatechart("mc.feature.filefindertest.Model1"); - Assertions.assertFalse(statechartSymbol.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(statechartSymbol.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -116,7 +115,7 @@ public void testFileFinder6() { gs.setFileExt("json"); gs.setSymbolPath(new MCPath(Paths.get(SYMBOL_PATH))); Optional statechartSymbol = gs.resolveStatechart("mc.feature.filefindertest.Model1"); - Assertions.assertTrue(statechartSymbol.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(statechartSymbol.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/followoption/FollowOptionTest.java b/monticore-test/it/src/test/java/mc/feature/followoption/FollowOptionTest.java index 630187d1a6..6c84fea9fa 100644 --- a/monticore-test/it/src/test/java/mc/feature/followoption/FollowOptionTest.java +++ b/monticore-test/it/src/test/java/mc/feature/followoption/FollowOptionTest.java @@ -2,21 +2,19 @@ package mc.feature.followoption; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; import mc.feature.followoption.followoption._parser.FollowOptionParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class FollowOptionTest extends GeneratorIntegrationsTest { @BeforeEach @@ -31,9 +29,9 @@ public void test1() throws IOException { //-- extractfile gen/FollowOptionTest.x FollowOptionParser simpleAParser = new FollowOptionParser(); simpleAParser.parseA(new StringReader("test ,")); - Assertions.assertEquals(false, simpleAParser.hasErrors()); + assertFalse(simpleAParser.hasErrors()); //-- endfile gen/FollowOptionTest.x - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -42,7 +40,7 @@ public void test2() throws IOException { FollowOptionParser simpleBParser = new FollowOptionParser(); simpleBParser.parseB(new StringReader("test ,")); - Assertions.assertEquals(true, simpleBParser.hasErrors()); + assertTrue(simpleBParser.hasErrors()); //-- endfile gen/FollowOptionTest.x } @@ -57,7 +55,7 @@ public void test3() throws IOException { FollowOptionParser simpleParser = new FollowOptionParser(); simpleParser.parseB(new StringReader(",")); - Assertions.assertEquals(true, simpleParser.hasErrors()); + assertTrue(simpleParser.hasErrors()); } @Test @@ -65,7 +63,7 @@ public void test4() throws IOException { FollowOptionParser simpleAParser = new FollowOptionParser(); simpleAParser.parseA(new StringReader("test .")); - - Assertions.assertEquals(true, simpleAParser.hasErrors()); + + assertTrue(simpleAParser.hasErrors()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/grammarinherit/TestGrammarInherit.java b/monticore-test/it/src/test/java/mc/feature/grammarinherit/TestGrammarInherit.java index 976254c95d..ba298f0e44 100644 --- a/monticore-test/it/src/test/java/mc/feature/grammarinherit/TestGrammarInherit.java +++ b/monticore-test/it/src/test/java/mc/feature/grammarinherit/TestGrammarInherit.java @@ -6,15 +6,13 @@ import de.se_rwth.commons.logging.LogStub; import mc.GeneratorIntegrationsTest; import mc.feature.grammarinherit.sub.subfeaturedslgrammarinherit._parser.SubFeatureDSLgrammarinheritParser; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.io.StringReader; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class TestGrammarInherit extends GeneratorIntegrationsTest { @@ -32,9 +30,10 @@ public void test1() throws IOException { SubFeatureDSLgrammarinheritParser p = new SubFeatureDSLgrammarinheritParser(); p.parseFile(s); - Assertions.assertEquals(false, p.hasErrors()); + assertFalse(p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/hwc/BuildersTest.java b/monticore-test/it/src/test/java/mc/feature/hwc/BuildersTest.java index 98351c3191..fabed90a74 100644 --- a/monticore-test/it/src/test/java/mc/feature/hwc/BuildersTest.java +++ b/monticore-test/it/src/test/java/mc/feature/hwc/BuildersTest.java @@ -1,14 +1,10 @@ /* (c) https://github.com/MontiCore/monticore */ package mc.feature.hwc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import de.se_rwth.commons.logging.LogStub; import org.antlr.v4.runtime.RecognitionException; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,6 +14,9 @@ import mc.feature.hwc.statechartdsl._ast.ASTTransition; import mc.feature.hwc.statechartdsl.StatechartDSLMill; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class BuildersTest { @BeforeEach @@ -34,22 +33,22 @@ public void setUp() throws RecognitionException, IOException { @Test public void testMyTransitionBuilder() throws IOException { ASTTransition transition = StatechartDSLMill.transitionBuilder().setFrom("setByGenBuilder").setFrom("xxxx").setTo("setByGenBuilder").build(); - Assertions.assertEquals("xxxxSuf2", transition.getFrom()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("xxxxSuf2", transition.getFrom()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testHWCClassGeneratedBuilder() throws IOException { ASTStatechart aut = StatechartDSLMill.statechartBuilder().setName("setByGeneratedBuilder").build(); - Assertions.assertEquals("setByGeneratedBuilder", aut.getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("setByGeneratedBuilder", aut.getName()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testHWCClassHWCBuilder() throws IOException { ASTState state = StatechartDSLMill.stateBuilder().setName("x2").setFinal(true).setName("state1").build(); - Assertions.assertEquals(state.getName(), "state1Suf1"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("state1Suf1", state.getName()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/inheritedbuilder/TestInheritedBuilder.java b/monticore-test/it/src/test/java/mc/feature/inheritedbuilder/TestInheritedBuilder.java index 2fcd9707bf..5aedf7c1fc 100644 --- a/monticore-test/it/src/test/java/mc/feature/inheritedbuilder/TestInheritedBuilder.java +++ b/monticore-test/it/src/test/java/mc/feature/inheritedbuilder/TestInheritedBuilder.java @@ -5,11 +5,11 @@ import de.se_rwth.commons.logging.LogStub; import mc.feature.inheritedbuilder.buildertest.BuilderTestMill; import mc.feature.inheritedbuilder.buildertest._ast.ASTSubBuilder; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestInheritedBuilder { @@ -22,8 +22,8 @@ public void before() { @Test public void test(){ //test if the return type of the builder for the inherited attribute name of Sub is correct - Assertions.assertTrue(BuilderTestMill.subBuilder().setName("Foo") instanceof ASTSubBuilder); + assertInstanceOf(ASTSubBuilder.class, BuilderTestMill.subBuilder().setName("Foo")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/inheritence/CloneInheritenceTest.java b/monticore-test/it/src/test/java/mc/feature/inheritence/CloneInheritenceTest.java index 7906584d97..645ff85df4 100644 --- a/monticore-test/it/src/test/java/mc/feature/inheritence/CloneInheritenceTest.java +++ b/monticore-test/it/src/test/java/mc/feature/inheritence/CloneInheritenceTest.java @@ -8,11 +8,10 @@ import mc.feature.inheritence.inheritence._ast.ASTSub; import mc.feature.inheritence.inheritence._ast.ASTSuper; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CloneInheritenceTest extends GeneratorIntegrationsTest { @@ -41,7 +40,7 @@ public void test() { .uncheckedBuild(); t.deepClone(); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/inheritence/InheritenceTest.java b/monticore-test/it/src/test/java/mc/feature/inheritence/InheritenceTest.java index 17280d5181..8a700c7f76 100644 --- a/monticore-test/it/src/test/java/mc/feature/inheritence/InheritenceTest.java +++ b/monticore-test/it/src/test/java/mc/feature/inheritence/InheritenceTest.java @@ -2,16 +2,12 @@ package mc.feature.inheritence; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -31,6 +27,8 @@ import mc.feature.inheritence.inheritence._ast.ASTXP; import mc.feature.inheritence.inheritence._parser.InheritenceParser; +import static org.junit.jupiter.api.Assertions.*; + public class InheritenceTest extends GeneratorIntegrationsTest { @BeforeEach @@ -53,8 +51,8 @@ public void test1a() throws IOException { InheritenceParser parser = new InheritenceParser(); Optional ast = parser.parseIG(new StringReader("a")); - Assertions.assertTrue(ast.get() instanceof ASTA); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertInstanceOf(ASTA.class, ast.get()); + assertTrue(Log.getFindings().isEmpty()); } @@ -64,8 +62,8 @@ public void test1b() throws IOException { InheritenceParser parser = new InheritenceParser(); Optional ast = parser.parseIG(new StringReader("b")); - Assertions.assertTrue(ast.get() instanceof ASTB); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertInstanceOf(ASTB.class, ast.get()); + assertTrue(Log.getFindings().isEmpty()); } @@ -75,8 +73,8 @@ public void test1c() throws IOException { InheritenceParser parser = new InheritenceParser(); Optional ast = parser.parseIG(new StringReader("c")); - Assertions.assertTrue(ast.get() instanceof ASTC); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertInstanceOf(ASTC.class, ast.get()); + assertTrue(Log.getFindings().isEmpty()); } @@ -90,8 +88,8 @@ public void test2() throws IOException { InheritenceParser parser = new InheritenceParser(); Optional ast = parser.parseIH(new StringReader("d")); - Assertions.assertTrue(ast.get() instanceof ASTD); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertInstanceOf(ASTD.class, ast.get()); + assertTrue(Log.getFindings().isEmpty()); } @@ -106,8 +104,8 @@ public void test3a() throws IOException { InheritenceParser parser = new InheritenceParser(); Optional ast = parser.parseIM(new StringReader("aa")); - Assertions.assertTrue(ast.get() instanceof ASTK); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertInstanceOf(ASTK.class, ast.get()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -115,8 +113,8 @@ public void test3b() throws IOException { InheritenceParser parser = new InheritenceParser(); Optional ast = parser.parseIM(new StringReader("bb")); - Assertions.assertTrue(ast.get() instanceof ASTK); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertInstanceOf(ASTK.class, ast.get()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -124,8 +122,8 @@ public void test3c() throws IOException { InheritenceParser parser = new InheritenceParser(); Optional ast = parser.parseIM(new StringReader("ab")); - Assertions.assertTrue(ast.get() instanceof ASTL); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertInstanceOf(ASTL.class, ast.get()); + assertTrue(Log.getFindings().isEmpty()); } @@ -136,8 +134,8 @@ public void test4a() throws IOException { InheritenceParser parser = new InheritenceParser(); Optional ast = parser.parseXAE(new StringReader("f")); - Assertions.assertTrue(ast.get() instanceof ASTXF); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertInstanceOf(ASTXF.class, ast.get()); + assertTrue(Log.getFindings().isEmpty()); } // Test 5 : XAO should parse "p" but not "q" and return an XP @@ -147,9 +145,9 @@ public void test5a() throws IOException { InheritenceParser parser = new InheritenceParser(); Optional ast = parser.parseXAO(new StringReader("p")); - Assertions.assertTrue(ast.get() instanceof ASTXP); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertInstanceOf(ASTXP.class, ast.get()); + assertFalse(parser.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } @@ -158,7 +156,7 @@ public void test5b() throws IOException { InheritenceParser parser = new InheritenceParser(); parser.parseXAO(new StringReader("q")); - Assertions.assertTrue(parser.hasErrors()); + assertTrue(parser.hasErrors()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/interfaces/InterfacesTest.java b/monticore-test/it/src/test/java/mc/feature/interfaces/InterfacesTest.java index c27bb0a84c..d868b160d7 100644 --- a/monticore-test/it/src/test/java/mc/feature/interfaces/InterfacesTest.java +++ b/monticore-test/it/src/test/java/mc/feature/interfaces/InterfacesTest.java @@ -2,16 +2,12 @@ package mc.feature.interfaces; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; @@ -19,6 +15,8 @@ import mc.feature.interfaces.sub._parser.SubParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class InterfacesTest extends GeneratorIntegrationsTest { @BeforeEach @@ -33,10 +31,10 @@ public void test1a() throws IOException { SubParser parser = new SubParser(); Optional ast = parser.parseA(new StringReader("Hello Otto Mustermann")); - Assertions.assertTrue(ast.get() instanceof ASTA); + assertInstanceOf(ASTA.class, ast.get()); ASTA astA = ast.get(); - Assertions.assertNotNull(astA.getB()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertNotNull(astA.getB()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/interfaces/ListInterfaceTest.java b/monticore-test/it/src/test/java/mc/feature/interfaces/ListInterfaceTest.java index 56eba2edeb..1d149435b3 100644 --- a/monticore-test/it/src/test/java/mc/feature/interfaces/ListInterfaceTest.java +++ b/monticore-test/it/src/test/java/mc/feature/interfaces/ListInterfaceTest.java @@ -5,16 +5,13 @@ import de.se_rwth.commons.logging.LogStub; import mc.feature.interfaces.listgeneration._ast.*; import mc.feature.interfaces.listgeneration._parser.ListGenerationParser; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ListInterfaceTest { @@ -28,49 +25,49 @@ public void before() { public void testMethodExistenceTokenPlus() throws IOException{ ListGenerationParser parser = new ListGenerationParser(); Optional ast = parser.parse_StringTokenPlus("+ Name, name"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals(2, ast.get().getNameList().size()); - Assertions.assertFalse(ast.get().isEmptyNames()); - Assertions.assertEquals(0, ast.get().indexOfName("Name")); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals(2, ast.get().getNameList().size()); + assertFalse(ast.get().isEmptyNames()); + assertEquals(0, ast.get().indexOfName("Name")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMethodExistenceTokenStar() throws IOException{ ListGenerationParser parser = new ListGenerationParser(); Optional ast = parser.parse_StringTokenStar("something * Name name"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals(2, ast.get().getNameList().size()); - Assertions.assertFalse(ast.get().isEmptyNames()); - Assertions.assertEquals(0, ast.get().indexOfName("Name")); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals(2, ast.get().getNameList().size()); + assertFalse(ast.get().isEmptyNames()); + assertEquals(0, ast.get().indexOfName("Name")); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMethodExistenceListPlus() throws IOException{ ListGenerationParser parser = new ListGenerationParser(); Optional ast = parser.parse_StringListPlus("something Abc Dec"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals(2, ast.get().getTestList().size()); - Assertions.assertFalse(ast.get().isEmptyTest()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals(2, ast.get().getTestList().size()); + assertFalse(ast.get().isEmptyTest()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMethodExistenceListStar() throws IOException{ ListGenerationParser parser = new ListGenerationParser(); Optional ast = parser.parse_StringListStar("Abc Dec Abc word"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals(3, ast.get().getTestList().size()); - Assertions.assertFalse(ast.get().isEmptyTest()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals(3, ast.get().getTestList().size()); + assertFalse(ast.get().isEmptyTest()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/interfaces/MethodInterfaceTest.java b/monticore-test/it/src/test/java/mc/feature/interfaces/MethodInterfaceTest.java index 42758c298f..a53e72e9d3 100644 --- a/monticore-test/it/src/test/java/mc/feature/interfaces/MethodInterfaceTest.java +++ b/monticore-test/it/src/test/java/mc/feature/interfaces/MethodInterfaceTest.java @@ -6,16 +6,13 @@ import de.se_rwth.commons.logging.LogStub; import mc.feature.interfaces.methodinterface._ast.*; import mc.feature.interfaces.methodinterface._parser.MethodInterfaceParser; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class MethodInterfaceTest { @@ -29,65 +26,65 @@ public void before() { public void testInterfaceDefaultA() throws IOException { MethodInterfaceParser parser = new MethodInterfaceParser(); Optional ast = parser.parse_StringInterfaceDefault("Hello3"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("test", ast.get().getTest()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals("test", ast.get().getTest()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInterfaceDefaultA1() throws IOException { MethodInterfaceParser parser = new MethodInterfaceParser(); Optional ast = parser.parse_StringInterfaceDefaultA("Hello"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("A", ast.get().getTest()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals("A", ast.get().getTest()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInterfaceDefaultA2() throws IOException { MethodInterfaceParser parser = new MethodInterfaceParser(); Optional ast = parser.parse_StringA("Hello"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("A", ast.get().getTest()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals("A", ast.get().getTest()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInterfaceAbstract() throws IOException { MethodInterfaceParser parser = new MethodInterfaceParser(); Optional ast = parser.parse_StringInterfaceAbstract("Hello2"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("B", ast.get().getTest2()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals("B", ast.get().getTest2()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testInterfaceAbstractB() throws IOException { MethodInterfaceParser parser = new MethodInterfaceParser(); Optional ast = parser.parse_StringB("Hello2"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("B", ast.get().getTest2()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals("B", ast.get().getTest2()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testClassMethod() throws IOException { MethodInterfaceParser parser = new MethodInterfaceParser(); Optional ast = parser.parse_StringClassMethod("Name C"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("ABC", ast.get().getTest3()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals("ABC", ast.get().getTest3()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/interfaces/OptionalInterfacesTest.java b/monticore-test/it/src/test/java/mc/feature/interfaces/OptionalInterfacesTest.java index 7b777d4a2a..7a75fa8ead 100644 --- a/monticore-test/it/src/test/java/mc/feature/interfaces/OptionalInterfacesTest.java +++ b/monticore-test/it/src/test/java/mc/feature/interfaces/OptionalInterfacesTest.java @@ -5,16 +5,13 @@ import de.se_rwth.commons.logging.LogStub; import mc.feature.interfaces.optionalgeneration._ast.*; import mc.feature.interfaces.optionalgeneration._parser.OptionalGenerationParser; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class OptionalInterfacesTest { @@ -28,48 +25,48 @@ public void before() { public void testMethodExistenceTest1() throws IOException{ OptionalGenerationParser parser = new OptionalGenerationParser(); Optional astOpt1 = parser.parse_StringOpt1("abc Name"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astOpt1.isPresent()); - Assertions.assertTrue(astOpt1.get().isPresentName()); - Assertions.assertEquals("Name", astOpt1.get().getName()); + assertFalse(parser.hasErrors()); + assertTrue(astOpt1.isPresent()); + assertTrue(astOpt1.get().isPresentName()); + assertEquals("Name", astOpt1.get().getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMethodExistenceTest2() throws IOException{ OptionalGenerationParser parser = new OptionalGenerationParser(); Optional astTest2 = parser.parse_StringTest2("abc someName"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astTest2.isPresent()); - Assertions.assertTrue(astTest2.get().isPresentName()); - Assertions.assertEquals("someName", astTest2.get().getName()); + assertFalse(parser.hasErrors()); + assertTrue(astTest2.isPresent()); + assertTrue(astTest2.get().isPresentName()); + assertEquals("someName", astTest2.get().getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMethodExistenceTest3() throws IOException{ OptionalGenerationParser parser = new OptionalGenerationParser(); Optional astOpt2 = parser.parse_StringOpt2("def Name"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astOpt2.isPresent()); - Assertions.assertTrue(astOpt2.get().isPresentName()); - Assertions.assertEquals("Name", astOpt2.get().getName()); + assertFalse(parser.hasErrors()); + assertTrue(astOpt2.isPresent()); + assertTrue(astOpt2.get().isPresentName()); + assertEquals("Name", astOpt2.get().getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testMethodExistenceTest4() throws IOException{ OptionalGenerationParser parser = new OptionalGenerationParser(); Optional astTest4 = parser.parse_StringTest4("def someName"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astTest4.isPresent()); - Assertions.assertEquals("someName", astTest4.get().getName()); - Assertions.assertTrue(astTest4.get().isPresentName()); + assertFalse(parser.hasErrors()); + assertTrue(astTest4.isPresent()); + assertEquals("someName", astTest4.get().getName()); + assertTrue(astTest4.get().isPresentName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/javasql/JavaSQLTest.java b/monticore-test/it/src/test/java/mc/feature/javasql/JavaSQLTest.java index 4477b943dc..eb2c0e4c67 100644 --- a/monticore-test/it/src/test/java/mc/feature/javasql/JavaSQLTest.java +++ b/monticore-test/it/src/test/java/mc/feature/javasql/JavaSQLTest.java @@ -2,21 +2,20 @@ package mc.feature.javasql; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; import mc.feature.javasql.javasql.javasql._parser.JavaSQLParser; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class JavaSQLTest extends GeneratorIntegrationsTest { @BeforeEach @@ -31,8 +30,8 @@ public void test1() throws IOException { JavaSQLParser p = new JavaSQLParser(); p.parseStart(new StringReader("a++,a=SELECT a FROM x ,i++")); - Assertions.assertEquals(false, p.hasErrors()); + assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/keyrule/KeyRuleTest.java b/monticore-test/it/src/test/java/mc/feature/keyrule/KeyRuleTest.java index 40a31cea07..862903c354 100644 --- a/monticore-test/it/src/test/java/mc/feature/keyrule/KeyRuleTest.java +++ b/monticore-test/it/src/test/java/mc/feature/keyrule/KeyRuleTest.java @@ -8,16 +8,13 @@ import mc.feature.keyrule.keyrule._ast.ASTB; import mc.feature.keyrule.keyrule._ast.ASTJ; import mc.feature.keyrule.keyrule._parser.KeyRuleParser; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class KeyRuleTest extends GeneratorIntegrationsTest { @@ -31,24 +28,24 @@ public void before() { public void test() throws IOException { KeyRuleParser parser = new KeyRuleParser(); parser.parse_StringA("bla1 Foo"); - Assertions.assertFalse(parser.hasErrors()); + assertFalse(parser.hasErrors()); parser.parse_StringA("bla2 Foo"); - Assertions.assertFalse(parser.hasErrors()); + assertFalse(parser.hasErrors()); parser.parse_StringA("bla3 Foo"); - Assertions.assertTrue(parser.hasErrors()); + assertTrue(parser.hasErrors()); Optional ast = parser.parse_StringB("bla1 Foo"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("bla1", ast.get().getBla()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals("bla1", ast.get().getBla()); ast = parser.parse_StringB("bla2 Foo"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("bla2", ast.get().getBla()); + assertFalse(parser.hasErrors()); + assertTrue(ast.isPresent()); + assertEquals("bla2", ast.get().getBla()); Optional astj = parser.parse_StringJ("blaj"); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(astj.isPresent()); + assertFalse(parser.hasErrors()); + assertTrue(astj.isPresent()); astj = parser.parse_StringJ("blax"); - Assertions.assertTrue(parser.hasErrors()); + assertTrue(parser.hasErrors()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/lexerformat/KleenePlusTest.java b/monticore-test/it/src/test/java/mc/feature/lexerformat/KleenePlusTest.java index 79d22d5858..9e230c3ce8 100644 --- a/monticore-test/it/src/test/java/mc/feature/lexerformat/KleenePlusTest.java +++ b/monticore-test/it/src/test/java/mc/feature/lexerformat/KleenePlusTest.java @@ -2,17 +2,12 @@ package mc.feature.lexerformat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -20,6 +15,8 @@ import mc.feature.lexerformat.kleeneplus._ast.ASTKPStart; import mc.feature.lexerformat.kleeneplus._parser.KleenePlusParser; +import static org.junit.jupiter.api.Assertions.*; + public class KleenePlusTest extends GeneratorIntegrationsTest { @BeforeEach @@ -38,23 +35,23 @@ public void testKleeneStar() throws IOException { Optional ast; ast = p.parseKPStart(new StringReader("a")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("a", ast.get().getKleene()); + assertTrue(ast.isPresent()); + assertEquals("a", ast.get().getKleene()); ast = p.parseKPStart(new StringReader("ab")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("ab", ast.get().getKleene()); + assertTrue(ast.isPresent()); + assertEquals("ab", ast.get().getKleene()); ast = p.parseKPStart(new StringReader("abb")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("abb", ast.get().getKleene()); + assertTrue(ast.isPresent()); + assertEquals("abb", ast.get().getKleene()); ast = p.parseKPStart(new StringReader("abbbb")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("abbbb", ast.get().getKleene()); + assertTrue(ast.isPresent()); + assertEquals("abbbb", ast.get().getKleene()); ast = p.parseKPStart(new StringReader("b")); - Assertions.assertFalse(ast.isPresent()); + assertFalse(ast.isPresent()); } /** @@ -67,23 +64,23 @@ public void testSimpleKleene() throws IOException { Optional ast; ast = p.parseKPStart(new StringReader("c")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("c", ast.get().getSimpleKleene()); + assertTrue(ast.isPresent()); + assertEquals("c", ast.get().getSimpleKleene()); ast = p.parseKPStart(new StringReader("cd")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("cd", ast.get().getSimpleKleene()); + assertTrue(ast.isPresent()); + assertEquals("cd", ast.get().getSimpleKleene()); ast = p.parseKPStart(new StringReader("cdd")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("cdd", ast.get().getSimpleKleene()); + assertTrue(ast.isPresent()); + assertEquals("cdd", ast.get().getSimpleKleene()); ast = p.parseKPStart(new StringReader("cdddd")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("cdddd", ast.get().getSimpleKleene()); + assertTrue(ast.isPresent()); + assertEquals("cdddd", ast.get().getSimpleKleene()); ast = p.parseKPStart(new StringReader("d")); - Assertions.assertFalse(ast.isPresent()); + assertFalse(ast.isPresent()); } /** @@ -96,23 +93,23 @@ public void testSimpleKleeneString() throws IOException { Optional ast; ast = p.parseKPStart(new StringReader("ee")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("ee", ast.get().getSimpleKleeneString()); + assertTrue(ast.isPresent()); + assertEquals("ee", ast.get().getSimpleKleeneString()); ast = p.parseKPStart(new StringReader("eefg")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("eefg", ast.get().getSimpleKleeneString()); + assertTrue(ast.isPresent()); + assertEquals("eefg", ast.get().getSimpleKleeneString()); ast = p.parseKPStart(new StringReader("eefgfg")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("eefgfg", ast.get().getSimpleKleeneString()); + assertTrue(ast.isPresent()); + assertEquals("eefgfg", ast.get().getSimpleKleeneString()); ast = p.parseKPStart(new StringReader("eefgfgfgfg")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("eefgfgfgfg", ast.get().getSimpleKleeneString()); + assertTrue(ast.isPresent()); + assertEquals("eefgfgfgfg", ast.get().getSimpleKleeneString()); ast = p.parseKPStart(new StringReader("fg")); - Assertions.assertFalse(ast.isPresent()); + assertFalse(ast.isPresent()); } /** @@ -125,22 +122,22 @@ public void testPlus() throws IOException { Optional ast; ast = p.parseKPStart(new StringReader("g")); - Assertions.assertFalse(ast.isPresent()); + assertFalse(ast.isPresent()); ast = p.parseKPStart(new StringReader("gh")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("gh", ast.get().getPlus()); + assertTrue(ast.isPresent()); + assertEquals("gh", ast.get().getPlus()); ast = p.parseKPStart(new StringReader("ghh")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("ghh", ast.get().getPlus()); + assertTrue(ast.isPresent()); + assertEquals("ghh", ast.get().getPlus()); ast = p.parseKPStart(new StringReader("ghhhh")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("ghhhh", ast.get().getPlus()); + assertTrue(ast.isPresent()); + assertEquals("ghhhh", ast.get().getPlus()); ast = p.parseKPStart(new StringReader("h")); - Assertions.assertFalse(ast.isPresent()); + assertFalse(ast.isPresent()); } /** @@ -153,22 +150,22 @@ public void testSimplePlus() throws IOException { Optional ast; ast = p.parseKPStart(new StringReader("i")); - Assertions.assertFalse(ast.isPresent()); + assertFalse(ast.isPresent()); ast = p.parseKPStart(new StringReader("ij")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("ij", ast.get().getSimplePlus()); + assertTrue(ast.isPresent()); + assertEquals("ij", ast.get().getSimplePlus()); ast = p.parseKPStart(new StringReader("ijj")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("ijj", ast.get().getSimplePlus()); + assertTrue(ast.isPresent()); + assertEquals("ijj", ast.get().getSimplePlus()); ast = p.parseKPStart(new StringReader("ijjjj")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("ijjjj", ast.get().getSimplePlus()); + assertTrue(ast.isPresent()); + assertEquals("ijjjj", ast.get().getSimplePlus()); ast = p.parseKPStart(new StringReader("j")); - Assertions.assertFalse(ast.isPresent()); + assertFalse(ast.isPresent()); } /** @@ -183,22 +180,22 @@ public void testSimplePlusString() throws IOException { ast = p.parseKPStart(new StringReader("kk")); ast = null; - Assertions.assertTrue(p.hasErrors()); + assertTrue(p.hasErrors()); ast = p.parseKPStart(new StringReader("kklm")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("kklm", ast.get().getSimplePlusString()); + assertTrue(ast.isPresent()); + assertEquals("kklm", ast.get().getSimplePlusString()); ast = p.parseKPStart(new StringReader("kklmlm")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("kklmlm", ast.get().getSimplePlusString()); + assertTrue(ast.isPresent()); + assertEquals("kklmlm", ast.get().getSimplePlusString()); ast = p.parseKPStart(new StringReader("kklmlmlmlm")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals("kklmlmlmlm", ast.get().getSimplePlusString()); + assertTrue(ast.isPresent()); + assertEquals("kklmlmlmlm", ast.get().getSimplePlusString()); ast = p.parseKPStart(new StringReader("lm")); - Assertions.assertFalse(ast.isPresent()); + assertFalse(ast.isPresent()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/lexerformat/LexRulesOrderTest.java b/monticore-test/it/src/test/java/mc/feature/lexerformat/LexRulesOrderTest.java index 6ef945325b..6655e2e0ea 100644 --- a/monticore-test/it/src/test/java/mc/feature/lexerformat/LexRulesOrderTest.java +++ b/monticore-test/it/src/test/java/mc/feature/lexerformat/LexRulesOrderTest.java @@ -2,21 +2,20 @@ package mc.feature.lexerformat; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import mc.GeneratorIntegrationsTest; import mc.feature.featuredsl._parser.FeatureDSLParser; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class LexRulesOrderTest extends GeneratorIntegrationsTest { @BeforeEach @@ -29,8 +28,8 @@ public void before() { public void testOrder() throws IOException { FeatureDSLParser parser = new FeatureDSLParser(); parser.parseClassProd(new StringReader("aString")); - Assertions.assertFalse(parser.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(parser.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/lexerformat/LexerTest.java b/monticore-test/it/src/test/java/mc/feature/lexerformat/LexerTest.java index 72d10fb5e7..e7290f2b34 100644 --- a/monticore-test/it/src/test/java/mc/feature/lexerformat/LexerTest.java +++ b/monticore-test/it/src/test/java/mc/feature/lexerformat/LexerTest.java @@ -2,16 +2,12 @@ package mc.feature.lexerformat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -20,6 +16,8 @@ import mc.feature.lexerformat.lexerformat._ast.ASTTest2; import mc.feature.lexerformat.lexerformat._parser.LexerFormatParser; +import static org.junit.jupiter.api.Assertions.*; + public class LexerTest extends GeneratorIntegrationsTest { @BeforeEach @@ -33,11 +31,11 @@ public void test0() throws IOException { LexerFormatParser p = new LexerFormatParser(); Optional ast = p.parseTest(new StringReader("007")); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); int r = ast.get().getA(); - Assertions.assertEquals(7, r); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(7, r); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -45,55 +43,55 @@ public void test1() throws IOException { LexerFormatParser p = new LexerFormatParser(); Optional ast = p.parseTest(new StringReader("on")); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); boolean r = ast.get().isB(); - Assertions.assertEquals(true, r); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(r); + assertTrue(Log.getFindings().isEmpty()); } @Test public void test1a() throws IOException { LexerFormatParser p = new LexerFormatParser(); Optional ast = p.parseTest(new StringReader("start")); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); boolean r = ast.get().isB(); - Assertions.assertEquals(true, r); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(r); + assertTrue(Log.getFindings().isEmpty()); } @Test public void test1b() throws IOException { LexerFormatParser p = new LexerFormatParser(); Optional ast = p.parseTest(new StringReader("stop")); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); boolean r = ast.get().isB(); - Assertions.assertEquals(false, r); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(r); + assertTrue(Log.getFindings().isEmpty()); } @Test public void test1c() throws IOException { LexerFormatParser p = new LexerFormatParser(); Optional ast = p.parseTest(new StringReader("off")); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); boolean r = ast.get().isB(); - Assertions.assertEquals(false, r); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(r); + assertTrue(Log.getFindings().isEmpty()); } @Test public void test2() throws IOException { LexerFormatParser p = new LexerFormatParser(); Optional ast = p.parseTest(new StringReader("a")); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); char r = ast.get().getC(); - Assertions.assertEquals('a', r); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals('a', r); + assertTrue(Log.getFindings().isEmpty()); } @@ -101,44 +99,44 @@ public void test2() throws IOException { public void test3() throws IOException { LexerFormatParser p = new LexerFormatParser(); Optional ast = p.parseTest(new StringReader("99.5")); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); float r = ast.get().getD(); - Assertions.assertEquals(99.5f, r, 0); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(99.5f, r, 0); + assertTrue(Log.getFindings().isEmpty()); } @Test public void test4() throws IOException { LexerFormatParser p = new LexerFormatParser(); Optional ast = p.parseTest(new StringReader("*")); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); int r = ast.get().getE(); - Assertions.assertEquals(-1, r); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(-1, r); + assertTrue(Log.getFindings().isEmpty()); } @Test public void test5() throws IOException { LexerFormatParser p = new LexerFormatParser(); Optional ast = p.parseTest2(new StringReader("1;1")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(ast.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void test6() throws IOException { LexerFormatParser p = new LexerFormatParser(); Optional ast = p.parseTest(new StringReader("<>")); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(ast.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void test7() throws IOException { LexerFormatParser p = new LexerFormatParser(); Optional ast = p.parseTest(new StringReader("<>fd>>")); - Assertions.assertTrue(p.hasErrors()); + assertTrue(p.hasErrors()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/linepreprocess/embedding/AutomatonOverallParserTest.java b/monticore-test/it/src/test/java/mc/feature/linepreprocess/embedding/AutomatonOverallParserTest.java index ee7d7c87d0..2b8b1dcb65 100644 --- a/monticore-test/it/src/test/java/mc/feature/linepreprocess/embedding/AutomatonOverallParserTest.java +++ b/monticore-test/it/src/test/java/mc/feature/linepreprocess/embedding/AutomatonOverallParserTest.java @@ -2,15 +2,11 @@ package mc.feature.linepreprocess.embedding; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,6 +14,9 @@ import mc.feature.linepreprocess.embedding.automaton._ast.ASTAutomaton; import mc.feature.linepreprocess.embedding.automatonwithaction._parser.AutomatonWithActionParser; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class AutomatonOverallParserTest extends GeneratorIntegrationsTest { @BeforeEach @@ -31,9 +30,9 @@ public void testRun() throws IOException { StringReader s = new StringReader("automaton foo { a-e>b / { DUMMY_ACTION } ; } "); AutomatonWithActionParser p = new AutomatonWithActionParser(); java.util.Optional ast = p.parseAutomaton(s); - Assertions.assertFalse(p.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertFalse(p.hasErrors()); + assertTrue(ast.isPresent()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/listrule/ListRuleTest.java b/monticore-test/it/src/test/java/mc/feature/listrule/ListRuleTest.java index f94f77ffc2..75b1149b13 100644 --- a/monticore-test/it/src/test/java/mc/feature/listrule/ListRuleTest.java +++ b/monticore-test/it/src/test/java/mc/feature/listrule/ListRuleTest.java @@ -2,21 +2,19 @@ package mc.feature.listrule; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import mc.GeneratorIntegrationsTest; import mc.feature.listrule.listrule._parser.ListRuleParser; +import static org.junit.jupiter.api.Assertions.*; + public class ListRuleTest extends GeneratorIntegrationsTest { @BeforeEach @@ -31,14 +29,14 @@ public void testParent1() throws IOException { "P1 a, P1 b"); ListRuleParser p = new ListRuleParser(); p.parseParent(s); - - Assertions.assertEquals(false, p.hasErrors()); + + assertFalse(p.hasErrors()); // Empty lists are NOT allowed s = new StringReader(""); p.parse(s); - - Assertions.assertEquals(true, p.hasErrors()); + + assertTrue(p.hasErrors()); } @Test @@ -47,9 +45,9 @@ public void testParent2() throws IOException { "Parent2 P2 a, P2 b Parent2"); ListRuleParser p = new ListRuleParser(); p.parseParent2(s); - - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -58,9 +56,9 @@ public void testParent3() throws IOException { "P3 a, P3 b"); ListRuleParser p = new ListRuleParser(); p.parseParent3(s); - - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -69,15 +67,15 @@ public void testParent4() throws IOException { "P4 a, P4 b"); ListRuleParser p = new ListRuleParser(); p.parseParent4(s); - - Assertions.assertEquals(false, p.hasErrors()); + + assertFalse(p.hasErrors()); // Empty lists are allowed s = new StringReader(""); p.parseParent4(s); - - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); } @@ -87,7 +85,7 @@ public void testParent6() throws IOException { "a, P"); ListRuleParser p = new ListRuleParser(); p.parseParent6(s); - - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + + assertFalse(p.hasErrors()); + assertTrue(Log.getFindings().isEmpty()); }} diff --git a/monticore-test/it/src/test/java/mc/feature/mcenum/EnumTest.java b/monticore-test/it/src/test/java/mc/feature/mcenum/EnumTest.java index e02284c6a6..e85e025c1f 100644 --- a/monticore-test/it/src/test/java/mc/feature/mcenum/EnumTest.java +++ b/monticore-test/it/src/test/java/mc/feature/mcenum/EnumTest.java @@ -5,10 +5,8 @@ import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import mc.GeneratorIntegrationsTest; - import mc.feature.mcenum.enums._ast.*; import mc.feature.mcenum.enums._parser.EnumsParser; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -16,8 +14,7 @@ import java.io.StringReader; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class EnumTest extends GeneratorIntegrationsTest { @@ -29,76 +26,76 @@ public void before() { @Test public void testa() throws IOException { - + EnumsParser p = new EnumsParser(); Optional optAst = p.parse(new StringReader("++++WORD")); - Assertions.assertTrue(optAst.isPresent()); + assertTrue(optAst.isPresent()); ASTA ast = optAst.get(); - Assertions.assertEquals(true, ast.isA()); - Assertions.assertEquals(true, ast.getE() == ASTE.PLUS); - Assertions.assertEquals(true, ast.getG() == ASTG.PLUS); - Assertions.assertEquals(true, ast.getF() == ASTF.PLUS); - Assertions.assertEquals(true, ast.getF().getIntValue() == ASTConstantsEnums.PLUS); - Assertions.assertEquals(true, ast.getF().ordinal() == 0); - Assertions.assertEquals(true, ast.getF().name() == "PLUS"); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(true, ast.isA()); + assertEquals(true, ast.getE() == ASTE.PLUS); + assertEquals(true, ast.getG() == ASTG.PLUS); + assertEquals(true, ast.getF() == ASTF.PLUS); + assertEquals(true, ast.getF().getIntValue() == ASTConstantsEnums.PLUS); + assertEquals(true, ast.getF().ordinal() == 0); + assertEquals(true, ast.getF().name() == "PLUS"); + assertTrue(Log.getFindings().isEmpty()); } - @Test + @Test public void testB() throws IOException { - - EnumsParser p = new EnumsParser(); + + EnumsParser p = new EnumsParser(); Optional optAst = p.parseB(new StringReader("++,++")); - Assertions.assertTrue(optAst.isPresent()); + assertTrue(optAst.isPresent()); ASTB ast = optAst.get(); - Assertions.assertEquals(true, ast.getE(0) == ASTE.PLUS); - Assertions.assertEquals(true, ast.getE(0).getIntValue() == ASTConstantsEnums.PLUS); - Assertions.assertEquals(2, ast.sizeEs()); - Assertions.assertEquals(true, ast.getF(0) == ASTF.PLUS); - Assertions.assertEquals(true, ast.getF(0).getIntValue() == ASTConstantsEnums.PLUS); - Assertions.assertEquals(2, ast.sizeFs()); - - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(true, ast.getE(0) == ASTE.PLUS); + assertEquals(true, ast.getE(0).getIntValue() == ASTConstantsEnums.PLUS); + assertEquals(2, ast.sizeEs()); + assertEquals(true, ast.getF(0) == ASTF.PLUS); + assertEquals(true, ast.getF(0).getIntValue() == ASTConstantsEnums.PLUS); + assertEquals(2, ast.sizeFs()); + + assertTrue(Log.getFindings().isEmpty()); } - @Test + @Test public void testB2() throws IOException { - - EnumsParser p = new EnumsParser(); + + EnumsParser p = new EnumsParser(); Optional optAst = p.parseB(new StringReader("++,#+")); - Assertions.assertTrue(optAst.isPresent()); + assertTrue(optAst.isPresent()); ASTB ast = optAst.get(); - Assertions.assertEquals(true, ast.getE(0) == ASTE.PLUS); - Assertions.assertEquals(2, ast.sizeEs()); - Assertions.assertEquals(true, ast.getF(0).ordinal() == 0); - Assertions.assertEquals(2, ast.sizeFs()); - Assertions.assertEquals(ast.getF(0), ast.getF(1)); - Assertions.assertEquals(true, ast.getF(0) == ASTF.PLUS); - - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertSame(ASTE.PLUS, ast.getE(0)); + assertEquals(2, ast.sizeEs()); + assertEquals(0, ast.getF(0).ordinal()); + assertEquals(2, ast.sizeFs()); + assertEquals(ast.getF(0), ast.getF(1)); + assertSame(ASTF.PLUS, ast.getF(0)); + + assertTrue(Log.getFindings().isEmpty()); } - @Test + @Test public void testB3() throws IOException { - - EnumsParser p = new EnumsParser(); + + EnumsParser p = new EnumsParser(); Optional optAst = p.parseB(new StringReader("++,#-")); - Assertions.assertTrue(optAst.isPresent()); + assertTrue(optAst.isPresent()); ASTB ast = optAst.get(); - - Assertions.assertEquals(2, ast.sizeEs()); - Assertions.assertEquals(true, ast.getE(0) == ASTE.PLUS); - Assertions.assertEquals(true, ast.getE(1) == ASTE.PLUS); - Assertions.assertEquals(2, ast.sizeFs()); - Assertions.assertEquals(true, ast.getF(0) == ASTF.PLUS); - Assertions.assertEquals(true, ast.getF(1) == ASTF.MINUS); - - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(2, ast.sizeEs()); + assertSame(ASTE.PLUS, ast.getE(0)); + assertSame(ASTE.PLUS, ast.getE(1)); + + assertEquals(2, ast.sizeFs()); + assertSame(ASTF.PLUS, ast.getF(0)); + assertSame(ASTF.MINUS, ast.getF(1)); + + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/multipletopsymbols/StatechartResolvingTest.java b/monticore-test/it/src/test/java/mc/feature/multipletopsymbols/StatechartResolvingTest.java index 61fa3b822e..cbfb6cc04c 100644 --- a/monticore-test/it/src/test/java/mc/feature/multipletopsymbols/StatechartResolvingTest.java +++ b/monticore-test/it/src/test/java/mc/feature/multipletopsymbols/StatechartResolvingTest.java @@ -11,7 +11,6 @@ import mc.feature.multipletopsymbols.statechart._symboltable.IStatechartGlobalScope; import mc.feature.multipletopsymbols.statechart._symboltable.StateSymbol; import mc.feature.multipletopsymbols.statechart._symboltable.StatechartSymbol; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -20,8 +19,8 @@ import java.nio.file.Paths; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class StatechartResolvingTest { @@ -44,8 +43,8 @@ public void before() { public void testResolving() throws IOException { StatechartParser parser = StatechartMill.parser(); Optional artifact = parser.parse("src/test/resources/mc/feature/multipletopsymbols/MyStatechart.sc"); - Assertions.assertTrue(artifact.isPresent()); - Assertions.assertFalse(parser.hasErrors()); + assertTrue(artifact.isPresent()); + assertFalse(parser.hasErrors()); IStatechartArtifactScope as = StatechartMill.scopesGenitorDelegator().createFromAST(artifact.get()); String packageName = String.join(".", artifact.get().getPackageDeclaration().getQualifiedName().getPartList()); @@ -60,14 +59,14 @@ public void testResolving() throws IOException { Optional t = gs.resolveState("mc.feature.multipletopsymbols.MyStatechart.s.t"); Optional s2 = gs.resolveState("mc.feature.multipletopsymbols.MyStatechart.MySC.s"); Optional u = gs.resolveState("mc.feature.multipletopsymbols.MyStatechart.MySC.u"); - Assertions.assertTrue(myStatechart.isPresent()); - Assertions.assertTrue(mySC.isPresent()); - Assertions.assertTrue(s.isPresent()); - Assertions.assertTrue(t.isPresent()); - Assertions.assertTrue(s2.isPresent()); - Assertions.assertTrue(u.isPresent()); + assertTrue(myStatechart.isPresent()); + assertTrue(mySC.isPresent()); + assertTrue(s.isPresent()); + assertTrue(t.isPresent()); + assertTrue(s2.isPresent()); + assertTrue(u.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-test/it/src/test/java/mc/feature/options/MultipleOptionTest.java b/monticore-test/it/src/test/java/mc/feature/options/MultipleOptionTest.java index d1d1595015..c17cf5be58 100644 --- a/monticore-test/it/src/test/java/mc/feature/options/MultipleOptionTest.java +++ b/monticore-test/it/src/test/java/mc/feature/options/MultipleOptionTest.java @@ -2,15 +2,11 @@ package mc.feature.options; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -19,6 +15,8 @@ import mc.feature.featuredsl._parser.FeatureDSLParser; import de.se_rwth.commons.logging.Log; +import static org.junit.jupiter.api.Assertions.*; + public class MultipleOptionTest extends GeneratorIntegrationsTest { @BeforeEach @@ -36,10 +34,10 @@ public void test() throws IOException { Optional ast = p.parseTestOptions(r); - Assertions.assertEquals(false, p.hasErrors()); - Assertions.assertTrue(ast.isPresent()); - Assertions.assertEquals(false, ast.get().isA()); + assertFalse(p.hasErrors()); + assertTrue(ast.isPresent()); + assertFalse(ast.get().isA()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/parserinfo/ComponentGrammarParserInfoTest.java b/monticore-test/it/src/test/java/mc/feature/parserinfo/ComponentGrammarParserInfoTest.java index 958a6cb207..95282ac3fa 100644 --- a/monticore-test/it/src/test/java/mc/feature/parserinfo/ComponentGrammarParserInfoTest.java +++ b/monticore-test/it/src/test/java/mc/feature/parserinfo/ComponentGrammarParserInfoTest.java @@ -3,7 +3,7 @@ import mc.feature.parserinfo.parserinfocomponentgrammartest._parser.ParserInfoComponentGrammarTestParserInfo; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; public class ComponentGrammarParserInfoTest { diff --git a/monticore-test/it/src/test/java/mc/feature/parserinfo/ParserInfoTest.java b/monticore-test/it/src/test/java/mc/feature/parserinfo/ParserInfoTest.java index a21a41818d..4c66aed6fa 100644 --- a/monticore-test/it/src/test/java/mc/feature/parserinfo/ParserInfoTest.java +++ b/monticore-test/it/src/test/java/mc/feature/parserinfo/ParserInfoTest.java @@ -4,43 +4,35 @@ import de.se_rwth.commons.logging.LogStub; import mc.feature.parserinfo.parserinfosimpleinheritancetest._parser._auxiliary.ParserInfoSimpleInheritanceTestParserInfoForParserInfoTest; import mc.feature.parserinfo.parserinfotest._parser.ParserInfoTestParserInfo; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.util.Arrays; -import java.util.Collection; + import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; -import static org.junit.Assert.*; import de.se_rwth.commons.logging.Log; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.Parameter; +import org.junit.jupiter.params.ParameterizedClass; +import org.junit.jupiter.params.provider.ValueSource; + +import static org.junit.jupiter.api.Assertions.*; /** * Test the generated ParserInfo classes. * Since the concrete antlr state numbers are not stable, we must always check a range of state numbers. */ -@RunWith(Parameterized.class) +@ParameterizedClass +@ValueSource(booleans = {true, false}) public class ParserInfoTest { + @Parameter private boolean useSimpleInheritance; - @Parameterized.Parameters - public static Collection data(){ - return Arrays.asList(new Boolean[]{false}, new Boolean[]{true}); - } - - public ParserInfoTest(boolean useSimpleInheritance){ - this.useSimpleInheritance = useSimpleInheritance; - } - // The generated parser has around 125 states // => add some safety margin private final int MAX_STATE_NUMBER = 250; - @Before + @BeforeEach public void init(){ if(useSimpleInheritance){ ParserInfoTestParserInfo.initMe(new ParserInfoSimpleInheritanceTestParserInfoForParserInfoTest()); @@ -49,7 +41,7 @@ public void init(){ } } - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/it/src/test/java/mc/feature/replacekeyword/ReplaceRuleTest.java b/monticore-test/it/src/test/java/mc/feature/replacekeyword/ReplaceRuleTest.java index 1180d2b7b5..a65b90709f 100644 --- a/monticore-test/it/src/test/java/mc/feature/replacekeyword/ReplaceRuleTest.java +++ b/monticore-test/it/src/test/java/mc/feature/replacekeyword/ReplaceRuleTest.java @@ -7,14 +7,13 @@ import mc.GeneratorIntegrationsTest; import mc.feature.replacerule.replacerule2.ReplaceRule2Mill; import mc.feature.replacerule.replacerule2._parser.ReplaceRule2Parser; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ReplaceRuleTest extends GeneratorIntegrationsTest { @@ -30,38 +29,38 @@ public void test() throws IOException { // Replace keyword parser.parse_StringA("a1 Foo"); - Assertions.assertFalse(parser.hasErrors()); + assertFalse(parser.hasErrors()); parser.parse_StringA("A Foo"); - Assertions.assertTrue(parser.hasErrors()); + assertTrue(parser.hasErrors()); // Add keyword in combination with nokeyword parser.parse_StringB("BLA Foo"); - Assertions.assertFalse(parser.hasErrors()); + assertFalse(parser.hasErrors()); parser.parse_StringB("bla Foo"); - Assertions.assertFalse(parser.hasErrors()); + assertFalse(parser.hasErrors()); // Replace keyword in combination with key parser.parse_StringC("bla_c Foo"); - Assertions.assertFalse(parser.hasErrors()); + assertFalse(parser.hasErrors()); parser.parse_StringC("BLA_C Foo"); - Assertions.assertTrue(parser.hasErrors()); + assertTrue(parser.hasErrors()); // Replace keyword in combination with splittoken parser.parse_StringD("}} Foo"); - Assertions.assertFalse(parser.hasErrors()); + assertFalse(parser.hasErrors()); parser.parse_StringD(">> Foo"); - Assertions.assertTrue(parser.hasErrors()); + assertTrue(parser.hasErrors()); // Add keyword in combination with token parser.parse_StringE("{{ Foo"); - Assertions.assertFalse(parser.hasErrors()); + assertFalse(parser.hasErrors()); parser.parse_StringE("<< Foo"); - Assertions.assertFalse(parser.hasErrors()); + assertFalse(parser.hasErrors()); } diff --git a/monticore-test/it/src/test/java/mc/feature/scoperules/ScoperuleTest.java b/monticore-test/it/src/test/java/mc/feature/scoperules/ScoperuleTest.java index 560381c96d..04fefba05a 100644 --- a/monticore-test/it/src/test/java/mc/feature/scoperules/ScoperuleTest.java +++ b/monticore-test/it/src/test/java/mc/feature/scoperules/ScoperuleTest.java @@ -9,17 +9,16 @@ import mc.feature.scoperules.scoperuletest._parser.ScoperuleTestParser; import mc.feature.scoperules.scoperuletest._symboltable.*; import mc.feature.scoperules.scoperuletest._ast.ASTFoo; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class ScoperuleTest { @BeforeEach @@ -39,7 +38,7 @@ public void setup(){ public void testModel() throws IOException { ScoperuleTestParser parser = ScoperuleTestMill.parser(); Optional optModel = parser.parse("src/test/resources/mc/feature/symbolrules/SymbolruleTest.rule"); - Assertions.assertTrue(optModel.isPresent()); + assertTrue(optModel.isPresent()); ScoperuleTestScopesGenitorDelegator scopesGenitorDelegator = ScoperuleTestMill.scopesGenitorDelegator(); IScoperuleTestArtifactScope scope = scopesGenitorDelegator.createFromAST(optModel.get()); @@ -52,26 +51,26 @@ public void testModel() throws IOException { scope.accept(symbols2Json.getTraverser()); String serialized = symbols2Json.getSerializedString(); IScoperuleTestScope as = symbols2Json.deserialize(serialized); - Assertions.assertTrue(as.isBar()); - Assertions.assertEquals(17, as.getNumber()); - Assertions.assertEquals(3, as.getModifiedNameList().size()); - Assertions.assertEquals("foo", as.getModifiedName(0)); - Assertions.assertEquals("bar", as.getModifiedName(1)); - Assertions.assertEquals("test", as.getModifiedName(2)); - Assertions.assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(as.getSymType())); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(as.isBar()); + assertEquals(17, as.getNumber()); + assertEquals(3, as.getModifiedNameList().size()); + assertEquals("foo", as.getModifiedName(0)); + assertEquals("bar", as.getModifiedName(1)); + assertEquals("test", as.getModifiedName(2)); + assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(as.getSymType())); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExtendsAndImplements(){ IScoperuleTestScope scope = ScoperuleTestMill.scope(); - - Assertions.assertTrue(scope instanceof ScoperuleTestScope); + + assertInstanceOf(ScoperuleTestScope.class, scope); Dummy dummy = (ScoperuleTestScope) scope; - - Assertions.assertTrue(scope instanceof IDummy); + + assertInstanceOf(IDummy.class, scope); IDummy dummyI = (IDummy) scope; - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/scopes/ScopesTest.java b/monticore-test/it/src/test/java/mc/feature/scopes/ScopesTest.java index b3e28caf5f..1aa31f1f03 100644 --- a/monticore-test/it/src/test/java/mc/feature/scopes/ScopesTest.java +++ b/monticore-test/it/src/test/java/mc/feature/scopes/ScopesTest.java @@ -19,8 +19,8 @@ import java.nio.file.Paths; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ScopesTest { @@ -40,8 +40,8 @@ public void setUp() throws IOException { SupAutomatonMill.init(); SupAutomatonParser supAutomatonParser = new SupAutomatonParser(); Optional astSup = supAutomatonParser.parse("src/test/resources/mc/feature/scopes/SupAutomatonModel.aut"); - Assertions.assertFalse(supAutomatonParser.hasErrors()); - Assertions.assertTrue(astSup.isPresent()); + assertFalse(supAutomatonParser.hasErrors()); + assertTrue(astSup.isPresent()); ISupAutomatonGlobalScope globalScope = SupAutomatonMill.globalScope(); globalScope.setFileExt("aut"); @@ -71,13 +71,13 @@ public void testResolvingFromGrammarScope(){ //findet also voll qualifiziert auch vom global aus Optional pingStateSymbolGlobal = globalScope.resolveState("TopPingPong.PingPong.Ping"); - Assertions.assertTrue(pingPongAutomatonSymbolLokal.isPresent()); - Assertions.assertTrue(pingPongAutomatonSymbolGlobal.isPresent()); - Assertions.assertTrue(pingStateSymbol.isPresent()); - Assertions.assertTrue(pongStateSymbol.isPresent()); - Assertions.assertTrue(noGameStateSymbol.isPresent()); - Assertions.assertTrue(pingStateSymbolGlobal.isPresent()); + assertTrue(pingPongAutomatonSymbolLokal.isPresent()); + assertTrue(pingPongAutomatonSymbolGlobal.isPresent()); + assertTrue(pingStateSymbol.isPresent()); + assertTrue(pongStateSymbol.isPresent()); + assertTrue(noGameStateSymbol.isPresent()); + assertTrue(pingStateSymbolGlobal.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/semanticpredicate/SemPredWithInterfaceParserTest.java b/monticore-test/it/src/test/java/mc/feature/semanticpredicate/SemPredWithInterfaceParserTest.java index 1ec00b4104..9579a750bc 100644 --- a/monticore-test/it/src/test/java/mc/feature/semanticpredicate/SemPredWithInterfaceParserTest.java +++ b/monticore-test/it/src/test/java/mc/feature/semanticpredicate/SemPredWithInterfaceParserTest.java @@ -2,16 +2,10 @@ package mc.feature.semanticpredicate; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; @@ -20,6 +14,8 @@ import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class SemPredWithInterfaceParserTest extends GeneratorIntegrationsTest { @BeforeEach @@ -36,15 +32,15 @@ public void testParse() { try { ast = p.parseISequence(new StringReader(input)); } catch (IOException e) { - Assertions.fail(); + fail(); } - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); ASTISequence seq = ast.get(); - Assertions.assertEquals(2, seq.getIList().size()); + assertEquals(2, seq.getIList().size()); - Assertions.assertTrue(seq.getIList().get(0).isFirst()); - Assertions.assertFalse(seq.getIList().get(1).isFirst()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(seq.getIList().get(0).isFirst()); + assertFalse(seq.getIList().get(1).isFirst()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/sourcepositions/ExpressionSourcePositionsTest.java b/monticore-test/it/src/test/java/mc/feature/sourcepositions/ExpressionSourcePositionsTest.java index 5e8b3bc5fe..c292d8f093 100644 --- a/monticore-test/it/src/test/java/mc/feature/sourcepositions/ExpressionSourcePositionsTest.java +++ b/monticore-test/it/src/test/java/mc/feature/sourcepositions/ExpressionSourcePositionsTest.java @@ -2,14 +2,11 @@ package mc.feature.sourcepositions; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; @@ -18,6 +15,9 @@ import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Tests the source position's computing for the AST nodes * Defined grammar: mc.feature.expression.Expression.mc @@ -53,30 +53,33 @@ private void doTestPExpSourcePositions(ASTExpr node) { ASTExpr leftChild = null; if (node.isPresentLeft()) { leftChild = node.getLeft(); - Assertions.assertTrue(node.get_SourcePositionStart().compareTo(leftChild.get_SourcePositionStart()) == 0); + assertEquals(0, + node.get_SourcePositionStart().compareTo(leftChild.get_SourcePositionStart())); if (node.isPresentRight()) { ASTExpr rightChild = node.getRight(); // End position of expression node coincides with the end position of // the right child - Assertions.assertTrue(node.get_SourcePositionEnd().compareTo(rightChild.get_SourcePositionEnd()) == 0); + assertEquals(0, + node.get_SourcePositionEnd().compareTo(rightChild.get_SourcePositionEnd())); // Start position of the right child is the next to the end position of // the left child - Assertions.assertTrue(rightChild.get_SourcePositionStart().getColumn() - - leftChild.get_SourcePositionEnd().getColumn() == 1); + assertEquals(1, + rightChild.get_SourcePositionStart().getColumn() - leftChild.get_SourcePositionEnd() + .getColumn()); } } node = leftChild; } - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } private ASTExpr parse(String input) throws IOException { ExpressionParser parser = new ExpressionParser(); Optional ast = parser.parseExpr(new StringReader(input)); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); return ast.get(); } diff --git a/monticore-test/it/src/test/java/mc/feature/symbolrules/SymbolruleTest.java b/monticore-test/it/src/test/java/mc/feature/symbolrules/SymbolruleTest.java index 2faecb6ba2..23d17bf9b9 100644 --- a/monticore-test/it/src/test/java/mc/feature/symbolrules/SymbolruleTest.java +++ b/monticore-test/it/src/test/java/mc/feature/symbolrules/SymbolruleTest.java @@ -14,17 +14,16 @@ import mc.feature.symbolrules.symbolruletest._ast.ASTFoo; import mc.feature.symbolrules.symbolruletest._parser.SymbolruleTestParser; import mc.feature.symbolrules.symbolruletest._symboltable.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import de.se_rwth.commons.logging.Log; +import static org.junit.jupiter.api.Assertions.*; + public class SymbolruleTest { @BeforeEach @@ -48,8 +47,8 @@ public void testSymbols(){ FooSymbolDeSer fooSymbolDeSer = new FooSymbolDeSer(); String serializedFoo = fooSymbolDeSer.serialize(fooSymbol, new SymbolruleTestSymbols2Json()); FooSymbol deserializedFoo = fooSymbolDeSer.deserialize(serializedFoo); - Assertions.assertEquals(fooSymbol.getName(), deserializedFoo.getName()); - Assertions.assertEquals(fooSymbol.getBarName(), deserializedFoo.getBarName()); + assertEquals(fooSymbol.getName(), deserializedFoo.getName()); + assertEquals(fooSymbol.getBarName(), deserializedFoo.getBarName()); ITestSymbol itest = SymbolruleTestMill.iTestSymbolBuilder().setName("itest").build(); @@ -57,10 +56,10 @@ public void testSymbols(){ ITestSymbolDeSer iTestSymbolDeSer = new ITestSymbolDeSer(); String serializedITest = iTestSymbolDeSer.serialize(itest, new SymbolruleTestSymbols2Json()); ITestSymbol deserializedITest = iTestSymbolDeSer.deserialize(serializedITest); - Assertions.assertEquals(itest.getName(), deserializedITest.getName()); - Assertions.assertEquals(1, deserializedITest.sizeSuperTypes()); - Assertions.assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedITest.getSuperTypes(0))); - Assertions.assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedITest.getByName("int"))); + assertEquals(itest.getName(), deserializedITest.getName()); + assertEquals(1, deserializedITest.sizeSuperTypes()); + assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedITest.getSuperTypes(0))); + assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedITest.getByName("int"))); Test1Symbol test1 = SymbolruleTestMill.test1SymbolBuilder().setName("test11").build(); test1.setSuperTypesList(Lists.newArrayList(SymTypeExpressionFactory.createPrimitive("int"))); @@ -68,12 +67,12 @@ public void testSymbols(){ Test1SymbolDeSer test1SymbolDeSer = new Test1SymbolDeSer(); String serializedTest1 = test1SymbolDeSer.serialize(test1, new SymbolruleTestSymbols2Json()); Test1Symbol deserializedTest1 = test1SymbolDeSer.deserialize(serializedTest1); - Assertions.assertEquals(test1.getName(), deserializedTest1.getName()); - Assertions.assertEquals(1, deserializedTest1.sizeSuperTypes()); - Assertions.assertTrue(deserializedTest1.isIsPrivate()); - Assertions.assertEquals(deserializedTest1, deserializedTest1.getIfPrivate()); - Assertions.assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedTest1.getSuperTypes(0))); - Assertions.assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedTest1.getByName("int"))); + assertEquals(test1.getName(), deserializedTest1.getName()); + assertEquals(1, deserializedTest1.sizeSuperTypes()); + assertTrue(deserializedTest1.isIsPrivate()); + assertEquals(deserializedTest1, deserializedTest1.getIfPrivate()); + assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedTest1.getSuperTypes(0))); + assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedTest1.getByName("int"))); Test2Symbol test2 = SymbolruleTestMill.test2SymbolBuilder().setName("test22").build(); test2.setSuperTypesList(Lists.newArrayList(SymTypeExpressionFactory.createPrimitive("int"))); @@ -81,20 +80,20 @@ public void testSymbols(){ Test2SymbolDeSer test2SymbolDeSer = new Test2SymbolDeSer(); String serializedTest2 = test2SymbolDeSer.serialize(test2, new SymbolruleTestSymbols2Json()); Test2Symbol deserializedTest2 = test2SymbolDeSer.deserialize(serializedTest2); - Assertions.assertEquals(test2.getName(), deserializedTest2.getName()); - Assertions.assertEquals(1, deserializedTest2.sizeSuperTypes()); - Assertions.assertTrue(deserializedTest2.isIsPublic()); - Assertions.assertEquals(deserializedTest2, deserializedTest2.getIfPublic()); - Assertions.assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedTest2.getSuperTypes(0))); - Assertions.assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedTest2.getByName("int"))); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(test2.getName(), deserializedTest2.getName()); + assertEquals(1, deserializedTest2.sizeSuperTypes()); + assertTrue(deserializedTest2.isIsPublic()); + assertEquals(deserializedTest2, deserializedTest2.getIfPublic()); + assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedTest2.getSuperTypes(0))); + assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(deserializedTest2.getByName("int"))); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testModel() throws IOException { SymbolruleTestParser parser = SymbolruleTestMill.parser(); Optional model = parser.parse("src/test/resources/mc/feature/symbolrules/SymbolruleTest.rule"); - Assertions.assertTrue(model.isPresent()); + assertTrue(model.isPresent()); SymbolruleTestScopesGenitorDelegator scopesGenitor = SymbolruleTestMill.scopesGenitorDelegator(); ISymbolruleTestArtifactScope as = scopesGenitor.createFromAST(model.get()); @@ -109,50 +108,50 @@ public void testModel() throws IOException { String serialized = symbols2Json.getSerializedString(); ISymbolruleTestArtifactScope as2 = symbols2Json.deserialize(serialized); - Assertions.assertEquals(as.getName(), as2.getName()); - Assertions.assertEquals(as.getSymbolsSize(), as2.getSymbolsSize()); - Assertions.assertTrue(as2.isBar()); - Assertions.assertEquals(17, as2.getNumber()); - Assertions.assertEquals(3, as.getModifiedNameList().size()); - Assertions.assertEquals("foo", as.getModifiedName(0)); - Assertions.assertEquals("bar", as.getModifiedName(1)); - Assertions.assertEquals("test", as.getModifiedName(2)); - Assertions.assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(as2.getSymType())); - Assertions.assertEquals(1, as2.getLocalFooSymbols().size()); + assertEquals(as.getName(), as2.getName()); + assertEquals(as.getSymbolsSize(), as2.getSymbolsSize()); + assertTrue(as2.isBar()); + assertEquals(17, as2.getNumber()); + assertEquals(3, as.getModifiedNameList().size()); + assertEquals("foo", as.getModifiedName(0)); + assertEquals("bar", as.getModifiedName(1)); + assertEquals("test", as.getModifiedName(2)); + assertTrue(SymTypeExpressionFactory.createPrimitive("int").deepEquals(as2.getSymType())); + assertEquals(1, as2.getLocalFooSymbols().size()); ISymbolruleTestScope fooSpannedScope = as2.getLocalFooSymbols().get(0).getSpannedScope(); - Assertions.assertEquals(2, fooSpannedScope.getLocalBarSymbols().size()); - Assertions.assertEquals("Test1", fooSpannedScope.getLocalBarSymbols().get(0).getName()); - Assertions.assertEquals("Test2", fooSpannedScope.getLocalBarSymbols().get(1).getName()); + assertEquals(2, fooSpannedScope.getLocalBarSymbols().size()); + assertEquals("Test1", fooSpannedScope.getLocalBarSymbols().get(0).getName()); + assertEquals("Test2", fooSpannedScope.getLocalBarSymbols().get(1).getName()); ISymbolruleTestScope bar1SpannedScope = fooSpannedScope.getLocalBarSymbols().get(0).getSpannedScope(); - Assertions.assertEquals(2, bar1SpannedScope.getLocalTest1Symbols().size()); - Assertions.assertEquals("symbol1", bar1SpannedScope.getLocalTest1Symbols().get(0).getName()); - Assertions.assertEquals("symbol11", bar1SpannedScope.getLocalTest1Symbols().get(1).getName()); - Assertions.assertEquals(1, bar1SpannedScope.getLocalTest2Symbols().size()); - Assertions.assertEquals("symbol2", bar1SpannedScope.getLocalTest2Symbols().get(0).getName()); + assertEquals(2, bar1SpannedScope.getLocalTest1Symbols().size()); + assertEquals("symbol1", bar1SpannedScope.getLocalTest1Symbols().get(0).getName()); + assertEquals("symbol11", bar1SpannedScope.getLocalTest1Symbols().get(1).getName()); + assertEquals(1, bar1SpannedScope.getLocalTest2Symbols().size()); + assertEquals("symbol2", bar1SpannedScope.getLocalTest2Symbols().get(0).getName()); ISymbolruleTestScope bar2SpannedScope = fooSpannedScope.getLocalBarSymbols().get(1).getSpannedScope(); - Assertions.assertEquals(2, bar2SpannedScope.getLocalTest1Symbols().size()); - Assertions.assertEquals("symbol3", bar2SpannedScope.getLocalTest1Symbols().get(0).getName()); - Assertions.assertEquals("symbol4", bar2SpannedScope.getLocalTest1Symbols().get(1).getName()); - Assertions.assertEquals(1, bar2SpannedScope.getLocalTest2Symbols().size()); - Assertions.assertEquals("symbol22", bar2SpannedScope.getLocalTest2Symbols().get(0).getName()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(2, bar2SpannedScope.getLocalTest1Symbols().size()); + assertEquals("symbol3", bar2SpannedScope.getLocalTest1Symbols().get(0).getName()); + assertEquals("symbol4", bar2SpannedScope.getLocalTest1Symbols().get(1).getName()); + assertEquals(1, bar2SpannedScope.getLocalTest2Symbols().size()); + assertEquals("symbol22", bar2SpannedScope.getLocalTest2Symbols().get(0).getName()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testExtendsAndImplements(){ IBarSymbol symbol = SymbolruleTestMill.barSymbolBuilder().setName("lala").build(); - Assertions.assertTrue(symbol instanceof Dummy); + assertInstanceOf(Dummy.class, symbol); Dummy dummy = (Dummy) symbol; - Assertions.assertTrue(symbol instanceof IDummy); + assertInstanceOf(IDummy.class, symbol); IDummy iDummy = (IDummy) symbol; - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSymbolruleListAttributes() throws IOException{ SymbolruleListTestParser parser = SymbolruleListTestMill.parser(); Optional opt = parser.parse("src/test/resources/mc/feature/symbolrules/SymbolruleTest.rule"); - Assertions.assertTrue(opt.isPresent()); + assertTrue(opt.isPresent()); SymbolruleListTestScopesGenitorDelegator scopesGenitor = SymbolruleListTestMill.scopesGenitorDelegator(); ISymbolruleListTestArtifactScope as = scopesGenitor.createFromAST(opt.get()); as.setName("SymbolruleTest"); @@ -169,34 +168,34 @@ public void testSymbolruleListAttributes() throws IOException{ String serialized = symbols2Json.getSerializedString(); ISymbolruleListTestArtifactScope as2 = symbols2Json.deserialize(serialized); - Assertions.assertEquals(as.getName(), as2.getName()); - Assertions.assertEquals(as.sizeNumbers(), as2.sizeNumbers()); - Assertions.assertEquals(as.getNumbers(0), as2.getNumbers(0)); - Assertions.assertEquals(as.getNumbers(1), as2.getNumbers(1)); - Assertions.assertEquals(as.getNumbers(2), as2.getNumbers(2)); - Assertions.assertEquals(as.sizeNames(), as2.sizeNames()); - Assertions.assertEquals(as.getNames(0), as2.getNames(0)); - Assertions.assertEquals(as.getNames(1), as2.getNames(1)); - Assertions.assertEquals(as.getNames(2), as2.getNames(2)); - Assertions.assertEquals(as.sizeSymTypes(), as2.sizeSymTypes()); - Assertions.assertTrue(as.getSymTypes(0).deepEquals(as2.getSymTypes(0))); - Assertions.assertTrue(as.getSymTypes(1).deepEquals(as2.getSymTypes(1))); - Assertions.assertEquals(as.sizeArePresent(), as2.sizeArePresent()); - Assertions.assertEquals(as.getArePresent(0), as2.getArePresent(0)); - Assertions.assertEquals(as.getArePresent(1), as2.getArePresent(1)); - Assertions.assertEquals(as.getArePresent(2), as2.getArePresent(2)); - Assertions.assertEquals(as.getArePresent(3), as2.getArePresent(3)); - Assertions.assertEquals(as.sizeBigNumbers(), as2.sizeBigNumbers()); - Assertions.assertEquals(as.getBigNumbers(0), as2.getBigNumbers(0)); - Assertions.assertEquals(as.sizeDoubleFloatingPoints(), as2.sizeDoubleFloatingPoints()); - Assertions.assertEquals(as.getDoubleFloatingPoints(0), as2.getDoubleFloatingPoints(0)); - Assertions.assertEquals(as.getDoubleFloatingPoints(1), as2.getDoubleFloatingPoints(1)); - Assertions.assertEquals(as.getDoubleFloatingPoints(2), as2.getDoubleFloatingPoints(2)); - Assertions.assertEquals(as.sizeFloatingPoints(), as2.sizeFloatingPoints()); - Assertions.assertEquals(as.getFloatingPoints(0), as2.getFloatingPoints(0)); - Assertions.assertEquals(as.getFloatingPoints(1), as2.getFloatingPoints(1)); - Assertions.assertEquals(as.getFloatingPoints(2), as2.getFloatingPoints(2)); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(as.getName(), as2.getName()); + assertEquals(as.sizeNumbers(), as2.sizeNumbers()); + assertEquals(as.getNumbers(0), as2.getNumbers(0)); + assertEquals(as.getNumbers(1), as2.getNumbers(1)); + assertEquals(as.getNumbers(2), as2.getNumbers(2)); + assertEquals(as.sizeNames(), as2.sizeNames()); + assertEquals(as.getNames(0), as2.getNames(0)); + assertEquals(as.getNames(1), as2.getNames(1)); + assertEquals(as.getNames(2), as2.getNames(2)); + assertEquals(as.sizeSymTypes(), as2.sizeSymTypes()); + assertTrue(as.getSymTypes(0).deepEquals(as2.getSymTypes(0))); + assertTrue(as.getSymTypes(1).deepEquals(as2.getSymTypes(1))); + assertEquals(as.sizeArePresent(), as2.sizeArePresent()); + assertEquals(as.getArePresent(0), as2.getArePresent(0)); + assertEquals(as.getArePresent(1), as2.getArePresent(1)); + assertEquals(as.getArePresent(2), as2.getArePresent(2)); + assertEquals(as.getArePresent(3), as2.getArePresent(3)); + assertEquals(as.sizeBigNumbers(), as2.sizeBigNumbers()); + assertEquals(as.getBigNumbers(0), as2.getBigNumbers(0)); + assertEquals(as.sizeDoubleFloatingPoints(), as2.sizeDoubleFloatingPoints()); + assertEquals(as.getDoubleFloatingPoints(0), as2.getDoubleFloatingPoints(0)); + assertEquals(as.getDoubleFloatingPoints(1), as2.getDoubleFloatingPoints(1)); + assertEquals(as.getDoubleFloatingPoints(2), as2.getDoubleFloatingPoints(2)); + assertEquals(as.sizeFloatingPoints(), as2.sizeFloatingPoints()); + assertEquals(as.getFloatingPoints(0), as2.getFloatingPoints(0)); + assertEquals(as.getFloatingPoints(1), as2.getFloatingPoints(1)); + assertEquals(as.getFloatingPoints(2), as2.getFloatingPoints(2)); + assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo1Test.java b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo1Test.java index 4f5c025cb4..915c09b56d 100644 --- a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo1Test.java +++ b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo1Test.java @@ -5,13 +5,14 @@ import de.se_rwth.commons.logging.LogStub; import mc.GeneratorIntegrationsTest; import mc.feature.symboltable.automatonwithstinfo1._symboltable.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; -import static org.junit.Assert.assertTrue; import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class AutomatonWithSTInfo1Test extends GeneratorIntegrationsTest { @BeforeEach @@ -32,11 +33,11 @@ public void test() { AutomatonSymbolSurrogate automatonSymbolSurrogate; AutomatonWithSTInfo1ScopesGenitorDelegator automatonWithSTInfo1SymbolTableCreator; StateSymbol stateSymbol = new StateSymbol("S"); - Assertions.assertTrue(stateSymbol instanceof StateSymbol); + assertInstanceOf(StateSymbol.class, stateSymbol); // Collection stateSymbols2 = stateSymbol.getStates(); StateSymbolSurrogate stateSymbolReference; - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo2Test.java b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo2Test.java index 175b9e73f1..47909b1f12 100644 --- a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo2Test.java +++ b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo2Test.java @@ -6,14 +6,13 @@ import de.se_rwth.commons.logging.LogStub; import mc.GeneratorIntegrationsTest; import mc.feature.symboltable.automatonwithstinfo2._symboltable.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import de.se_rwth.commons.logging.Log; +import static org.junit.jupiter.api.Assertions.*; + public class AutomatonWithSTInfo2Test extends GeneratorIntegrationsTest { @BeforeEach @@ -29,14 +28,14 @@ public void before() { @Test public void test() { AutomatonElementSymbol automatonElementSymbol = new AutomatonElementSymbol("A"); - Assertions.assertFalse(automatonElementSymbol instanceof IScopeSpanningSymbol); + assertFalse(automatonElementSymbol instanceof IScopeSpanningSymbol); AutomatonWithSTInfo2Scope automatonScope; AutomatonSymbol automatonSymbol = new AutomatonSymbol("A"); - Assertions.assertTrue(automatonSymbol instanceof IScopeSpanningSymbol); + assertInstanceOf(IScopeSpanningSymbol.class, automatonSymbol); // Collection automatonElementSymbols = automatonSymbol.getAutomatonElements(); AutomatonSymbolSurrogate automatonSymbolSurrogate; AutomatonWithSTInfo2ScopesGenitorDelegator automatonWithSTInfo2SymbolTableCreator; - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo3Test.java b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo3Test.java index 66d6b41307..a37267138b 100644 --- a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo3Test.java +++ b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo3Test.java @@ -7,14 +7,14 @@ import mc.GeneratorIntegrationsTest; import mc.feature.symboltable.automatonwithstinfo3.AutomatonWithSTInfo3Mill; import mc.feature.symboltable.automatonwithstinfo3._symboltable.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class AutomatonWithSTInfo3Test extends GeneratorIntegrationsTest { @BeforeEach @@ -30,7 +30,7 @@ public void before() { @Test public void test() { AutomatonSymbol automatonSymbol = new AutomatonSymbol("A"); - Assertions.assertFalse(automatonSymbol instanceof IScopeSpanningSymbol); + assertFalse(automatonSymbol instanceof IScopeSpanningSymbol); AutomatonSymbolSurrogate automatonSymbolSurrogate; AutomatonWithSTInfo3ScopesGenitor automatonWithSTInfo3SymbolTableCreator; AutomatonWithSTInfo3ScopesGenitorDelegator automatonWithSTInfo3SymbolTableCreatorDelegator; @@ -41,9 +41,9 @@ public void test() { IAutomatonWithSTInfo3Scope iAutomatonWithSTInfo3Scope; ICommonAutomatonWithSTInfo3Symbol iCommonAutomatonWithSTInfo3Symbol; StateSymbol stateSymbol = new StateSymbol("S"); - Assertions.assertFalse(stateSymbol instanceof IScopeSpanningSymbol); + assertFalse(stateSymbol instanceof IScopeSpanningSymbol); StateSymbolSurrogate stateSymbolSurrogate; - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo4Test.java b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo4Test.java index 2c0a13048b..5646b1b90e 100644 --- a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo4Test.java +++ b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo4Test.java @@ -8,14 +8,13 @@ import mc.feature.symboltable.automatonwithstinfo4.AutomatonWithSTInfo4Mill; import mc.feature.symboltable.automatonwithstinfo4._ast.ASTState; import mc.feature.symboltable.automatonwithstinfo4._symboltable.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import de.se_rwth.commons.logging.Log; +import static org.junit.jupiter.api.Assertions.*; + public class AutomatonWithSTInfo4Test extends GeneratorIntegrationsTest { @BeforeEach @@ -31,11 +30,11 @@ public void before() { @Test public void test() { AutomatonElementSymbol automatonElementSymbol = new AutomatonElementSymbol("A"); - Assertions.assertFalse(automatonElementSymbol instanceof IScopeSpanningSymbol); + assertFalse(automatonElementSymbol instanceof IScopeSpanningSymbol); AutomatonElementSymbolSurrogate automatonElementSymbolSurrogate; AutomatonWithSTInfo4Scope automatonScope; AutomatonSymbol automatonSymbol= new AutomatonSymbol("A"); - Assertions.assertTrue(automatonSymbol instanceof IScopeSpanningSymbol); + assertInstanceOf(IScopeSpanningSymbol.class, automatonSymbol); AutomatonSymbolSurrogate automatonSymbolSurrogate; AutomatonWithSTInfo4ScopesGenitor automatonWithSTInfo4SymbolTableCreator; ASTState s = AutomatonWithSTInfo4Mill.stateBuilder().setName("S").build(); @@ -43,7 +42,7 @@ public void test() { AutomatonElementSymbol aESymbol = s.getSymbol(); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo5Test.java b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo5Test.java index 18dd714ddf..c33a26ba7c 100644 --- a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo5Test.java +++ b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo5Test.java @@ -6,14 +6,13 @@ import de.se_rwth.commons.logging.LogStub; import mc.GeneratorIntegrationsTest; import mc.feature.symboltable.automatonwithstinfo5._symboltable.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class AutomatonWithSTInfo5Test extends GeneratorIntegrationsTest { @BeforeEach @@ -30,14 +29,14 @@ public void before() { public void test() { AutomatonWithSTInfo5Scope automatonScope; AutomatonSymbol automatonSymbol = new AutomatonSymbol("A"); - Assertions.assertTrue(automatonSymbol instanceof IScopeSpanningSymbol); + assertInstanceOf(IScopeSpanningSymbol.class, automatonSymbol); AutomatonSymbolSurrogate automatonSymbolSurrogate; AutomatonWithSTInfo5ScopesGenitor automatonWithSTInfo5SymbolTableCreator; StateSymbol stateSymbol = new StateSymbol("A"); - Assertions.assertFalse(stateSymbol instanceof IScopeSpanningSymbol); + assertFalse(stateSymbol instanceof IScopeSpanningSymbol); StateSymbolSurrogate stateSymbolSurrogate; TransitionSymbol transitionSymbol = new TransitionSymbol("T"); - Assertions.assertFalse(transitionSymbol instanceof IScopeSpanningSymbol); + assertFalse(transitionSymbol instanceof IScopeSpanningSymbol); TransitionSymbolSurrogate transitionSymbolReference; // Collection stateSymbols = automatonSymbol.getStates(); @@ -46,7 +45,7 @@ public void test() { // StateSymbol from = transitionSymbol.getFrom(); // StateSymbol to = transitionSymbol.getTo(); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo6Test.java b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo6Test.java index 7e049316d6..e6bf973a4d 100644 --- a/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo6Test.java +++ b/monticore-test/it/src/test/java/mc/feature/symboltable/AutomatonWithSTInfo6Test.java @@ -6,14 +6,13 @@ import de.se_rwth.commons.logging.LogStub; import mc.GeneratorIntegrationsTest; import mc.feature.symboltable.automatonwithstinfo6._symboltable.*; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class AutomatonWithSTInfo6Test extends GeneratorIntegrationsTest { @BeforeEach @@ -30,16 +29,16 @@ public void before() { public void test() { AutomatonWithSTInfo6Scope automatonScope; AutomatonSymbol automatonSymbol = new AutomatonSymbol("A"); - Assertions.assertTrue(automatonSymbol instanceof IScopeSpanningSymbol); + assertInstanceOf(IScopeSpanningSymbol.class, automatonSymbol); AutomatonSymbolSurrogate automatonSymbolSurrogate; AutomatonWithSTInfo6ScopesGenitor automatonwithstinfo6SymbolTableCreator; StateSymbol stateSymbol = new StateSymbol("A"); - Assertions.assertFalse(stateSymbol instanceof IScopeSpanningSymbol); + assertFalse(stateSymbol instanceof IScopeSpanningSymbol); StateSymbolSurrogate stateSymbolSurrogate; TransitionSymbol transitionSymbol = new TransitionSymbol("T"); - Assertions.assertFalse(transitionSymbol instanceof IScopeSpanningSymbol); + assertFalse(transitionSymbol instanceof IScopeSpanningSymbol); TransitionSymbolSurrogate transitionSymbolSurrogate; - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/visitor/VisitorTest.java b/monticore-test/it/src/test/java/mc/feature/visitor/VisitorTest.java index a08235bdb4..cf3620bcaf 100644 --- a/monticore-test/it/src/test/java/mc/feature/visitor/VisitorTest.java +++ b/monticore-test/it/src/test/java/mc/feature/visitor/VisitorTest.java @@ -2,17 +2,11 @@ package mc.feature.visitor; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.IOException; import java.io.StringReader; import java.util.Optional; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import de.se_rwth.commons.logging.Log; @@ -25,6 +19,8 @@ import mc.feature.visitor.sup._visitor.SupVisitor2; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class VisitorTest extends GeneratorIntegrationsTest { @BeforeEach @@ -38,8 +34,8 @@ public void testConcreteVisitor() throws IOException { // Create AST SubParser p = new SubParser(); Optional node = p.parseA(new StringReader("test1 test2")); - Assertions.assertFalse(p.hasErrors()); - Assertions.assertTrue(node.isPresent()); + assertFalse(p.hasErrors()); + assertTrue(node.isPresent()); // Running Visitor SubTraverser t1 = SubMill.traverser(); @@ -47,7 +43,7 @@ public void testConcreteVisitor() throws IOException { t1.add4Sub(v); t1.handle(node.get()); - Assertions.assertTrue(v.hasVisited()); + assertTrue(v.hasVisited()); SubTraverser t2 = SubMill.traverser(); SupVisitor2 vSup = new SupVisitor2() {}; @@ -55,8 +51,8 @@ public void testConcreteVisitor() throws IOException { long errorCount = Log.getErrorCount(); // no expected error, as super visitor should run on sub language t2.handle(node.get()); - Assertions.assertEquals(errorCount, Log.getErrorCount()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(errorCount, Log.getErrorCount()); + assertTrue(Log.getFindings().isEmpty()); } @@ -64,8 +60,8 @@ public void testConcreteVisitor() throws IOException { public void testInheritanceTraversal() throws IOException { SubParser p = new SubParser(); Optional node = p.parse_String("test2 NodeOverride"); - Assertions.assertFalse(p.hasErrors()); - Assertions.assertTrue(node.isPresent()); + assertFalse(p.hasErrors()); + assertTrue(node.isPresent()); // init with plain traverser SubTraverser t1 = SubMill.traverser(); @@ -74,7 +70,7 @@ public void testInheritanceTraversal() throws IOException { // plain traverser should not reach the interface implementation node.get().accept(t1); - Assertions.assertEquals(0, c1.getNum()); + assertEquals(0, c1.getNum()); // init with inheritance traverser @@ -84,7 +80,7 @@ public void testInheritanceTraversal() throws IOException { // inheritance traverser should reach the interface implementation precisely once node.get().accept(t2); - Assertions.assertEquals(1, c2.getNum()); + assertEquals(1, c2.getNum()); } diff --git a/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/InheritanceVisitorTest.java b/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/InheritanceVisitorTest.java index 3bc0c72aee..e733ffaaca 100644 --- a/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/InheritanceVisitorTest.java +++ b/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/InheritanceVisitorTest.java @@ -16,10 +16,9 @@ import mc.feature.visitors.c._visitor.CInheritanceHandler; import mc.feature.visitors.c._visitor.CTraverser; import mc.feature.visitors.c._visitor.CVisitor2; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class InheritanceVisitorTest { @@ -39,21 +38,21 @@ public void testInheritanceHandler() { ICScope scope = CMill.scope(); scope.accept(traverser); - Assertions.assertEquals("ASBSCS", sb.toString()); + assertEquals("ASBSCS", sb.toString()); sb = new StringBuilder(); ICGlobalScope globalScope = CMill.globalScope(); globalScope.accept(traverser); - Assertions.assertEquals("AGSASBGSBSCSCGS", sb.toString()); + assertEquals("AGSASBGSBSCSCGS", sb.toString()); sb = new StringBuilder(); ICArtifactScope artifactScope = CMill.artifactScope(); artifactScope.accept(traverser); - Assertions.assertEquals("AASASBASBSCSCAS", sb.toString()); + assertEquals("AASASBASBSCSCAS", sb.toString()); } diff --git a/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/VisitorTest.java b/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/VisitorTest.java index f20220b373..d39e053fb7 100644 --- a/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/VisitorTest.java +++ b/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/VisitorTest.java @@ -2,14 +2,10 @@ package mc.feature.visitor.inheritance; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import de.se_rwth.commons.logging.LogStub; import mc.feature.visitor.inheritance.a.AMill; import mc.feature.visitor.inheritance.b.BMill; import mc.feature.visitor.inheritance.c.CMill; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; @@ -17,6 +13,9 @@ import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Tests that for grammar C extends B extends A the CVisitor also visits rules * from B and A. Furthermore, we test that rules extending rules from a super @@ -40,14 +39,14 @@ public void testSimple() { traverser.add4C(v); traverser.handle(AMill.xABuilder().build()); - Assertions.assertEquals("A", v.getRun()); + assertEquals("A", v.getRun()); v.clear(); traverser.handle(BMill.xBBuilder().build()); - Assertions.assertEquals("B", v.getRun()); + assertEquals("B", v.getRun()); v.clear(); traverser.handle(CMill.xCBuilder().build()); - Assertions.assertEquals("C", v.getRun()); + assertEquals("C", v.getRun()); v.clear(); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/delegator/ComposeSimpleTest.java b/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/delegator/ComposeSimpleTest.java index 34881a54e5..1226f47e44 100644 --- a/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/delegator/ComposeSimpleTest.java +++ b/monticore-test/it/src/test/java/mc/feature/visitor/inheritance/delegator/ComposeSimpleTest.java @@ -2,11 +2,7 @@ package mc.feature.visitor.inheritance.delegator; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -26,6 +22,9 @@ import mc.feature.visitor.inheritance.c._visitor.CVisitor2; import de.se_rwth.commons.logging.Log; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Tests composing simple visiors using the traverser visitor. The * SimpleXVisitors append "[NameOfVisitor].[h|t|v|e][ASTNode]" when a method of @@ -70,22 +69,22 @@ public void setUp() { @Test public void testSimpleComposed() { traverser.handle(AMill.xABuilder().build()); - Assertions.assertEquals("SimpleAVisitor.hXASimpleAVisitor.vXASimpleAVisitor.tXASimpleAVisitor.eXA", run.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("SimpleAVisitor.hXASimpleAVisitor.vXASimpleAVisitor.tXASimpleAVisitor.eXA", run.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSimpleComposed2() { traverser.handle(BMill.xBBuilder().build()); - Assertions.assertEquals("SimpleBVisitor.hXBSimpleBVisitor.vXBSimpleBVisitor.tXBSimpleBVisitor.eXB", run.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("SimpleBVisitor.hXBSimpleBVisitor.vXBSimpleBVisitor.tXBSimpleBVisitor.eXB", run.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test public void testSimpleComposed3() { traverser.handle(mc.feature.visitor.inheritance.c.CMill.xCBuilder().build()); - Assertions.assertEquals("SimpleCVisitor.hXCSimpleCVisitor.vXCSimpleCVisitor.tXCSimpleCVisitor.eXC", run.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals("SimpleCVisitor.hXCSimpleCVisitor.vXCSimpleCVisitor.tXCSimpleCVisitor.eXC", run.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -101,8 +100,8 @@ public void testSimpleComposed4() { expectedRun.append("SimpleBVisitor.hYBSimpleBVisitor.vYBSimpleBVisitor.tYBSimpleBVisitor.eYB"); // rest of yc expectedRun.append("SimpleCVisitor.eYC"); - Assertions.assertEquals(expectedRun.toString(), run.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(expectedRun.toString(), run.toString()); + assertTrue(Log.getFindings().isEmpty()); } @Test @@ -123,8 +122,8 @@ public void testSimpleComposed5() { expectedRun.append("SimpleBVisitor.hYBSimpleBVisitor.vYBSimpleBVisitor.tYBSimpleBVisitor.eYB"); // rest of zb expectedRun.append("SimpleBVisitor.eZB"); - Assertions.assertEquals(expectedRun.toString(), run.toString()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertEquals(expectedRun.toString(), run.toString()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/feature/wiki/WikiTest.java b/monticore-test/it/src/test/java/mc/feature/wiki/WikiTest.java index 716c875d36..ba03429f1a 100644 --- a/monticore-test/it/src/test/java/mc/feature/wiki/WikiTest.java +++ b/monticore-test/it/src/test/java/mc/feature/wiki/WikiTest.java @@ -2,14 +2,10 @@ package mc.feature.wiki; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.io.StringReader; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import mc.GeneratorIntegrationsTest; @@ -17,6 +13,8 @@ import de.se_rwth.commons.logging.Log; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + public class WikiTest extends GeneratorIntegrationsTest { @BeforeEach @@ -31,9 +29,9 @@ public void test() throws IOException { WikiParser p = new WikiParser(); p.parseWikiArtikel(new StringReader("==Test==\n==Test== ==\n== test ==\n")); - Assertions.assertEquals(false, p.hasErrors()); + assertFalse(p.hasErrors()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/grammar/MCParserTest.java b/monticore-test/it/src/test/java/mc/grammar/MCParserTest.java index 0d99b6edcb..0d6ff6cc6f 100644 --- a/monticore-test/it/src/test/java/mc/grammar/MCParserTest.java +++ b/monticore-test/it/src/test/java/mc/grammar/MCParserTest.java @@ -2,13 +2,10 @@ package mc.grammar; -import static org.junit.Assert.assertTrue; - import java.io.IOException; import java.util.Optional; import de.se_rwth.commons.logging.LogStub; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -17,6 +14,8 @@ import mc.grammar.ittestgrammar_withconcepts._parser.ItTestGrammar_WithConceptsParser; import de.se_rwth.commons.logging.Log; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class MCParserTest extends GeneratorIntegrationsTest { @BeforeEach @@ -32,9 +31,9 @@ public void test1() throws IOException { Optional ast = parser.parseMCGrammar("src/test/resources/mc/grammar/SimpleGrammarWithConcept.mc4"); - Assertions.assertTrue(ast.isPresent()); + assertTrue(ast.isPresent()); - Assertions.assertTrue(Log.getFindings().isEmpty()); + assertTrue(Log.getFindings().isEmpty()); } } diff --git a/monticore-test/it/src/test/java/mc/tfcs/ast/TestVisitor.java b/monticore-test/it/src/test/java/mc/tfcs/ast/TestVisitor.java index d7af885fa8..9b37225fad 100644 --- a/monticore-test/it/src/test/java/mc/tfcs/ast/TestVisitor.java +++ b/monticore-test/it/src/test/java/mc/tfcs/ast/TestVisitor.java @@ -4,12 +4,13 @@ import mc.feature.featuredsl._ast.ASTState; import mc.feature.featuredsl._visitor.FeatureDSLVisitor2; -import org.junit.Assert; + +import static org.junit.jupiter.api.Assertions.fail; public class TestVisitor implements FeatureDSLVisitor2 { public void visit(ASTState a) { - Assert.fail("Should be ignored by overriding the traverse method of automaton"); + fail("Should be ignored by overriding the traverse method of automaton"); } } diff --git a/monticore-test/it/src/test_emf/java/mc/emf/east/GeneratedAstClassesTest.java b/monticore-test/it/src/test_emf/java/mc/emf/east/GeneratedAstClassesTest.java index 7d4bacce9c..e8a15b1181 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/east/GeneratedAstClassesTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/east/GeneratedAstClassesTest.java @@ -5,22 +5,18 @@ import mc.GeneratorIntegrationsTest; import mc.feature.hwc.statechartdsl._ast.ASTState; import mc.feature.hwc.statechartdsl.StatechartDSLMill; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class GeneratedAstClassesTest extends GeneratorIntegrationsTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void testErrorsIfNullByAstNodes() { ASTState b = StatechartDSLMill.stateBuilder().uncheckedBuild(); - thrown.expect(NullPointerException.class); // Preconditions.checkNotNull is not generated // NullPointerException is thrown - b.setTransitionsList(null); + assertThrows(NullPointerException.class, () -> b.setTransitionsList(null)); } } diff --git a/monticore-test/it/src/test_emf/java/mc/emf/emethods/EGeterSeterTest.java b/monticore-test/it/src/test_emf/java/mc/emf/emethods/EGeterSeterTest.java index 00427c7749..d30242fb17 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/emethods/EGeterSeterTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/emethods/EGeterSeterTest.java @@ -8,12 +8,12 @@ import mc.feature.fautomaton.action.expression._ast.ExpressionPackage; import mc.feature.fautomaton.automaton.flatautomaton._ast.*; import mc.feature.fautomaton.automaton.flatautomaton.*; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class EGeterSeterTest extends GeneratorIntegrationsTest { @@ -21,7 +21,7 @@ public class EGeterSeterTest extends GeneratorIntegrationsTest { private ASTTransition transition; private ASTAssignment assign; - @Before + @BeforeEach public void setUp() { aut = FlatAutomatonMill.automatonBuilder().uncheckedBuild(); aut.setName("aut1"); diff --git a/monticore-test/it/src/test_emf/java/mc/emf/emethods/FeatureIDConversionTest.java b/monticore-test/it/src/test_emf/java/mc/emf/emethods/FeatureIDConversionTest.java index cd99eb88fa..fc573710d9 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/emethods/FeatureIDConversionTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/emethods/FeatureIDConversionTest.java @@ -2,23 +2,23 @@ package mc.emf.emethods; -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - import mc.GeneratorIntegrationsTest; import mc.feature.fautomaton.action.expression._ast.ASTComplexAssigment; import mc.feature.fautomaton.action.expression._ast.ASTValue; import mc.feature.fautomaton.action.expression.ExpressionMill; import mc.feature.fautomaton.action.expression._ast.ExpressionPackage; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +@Disabled public class FeatureIDConversionTest extends GeneratorIntegrationsTest { ASTComplexAssigment ast; - @Before + @BeforeEach public void setUp() throws Exception { ast = ExpressionMill.complexAssigmentBuilder().uncheckedBuild(); } @@ -30,6 +30,7 @@ public void testDerivedFeatureID() { assertEquals(expectedDerivedID, derivedID); } + @Test public void testBaseFeatureID() { int baseID = ast.eBaseStructuralFeatureID( ExpressionPackage.ASTComplexAssigment_A, ASTValue.class); diff --git a/monticore-test/it/src/test_emf/java/mc/emf/eobjects/CreateEObjectsTest.java b/monticore-test/it/src/test_emf/java/mc/emf/eobjects/CreateEObjectsTest.java index 273fe82b34..5fa030f94f 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/eobjects/CreateEObjectsTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/eobjects/CreateEObjectsTest.java @@ -8,25 +8,24 @@ import mc.feature.fautomaton.automaton.flatautomaton._ast.ASTAutomaton; import mc.feature.fautomaton.automaton.flatautomaton._ast.ASTState; import mc.feature.fautomaton.automaton.flatautomaton._ast.ASTTransition; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class CreateEObjectsTest extends GeneratorIntegrationsTest { @Test public void builderTest() { ASTENode ast = FlatAutomatonMill.automatonBuilder().setName(("A")).build(); assertNotNull(ast); - assertTrue(ast instanceof ASTAutomaton); + assertInstanceOf(ASTAutomaton.class, ast); ast = FlatAutomatonMill.stateBuilder().setName("s").build(); assertNotNull(ast); - assertTrue(ast instanceof ASTState); + assertInstanceOf(ASTState.class, ast); ast = FlatAutomatonMill.transitionBuilder().setActivate("t").setFrom("a").setTo("b").build(); assertNotNull(ast); - assertTrue(ast instanceof ASTTransition); + assertInstanceOf(ASTTransition.class, ast); } } diff --git a/monticore-test/it/src/test_emf/java/mc/emf/epackage/IDTest.java b/monticore-test/it/src/test_emf/java/mc/emf/epackage/IDTest.java index 7c144e4782..b14b98e0b9 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/epackage/IDTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/epackage/IDTest.java @@ -6,9 +6,9 @@ import mc.feature.fautomaton.action.expression._ast.ExpressionPackage; import mc.feature.fautomaton.automaton.flatautomaton._ast.FlatAutomatonPackage; import mc.feature.fautomaton.automaton.flatautomaton._ast.FlatAutomatonPackageImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class IDTest extends GeneratorIntegrationsTest { diff --git a/monticore-test/it/src/test_emf/java/mc/emf/epackage/MetaObjectTest.java b/monticore-test/it/src/test_emf/java/mc/emf/epackage/MetaObjectTest.java index ef6b8c301b..b8a62cf0a6 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/epackage/MetaObjectTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/epackage/MetaObjectTest.java @@ -9,12 +9,10 @@ import mc.feature.fautomaton.automaton.flatautomaton._ast.FlatAutomatonPackage; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.*; -import org.junit.Test; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class MetaObjectTest extends GeneratorIntegrationsTest { @@ -22,7 +20,7 @@ public void setup() { } @Test - @Ignore + @Disabled public void testSuperTypes() { EClass compAssig = ExpressionPackage.eINSTANCE.getASTComplexAssigment(); diff --git a/monticore-test/it/src/test_emf/java/mc/emf/etools/EcoreUtilTest.java b/monticore-test/it/src/test_emf/java/mc/emf/etools/EcoreUtilTest.java index efc6f0b840..e0cce084d0 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/etools/EcoreUtilTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/etools/EcoreUtilTest.java @@ -9,9 +9,6 @@ import org.antlr.v4.runtime.RecognitionException; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.EcoreUtil; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; import de.monticore.emf.util.AST2ModelFiles; import mc.GeneratorIntegrationsTest; @@ -21,10 +18,12 @@ import mc.feature.fautomaton.automaton.flatautomaton.FlatAutomatonMill; import mc.feature.fautomaton.automaton.flatautomaton._ast.FlatAutomatonPackage; import mc.feature.fautomaton.automaton.flatautomaton._parser.FlatAutomatonParser; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; -@Ignore +@Disabled public class EcoreUtilTest extends GeneratorIntegrationsTest { @Test @@ -48,14 +47,14 @@ public void testSerializeAndDeserializeParseInstance() { EObject deserAstTransC = AST2ModelFiles.get().deserializeASTInstance("ASTAutomaton_C", FlatAutomatonPackage.eINSTANCE); assertNotNull(deserAstTransC); - assertTrue(deserAstTransC instanceof ASTAutomaton); + assertInstanceOf(ASTAutomaton.class, deserAstTransC); EObject deserAstTransA = AST2ModelFiles.get().deserializeASTInstance("ASTAutomaton_A", FlatAutomatonPackage.eINSTANCE); assertNotNull(deserAstTransA); - assertTrue(deserAstTransA instanceof ASTAutomaton); + assertInstanceOf(ASTAutomaton.class, deserAstTransA); assertNotEquals(deserAstTransA.toString(),deserAstTransC.toString()); assertFalse(EcoreUtil.equals(deserAstTransA, deserAstTransC)); @@ -94,12 +93,12 @@ public void testSerializeAndDeserializeParseInstance2() { EObject deserAstTransC = AST2ModelFiles.get().deserializeASTInstance("ASTAutomaton_C2", FlatAutomatonPackage.eINSTANCE); assertNotNull(deserAstTransC); - assertTrue(deserAstTransC instanceof ASTAutomaton); + assertInstanceOf(ASTAutomaton.class, deserAstTransC); EObject deserAstTransB = AST2ModelFiles.get().deserializeASTInstance("ASTAutomaton_B2", FlatAutomatonPackage.eINSTANCE); assertNotNull(deserAstTransB); - assertTrue(deserAstTransB instanceof ASTAutomaton); + assertInstanceOf(ASTAutomaton.class, deserAstTransB); assertEquals(deserAstTransB.toString(),deserAstTransC.toString()); diff --git a/monticore-test/it/src/test_emf/java/mc/emf/etools/EmfDiffTest.java b/monticore-test/it/src/test_emf/java/mc/emf/etools/EmfDiffTest.java index c97103be3a..05b6190c72 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/etools/EmfDiffTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/etools/EmfDiffTest.java @@ -7,19 +7,19 @@ import mc.feature.fautomaton.automaton.flatautomaton._parser.FlatAutomatonParser; import org.antlr.v4.runtime.RecognitionException; import org.eclipse.emf.compare.diff.metamodel.DiffElement; -import org.junit.Test; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.List; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class EmfDiffTest extends GeneratorIntegrationsTest { - @Ignore + @Disabled @Test public void testDiffAutomaton() { try { @@ -63,10 +63,7 @@ public void testDiffAutomaton() { fail("Parse errors"); } } - catch (RecognitionException | IOException e) { - fail("Should not reach this, but: " + e); - } - catch (InterruptedException e) { + catch (RecognitionException | IOException | InterruptedException e) { fail("Should not reach this, but: " + e); } } diff --git a/monticore-test/it/src/test_emf/java/mc/emf/generator/ASTNodeTest.java b/monticore-test/it/src/test_emf/java/mc/emf/generator/ASTNodeTest.java index b9807cd2a2..7ea73d5f9c 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/generator/ASTNodeTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/generator/ASTNodeTest.java @@ -6,16 +6,16 @@ import de.monticore.emf.util.AST2ModelFiles; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class ASTNodeTest { - @BeforeClass + @BeforeAll public static void setup() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/it/src/test_emf/java/mc/emf/generator/GrammarDiffsTest.java b/monticore-test/it/src/test_emf/java/mc/emf/generator/GrammarDiffsTest.java index e7ad706076..ce18bcd909 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/generator/GrammarDiffsTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/generator/GrammarDiffsTest.java @@ -9,26 +9,24 @@ import mc.grammar.ittestgrammar_withconcepts._parser.ItTestGrammar_WithConceptsParser; import org.antlr.v4.runtime.RecognitionException; import org.eclipse.emf.compare.diff.metamodel.DiffElement; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.List; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; public class GrammarDiffsTest { - @BeforeClass + @BeforeAll public static void setup() { LogStub.init(); Log.enableFailQuick(false); } - @Ignore // TODO + @Disabled // TODO @Test public void testAstGrammarDiffs() throws IOException { try { @@ -59,10 +57,7 @@ public void testAstGrammarDiffs() throws IOException { fail("Parse errors"); } } - catch (RecognitionException | IOException e) { - fail("Should not reach this, but: " + e); - } - catch (InterruptedException e) { + catch (RecognitionException | IOException | InterruptedException e) { fail("Should not reach this, but: " + e); } } diff --git a/monticore-test/it/src/test_emf/java/mc/emf/generator/GrammarSerDeserTest.java b/monticore-test/it/src/test_emf/java/mc/emf/generator/GrammarSerDeserTest.java index ae770102c8..524c549025 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/generator/GrammarSerDeserTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/generator/GrammarSerDeserTest.java @@ -12,28 +12,25 @@ import org.antlr.v4.runtime.RecognitionException; import org.eclipse.emf.compare.diff.metamodel.DiffElement; import org.eclipse.emf.ecore.EObject; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.List; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; public class GrammarSerDeserTest { - @BeforeClass + @BeforeAll public static void setup() { LogStub.init(); Log.enableFailQuick(false); } - @Ignore // TODO + @Disabled // TODO @Test public void testSerializeDesirializeASTMCGrammarInstance() { try { @@ -47,7 +44,7 @@ public void testSerializeDesirializeASTMCGrammarInstance() { EObject deserAutomatonGrammar = AST2ModelFiles.get().deserializeASTInstance("ASTMCGrammar_Automaton", ItTestGrammarPackage.eINSTANCE); assertNotNull(deserAutomatonGrammar); - assertTrue(deserAutomatonGrammar instanceof ASTMCGrammar); + assertInstanceOf(ASTMCGrammar.class, deserAutomatonGrammar); assertTrue(automatonGrammar.get().deepEquals(deserAutomatonGrammar)); assertEquals("Automaton", ((ASTMCGrammar) deserAutomatonGrammar).getName()); @@ -56,10 +53,7 @@ public void testSerializeDesirializeASTMCGrammarInstance() { (ASTMCGrammar) deserAutomatonGrammar); assertTrue(diffs.isEmpty()); } - catch (RecognitionException | IOException e) { - fail("Should not reach this, but: " + e); - } - catch (InterruptedException e) { + catch (RecognitionException | IOException | InterruptedException e) { fail("Should not reach this, but: " + e); } } diff --git a/monticore-test/it/src/test_emf/java/mc/emf/modularity/ExternalTest.java b/monticore-test/it/src/test_emf/java/mc/emf/modularity/ExternalTest.java index ab98b08dd5..02e4747bae 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/modularity/ExternalTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/modularity/ExternalTest.java @@ -10,17 +10,17 @@ import mc.feature.fautomaton.automatonwithaction.actionautomaton.ActionAutomatonMill; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EReference; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ExternalTest extends GeneratorIntegrationsTest { private ASTAutomaton aut; - @Before + @BeforeEach public void setUp() throws Exception { aut = ActionAutomatonMill.automatonBuilder().uncheckedBuild(); } diff --git a/monticore-test/it/src/test_emf/java/mc/emf/serialization/ASTInstanceSerialDeserialTest.java b/monticore-test/it/src/test_emf/java/mc/emf/serialization/ASTInstanceSerialDeserialTest.java index 061a5454e1..03971a86f9 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/serialization/ASTInstanceSerialDeserialTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/serialization/ASTInstanceSerialDeserialTest.java @@ -1,12 +1,6 @@ /* (c) https://github.com/MontiCore/monticore */ package mc.emf.serialization; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.IOException; import java.util.List; import java.util.Optional; @@ -15,8 +9,6 @@ import org.eclipse.emf.compare.diff.metamodel.DiffElement; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.EcoreUtil; -import org.junit.Ignore; -import org.junit.Test; //import de.monticore.emf.fautomaton.automatonwithaction.actionautomaton._ast.ActionAutomatonPackage; import de.monticore.emf.util.AST2ModelFiles; @@ -28,8 +20,12 @@ import mc.feature.fautomaton.automaton.flatautomaton.FlatAutomatonMill; import mc.feature.fautomaton.automaton.flatautomaton._ast.FlatAutomatonPackage; import mc.feature.fautomaton.automaton.flatautomaton._parser.FlatAutomatonParser; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; -@Ignore +@Disabled public class ASTInstanceSerialDeserialTest extends GeneratorIntegrationsTest { @Test @@ -49,7 +45,7 @@ public void testSerializeAndDeserializeParseInstance() { EObject deserAstTransB = AST2ModelFiles.get().deserializeASTInstance("ASTAutomaton_B1", FlatAutomatonPackage.eINSTANCE); assertNotNull(deserAstTransB); - assertTrue(deserAstTransB instanceof ASTAutomaton); + assertInstanceOf(ASTAutomaton.class, deserAstTransB); assertTrue(transB.get().deepEquals(deserAstTransB)); assertFalse(transC.get().deepEquals(deserAstTransB)); assertEquals("Testautomat", ((ASTAutomaton) deserAstTransB).getName()); @@ -63,10 +59,7 @@ public void testSerializeAndDeserializeParseInstance() { } } - catch (RecognitionException | IOException e) { - fail("Should not reach this, but: " + e); - } - catch (InterruptedException e) { + catch (RecognitionException | IOException | InterruptedException e) { fail("Should not reach this, but: " + e); } } @@ -96,7 +89,7 @@ public void testSerializeAndDeserializeCreatedInstance() { EObject deserObject = AST2ModelFiles.get().deserializeASTInstance("ASTAutomaton_Aut1", FlatAutomatonPackage.eINSTANCE); assertNotNull(deserObject); - assertTrue(deserObject instanceof ASTAutomaton); + assertInstanceOf(ASTAutomaton.class, deserObject); ASTAutomaton serializedAut = (ASTAutomaton) deserObject; assertTrue(EcoreUtil.equals(aut, serializedAut)); diff --git a/monticore-test/it/src/test_emf/java/mc/emf/serialization/ASTModelSerialDeserialTest.java b/monticore-test/it/src/test_emf/java/mc/emf/serialization/ASTModelSerialDeserialTest.java index c5b6482e24..1010d60148 100644 --- a/monticore-test/it/src/test_emf/java/mc/emf/serialization/ASTModelSerialDeserialTest.java +++ b/monticore-test/it/src/test_emf/java/mc/emf/serialization/ASTModelSerialDeserialTest.java @@ -15,14 +15,18 @@ import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; +@Disabled public class ASTModelSerialDeserialTest extends GeneratorIntegrationsTest { + @Test public void testECoreFileOFSuperGrammar() { ASTAutomaton aut = FlatAutomatonMill.automatonBuilder().uncheckedBuild(); @@ -53,6 +57,7 @@ public void testECoreFileOFSuperGrammar() { } } + @Test public void testECoreFileOFGrammar() { ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( @@ -76,6 +81,7 @@ public void testECoreFileOFGrammar() { serializedTransitionWithAction.getEAllStructuralFeatures().get(ActionAutomatonPackage.ASTCounter_Names).getName()); } + @Test public void testECoreFileOFASTENode() { ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put( diff --git a/monticore-test/monticore-grammar-it/build.gradle b/monticore-test/monticore-grammar-it/build.gradle index 64c41b9269..90931b8677 100644 --- a/monticore-test/monticore-grammar-it/build.gradle +++ b/monticore-test/monticore-grammar-it/build.gradle @@ -17,8 +17,8 @@ dependencies { implementation project(':monticore-grammar') implementation "de.se_rwth.commons:se-commons-utilities:$se_commons_version" testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" - testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" grammar (project(path: ':monticore-grammar')){ capabilities { requireCapability("de.monticore:monticore-grammar-grammars") @@ -26,6 +26,10 @@ dependencies { } } +test { + useJUnitPlatform() +} + buildDir = file("$projectDir/target") // The grammars of this subproject are built by the generateMCGrammars MCGenTask diff --git a/monticore-test/monticore-grammar-it/src/test/java/mc/typechecktest/CoCoTests.java b/monticore-test/monticore-grammar-it/src/test/java/mc/typechecktest/CoCoTests.java index 265508c461..61d641044f 100644 --- a/monticore-test/monticore-grammar-it/src/test/java/mc/typechecktest/CoCoTests.java +++ b/monticore-test/monticore-grammar-it/src/test/java/mc/typechecktest/CoCoTests.java @@ -13,7 +13,6 @@ import mc.typechecktest._cocos.VariableDeclarationIsCorrect; import mc.typechecktest._parser.TypeCheckTestParser; import mc.typechecktest._symboltable.TypeCheckTestPhasedSTC; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -22,8 +21,8 @@ import java.nio.file.Paths; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CoCoTests { @@ -61,28 +60,28 @@ public void setup() throws IOException { TypeCheckTestParser parser = TypeCheckTestMill.parser(); Optional bar = parser .parse("src/test/resources/mc/typescalculator/valid/Bar.tc"); - Assertions.assertTrue(bar.isPresent()); + assertTrue(bar.isPresent()); TypeCheckTestPhasedSTC stc = new TypeCheckTestPhasedSTC(); stc.createFromAST(bar.get()); this.bar = bar.get(); Optional inheritanceBar = parser .parse("src/test/resources/mc/typescalculator/valid/InheritanceBar.tc"); - Assertions.assertTrue(inheritanceBar.isPresent()); + assertTrue(inheritanceBar.isPresent()); stc = new TypeCheckTestPhasedSTC(); stc.createFromAST(inheritanceBar.get()); this.inheritanceBar = inheritanceBar.get(); Optional staticAbstractOOMethods = parser .parse("src/test/resources/mc/typescalculator/inbetween/StaticAbstractOOMethods.tc"); - Assertions.assertTrue(staticAbstractOOMethods.isPresent()); + assertTrue(staticAbstractOOMethods.isPresent()); stc = new TypeCheckTestPhasedSTC(); stc.createFromAST(staticAbstractOOMethods.get()); this.staticAbstractOOMethods = staticAbstractOOMethods.get(); Optional staticAbstractOOFields = parser .parse("src/test/resources/mc/typescalculator/inbetween/StaticAbstractOOFields.tc"); - Assertions.assertTrue(staticAbstractOOFields.isPresent()); + assertTrue(staticAbstractOOFields.isPresent()); stc = new TypeCheckTestPhasedSTC(); stc.createFromAST(staticAbstractOOFields.get()); this.staticAbstractOOFields = staticAbstractOOFields.get(); @@ -90,35 +89,35 @@ public void setup() throws IOException { Optional check = parser .parse("src/test/resources/mc/typescalculator/valid/Check.tc"); - Assertions.assertTrue(check.isPresent()); + assertTrue(check.isPresent()); this.check = check.get(); stc = new TypeCheckTestPhasedSTC(); stc.createFromAST(check.get()); Optional wrongAssignment = parser .parse("src/test/resources/mc/typescalculator/invalid/WrongAssignment.tc"); - Assertions.assertTrue(wrongAssignment.isPresent()); + assertTrue(wrongAssignment.isPresent()); this.wrongAssignment = wrongAssignment.get(); stc = new TypeCheckTestPhasedSTC(); stc.createFromAST(wrongAssignment.get()); Optional complicatedWrongAssignment = parser .parse("src/test/resources/mc/typescalculator/invalid/ComplicatedWrongAssignment.tc"); - Assertions.assertTrue(complicatedWrongAssignment.isPresent()); + assertTrue(complicatedWrongAssignment.isPresent()); this.complicatedWrongAssignment = complicatedWrongAssignment.get(); stc = new TypeCheckTestPhasedSTC(); stc.createFromAST(complicatedWrongAssignment.get()); Optional complicatedCorrectAssignment = parser .parse("src/test/resources/mc/typescalculator/valid/ComplicatedCorrectAssignment.tc"); - Assertions.assertTrue(complicatedCorrectAssignment.isPresent()); + assertTrue(complicatedCorrectAssignment.isPresent()); this.complicatedCorrectAssignment = complicatedCorrectAssignment.get(); stc = new TypeCheckTestPhasedSTC(); stc.createFromAST(complicatedCorrectAssignment.get()); Optional inheritedCannotUseStaticFromSuper = parser .parse("src/test/resources/mc/typescalculator/inbetween/InheritedCannotUseStaticFromSuper.tc"); - Assertions.assertTrue(inheritedCannotUseStaticFromSuper.isPresent()); + assertTrue(inheritedCannotUseStaticFromSuper.isPresent()); this.inheritedCannotUseStaticFromSuper = inheritedCannotUseStaticFromSuper.get(); stc = new TypeCheckTestPhasedSTC(); stc.createFromAST(inheritedCannotUseStaticFromSuper.get()); @@ -186,8 +185,8 @@ protected void testInvalidAbstract(String errorCode, ASTTCCompilationUnit comp){ }catch(Exception e){ //do nothing here, just catch the exception for further testing } - Assertions.assertTrue(Log.getFindingsCount()>=1); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith(errorCode)); + assertTrue(Log.getFindingsCount()>=1); + assertTrue(Log.getFindings().get(0).getMsg().startsWith(errorCode)); } protected void testInvalidOO(String errorCode, ASTTCCompilationUnit comp){ @@ -198,22 +197,22 @@ protected void testInvalidOO(String errorCode, ASTTCCompilationUnit comp){ }catch(Exception e){ //do nothing here, just catch the exception for further testing } - Assertions.assertTrue(Log.getFindingsCount()>=1); - Assertions.assertTrue(Log.getFindings().get(0).getMsg().startsWith(errorCode)); + assertTrue(Log.getFindingsCount()>=1); + assertTrue(Log.getFindings().get(0).getMsg().startsWith(errorCode)); } protected void testValidAbstract(ASTTCCompilationUnit comp){ Log.clearFindings(); TypeCheckTestCoCoChecker checker = getAbstractChecker(); checker.checkAll(comp); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); } protected void testValidOO(ASTTCCompilationUnit comp){ Log.clearFindings(); TypeCheckTestCoCoChecker checker = getOOChecker(); checker.checkAll(comp); - Assertions.assertEquals(0, Log.getFindingsCount()); + assertEquals(0, Log.getFindingsCount()); } protected TypeCheckTestCoCoChecker getOOChecker(){ diff --git a/monticore-test/monticore-grammar-it/src/test/java/mc/typescalculator/CombineExpressionsWithLiteralsTest.java b/monticore-test/monticore-grammar-it/src/test/java/mc/typescalculator/CombineExpressionsWithLiteralsTest.java index 472b465f70..7b15c0d4e1 100644 --- a/monticore-test/monticore-grammar-it/src/test/java/mc/typescalculator/CombineExpressionsWithLiteralsTest.java +++ b/monticore-test/monticore-grammar-it/src/test/java/mc/typescalculator/CombineExpressionsWithLiteralsTest.java @@ -21,7 +21,6 @@ import mc.typescalculator.combineexpressionswithliterals._symboltable.CombineExpressionsWithLiteralsScopesGenitorDelegator; import mc.typescalculator.combineexpressionswithliterals._symboltable.ICombineExpressionsWithLiteralsArtifactScope; import mc.typescalculator.combineexpressionswithliterals._symboltable.ICombineExpressionsWithLiteralsGlobalScope; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -30,8 +29,8 @@ import java.util.Optional; import static de.monticore.types.check.SymTypePrimitive.unbox; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CombineExpressionsWithLiteralsTest { @@ -70,10 +69,10 @@ public void testCD() throws IOException { globalScope1.addAdaptedTypeSymbolResolver(adapter); Optional classD = globalScope1.resolveOOType("mc.typescalculator.TestCD.D"); - Assertions.assertTrue(classD.isPresent()); + assertTrue(classD.isPresent()); Optional classB = globalScope1.resolveOOType("mc.typescalculator.TestCD.B"); - Assertions.assertTrue(classB.isPresent()); + assertTrue(classB.isPresent()); OOTypeSymbol dSurrogate = new OOTypeSymbolSurrogate("D"); dSurrogate.setEnclosingScope(classD.get().getEnclosingScope()); @@ -101,46 +100,46 @@ public void testCD() throws IOException { Optional expr = p.parse_StringExpression("d.s+=d.s"); CombineExpressionsWithLiteralsScopesGenitorDelegator del = new CombineExpressionsWithLiteralsScopesGenitorDelegator(); - Assertions.assertTrue(expr.isPresent()); + assertTrue(expr.isPresent()); ICombineExpressionsWithLiteralsArtifactScope art = del.createFromAST(expr.get()); art.setName(""); art.setImportsList(Lists.newArrayList(new ImportStatement("mc.typescalculator.TestCD.D", true))); TypeCheckResult j = calc.deriveType(expr.get()); - Assertions.assertTrue(j.isPresentResult()); - Assertions.assertEquals("int", unbox(j.getResult().print())); + assertTrue(j.isPresentResult()); + assertEquals("int", unbox(j.getResult().print())); Optional exprC = p.parse_StringExpression("d.f = mc.typescalculator.TestCD.C.f"); - Assertions.assertTrue(exprC.isPresent()); + assertTrue(exprC.isPresent()); ICombineExpressionsWithLiteralsArtifactScope artifactScope = del.createFromAST(exprC.get()); artifactScope.setName(""); j = calc.deriveType(exprC.get()); - Assertions.assertTrue(j.isPresentResult()); - Assertions.assertEquals("G", j.getResult().print()); + assertTrue(j.isPresentResult()); + assertEquals("G", j.getResult().print()); Optional exprD = p.parse_StringExpression("(b.a)++"); - Assertions.assertTrue(exprD.isPresent()); + assertTrue(exprD.isPresent()); artifactScope = del.createFromAST(exprD.get()); artifactScope.setName(""); TypeCheckResult j3 = calc.deriveType(exprD.get()); - Assertions.assertTrue(j3.isPresentResult()); - Assertions.assertEquals("double", j3.getResult().print()); + assertTrue(j3.isPresentResult()); + assertEquals("double", j3.getResult().print()); Optional exprB = p.parse_StringExpression("b.x = mc.typescalculator.TestCD.B.z"); - Assertions.assertTrue(exprB.isPresent()); + assertTrue(exprB.isPresent()); artifactScope = del.createFromAST(exprB.get()); artifactScope.setName(""); ASTExpression eb = exprB.get(); TypeCheckResult k = calc.deriveType(eb); - Assertions.assertTrue(k.isPresentResult()); - Assertions.assertEquals("C", k.getResult().print()); + assertTrue(k.isPresentResult()); + assertEquals("C", k.getResult().print()); Optional complicated = p.parse_StringExpression("b.z.f.toString()"); - Assertions.assertTrue(complicated.isPresent()); + assertTrue(complicated.isPresent()); artifactScope = del.createFromAST(complicated.get()); artifactScope.setName(""); TypeCheckResult sym = calc.deriveType(complicated.get()); - Assertions.assertTrue(sym.isPresentResult()); - Assertions.assertEquals("String", sym.getResult().print()); + assertTrue(sym.isPresentResult()); + assertEquals("String", sym.getResult().print()); } } diff --git a/monticore-test/monticore-grammar-it/src/test/java/mc/typescalculator/SynthesizeSymTypeFromMyOwnLanguageTest.java b/monticore-test/monticore-grammar-it/src/test/java/mc/typescalculator/SynthesizeSymTypeFromMyOwnLanguageTest.java index 117fb84daa..f5be513219 100644 --- a/monticore-test/monticore-grammar-it/src/test/java/mc/typescalculator/SynthesizeSymTypeFromMyOwnLanguageTest.java +++ b/monticore-test/monticore-grammar-it/src/test/java/mc/typescalculator/SynthesizeSymTypeFromMyOwnLanguageTest.java @@ -14,7 +14,6 @@ import mc.typescalculator.myownlanguage._parser.MyOwnLanguageParser; import mc.typescalculator.myownlanguage._symboltable.IMyOwnLanguageGlobalScope; import mc.typescalculator.unittypes._ast.ASTMinuteType; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -22,8 +21,8 @@ import java.util.Arrays; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SynthesizeSymTypeFromMyOwnLanguageTest { @@ -79,19 +78,19 @@ protected static TypeVarSymbol buildTypeParam(String typeParamName) { @Test public void testMCCollectionTypes() throws IOException { Optional type = parser.parse_StringMCType("List"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); type.get().setEnclosingScope(MyOwnLanguageMill.globalScope()); ((ASTMCListType)(type.get())).getMCTypeArgument().getMCTypeOpt().get().setEnclosingScope(MyOwnLanguageMill.globalScope()); - Assertions.assertEquals("List", tc.symTypeFromAST(type.get()).printFullName()); + assertEquals("List", tc.symTypeFromAST(type.get()).printFullName()); } @Test public void testUnitTypes() throws IOException { Optional type = parser.parse_StringMinuteType("min"); - Assertions.assertTrue(type.isPresent()); + assertTrue(type.isPresent()); // pretend to use the scope genitor type.get().setEnclosingScope(MyOwnLanguageMill.globalScope()); - Assertions.assertEquals("min", tc.symTypeFromAST(type.get()).print()); + assertEquals("min", tc.symTypeFromAST(type.get()).print()); } diff --git a/monticore-test/montitrans/build.gradle b/monticore-test/montitrans/build.gradle index 05df53cc57..6cff8c4881 100644 --- a/monticore-test/montitrans/build.gradle +++ b/monticore-test/montitrans/build.gradle @@ -32,8 +32,8 @@ subprojects { testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" - testImplementation "org.junit.vintage:junit-vintage-engine:$junit_version" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version" + testRuntimeOnly "org.junit.platform:junit-platform-launcher:$junit_platform_version" } java { @@ -41,6 +41,10 @@ subprojects { languageVersion = JavaLanguageVersion.of(11) } } + + test { + useJUnitPlatform() + } } jar.enabled = false diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_cocos/NoOptOnRHSCoCoTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_cocos/NoOptOnRHSCoCoTest.java index fd6de0be79..790d032159 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_cocos/NoOptOnRHSCoCoTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_cocos/NoOptOnRHSCoCoTest.java @@ -7,27 +7,26 @@ import mc.testcases.automaton.tr.automatontr._cocos.AutomatonTRCoCoChecker; import mc.testcases.automaton.tr.automatontr._cocos.NoOptOnRHSCoCo; import mc.testcases.automaton.tr.automatontr._parser.AutomatonTRParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * Created by DW */ public class NoOptOnRHSCoCoTest { - @Before + @BeforeEach public void disableFailQuick() { LogStub.init(); Log.enableFailQuick(false); } - @Before + @BeforeEach public void setUp() { Log.getFindings().clear(); } diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_cocos/NoOptWithinNotCoCoTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_cocos/NoOptWithinNotCoCoTest.java index 978b8cabe6..2f6f78f79a 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_cocos/NoOptWithinNotCoCoTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_cocos/NoOptWithinNotCoCoTest.java @@ -7,28 +7,26 @@ import mc.testcases.automaton.tr.automatontr._cocos.AutomatonTRCoCoChecker; import mc.testcases.automaton.tr.automatontr._cocos.NoOptWithinNotCoCo; import mc.testcases.automaton.tr.automatontr._ast.*; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * Created by DW */ public class NoOptWithinNotCoCoTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); } - @Before + @BeforeEach public void setUp() { Log.getFindings().clear(); } diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleParserTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleParserTest.java index bdaefe09ad..6d0c83fe88 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleParserTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleParserTest.java @@ -6,19 +6,18 @@ import mc.testcases.automaton.tr.automatontr.AutomatonTRMill; import mc.testcases.automaton.tr.automatontr._ast.*; import mc.testcases.automaton.tr.automatontr._parser.AutomatonTRParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class AutomatonTransformationRuleParserTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -64,7 +63,8 @@ public void testForwardToInitialRule() throws IOException { assertTrue(Log.getFindings().isEmpty()); } - @Test @Ignore + @Test + @Disabled public void testIsIdentifierFix() throws IOException { String inputFile = "src/test/resources/IsIdentifierFix.mtr"; AutomatonTRParser parser = new AutomatonTRParser(); diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleState_PatternMCConcreteParserTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleState_PatternMCConcreteParserTest.java index a9205d2a7f..e4028a3f5d 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleState_PatternMCConcreteParserTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleState_PatternMCConcreteParserTest.java @@ -4,21 +4,19 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton.tr.automatontr._ast.ASTState_Pat; import mc.testcases.automaton.tr.automatontr._parser.AutomatonTRParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import de.se_rwth.commons.logging.Log; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AutomatonTransformationRuleState_PatternMCConcreteParserTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransistion_PatternMCConcreteParserTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransistion_PatternMCConcreteParserTest.java index 7a8b761d56..99756c3191 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransistion_PatternMCConcreteParserTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransistion_PatternMCConcreteParserTest.java @@ -4,19 +4,19 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton.tr.automatontr._ast.ASTTransition_Pat; import mc.testcases.automaton.tr.automatontr._parser.AutomatonTRParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; import de.se_rwth.commons.logging.Log; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AutomatonTransformationRuleTransistion_PatternMCConcreteParserTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransitionMCConcreteParserTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransitionMCConcreteParserTest.java index 060d87c82c..5c61556f17 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransitionMCConcreteParserTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransitionMCConcreteParserTest.java @@ -3,18 +3,18 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton.tr.automatontr._parser.AutomatonTRParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; import java.io.IOException; -import static org.junit.Assert.*; import de.se_rwth.commons.logging.Log; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AutomatonTransformationRuleTransitionMCConcreteParserTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransition_ReplacementMCConcreteParserTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransition_ReplacementMCConcreteParserTest.java index c797a84142..2d9ae8db2f 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransition_ReplacementMCConcreteParserTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/_parser/AutomatonTransformationRuleTransition_ReplacementMCConcreteParserTest.java @@ -5,16 +5,16 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton.tr.automatontr._parser.AutomatonTRParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; import de.se_rwth.commons.logging.Log; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; public class AutomatonTransformationRuleTransition_ReplacementMCConcreteParserTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/translation/AutomatonRule2ODToolTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/translation/AutomatonRule2ODToolTest.java index c3e2e8f928..b52a7c446d 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/translation/AutomatonRule2ODToolTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/automaton/transformation/rule/translation/AutomatonRule2ODToolTest.java @@ -1,11 +1,11 @@ /* (c) https://github.com/MontiCore/monticore */ package mc.testcases.automaton.transformation.rule.translation; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; public class AutomatonRule2ODToolTest { - @Before + @BeforeEach public void setUp() { } diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/expressiondsl/ExpressionDSLTRParseTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/expressiondsl/ExpressionDSLTRParseTest.java index 8753b4ccd4..147a95e330 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/expressiondsl/ExpressionDSLTRParseTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/expressiondsl/ExpressionDSLTRParseTest.java @@ -10,19 +10,19 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.tr.expressiondsltr.ExpressionDSLTRMill; import mc.testcases.tr.expressiondsltr._parser.ExpressionDSLTRParser; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; +import static org.junit.jupiter.api.Assertions.*; + /** * Test for literal support in left recursive grammars (aka expressions) */ public class ExpressionDSLTRParseTest { - @Before + @BeforeEach public void beforeEach() { LogStub.init(); Log.enableFailQuick(false); @@ -58,23 +58,23 @@ public void testTypes() throws IOException { @Test public void testAssigns() throws IOException { ASTAssign ast = test("$exp1 = $exp2 ;", ExpressionDSLTRParser::parse_StringAssign); - Assert.assertEquals(ASTNameExpression.class.getName(), ast.getValue().getClass().getName()); + assertEquals(ASTNameExpression.class.getName(), ast.getValue().getClass().getName()); ast = test("$exp1 = \"string\" ;", ExpressionDSLTRParser::parse_StringAssign); - Assert.assertEquals(ASTLiteralExpression.class.getName(), ast.getValue().getClass().getName()); - Assert.assertEquals(ASTStringLiteral.class.getName(), ((ASTLiteralExpression)ast.getValue()).getLiteral().getClass().getName()); - Assert.assertEquals("string", ((ASTStringLiteral)((ASTLiteralExpression)ast.getValue()).getLiteral()).getValue()); + assertEquals(ASTLiteralExpression.class.getName(), ast.getValue().getClass().getName()); + assertEquals(ASTStringLiteral.class.getName(), ((ASTLiteralExpression)ast.getValue()).getLiteral().getClass().getName()); + assertEquals("string", ((ASTStringLiteral)((ASTLiteralExpression)ast.getValue()).getLiteral()).getValue()); ast = test("$exp1 = $exp1 + \"string\" ;", ExpressionDSLTRParser::parse_StringAssign); - Assert.assertEquals(ASTPlusExpression.class.getName(), ast.getValue().getClass().getName()); - Assert.assertEquals(ASTNameExpression.class.getName(), ((ASTPlusExpression)ast.getValue()).getLeft().getClass().getName()); - Assert.assertEquals(ASTLiteralExpression.class.getName(), ((ASTPlusExpression)ast.getValue()).getRight().getClass().getName()); - Assert.assertEquals("string", ((ASTStringLiteral)((ASTLiteralExpression)((ASTPlusExpression)ast.getValue()).getRight()).getLiteral()).getValue()); + assertEquals(ASTPlusExpression.class.getName(), ast.getValue().getClass().getName()); + assertEquals(ASTNameExpression.class.getName(), ((ASTPlusExpression)ast.getValue()).getLeft().getClass().getName()); + assertEquals(ASTLiteralExpression.class.getName(), ((ASTPlusExpression)ast.getValue()).getRight().getClass().getName()); + assertEquals("string", ((ASTStringLiteral)((ASTLiteralExpression)((ASTPlusExpression)ast.getValue()).getRight()).getLiteral()).getValue()); } protected
A test(String exp, ParserFunction parserFunction) throws IOException { ExpressionDSLTRParser parser = ExpressionDSLTRMill.parser(); Optional typeOptional = parserFunction.parse(parser, exp); - Assert.assertFalse("Parser error while parsing: " + exp, parser.hasErrors()); - Assert.assertTrue("Failed to parse: " + exp, typeOptional.isPresent()); + assertFalse(parser.hasErrors(), "Parser error while parsing: " + exp); + assertTrue(typeOptional.isPresent(), "Failed to parse: " + exp); return typeOptional.get(); } diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/grammartransformation/TFLanguageOverrideTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/grammartransformation/TFLanguageOverrideTest.java index 7776bfdb9b..09625c5c96 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/grammartransformation/TFLanguageOverrideTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/grammartransformation/TFLanguageOverrideTest.java @@ -6,21 +6,18 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.tr.genericdsltr._ast.ASTNewClassProd; import mc.testcases.tr.genericdsltr._parser.GenericDSLTRParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; - import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TFLanguageOverrideTest { - @Before + @BeforeEach public void disableFailQuick() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/transformation/rule/translation/DSLWithOtherPropertiesThanAutomatonRule2ODVisitorTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/transformation/rule/translation/DSLWithOtherPropertiesThanAutomatonRule2ODVisitorTest.java index ebb6dc88bc..6d45ed656c 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/transformation/rule/translation/DSLWithOtherPropertiesThanAutomatonRule2ODVisitorTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/testcases/transformation/rule/translation/DSLWithOtherPropertiesThanAutomatonRule2ODVisitorTest.java @@ -20,14 +20,13 @@ import de.monticore.tf.odrules._ast.ASTODRule; import de.monticore.tf.rule2od.Variable2AttributeMap; import de.monticore.tf.ruletranslation.Rule2ODState; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class DSLWithOtherPropertiesThanAutomatonRule2ODVisitorTest { private static void createSymboltable(ASTODRule od) { @@ -35,13 +34,13 @@ private static void createSymboltable(ASTODRule od) { symbolTable.createFromAST(od); } - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); } - @BeforeClass + @BeforeAll public static void disableFailQuick() { DSLWithOtherPropertiesThanAutomatonTRMill.init(); } diff --git a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/tfcs/TransformationRuleParserTest.java b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/tfcs/TransformationRuleParserTest.java index 327c94db93..ef1fc3940b 100644 --- a/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/tfcs/TransformationRuleParserTest.java +++ b/monticore-test/montitrans/test-dstl-gen/src/test/java/mc/tfcs/TransformationRuleParserTest.java @@ -2,23 +2,22 @@ package mc.tfcs; import de.se_rwth.commons.logging.LogStub; -import junit.framework.TestCase; import mc.testcases.automaton.tr.automatontr._ast.ASTITFAutomaton; import mc.testcases.automaton.tr.automatontr._ast.ASTAutomatonTFRule; import mc.testcases.automaton.tr.automatontr._parser.AutomatonTRParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertTrue; import de.se_rwth.commons.logging.Log; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class TransformationRuleParserTest extends TestCase { +import static org.junit.jupiter.api.Assertions.*; + +public class TransformationRuleParserTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-generated-dstls/src/test/java/expressiondsl/ExpressionDSLTest.java b/monticore-test/montitrans/test-generated-dstls/src/test/java/expressiondsl/ExpressionDSLTest.java index 29dd7caace..a97ecdf519 100644 --- a/monticore-test/montitrans/test-generated-dstls/src/test/java/expressiondsl/ExpressionDSLTest.java +++ b/monticore-test/montitrans/test-generated-dstls/src/test/java/expressiondsl/ExpressionDSLTest.java @@ -18,22 +18,24 @@ import mc.testcases.expressiondsl._ast.ASTCDAttribute; import mc.testcases.expressiondsl._ast.ASTFoo; import mc.testcases.tr.expressiondsltr.ExpressionDSLTRMill; -import org.junit.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; import java.util.function.Function; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class ExpressionDSLTest { - @Before + @BeforeEach public void beforeEach() { Log.clearFindings(); } - @BeforeClass + @BeforeAll public static void beforeClass() { LogStub.init(); Log.enableFailQuick(false); @@ -117,12 +119,12 @@ public void testChangeSetterCall() throws IOException { @Test public void testExpressionInterfacePatternPriority() throws IOException { Optional astExpressionOpt = ExpressionDSLTRMill.parser().parse_StringExpression_Pat("Expression $name"); - Assert.assertTrue(astExpressionOpt.isPresent()); - Assert.assertEquals(ASTExpression_Pat.class.getName(), astExpressionOpt.get().getClass().getName()); + assertTrue(astExpressionOpt.isPresent()); + assertEquals(ASTExpression_Pat.class.getName(), astExpressionOpt.get().getClass().getName()); Optional astitfExpressionOpt = ExpressionDSLTRMill.parser().parse_StringITFExpression("Expression $name"); - Assert.assertTrue(astitfExpressionOpt.isPresent()); - Assert.assertEquals(ASTExpression_Pat.class.getName(), astitfExpressionOpt.get().getClass().getName()); + assertTrue(astitfExpressionOpt.isPresent()); + assertEquals(ASTExpression_Pat.class.getName(), astitfExpressionOpt.get().getClass().getName()); } @@ -143,10 +145,10 @@ public void testCDAttributeChangeTypeFull() throws IOException { protected void test(String input, Function rule, String expected) throws IOException { Optional fooOpt = ExpressionDSLMill.parser().parse_String(input); - Assert.assertTrue(fooOpt.isPresent()); + assertTrue(fooOpt.isPresent()); ODRule trafo = rule.apply(fooOpt.get()); - assertTrue("Failed to match pattern", trafo.doPatternMatching()); + assertTrue(trafo.doPatternMatching(), "Failed to match pattern"); trafo.doReplacement(); testDeepEqualsFoo(fooOpt.get(), expected); @@ -154,10 +156,10 @@ protected void test(String input, Function rule, String expected protected void testCDAttribute(String input, Function rule, String expected) throws IOException { Optional fooOpt = ExpressionDSLMill.parser().parse_StringCDAttribute(input); - Assert.assertTrue(fooOpt.isPresent()); + assertTrue(fooOpt.isPresent()); ODRule trafo = rule.apply(fooOpt.get()); - assertTrue("Failed to match pattern", trafo.doPatternMatching()); + assertTrue(trafo.doPatternMatching(), "Failed to match pattern"); trafo.doReplacement(); testDeepEqualsCDAttribute(fooOpt.get(), expected); @@ -174,13 +176,13 @@ protected void testDeepEqualsCDAttribute(ASTCDAttribute ast, String expected) th } private void testDeepEquals(ASTNode ast, String expected, Optional fooOpt) { - Assert.assertTrue("Failed to parse expected", fooOpt.isPresent()); + assertTrue(fooOpt.isPresent(), "Failed to parse expected"); if (!fooOpt.get().deepEquals(ast)) { - Assert.assertEquals(ExpressionDSLMill.prettyPrint(fooOpt.get(), false), ExpressionDSLMill.prettyPrint(ast, false)); - Assert.assertEquals(astPrinter(fooOpt.get(), ExpressionDSLMill.inheritanceTraverser()), + assertEquals(ExpressionDSLMill.prettyPrint(fooOpt.get(), false), ExpressionDSLMill.prettyPrint(ast, false)); + assertEquals(astPrinter(fooOpt.get(), ExpressionDSLMill.inheritanceTraverser()), astPrinter(ast, ExpressionDSLMill.inheritanceTraverser())); - Assert.fail("Failed to deep equal: " + ExpressionDSLMill.prettyPrint(fooOpt.get(), false) + ", expected " + expected); + fail("Failed to deep equal: " + ExpressionDSLMill.prettyPrint(fooOpt.get(), false) + ", expected " + expected); } } diff --git a/monticore-test/montitrans/test-generated-dstls/src/test/java/social/DeleteAllEntriesFromUserTest.java b/monticore-test/montitrans/test-generated-dstls/src/test/java/social/DeleteAllEntriesFromUserTest.java index ebea71f706..b3c64c1b73 100644 --- a/monticore-test/montitrans/test-generated-dstls/src/test/java/social/DeleteAllEntriesFromUserTest.java +++ b/monticore-test/montitrans/test-generated-dstls/src/test/java/social/DeleteAllEntriesFromUserTest.java @@ -6,18 +6,18 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.social.socialnetwork._ast.ASTNetwork; import mc.testcases.social.socialnetwork._parser.SocialNetworkParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DeleteAllEntriesFromUserTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test01_ParsePedestrianLightTest.java b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test01_ParsePedestrianLightTest.java index 16708c0b89..84c96faaac 100644 --- a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test01_ParsePedestrianLightTest.java +++ b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test01_ParsePedestrianLightTest.java @@ -2,23 +2,25 @@ package trafo; import de.se_rwth.commons.logging.LogStub; -import junit.framework.TestCase; import mc.testcases.statechart.statechart._ast.ASTStatechart; import mc.testcases.statechart.statechart._parser.StatechartParser; -import org.junit.Before; -import org.junit.BeforeClass; import java.io.IOException; import de.se_rwth.commons.logging.Log; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class Test01_ParsePedestrianLightTest extends TestCase { +import static org.junit.jupiter.api.Assertions.*; + +public class Test01_ParsePedestrianLightTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); } + @Test public void testDoAll() throws IOException { StatechartParser px = new StatechartParser(); ASTStatechart sc =px.parse("src/test/resources/trafo/PedestrianLight.sc").get(); diff --git a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test02_EliminateDoTest.java b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test02_EliminateDoTest.java index 838f14bad6..0170c8c463 100644 --- a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test02_EliminateDoTest.java +++ b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test02_EliminateDoTest.java @@ -3,23 +3,25 @@ import de.monticore.tf.EliminateDo; import de.se_rwth.commons.logging.LogStub; -import junit.framework.TestCase; import mc.testcases.statechart.statechart._ast.*; import mc.testcases.statechart.statechart._parser.StatechartParser; -import org.junit.Before; -import org.junit.BeforeClass; import java.io.IOException; import de.se_rwth.commons.logging.Log; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -public class Test02_EliminateDoTest extends TestCase { +import static org.junit.jupiter.api.Assertions.*; + +public class Test02_EliminateDoTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); } + @Test public void testDoAll() throws IOException { StatechartParser p = new StatechartParser(); @@ -36,20 +38,20 @@ public void testDoAll() throws IOException { assertNotNull(state); ASTEntryAction entryAction = state.getEntryAction(); - assertNotNull("entry action has not been added", entryAction); - assertNotNull("entry action is empty", entryAction.getBlock()); + assertNotNull(entryAction, "entry action has not been added"); + assertNotNull(entryAction.getBlock(), "entry action is empty"); - assertFalse("do action has not been removed", state.isPresentDoAction()); + assertFalse(state.isPresentDoAction(), "do action has not been removed"); ASTExitAction exitAction = state.getExitAction(); - assertNotNull("exit action has not been added", exitAction); - assertNotNull("exit action is empty", exitAction.getBlock()); + assertNotNull(exitAction, "exit action has not been added"); + assertNotNull(exitAction.getBlock(), "exit action is empty"); ASTInternTransition internTransition = state.getInternTransition(0); - assertNotNull("intern transition has not been created", internTransition); + assertNotNull(internTransition, "intern transition has not been created"); ASTBlockStatement internAction = internTransition.getAction(); - assertNotNull("intern transition has no action", internAction); - assertEquals("incorrect number of statements in intern action", 2, internAction.getStatementList().size()); + assertNotNull(internAction, "intern transition has no action"); + assertEquals(2, internAction.getStatementList().size(), "incorrect number of statements in intern action"); testee.undoReplacement(); assertFalse(state.isPresentEntryAction()); diff --git a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test08_InsertStatesTest.java b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test08_InsertStatesTest.java index 256c96d113..2aa524632e 100644 --- a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test08_InsertStatesTest.java +++ b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test08_InsertStatesTest.java @@ -7,18 +7,18 @@ import de.monticore.tf.InsertStateRelative; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import junit.framework.TestCase; import mc.testcases.statechart.statechart._ast.*; import mc.testcases.statechart.statechart._parser.StatechartParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -public class Test08_InsertStatesTest extends TestCase { +import static org.junit.jupiter.api.Assertions.*; + +public class Test08_InsertStatesTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test09_CopyTransitionTest.java b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test09_CopyTransitionTest.java index efc388610b..70ca4da052 100644 --- a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test09_CopyTransitionTest.java +++ b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test09_CopyTransitionTest.java @@ -4,19 +4,19 @@ import de.monticore.tf.CopyTransitionToSubstate; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import junit.framework.TestCase; import mc.testcases.statechart.statechart._ast.ASTState; import mc.testcases.statechart.statechart._ast.ASTStatechart; import mc.testcases.statechart.statechart._parser.StatechartParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -public class Test09_CopyTransitionTest extends TestCase { +import static org.junit.jupiter.api.Assertions.*; + +public class Test09_CopyTransitionTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test10_DeleteTransitionTest.java b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test10_DeleteTransitionTest.java index b4960b4a27..497d072141 100644 --- a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test10_DeleteTransitionTest.java +++ b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test10_DeleteTransitionTest.java @@ -4,19 +4,19 @@ import de.monticore.tf.DeleteTransition; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import junit.framework.TestCase; import mc.testcases.statechart.statechart._ast.ASTState; import mc.testcases.statechart.statechart._ast.ASTStatechart; import mc.testcases.statechart.statechart._parser.StatechartParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -public class Test10_DeleteTransitionTest extends TestCase { +import static org.junit.jupiter.api.Assertions.*; + +public class Test10_DeleteTransitionTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test11_SetInitialTest.java b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test11_SetInitialTest.java index 6a5184145f..0197bcecaa 100644 --- a/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test11_SetInitialTest.java +++ b/monticore-test/montitrans/test-generated-dstls/src/test/java/trafo/Test11_SetInitialTest.java @@ -4,19 +4,19 @@ import de.monticore.tf.SetInitial; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; -import junit.framework.TestCase; import mc.testcases.statechart.statechart._ast.ASTState; import mc.testcases.statechart.statechart._ast.ASTStatechart; import mc.testcases.statechart.statechart._parser.StatechartParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -public class Test11_SetInitialTest extends TestCase { +import static org.junit.jupiter.api.Assertions.*; + +public class Test11_SetInitialTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/AtMostOneStateTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/AtMostOneStateTest.java index 54666a6e4f..aeb8fbab08 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/AtMostOneStateTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/AtMostOneStateTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class AtMostOneStateTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/AtMostOneSubstateTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/AtMostOneSubstateTest.java index 4931705ed5..e1e1ef9461 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/AtMostOneSubstateTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/AtMostOneSubstateTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class AtMostOneSubstateTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ChangeFixNameTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ChangeFixNameTest.java index 2fa254ca44..8d4417e827 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ChangeFixNameTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ChangeFixNameTest.java @@ -7,26 +7,25 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class ChangeFixNameTest { private ASTState state; - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); } - @Before + @BeforeEach public void setUp() throws IOException { String inputFile = "src/main/models/automaton/AutomatonWithSingleState.aut"; AutomatonParser parser = new AutomatonParser(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ChangeMarkerTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ChangeMarkerTest.java index 09a58e929c..52de972785 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ChangeMarkerTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ChangeMarkerTest.java @@ -5,27 +5,26 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.petrinet._ast.ASTPetrinet; import mc.testcases.petrinet._parser.PetrinetParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ChangeMarkerTest { ChangeMarker cm; ASTPetrinet petri; - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); } - @Before + @BeforeEach public void doBefore() throws IOException { String inputFile = "src/main/models/petrinet/TestPetriNet.pn"; PetrinetParser parser = new PetrinetParser(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintAlongOptionalTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintAlongOptionalTest.java index 5698f18714..7bca4ba6c5 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintAlongOptionalTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintAlongOptionalTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class ConstraintAlongOptionalTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintEmbeddingTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintEmbeddingTest.java index e773d0ee55..0ac2926156 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintEmbeddingTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintEmbeddingTest.java @@ -5,19 +5,18 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ConstraintEmbeddingTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintForOptionalTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintForOptionalTest.java index 6c76a647cf..67bcb88bd0 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintForOptionalTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ConstraintForOptionalTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class ConstraintForOptionalTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopySubListDefInListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopySubListDefInListTest.java index 8298bacfc8..50530f61ae 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopySubListDefInListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopySubListDefInListTest.java @@ -6,15 +6,15 @@ import mc.testcases.misc.MiscMill; import mc.testcases.misc._ast.ASTDef; import mc.testcases.misc._ast.ASTSub; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CopySubListDefInListTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -23,7 +23,7 @@ public void before() { ASTDef def, def2, def3, def4; ASTSub sub, sub2; - @Before + @BeforeEach public void setUp() { def = MiscMill.defBuilder().uncheckedBuild(); def2 = MiscMill.defBuilder().uncheckedBuild(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopySubListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopySubListTest.java index faf61f9eec..637da12c47 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopySubListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopySubListTest.java @@ -6,16 +6,15 @@ import mc.testcases.misc.MiscMill; import mc.testcases.misc._ast.ASTDef; import mc.testcases.misc._ast.ASTSub; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CopySubListTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -26,7 +25,7 @@ public void before() { ASTDef def2; ASTSub sub; - @Before + @BeforeEach public void setUp() { rootdef = MiscMill.defBuilder().uncheckedBuild(); def1 = MiscMill.defBuilder().uncheckedBuild(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopyTransitionsTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopyTransitionsTest.java index b53438d16d..d7d83cd393 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopyTransitionsTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CopyTransitionsTest.java @@ -6,19 +6,18 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CopyTransitionsTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CreateInOptionalTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CreateInOptionalTest.java index ebeff1f6fa..022f04d5cb 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CreateInOptionalTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CreateInOptionalTest.java @@ -5,21 +5,19 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class CreateInOptionalTest { private ASTAutomaton automaton; - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CreateStateTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CreateStateTest.java index 1000b6876f..0c233ecdc2 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CreateStateTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/CreateStateTest.java @@ -5,25 +5,24 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class CreateStateTest { ASTAutomaton aut; - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); } - @Before + @BeforeEach public void setUp() throws IOException { String inputFile = "src/main/models/automaton/EmptyAutomaton.aut"; AutomatonParser parser = new AutomatonParser(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteOptionalStateTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteOptionalStateTest.java index 5d980ba793..b6c0af6ff7 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteOptionalStateTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteOptionalStateTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class DeleteOptionalStateTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteStateListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteStateListTest.java index c1c3feb0a5..67a5fa6aad 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteStateListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteStateListTest.java @@ -7,28 +7,26 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DeleteStateListTest { ASTAutomaton aut; - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); } - @Before + @BeforeEach public void setUp() throws IOException { String inputFile = "src/main/models/automaton/AutomatonTwoStatesAndSubstate.aut"; AutomatonParser parser = new AutomatonParser(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteStateTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteStateTest.java index 753b90aada..35a0c6af52 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteStateTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteStateTest.java @@ -5,27 +5,25 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DeleteStateTest { ASTAutomaton aut; - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); } - @Before + @BeforeEach public void setUp() throws IOException { String inputFile = "src/main/models/automaton/AutomatonWithSingleState.aut"; AutomatonParser parser = new AutomatonParser(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteSubListDefInListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteSubListDefInListTest.java index 71b7d88a09..3a2b8ef9dc 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteSubListDefInListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteSubListDefInListTest.java @@ -6,15 +6,15 @@ import mc.testcases.misc.MiscMill; import mc.testcases.misc._ast.ASTDef; import mc.testcases.misc._ast.ASTSub; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DeleteSubListDefInListTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -25,7 +25,7 @@ public void before() { ASTSub sub; ASTSub sub2; - @Before + @BeforeEach public void setUp() { def = MiscMill.defBuilder().uncheckedBuild(); def2 = MiscMill.defBuilder().uncheckedBuild(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteSubListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteSubListTest.java index 9328d73bfb..191dffcb49 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteSubListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteSubListTest.java @@ -6,15 +6,14 @@ import mc.testcases.misc.MiscMill; import mc.testcases.misc._ast.ASTDef; import mc.testcases.misc._ast.ASTSub; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class DeleteSubListTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -23,7 +22,7 @@ public void before() { ASTDef def; ASTSub sub; - @Before + @BeforeEach public void setUp() { def = MiscMill.defBuilder().uncheckedBuild(); sub = MiscMill.subBuilder().uncheckedBuild(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteTransitionsTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteTransitionsTest.java index da85424dba..0f77aecc4c 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteTransitionsTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DeleteTransitionsTest.java @@ -6,20 +6,18 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import java.util.List; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DeleteTransitionsTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DoBlockTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DoBlockTest.java index 63eeff3642..322c02cb08 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DoBlockTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/DoBlockTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DoBlockTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ExpandInitialTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ExpandInitialTest.java index 5b534cae5f..f1e1e1f73e 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ExpandInitialTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ExpandInitialTest.java @@ -5,20 +5,18 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import org.junit.Ignore; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ExpandInitialTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FlattenStateTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FlattenStateTest.java index c0bea15750..6d500f6b27 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FlattenStateTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FlattenStateTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class FlattenStateTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FlattenStateWithAtMostTwoSubstatesTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FlattenStateWithAtMostTwoSubstatesTest.java index 2e388db7f4..4b32137c89 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FlattenStateWithAtMostTwoSubstatesTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FlattenStateWithAtMostTwoSubstatesTest.java @@ -5,19 +5,18 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class FlattenStateWithAtMostTwoSubstatesTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -120,7 +119,7 @@ public void testAutomatonWithTwoStatesAndSubstate() throws IOException { } // Todo: patternMatching doesnt terminate - @Ignore + @Disabled @Test public void testAutomatonWithThreeSubstates() throws IOException { String inputFile = "src/main/models/automaton/AutomatonStateWithThreeSubstates.aut"; diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FoldListStateRuleTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FoldListStateRuleTest.java index 108d0886a3..a499e9f6be 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FoldListStateRuleTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FoldListStateRuleTest.java @@ -6,20 +6,18 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.List; import java.util.Optional; -import static org.junit.Assert.*; -import org.junit.Ignore; +import static org.junit.jupiter.api.Assertions.*; public class FoldListStateRuleTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FoldStateRuleTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FoldStateRuleTest.java index 37593b80ae..af9c480ca2 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FoldStateRuleTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/FoldStateRuleTest.java @@ -6,19 +6,17 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class FoldStateRuleTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -42,7 +40,7 @@ public void testEmptyAutomat() throws IOException { assertFalse(state_1.isInitial()); ASTState state_2 = rule.get_state_2(); // compare by object identity - assertTrue(state_1 == state_2); + assertSame(state_1, state_2); assertTrue(Log.getFindings().isEmpty()); } diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ForwardTransitionRuleTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ForwardTransitionRuleTest.java index e7f10c29ba..4ea0e43109 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ForwardTransitionRuleTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ForwardTransitionRuleTest.java @@ -6,20 +6,19 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.List; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ForwardTransitionRuleTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListPrototypeCopyTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListPrototypeCopyTest.java index 9a655cf2ab..9d16bc2b91 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListPrototypeCopyTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListPrototypeCopyTest.java @@ -6,27 +6,26 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.ArrayList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ListPrototypeCopyTest { ASTAutomaton aut; - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); } - @Before + @BeforeEach public void setUp() throws IOException { String inputFile = "src/main/models/automaton/AutomatonSubstateWithSubstate.aut"; AutomatonParser parser = new AutomatonParser(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListPrototypeTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListPrototypeTest.java index 857c71d6ed..093684d6ce 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListPrototypeTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListPrototypeTest.java @@ -7,30 +7,27 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ListPrototypeTest { ASTAutomaton aut; - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); } - @Before + @BeforeEach public void setUp() throws IOException { String inputFile = "src/main/models/automaton/AutomatonSubstateWithSubstate.aut"; AutomatonParser parser = new AutomatonParser(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListStateTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListStateTest.java index 31c93dc42d..c9f27fb273 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListStateTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListStateTest.java @@ -6,20 +6,18 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.List; import java.util.Optional; -import static org.junit.Assert.*; -import org.junit.Ignore; +import static org.junit.jupiter.api.Assertions.*; public class ListStateTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -44,7 +42,7 @@ public void testEmptyAutomat() throws IOException { List list_state_1 = rule.get_list_1_state_1(); assertEquals(2, list_state_1.size()); for (ASTState s : list_state_1) { - assertTrue(s.getName() + "is not initial", s.isInitial()); + assertTrue(s.isInitial(), s.getName() + "is not initial"); } assertTrue(Log.getFindings().isEmpty()); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListThenNotTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListThenNotTest.java index 244d69dbba..441ea3a702 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListThenNotTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListThenNotTest.java @@ -6,20 +6,18 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import java.util.List; import java.util.Optional; -import static org.junit.Assert.*; -import org.junit.Ignore; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ListThenNotTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListWithAssignTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListWithAssignTest.java index 82f03ea8f9..361e956736 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListWithAssignTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListWithAssignTest.java @@ -6,20 +6,18 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import java.util.List; import java.util.Optional; -import static org.junit.Assert.*; -import org.junit.Ignore; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ListWithAssignTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListWithConstraintTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListWithConstraintTest.java index c93088dea3..8b4ff0d06f 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListWithConstraintTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/ListWithConstraintTest.java @@ -6,20 +6,17 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import java.util.List; import java.util.Optional; -import static org.junit.Assert.*; -import org.junit.Ignore; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ListWithConstraintTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubListDefInListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubListDefInListTest.java index 619128bc40..6ecd08322a 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubListDefInListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubListDefInListTest.java @@ -6,16 +6,15 @@ import mc.testcases.misc.MiscMill; import mc.testcases.misc._ast.ASTDef; import mc.testcases.misc._ast.ASTSub; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MoveSubListDefInListTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -24,7 +23,7 @@ public void before() { ASTDef def, def2, def3, def4; ASTSub sub, sub2; - @Before + @BeforeEach public void setUp() { def = MiscMill.defBuilder().uncheckedBuild(); def2 = MiscMill.defBuilder().uncheckedBuild(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubListTest.java index 860652782d..87ddf601dd 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubListTest.java @@ -6,15 +6,15 @@ import mc.testcases.misc.MiscMill; import mc.testcases.misc._ast.ASTDef; import mc.testcases.misc._ast.ASTSub; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MoveSubListTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -25,7 +25,7 @@ public void before() { ASTDef def2; ASTSub sub; - @Before + @BeforeEach public void setUp() { rootdef = MiscMill.defBuilder().uncheckedBuild(); def1 = MiscMill.defBuilder().uncheckedBuild(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubTest.java index 8fde8e74bc..4d67481e79 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubTest.java @@ -7,18 +7,17 @@ import mc.testcases.misc.MiscMill; import mc.testcases.misc._ast.ASTDef; import mc.testcases.misc._ast.ASTSub; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class MoveSubTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); @@ -27,7 +26,7 @@ public void before() { ASTDef oldParent, newParent; ASTSub child; - @Before + @BeforeEach public void setUp() { oldParent = MiscMill.defBuilder().uncheckedBuild(); newParent = MiscMill.defBuilder().uncheckedBuild(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubstateTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubstateTest.java index 2e9b0403e3..7a7aa0faea 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubstateTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveSubstateTest.java @@ -5,21 +5,19 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MoveSubstateTest { ASTAutomaton aut; - @Before + @BeforeEach public void setUp() throws IOException { String inputFile = "src/main/models/automaton/AutomatonTwoStatesAndSubstate.aut"; AutomatonParser parser = new AutomatonParser(); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveTransitionsTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveTransitionsTest.java index 59d930fbd6..00e79ac995 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveTransitionsTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/MoveTransitionsTest.java @@ -6,19 +6,18 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MoveTransitionsTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NonEmptyListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NonEmptyListTest.java index 02ffc09e47..8705304929 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NonEmptyListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NonEmptyListTest.java @@ -6,18 +6,17 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class NonEmptyListTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotInListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotInListTest.java index 42f6fc1a07..08ee919b7e 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotInListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotInListTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class NotInListTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotStateTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotStateTest.java index 37a7448564..5cda0f6581 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotStateTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotStateTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class NotStateTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotStateWithConditionsTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotStateWithConditionsTest.java index a11914e734..0e71725791 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotStateWithConditionsTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/NotStateWithConditionsTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class NotStateWithConditionsTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptInListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptInListTest.java index 563587a098..762b9b3d8d 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptInListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptInListTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class OptInListTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptStateWithOptSubstateTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptStateWithOptSubstateTest.java index dea0f6a3e3..69c211812f 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptStateWithOptSubstateTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptStateWithOptSubstateTest.java @@ -5,18 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class OptStateWithOptSubstateTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptionalChangeFixNameTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptionalChangeFixNameTest.java index f4c0f92e75..d93731bb34 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptionalChangeFixNameTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptionalChangeFixNameTest.java @@ -1,25 +1,23 @@ /* (c) https://github.com/MontiCore/monticore */ package de.monticore.tf; -import com.google.common.collect.Lists; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class OptionalChangeFixNameTest { private ASTAutomaton automaton; - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptionalListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptionalListTest.java index 4eb72899b4..0769941713 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptionalListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/OptionalListTest.java @@ -5,21 +5,19 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Optional; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class OptionalListTest { private ASTAutomaton automaton; - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/SetInitialToFalseInListTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/SetInitialToFalseInListTest.java index c6ca16cfd2..656fb13044 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/SetInitialToFalseInListTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/SetInitialToFalseInListTest.java @@ -5,19 +5,17 @@ import de.se_rwth.commons.logging.LogStub; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import org.junit.Ignore; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SetInitialToFalseInListTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/SetInitialToFalseTest.java b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/SetInitialToFalseTest.java index a9b0cb030e..75db10e25e 100644 --- a/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/SetInitialToFalseTest.java +++ b/monticore-test/montitrans/test-odrules/src/test/java/de/monticore/tf/SetInitialToFalseTest.java @@ -6,18 +6,16 @@ import mc.testcases.automaton._ast.ASTAutomaton; import mc.testcases.automaton._ast.ASTState; import mc.testcases.automaton._parser.AutomatonParser; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; public class SetInitialToFalseTest { - @Before + @BeforeEach public void before() { LogStub.init(); Log.enableFailQuick(false); diff --git a/prepare-next-release/0001-use-next-snapshot.patch b/prepare-next-release/0001-use-next-snapshot.patch index d1d121c263..f0699c2ec0 100644 --- a/prepare-next-release/0001-use-next-snapshot.patch +++ b/prepare-next-release/0001-use-next-snapshot.patch @@ -1,11 +1,11 @@ -From c569be63376d9fd5fed786832a502d910d5aa053 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Alex=20L=C3=BCpges?= -Date: Wed, 16 Jul 2025 12:20:05 +0200 -Subject: [PATCH] use next snapshot +From 28259ce5949049ee78bb720c13636850ebca0f1c Mon Sep 17 00:00:00 2001 +From: Janik Rapp +Date: Fri, 2 Jan 2026 14:32:48 +0100 +Subject: [PATCH] [PATCH] use next snapshot diff --git a/gradle.properties b/gradle.properties -index 15ccb34a2..758207c28 100644 +index 3bc21f46d..26a2df7a3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,11 +14,11 @@ org.gradle.caching=true @@ -21,19 +21,19 @@ index 15ccb34a2..758207c28 100644 -se_commons_version =7.8.0 +se_commons_version =7.9.0-SNAPSHOT antlr_version =4.12.0 - junit_version =5.10.3 - emf_compare_version =1.2.0 -@@ -28,4 +28,4 @@ freemarker_version = 2.3.34 + junit_version = 5.14.1 + junit_platform_version = 1.14.1 +@@ -29,4 +29,4 @@ freemarker_version = 2.3.34 guava_version =31.1-jre shadow_plugin_version=7.1.2 -cd4a_version =7.8.0 +cd4a_version =7.9.0-SNAPSHOT diff --git a/monticore-generator/gradle.properties b/monticore-generator/gradle.properties -index 94aaf8f47..a05001108 100644 +index a4171758b..5249f4006 100644 --- a/monticore-generator/gradle.properties +++ b/monticore-generator/gradle.properties -@@ -9,13 +9,13 @@ useLocalRepo=true +@@ -9,14 +9,14 @@ useLocalRepo=false showTestOutput=false # versions used @@ -45,12 +45,13 @@ index 94aaf8f47..a05001108 100644 -se_commons_version =7.8.0 +se_commons_version =7.9.0-SNAPSHOT antlr_version =4.12.0 - junit_version =5.10.3 + junit_version = 5.14.1 + junit_platform_version = 1.14.1 -cd4a_version =7.8.0 +cd4a_version =7.9.0-SNAPSHOT commons_lang3_version = 3.8.1 commons_cli_version = 1.4 freemarker_version = 2.3.28 -- -2.42.0.windows.2 +2.47.1.windows.1