Skip to content

Commit

Permalink
Restructure project at pipeline and test (cleanup)
Browse files Browse the repository at this point in the history
Introduced a "cleanup" test that removes temporary files that are needed (and reused) throughout multiple modules and need to be removed in the end during full compilation.
Additionally, reworked pipeline into multiple modules to be able to compile and run tests of certain classed/runners for certain profiles only.
  • Loading branch information
Gram21 committed May 5, 2023
1 parent dd86803 commit 8c8177c
Show file tree
Hide file tree
Showing 47 changed files with 492 additions and 643 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tests/src/test/resources/config.properties
/pipeline/src/test/resources/testout/

tmp*
temp*

.vscode/*

Expand Down
17 changes: 17 additions & 0 deletions pipeline/pipeline-core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.ardoco.core</groupId>
<artifactId>pipeline</artifactId>
<version>0.8.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>pipeline-core</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ProjectPipelineDataImpl implements ProjectPipelineData {

/**
* Construct this class using the project's name
*
*
* @param projectName the project's name
*/
ProjectPipelineDataImpl(String projectName) {
Expand Down
2 changes: 2 additions & 0 deletions pipeline/pipeline-core/src/test/resources/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.gitignore
!.gitignore
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions pipeline/pipeline-id/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.ardoco.core</groupId>
<artifactId>pipeline</artifactId>
<version>0.8.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>pipeline-id</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>io.github.ardoco.core</groupId>
<artifactId>pipeline-core</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ class ArDoCoForInconsistencyDetectionTest extends RunnerBaseTest {
@Test
@DisplayName("Test ArDoCo for Inconsistency Detection (PCM)")
void testInconsistencyDetectionPcm() {
var runner = new ArDoCoForInconsistencyDetection(projectName);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(additionalConfigs));
runner.setUp(inputText, inputModelArchitecture, ArchitectureModelType.PCM, additionalConfigsMap, outputDir);
var runner = new ArDoCoForInconsistencyDetection(PROJECT_NAME);
File additionalConfigsFile = new File(ADDITIONAL_CONFIGS);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(additionalConfigsFile);
runner.setUp(INPUT_TEXT, INPUT_MODEL_ARCHITECTURE, ArchitectureModelType.PCM, additionalConfigsMap, OUTPUT_DIR);

testRunnerAssertions(runner);
Assertions.assertNotNull(runner.run());
Expand All @@ -26,9 +27,9 @@ void testInconsistencyDetectionPcm() {
@Test
@DisplayName("Test ArDoCo for Inconsistency Detection (UML)")
void testInconsistencyDetectionUml() {
var runner = new ArDoCoForInconsistencyDetection(projectName);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(additionalConfigs));
runner.setUp(inputText, inputModelArchitectureUml, ArchitectureModelType.UML, additionalConfigsMap, outputDir);
var runner = new ArDoCoForInconsistencyDetection(PROJECT_NAME);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(ADDITIONAL_CONFIGS));
runner.setUp(INPUT_TEXT, INPUT_MODEL_ARCHITECTURE_UML, ArchitectureModelType.UML, additionalConfigsMap, OUTPUT_DIR);

testRunnerAssertions(runner);
Assertions.assertNotNull(runner.run());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* Licensed under MIT 2023. */
package edu.kit.kastel.mcse.ardoco.core.execution.runner;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Objects;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

// TODO improve this so this does not have to be in the src/main/java
class RunnerBaseTest {
private static final Logger logger = LoggerFactory.getLogger(RunnerBaseTest.class);

protected static final String INPUT_TEXT = "../pipeline-core/src/test/resources/teastore.txt";
protected static final String INPUT_MODEL_ARCHITECTURE = "../pipeline-core/src/test/resources/teastore.repository";
protected static final String INPUT_MODEL_ARCHITECTURE_UML = "../pipeline-core/src/test/resources/teastore.uml";
protected static final String OUTPUT_DIR = "../pipeline-core/src/test/resources/testout";
protected static final String ADDITIONAL_CONFIGS = "../pipeline-core/src/test/resources/additionalConfig.txt";
protected static final String PROJECT_NAME = "teastore";

@AfterEach
void cleanUp() {
for (File file : Objects.requireNonNull(new File(OUTPUT_DIR).listFiles())) {
if (!file.getName().equals(".gitkeep")) {
try {
Files.delete(file.toPath());
} catch (IOException e) {
logger.warn("Error when cleaning up!", e);
}
}
}
}

@SuppressWarnings("java:S5960")
@Test
@DisplayName("Test SetUp")
void testInput() {
File inputTextFile = new File(INPUT_TEXT);
File inputModelArchitectureFile = new File(INPUT_MODEL_ARCHITECTURE);
File inputModelArchitectureUmlFile = new File(INPUT_MODEL_ARCHITECTURE_UML);
File outputDirFile = new File(OUTPUT_DIR);
File additionalConfigsFile = new File(ADDITIONAL_CONFIGS);

Assertions.assertAll(//
() -> Assertions.assertTrue(inputTextFile.exists()),//
() -> Assertions.assertTrue(inputModelArchitectureFile.exists()),//
() -> Assertions.assertTrue(inputModelArchitectureUmlFile.exists()),//
() -> Assertions.assertTrue(outputDirFile.exists()),//
() -> Assertions.assertTrue(additionalConfigsFile.exists())//
);
}

protected void testRunnerAssertions(ArDoCoRunner runner) {
Assertions.assertAll(//
() -> Assertions.assertNotNull(runner),//
() -> Assertions.assertTrue(runner.isSetUp())//
);
}
}
24 changes: 24 additions & 0 deletions pipeline/pipeline-tlr/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.ardoco.core</groupId>
<artifactId>pipeline</artifactId>
<version>0.8.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>pipeline-tlr</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>io.github.ardoco.core</groupId>
<artifactId>pipeline-core</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Licensed under MIT 2023. */
package edu.kit.kastel.mcse.ardoco.core.execution.runner;
package edu.kit.kastel.mcse.ardoco.core.execution;

import java.io.File;
import java.io.IOException;
Expand All @@ -11,8 +11,7 @@
import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureModelType;
import edu.kit.kastel.mcse.ardoco.core.common.util.CommonUtilities;
import edu.kit.kastel.mcse.ardoco.core.common.util.DataRepositoryHelper;
import edu.kit.kastel.mcse.ardoco.core.execution.ArDoCo;
import edu.kit.kastel.mcse.ardoco.core.execution.PipelineUtils;
import edu.kit.kastel.mcse.ardoco.core.execution.runner.ArDoCoRunner;
import edu.kit.kastel.mcse.ardoco.core.models.ArCoTLModelProviderAgent;

public class ArDoCoForSadSamCodeTraceabilityLinkRecovery extends ArDoCoRunner {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Licensed under MIT 2023. */
package edu.kit.kastel.mcse.ardoco.core.execution.runner;
package edu.kit.kastel.mcse.ardoco.core.execution;

import java.io.File;
import java.io.IOException;
Expand All @@ -11,7 +11,7 @@
import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureModelType;
import edu.kit.kastel.mcse.ardoco.core.common.util.CommonUtilities;
import edu.kit.kastel.mcse.ardoco.core.common.util.DataRepositoryHelper;
import edu.kit.kastel.mcse.ardoco.core.execution.PipelineUtils;
import edu.kit.kastel.mcse.ardoco.core.execution.runner.ArDoCoRunner;

public class ArDoCoForSadSamTraceabilityLinkRecovery extends ArDoCoRunner {
private static final Logger logger = LoggerFactory.getLogger(ArDoCoForSadSamTraceabilityLinkRecovery.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Licensed under MIT 2023. */
package edu.kit.kastel.mcse.ardoco.core.execution.runner;
package edu.kit.kastel.mcse.ardoco.core.execution;

import java.io.File;
import java.io.IOException;
Expand All @@ -9,8 +9,7 @@
import org.slf4j.LoggerFactory;

import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureModelType;
import edu.kit.kastel.mcse.ardoco.core.execution.ArDoCo;
import edu.kit.kastel.mcse.ardoco.core.execution.PipelineUtils;
import edu.kit.kastel.mcse.ardoco.core.execution.runner.ArDoCoRunner;
import edu.kit.kastel.mcse.ardoco.core.models.ArCoTLModelProviderAgent;

public class ArDoCoForSamCodeTraceabilityLinkRecovery extends ArDoCoRunner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
import org.junit.jupiter.api.Test;

import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureModelType;
import edu.kit.kastel.mcse.ardoco.core.execution.ArDoCoForSadSamCodeTraceabilityLinkRecovery;
import edu.kit.kastel.mcse.ardoco.core.execution.ConfigurationHelper;

class ArDoCoForSadSamCodeTraceabilityLinkRecoveryTest extends CodeRunnerBaseTest {

@Test
@DisplayName("Test ArDoCo for SAD-SAM-Code-TLR (PCM)")
void testSadSamTlrPcm() {
var runner = new ArDoCoForSadSamCodeTraceabilityLinkRecovery(projectName);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(additionalConfigs));
runner.setUp(new File(inputText), new File(inputModelArchitecture), ArchitectureModelType.PCM, new File(inputCode), additionalConfigsMap, new File(
outputDir));
var runner = new ArDoCoForSadSamCodeTraceabilityLinkRecovery(PROJECT_NAME);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(ADDITIONAL_CONFIGS));
runner.setUp(new File(INPUT_TEXT), new File(INPUT_MODEL_ARCHITECTURE), ArchitectureModelType.PCM, new File(CodeRunnerBaseTest.inputCode),
additionalConfigsMap, new File(OUTPUT_DIR));

testRunnerAssertions(runner);
Assertions.assertNotNull(runner.run());
Expand All @@ -27,10 +28,10 @@ void testSadSamTlrPcm() {
@Test
@DisplayName("Test ArDoCo for SAD-SAM-Code-TLR (UML)")
void testSadSamTlrUml() {
var runner = new ArDoCoForSadSamCodeTraceabilityLinkRecovery(projectName);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(additionalConfigs));
runner.setUp(new File(inputText), new File(inputModelArchitectureUml), ArchitectureModelType.UML, new File(inputCode), additionalConfigsMap, new File(
outputDir));
var runner = new ArDoCoForSadSamCodeTraceabilityLinkRecovery(PROJECT_NAME);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(ADDITIONAL_CONFIGS));
runner.setUp(new File(INPUT_TEXT), new File(INPUT_MODEL_ARCHITECTURE_UML), ArchitectureModelType.UML, new File(CodeRunnerBaseTest.inputCode),
additionalConfigsMap, new File(OUTPUT_DIR));

testRunnerAssertions(runner);
Assertions.assertNotNull(runner.run());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
import org.junit.jupiter.api.Test;

import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureModelType;
import edu.kit.kastel.mcse.ardoco.core.execution.ArDoCoForSadSamTraceabilityLinkRecovery;
import edu.kit.kastel.mcse.ardoco.core.execution.ConfigurationHelper;

class ArDoCoForSadSamTraceabilityLinkRecoveryTest extends RunnerBaseTest {

@Test
@DisplayName("Test ArDoCo for SAD-SAM-TLR (PCM)")
void testSadSamTlrPcm() {
var runner = new ArDoCoForSadSamTraceabilityLinkRecovery(projectName);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(additionalConfigs));
runner.setUp(inputText, inputModelArchitecture, ArchitectureModelType.PCM, additionalConfigsMap, outputDir);
var runner = new ArDoCoForSadSamTraceabilityLinkRecovery(PROJECT_NAME);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(ADDITIONAL_CONFIGS));
runner.setUp(INPUT_TEXT, INPUT_MODEL_ARCHITECTURE, ArchitectureModelType.PCM, additionalConfigsMap, OUTPUT_DIR);

testRunnerAssertions(runner);
Assertions.assertNotNull(runner.run());
Expand All @@ -26,9 +27,9 @@ void testSadSamTlrPcm() {
@Test
@DisplayName("Test ArDoCo for SAD-SAM-TLR (UML)")
void testSadSamTlrUml() {
var runner = new ArDoCoForSadSamTraceabilityLinkRecovery(projectName);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(additionalConfigs));
runner.setUp(inputText, inputModelArchitectureUml, ArchitectureModelType.UML, additionalConfigsMap, outputDir);
var runner = new ArDoCoForSadSamTraceabilityLinkRecovery(PROJECT_NAME);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(ADDITIONAL_CONFIGS));
runner.setUp(INPUT_TEXT, INPUT_MODEL_ARCHITECTURE_UML, ArchitectureModelType.UML, additionalConfigsMap, OUTPUT_DIR);

testRunnerAssertions(runner);
Assertions.assertNotNull(runner.run());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@
import org.junit.jupiter.api.Test;

import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureModelType;
import edu.kit.kastel.mcse.ardoco.core.execution.ArDoCoForSamCodeTraceabilityLinkRecovery;
import edu.kit.kastel.mcse.ardoco.core.execution.ConfigurationHelper;

public class ArDoCoForSamCodeTraceabilityLinkRecoveryTest extends CodeRunnerBaseTest {
class ArDoCoForSamCodeTraceabilityLinkRecoveryTest extends CodeRunnerBaseTest {

@Test
@DisplayName("Test ArDoCo for SAM-Code-TLR (PCM)")
void testSamCodeTlrPcm() {
var runner = new ArDoCoForSamCodeTraceabilityLinkRecovery(projectName);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(additionalConfigs));
runner.setUp(new File(inputModelArchitecture), ArchitectureModelType.PCM, new File(inputCode), additionalConfigsMap, new File(outputDir));
var runner = new ArDoCoForSamCodeTraceabilityLinkRecovery(PROJECT_NAME);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(ADDITIONAL_CONFIGS));
runner.setUp(new File(INPUT_MODEL_ARCHITECTURE), ArchitectureModelType.PCM, new File(CodeRunnerBaseTest.inputCode), additionalConfigsMap, new File(
OUTPUT_DIR));

testRunnerAssertions(runner);
Assertions.assertNotNull(runner.run());
Expand All @@ -26,9 +28,10 @@ void testSamCodeTlrPcm() {
@Test
@DisplayName("Test ArDoCo for SAM-Code-TLR (UML)")
void testSamCodeTlrUml() {
var runner = new ArDoCoForSamCodeTraceabilityLinkRecovery(projectName);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(additionalConfigs));
runner.setUp(new File(inputModelArchitectureUml), ArchitectureModelType.UML, new File(inputCode), additionalConfigsMap, new File(outputDir));
var runner = new ArDoCoForSamCodeTraceabilityLinkRecovery(PROJECT_NAME);
var additionalConfigsMap = ConfigurationHelper.loadAdditionalConfigs(new File(ADDITIONAL_CONFIGS));
runner.setUp(new File(INPUT_MODEL_ARCHITECTURE_UML), ArchitectureModelType.UML, new File(CodeRunnerBaseTest.inputCode), additionalConfigsMap, new File(
OUTPUT_DIR));

testRunnerAssertions(runner);
Assertions.assertNotNull(runner.run());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Licensed under MIT 2023. */
package edu.kit.kastel.mcse.ardoco.core.execution.runner;

import java.io.File;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;

import edu.kit.kastel.mcse.ardoco.core.common.CodeUtils;

// TODO improve this so this does not have to be in the src/main/java
class CodeRunnerBaseTest extends RunnerBaseTest {
protected static final String inputCodeRepository = "https://github.com/ArDoCo/TeaStore.git";

// If you change the folder, make sure to also update the CleanupTest in the module "report"
protected static final String inputCode = "../../temp/code/teastore";

@BeforeAll
static void setup() {
File codeLocation = new File(inputCode);

if (!codeLocation.exists()) {
var successfulClone = CodeUtils.cloneRepository(inputCodeRepository, inputCode);
if (!successfulClone) {
Assertions.fail("Could not clone repository.");
}
}
}

}
Loading

0 comments on commit 8c8177c

Please sign in to comment.