Просмотр исходного кода

Merge pull request #551 from SuyDesignz/feature/EndToEndTesting

End to End Testing (Java)
Timur Sağlam 4 лет назад
Родитель
Сommit
19d39f2a48
31 измененных файлов с 1660 добавлено и 1 удалено
  1. 4 0
      jplag.cli/pom.xml
  2. 105 0
      jplag.endToEndTesting/README.md
  3. 29 0
      jplag.endToEndTesting/pom.xml
  4. 32 0
      jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/constants/TestDirectoryConstants.java
  5. 120 0
      jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/helper/JPlagTestSuiteHelper.java
  6. 33 0
      jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/helper/JsonHelper.java
  7. 52 0
      jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/model/JsonModel.java
  8. 48 0
      jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/model/ResultModel.java
  9. 46 0
      jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/model/TestCaseModel.java
  10. 114 0
      jplag.endToEndTesting/src/test/java/de/jplag/end_to_end_testing/JavaEndToEndTest.java
  11. 36 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo.java
  12. 63 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1.java
  13. 79 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1_2.java
  14. 81 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1_3.java
  15. 71 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1_4.java
  16. 91 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1_5.java
  17. 91 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1_6.java
  18. 38 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo2.java
  19. 44 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo2_5.java
  20. 47 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo3.java
  21. 59 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo3_5.java
  22. 54 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo3_6.java
  23. 33 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo4.java
  24. 40 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo4d1.java
  25. 39 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo4d2.java
  26. 39 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo4d3.java
  27. 44 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo5.java
  28. 45 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo6.java
  29. 33 0
      jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo7.java
  30. 36 0
      jplag.endToEndTesting/src/test/resources/results/JavaResult.json
  31. 14 1
      pom.xml

+ 4 - 0
jplag.cli/pom.xml

@@ -52,6 +52,10 @@
             <groupId>de.jplag</groupId>
             <artifactId>chars</artifactId>
         </dependency>
+        <dependency>
+            <groupId>de.jplag</groupId>
+            <artifactId>endToEndTesting</artifactId>
+        </dependency>
         <dependency>
             <groupId>net.sourceforge.argparse4j</groupId>
             <artifactId>argparse4j</artifactId>

+ 105 - 0
jplag.endToEndTesting/README.md

@@ -0,0 +1,105 @@
+# JPlag - End To End Testing
+With the help of the end-to-end module, changes to the detection of JPlag are to be tested.
+With the help of elaborated plagiarisms, which have been worked out from suggestions in the literature on the topic of "plagiarism detection and avoidance", a wide range of detectable change can be covered. The selected plagiarisms are the decisive factor here as to whether a change in recognition can be perceived. 
+
+### References
+These elaborations provide basic ideas on how a modification of the plagiarized source code can look like or be adapted.
+These code adaptations refer to a wide range of changes starting from
+adding/removing comments to architectural changes in the deliverables.
+
+The following elaborations were used to be able to create the plagiarisms with the largest coverage:
+- [Mossad: defeating software plagiarism detection](https://dl.acm.org/doi/abs/10.1145/3428206 "Mossad: defeating software plagiarism detection")
+- [Detecting Source Code Plagiarism on Introductory Programming Course Assignments Using a Bytecode Approach - Oscar Karnalim](https://ieeexplore.ieee.org/abstract/document/7910274 "Detecting Source Code Plagiarism on Introductory Programming Course Assignments Using a Bytecode Approach - Oscar Karnalim")
+- [Detecting Disguised Plagiarism - Hatem A. Mahmoud](https://arxiv.org/abs/1711.02149 "Detecting Disguised Plagiarism - Hatem A. Mahmoud")
+- [Instructor-centric source code plagiarism detection and plagiarism corpus](https://dl.acm.org/doi/abs/10.1145/2325296.2325328 "Instructor-centric source code plagiarism detection and plagiarism corpus")
+
+### Steps Towards Plagiarism
+The following changes were applied to sample tasks to create test cases:
+<ul type="1">
+	<li>Inserting comments or empty lines (normalization level)</li>
+	<li>Changing variable names or function names (normalization level)</li>
+	<li>Insertion of unnecessary or changed code lines (token generation)</li>
+	<li>Changing the program flow (token generation) (statments and functions must be independent from each other)</li>
+		<ul>
+			<li>Variable decleration at the beginning of the program</li>
+			<li>Combining declerations of variables</li>
+			<li>Reuse of the same variable for other functions</li>
+		</ul>
+	<li>Changing control structures</li>
+		<ul>
+			<li>for(...) to while(...)</li>
+			<li>if(...) to switch-case</li>
+		</ul>
+	<li>Modification of expressions</li>
+		<ul>
+			<li>(X < Y) to !(X >= Y) and ++x to x = x + 1</li>
+		</ul>
+	<li>Splitting and merging statements</li>
+		<ul>
+			<li>x = getSomeValue(); y = x- z; to y = (getSomeValue() - Z;</li>
+		</ul>
+	<li>Inserting unnecessary casts</li>
+</ul>
+
+More detailed information about the create as well as about the subject to the issue can be found in the issue [Develop an end-to-end testing strategy](https://github.com/jplag/JPlag/issues/193 "Develop an end-to-end testing strategy").
+
+**The changes listed above have been developed and evaluated for purely scientific purposes and are not intended to be used for plagiarism in the public or private domain.**
+
+Software is according to [§ 2 of the copyright law](https://www.gesetze-im-internet.de/urhg/__2.html "§ 2 of the copyright law") a protected work which may not be plagiarized. 
+
+### JPlag - End To End TestSuite Structure
+The construction of an end to end test is done with the help of the JPlag api. 
+
+``` java 
+[...]
+    /**
+     * This method creates the necessary results as well as models for a test run and summarizes them for a comparison.
+     * @param testClassNames Plagiarized classes names in the resource directorie which are needed for the test
+     * @param testIdentifier name of the testId to load and identify the stored results
+     * @throws IOException is thrown in case of problems with copying the plagiarism classes
+     * @throws ExitException in case the plagiarism detection with JPlag is preemptively terminated would be of the test.
+     */
+    private void runJPlagTestSuite(String[] testClassNames, int testIdentifier) throws IOException, ExitException {
+        String functionName = StackWalker.getInstance().walk(stream -> stream.skip(1).findFirst().get()).getMethodName();
+        TestCaseModel testCaseModel = jplagTestSuiteHelper.createNewTestCase(testClassNames, functionName);
+        JPlagResult jplagResult = new JPlag(testCaseModel.getJPlagOptionsFromCurrentModel()).run();
+
+        for (JPlagComparison jPlagComparison : jplagResult.getAllComparisons()) {
+            assertEquals(testCaseModel.getCurrentJsonModel().getResultModelById(testIdentifier).getResultSimilarity(), jPlagComparison.similarity(),
+                    "The JPlag results [similarity] do not match the stored values!");
+        }
+    }
+[...]
+```
+The created plagiarisms are copied with the JPlagTestSuiteHelper into temporary directories, which can then be checked with JPlag. 
+
+In order to be able to distinguish in which domain of the recognition changes have occurred, fine granular test cases are used. These are composed of the changes already mentioned above. The plagiarism is compared with the original delivery and thus it is possible to detect and test small sections of the recognition. 
+
+The values compared so far to detect a match are limited to the similarity of the JPlag scan. It is already planned to expand the comparative values in order to have more indications of a change. 
+
+The Current Discussion is already taking place and can be found at [End to end testing - "comparative values"](https://github.com/jplag/JPlag/issues/548 "End to end testing - \"comparative values\""). 
+
+The current JPlag scans will be compared with the stored ones.
+This was done by storing the data in a *.json file which is read at the beginning of each test run. 
+
+``` json  
+{
+[...]
+    "function_name": "normalizationLevelTest",
+    "test_results": [
+      {
+        "result_similarity": 100,
+        "test_identifier": 0
+      },
+      {
+        "result_similarity": 100,
+        "test_identifier": 1
+      },
+      {
+        "result_similarity": 100,
+        "test_identifier": 2
+      }
+    ]
+  }
+[...]
+```

+ 29 - 0
jplag.endToEndTesting/pom.xml

@@ -0,0 +1,29 @@
+<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>de.jplag</groupId>
+        <artifactId>aggregator</artifactId>
+        <version>${revision}</version>
+    </parent>
+    <artifactId>endToEndTesting</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>de.jplag</groupId>
+            <artifactId>jplag</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>de.jplag</groupId>
+            <artifactId>frontend-testutils</artifactId>
+            <version>${revision}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.13.3</version>
+        </dependency>
+    </dependencies>
+</project>

+ 32 - 0
jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/constants/TestDirectoryConstants.java

@@ -0,0 +1,32 @@
+package de.jplag.end_to_end_testing.constants;
+
+import java.nio.file.Path;
+
+/**
+ * All constant values that are needed in the test cases or helper classes.
+ */
+public final class TestDirectoryConstants {
+
+    private TestDirectoryConstants() {
+        // private constructor to prevent instantiation
+    }
+
+    /**
+     * Name for the folder to copy the submissions to in order to test them with JPlag
+     */
+    public static final String TEMPORARY_DIRECTORY_NAME = "testing-directory-submission";
+    /**
+     * Create the complete path to the submission files. Here the temporary system path is extended with the
+     * "TEMPORARY_DIRECTORY_NAME", which is predefined in this class.
+     */
+    public static final String TEMPORARY_SUBMISSION_DIRECTORY_NAME = Path.of("target", TEMPORARY_DIRECTORY_NAME).toString();
+
+    /**
+     * Base path to the created plagiarism and the main file located in the project resources.
+     */
+    public static final Path BASE_PATH_TO_JAVA_RESOURCES_SORTALGO = Path.of("src", "test", "resources", "java", "sortAlgo");
+    /**
+     * Base path to the saved results of the previous tests in a *.json file
+     */
+    public static final Path BASE_PATH_TO_JAVA_RESULT_JSON = Path.of("src", "test", "resources", "results", "JavaResult.json");
+}

+ 120 - 0
jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/helper/JPlagTestSuiteHelper.java

@@ -0,0 +1,120 @@
+package de.jplag.end_to_end_testing.helper;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.Arrays;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import de.jplag.end_to_end_testing.constants.TestDirectoryConstants;
+import de.jplag.end_to_end_testing.model.JsonModel;
+import de.jplag.end_to_end_testing.model.TestCaseModel;
+import de.jplag.options.LanguageOption;
+
+/**
+ * This helper class deals with creating the test cases as well as copying and deleting for the end-to-end tests. The
+ * required plagiarisms are copied from the resource folder to a temporary location, thus creating a folder structure
+ * that can be tested by JPlag. Models are instantiated here and required information for the tests is loaded.
+ */
+public class JPlagTestSuiteHelper {
+
+    private static final Logger logger = LoggerFactory.getLogger(JPlagTestSuiteHelper.class);
+
+    private String[] resourceNames;
+    private List<JsonModel> resultModel;
+    private LanguageOption languageOption;
+
+    /**
+     * Helper class for the endToEnd tests. In this class the necessary resources are loaded, prepared and copied for the
+     * tests based on the passed parameters. An instance of this class loads all necessary paths and properties for a test
+     * run with the specified language
+     * @param languageOption for loading language-specific resources
+     * @throws IOException is thrown for all problems that may occur while parsing the json file. This includes both reading
+     * and parsing problems.
+     */
+    public JPlagTestSuiteHelper(LanguageOption languageOption) throws IOException {
+        this.languageOption = languageOption;
+        this.resourceNames = new File(TestDirectoryConstants.BASE_PATH_TO_JAVA_RESOURCES_SORTALGO.toString()).list();
+
+        this.resultModel = JsonHelper.getResultModelFromPath();
+        logger.debug("temp path at [{}]", TestDirectoryConstants.TEMPORARY_SUBMISSION_DIRECTORY_NAME);
+    }
+
+    /**
+     * creates all necessary folder paths and objects for a test run. Also searches for the stored previous results of the
+     * test in order to compare them with the current results.
+     * @param classNames Array of class names with language specific extension to be prepared for a test.
+     * @return comparison results saved for the test
+     * @throws IOException Exception can be thrown in cases that involve reading, copying or locating files.
+     */
+    public TestCaseModel createNewTestCase(String[] classNames, String functionName) throws IOException {
+        createNewTestCaseDirectory(classNames);
+        JsonModel resultJsonModel = resultModel.stream().filter(jsonModel -> functionName.equals(jsonModel.getFunctionName())).findAny().orElse(null);
+        return new TestCaseModel(TestDirectoryConstants.TEMPORARY_SUBMISSION_DIRECTORY_NAME, resultJsonModel, languageOption);
+    }
+
+    /**
+     * The copied data should be deleted after instance closure
+     * @throws IOException if an I/O error occurs
+     */
+    public void clear() throws IOException {
+        logger.debug("Class instance was cleaned!");
+        deleteCopiedFiles(new File(TestDirectoryConstants.TEMPORARY_SUBMISSION_DIRECTORY_NAME));
+    }
+
+    /**
+     * Copies the passed filenames to a temporary path to use them in the tests
+     * @throws IOException Exception can be thrown in cases that involve reading, copying or locating files.
+     */
+    private void createNewTestCaseDirectory(String[] classNames) throws IOException {
+        // before copying files to the test path, check if all files are in the resource
+        // directory
+        for (String className : classNames) {
+            if (!Arrays.asList(resourceNames).contains(className)) {
+                throw new FileNotFoundException(String.format("The specified class could not be found! [%s]", className));
+            }
+        }
+        // Copy the resources data to the temporary path
+        for (int counter = 0; counter < classNames.length; counter++) {
+            Path originalPath = Path.of(TestDirectoryConstants.BASE_PATH_TO_JAVA_RESOURCES_SORTALGO.toString(), classNames[counter]);
+            Path copiePath = Path.of(TestDirectoryConstants.TEMPORARY_SUBMISSION_DIRECTORY_NAME,
+                    TestDirectoryConstants.TEMPORARY_DIRECTORY_NAME + (counter + 1), classNames[counter]);
+
+            File directory = new File(copiePath.toString());
+            if (!directory.exists()) {
+                directory.mkdirs();
+            }
+
+            Files.copy(originalPath, copiePath, StandardCopyOption.REPLACE_EXISTING);
+            logger.debug("Copy file from [{}] to [{}]", originalPath, copiePath);
+        }
+    }
+
+    /**
+     * Delete directory with including files
+     * @param file Path to a folder or file to be deleted. This happens recursively to the path
+     * @throws IOException if an I/O error occurs
+     */
+    private void deleteCopiedFiles(File folder) throws IOException {
+        File[] files = folder.listFiles();
+        if (files != null) { // some JVMs return null for empty dirs
+            for (File file : files) {
+                if (file.isDirectory()) {
+                    deleteCopiedFiles(file);
+                } else {
+                    Files.delete(file.toPath());
+                    logger.debug("Delete file in folder: [{}]", file);
+                }
+            }
+        }
+        Files.delete(folder.toPath());
+        logger.debug("Delete folder: [{}]", folder);
+    }
+
+}

+ 33 - 0
jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/helper/JsonHelper.java

@@ -0,0 +1,33 @@
+package de.jplag.end_to_end_testing.helper;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import de.jplag.end_to_end_testing.constants.TestDirectoryConstants;
+import de.jplag.end_to_end_testing.model.JsonModel;
+
+/**
+ * Helper class for serializing and creating all json dependent events.
+ */
+public final class JsonHelper {
+
+    /**
+     * private constructor to prevent instantiation
+     */
+    private JsonHelper() {
+        // For Serialization
+    }
+
+    /**
+     * Parsing the old results in the json file as a list from ResultJsonModel.
+     * @return list of saved results for the test cases
+     * @throws IOException is thrown for all problems that may occur while parsing the json file. This includes both reading
+     * and parsing problems.
+     */
+    public static List<JsonModel> getResultModelFromPath() throws IOException {
+        return Arrays.asList(new ObjectMapper().readValue(TestDirectoryConstants.BASE_PATH_TO_JAVA_RESULT_JSON.toFile(), JsonModel[].class));
+    }
+}

+ 52 - 0
jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/model/JsonModel.java

@@ -0,0 +1,52 @@
+package de.jplag.end_to_end_testing.model;
+
+import java.util.Arrays;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * The ResultJsonModel is the java object for the JavaResult.json file. The object contains all the necessary
+ * information for the comparisons in the test cases between old and new results, which have been stored in the
+ * JavaResult.json file.
+ */
+public class JsonModel {
+    @JsonProperty("function_name")
+    private String functionName;
+    @JsonProperty("test_results")
+    private ResultModel[] results;
+
+    /**
+     * Constructor for the JsonModel. The model is the serialization of the Json file in the form of a Java object.
+     * @param functionName the function name for the associated test results. Used as identifier to search results for the
+     * test cases.
+     * @param results Collection of the results that are in the current json file for certain tests
+     */
+    public JsonModel(String functionName, ResultModel[] results) {
+        this.functionName = functionName;
+        this.results = results;
+    }
+
+    /**
+     * empty constructor in case the serialization contains an empty object to prevent throwing exceptions. this constructor
+     * was necessary for serialization with the Jackson parse extension
+     */
+    public JsonModel() {
+        // For Serialization
+    }
+
+    /**
+     * @return the name of the currently used function stored in json
+     */
+    public String getFunctionName() {
+        return functionName;
+    }
+
+    /**
+     * returns the results for the function that have been stored for the given id.
+     * @param identifier for the comparative values
+     * @return associated comparison values that have been assigned to the identifier
+     */
+    public ResultModel getResultModelById(Integer identifier) {
+        return Arrays.asList(results).stream().filter(resultModel -> identifier.equals(resultModel.getTestId())).findAny().orElse(null);
+    }
+}

+ 48 - 0
jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/model/ResultModel.java

@@ -0,0 +1,48 @@
+package de.jplag.end_to_end_testing.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * The ResultModel contains all information and comparison values that are important for a test and that could be parsed
+ * from the json file.
+ */
+public class ResultModel {
+
+    @JsonProperty("result_similarity")
+    private float resultSimilarity;
+    @JsonProperty("test_identifier")
+    private int testIdentifier;
+
+    /**
+     * Constructor for the ResultModel. The model is the serialization of the Json file in the form of a Java object.
+     * @param resultSimilarity stored comparative value of the similarity
+     * @param testIdentifier specifies which associated test results are needed for a test case and are therefore associated
+     * with this Id.
+     */
+    public ResultModel(float resultSimilarity, int testIdentifier) {
+        this.resultSimilarity = resultSimilarity;
+        this.testIdentifier = testIdentifier;
+    }
+
+    /**
+     * empty constructor in case the serialization contains an empty object to prevent throwing exceptions. this constructor
+     * was necessary for serialization with the Jackson parse extension
+     */
+    public ResultModel() {
+        // For Serialization
+    }
+
+    /**
+     * @return Identifier assigned to the result
+     */
+    public int getTestId() {
+        return testIdentifier;
+    }
+
+    /**
+     * @return of the comparative similarity
+     */
+    public float getResultSimilarity() {
+        return resultSimilarity;
+    }
+}

+ 46 - 0
jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/model/TestCaseModel.java

@@ -0,0 +1,46 @@
+package de.jplag.end_to_end_testing.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import de.jplag.options.JPlagOptions;
+import de.jplag.options.LanguageOption;
+
+/**
+ * Median class for trading the results and the paths used in the tests. Also the JPlagOptions used for a test run are
+ * created here.
+ */
+public class TestCaseModel {
+
+    private JsonModel jsonModel;
+    private LanguageOption languageOption;
+    private String submissionFolderPath;
+
+    /**
+     * Constructor for creating the instance
+     * @param submissionFolderPath path to the plagiarism folder structure to be tested using Jplag
+     * @param jsonModel the parsed result model needed for the test to be able to match it later in the tests.
+     * @param languageOption the language selection in which the tests take place
+     */
+    public TestCaseModel(String submissionFolderPath, JsonModel jsonModel, LanguageOption languageOption) {
+        this.submissionFolderPath = submissionFolderPath;
+        this.jsonModel = jsonModel;
+        this.languageOption = languageOption;
+    }
+
+    /**
+     * returns the, for the test, current result model that has been persisted in the saved list.
+     * @return ResultJsonModel loaded for the test
+     */
+    public JsonModel getCurrentJsonModel() {
+        return jsonModel;
+    }
+
+    /**
+     * creates the JPlag options for the test run from the values passed in the constructor.
+     * @return current JPlag options for the created object
+     */
+    public JPlagOptions getJPlagOptionsFromCurrentModel() {
+        return new JPlagOptions(new ArrayList<>(Arrays.asList(submissionFolderPath)), new ArrayList<>(), languageOption);
+    }
+}

+ 114 - 0
jplag.endToEndTesting/src/test/java/de/jplag/end_to_end_testing/JavaEndToEndTest.java

@@ -0,0 +1,114 @@
+package de.jplag.end_to_end_testing;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import de.jplag.JPlag;
+import de.jplag.JPlagComparison;
+import de.jplag.JPlagResult;
+import de.jplag.end_to_end_testing.constants.TestDirectoryConstants;
+import de.jplag.end_to_end_testing.helper.JPlagTestSuiteHelper;
+import de.jplag.end_to_end_testing.model.TestCaseModel;
+import de.jplag.exceptions.ExitException;
+import de.jplag.options.LanguageOption;
+
+/**
+ * Main test class for end-to-end testing in the Java language. The test cases aim to detect changes in the detection of
+ * plagiarism in the Java language and to be able to roughly categorize them. The plagiarism is compared with the
+ * original class. The results are compared with the results from previous tests and changes are detected.
+ */
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+class JavaEndToEndTest {
+
+    private JPlagTestSuiteHelper jplagTestSuiteHelper;
+
+    @BeforeAll
+    public void setUp() throws IOException {
+        jplagTestSuiteHelper = new JPlagTestSuiteHelper(LanguageOption.JAVA);
+        assertTrue(TestDirectoryConstants.BASE_PATH_TO_JAVA_RESOURCES_SORTALGO.toFile().exists(), "Could not find base directory!");
+        assertTrue(TestDirectoryConstants.BASE_PATH_TO_JAVA_RESULT_JSON.toFile().isFile(), "Could not find java result json!");
+    }
+
+    @AfterEach
+    public void teardown() throws IOException {
+        // after close the created directories are deleted
+        jplagTestSuiteHelper.clear();
+    }
+
+    /**
+     * Test cases created for the normalization level
+     * @return the classes to be tested with the corresponding identifier
+     */
+    private static Stream<Arguments> normalizationLevelTestArguments() {
+        return Stream.of(Arguments.of((Object) new String[] {"SortAlgo.java", "SortAlgo1.java"}, 0),
+                Arguments.of((Object) new String[] {"SortAlgo.java", "SortAlgo2.java"}, 1),
+                Arguments.of((Object) new String[] {"SortAlgo1.java", "SortAlgo2.java"}, 2));
+    }
+
+    /**
+     * Test cases for the token generation level
+     * @return the classes to be tested with the corresponding identifier
+     */
+    private static Stream<Arguments> tokenGenerationLevelTestArguments() {
+        return Stream.of(Arguments.of((Object) new String[] {"SortAlgo.java", "SortAlgo3.java"}, 0),
+                Arguments.of((Object) new String[] {"SortAlgo.java", "SortAlgo4.java"}, 1),
+                Arguments.of((Object) new String[] {"SortAlgo.java", "SortAlgo4d1.java"}, 2));
+    }
+
+    /**
+     * Inserting comments or empty lines (normalization level) -> id = 0 Changing variable names or function names
+     * (normalization level) -> id = 1 Inserting comments or empty lines (normalization level) -> id = 2
+     * @param testClassNames Plagiarized classes names in the resource directorie which are needed for the test
+     * @param testIdentifier name of the testId to load and identify the stored results
+     * @throws IOException is thrown in case of problems with copying the plagiarism classes
+     * @throws ExitException in case the plagiarism detection with JPlag is preemptively terminated would be of the test.
+     */
+    @ParameterizedTest
+    @MethodSource("normalizationLevelTestArguments")
+    void normalizationLevelTest(String[] testClassNames, int testIdentifier) throws IOException, ExitException {
+        runJPlagTestSuite(testClassNames, testIdentifier);
+    }
+
+    /**
+     * Insertion of unnecessary or changed code lines (token generation) -> id = 0 Changing the program flow (token
+     * generation) (statements and functions must be independent from each other) -> id = 1 Variable declaration at the
+     * beginning of the program (Detecting Source Code Plagiarism [...]) -> id = 2
+     * @param testClassNames Plagiarized classes names in the resource directorie which are needed for the test
+     * @param testIdentifier name of the testId to load and identify the stored results
+     * @throws IOException is thrown in case of problems with copying the plagiarism classes
+     * @throws ExitException in case the plagiarism detection with JPlag is preemptively terminated would be of the test.
+     */
+    @ParameterizedTest
+    @MethodSource("tokenGenerationLevelTestArguments")
+    void tokenGenerationLevelTest(String[] testClassNames, int testIdentifier) throws IOException, ExitException {
+        runJPlagTestSuite(testClassNames, testIdentifier);
+    }
+
+    /**
+     * This method creates the necessary results as well as models for a test run and summarizes them for a comparison.
+     * @param testClassNames Plagiarized classes names in the resource directorie which are needed for the test
+     * @param testIdentifier name of the testId to load and identify the stored results
+     * @throws IOException is thrown in case of problems with copying the plagiarism classes
+     * @throws ExitException in case the plagiarism detection with JPlag is preemptively terminated would be of the test.
+     */
+    private void runJPlagTestSuite(String[] testClassNames, int testIdentifier) throws IOException, ExitException {
+        String functionName = StackWalker.getInstance().walk(stream -> stream.skip(1).findFirst().get()).getMethodName();
+        TestCaseModel testCaseModel = jplagTestSuiteHelper.createNewTestCase(testClassNames, functionName);
+        JPlagResult jplagResult = new JPlag(testCaseModel.getJPlagOptionsFromCurrentModel()).run();
+
+        for (JPlagComparison jPlagComparison : jplagResult.getAllComparisons()) {
+            assertEquals(testCaseModel.getCurrentJsonModel().getResultModelById(testIdentifier).getResultSimilarity(), jPlagComparison.similarity(),
+                    "The JPlag results [similarity] do not match the stored values!");
+        }
+    }
+}

+ 36 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo.java

@@ -0,0 +1,36 @@
+package SortAlgos;
+public class SortAlgo {
+
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		if (n == 1) 
+		{
+			return;
+		}
+
+		for (int i = 0; i < n - 1; i++)
+		{
+			if (arr[i] > arr[i + 1]) 
+			{ 
+				swap(arr, i , i+1);
+			}
+		}
+		BubbleSortRecursion(arr, n - 1);
+	}
+
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		for(int i = arr.length; i > 1 ; i--) {
+			for(int innerCounter = 0; innerCounter < arr.length-1; innerCounter++)
+			{
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					swap(arr, innerCounter, (innerCounter + 1));
+				}
+			}
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		T t = arr[i];
+		arr[i] = arr[j];
+		arr[j] = t;
+	}
+}

+ 63 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1.java

@@ -0,0 +1,63 @@
+package SortAlgos;
+
+/*
+ * Unnecessary comment
+ * Unnecessary comment
+ * Unnecessary comment
+ * */
+public class SortAlgo1 {
+	//Unnecessary comment
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		
+		if (n == 1) 
+		{
+			
+			return;
+			
+		}
+
+		for (int i = 0; i < n - 1; i++)
+		{
+			
+			if (arr[i] > arr[i + 1]) 
+				
+			{ 
+				
+				swap(arr, i , i+1);
+				
+			}
+		}
+		
+		BubbleSortRecursion(arr, n - 1);
+		
+	}
+	
+/*
+	
+	Unnecessary comment
+	*/
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		//Unnecessary comment
+		for(int i = arr.length; i > 1 ; i--) {
+			
+			for(int innerCounter = 0; innerCounter < arr.length-1; innerCounter++)
+				
+			{
+				
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					swap(arr, innerCounter, (innerCounter + 1));
+					
+				}
+			}
+		}
+	}
+
+	////Unnecessary comment
+	private final <T> void swap(T[] arr, int i, int j) {
+		T t = arr[i];
+		
+		arr[i] = arr[j];
+		
+		arr[j] = t;
+	}
+}

+ 79 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1_2.java

@@ -0,0 +1,79 @@
+package SortAlgos;
+
+public class SortAlgo1_2 {
+	//Unnecessary comment
+	public void ChangeFunctionName(Integer changeVariableArray[], int counter) {
+		
+		/*  
+		 * Comment
+		 * */
+		if (counter == 1) 
+		{
+			return;
+		}
+
+		for (int i = 0; i < counter - 1; i++)
+		{
+			
+			
+			if (changeVariableArray[i] > changeVariableArray[i + 1]) 
+			{ 
+				
+				
+				paws(changeVariableArray, i , i+1);
+				
+				
+			}
+		}
+		ChangeFunctionName(changeVariableArray, counter - 1);
+	}
+		
+	/*
+		
+		Unnecessary comment
+		*/
+	public void ChangeFunctionNameWithoutRecursion(Integer arr[]) {
+		//Unnecessary comment
+		for(int otherVariable = arr.length; otherVariable > 1 ; otherVariable--) {
+			
+			
+			for(int counter = 0; counter < arr.length-1; counter++)
+				
+			{
+				if (arr[counter] > arr[counter + 1]) {
+					paws(arr, counter, (counter + 1));
+					
+				}
+				
+			}
+		}
+	}
+		public void BubbleSortWithoutRecursion(Integer arr[]) {
+			//Unnecessary comment
+			for(int i = arr.length; i > 1 ; i--) {
+				
+				for(int innerCounter = 0; innerCounter < arr.length-1; innerCounter++)
+					
+				{
+					
+					if (arr[innerCounter] > arr[innerCounter + 1]) {
+						paws(arr, innerCounter, (innerCounter + 1));
+						
+					}
+					
+				}
+			}
+		}
+
+		////Unnecessary comment
+		private final <T> void paws(T[] arr, int i, int j) {
+			T t = arr[i];
+			//Comment
+			arr[i] = arr[j];
+			//Comment
+			arr[j] = t;
+		}
+}
+
+
+//Comment

+ 81 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1_3.java

@@ -0,0 +1,81 @@
+package SortAlgos;
+
+public class SortAlgo1_3 {
+	
+	private boolean _notUsedBool = false;
+	private int _thisIsNotUsed = 0;
+//Unnecessary comment
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		if (_thisIsNotUsed == 0 && !_notUsedBool)
+			if (n == 1) {
+				return;
+			}
+		/*
+		 * Unnecessary comment
+		 * */
+
+		var tempVar = 0;
+		//Comment
+		var tempVar1 = tempVar + 1;
+		//Comment
+		var tempVar2 = tempVar1 + 1;
+		
+		for (int i = 0; i < n - 1; i++) {
+			
+			/*
+			 * Comment
+			 * Comment
+			 * */
+			if (arr[i] > arr[i + 1]) {
+				
+				
+				swap(arr, i, i + 1);
+				
+			}
+		}
+		
+		
+		//Unnecessary comment
+		BubbleSortRecursion(arr, n - 1);
+	}
+/*
+ * Unnecessary comment
+ * Unnecessary comment
+ * */
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		//Unnecessary comment
+		var tempVar = 0;
+		var tempVar1 = tempVar + 1;
+		tempVar1 = tempVar1 + 1;
+		tempVar = tempVar1 *1;
+		
+		for (int i = arr.length; i > 1; i--) {
+			//Comment
+			for (int innerCounter = 0; innerCounter < arr.length - 1; innerCounter++) {
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					
+					swap(arr, innerCounter, (innerCounter + 1));
+					
+					
+					
+				}
+			}
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		var tempVar1 = 0;
+		var tempVar2 = tempVar1 + 1;
+		tempVar2 = tempVar2 + 1;
+		
+		//Unnecessary comment
+		
+		
+		if (true) {
+			T t = arr[i];
+			arr[i] = arr[j];
+			arr[j] = t;
+			tempVar2 = 0;
+		}
+	}
+}

+ 71 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1_4.java

@@ -0,0 +1,71 @@
+package SortAlgos;
+/*
+ * Unnecessary comment
+ * Unnecessary comment
+ * Unnecessary comment
+ * */
+public class SortAlgo1_4 {
+	
+	/*
+	
+	Unnecessary comment
+	*/
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		//Unnecessary comment
+		for(int i = arr.length; i > 1 ; i--) {
+			
+			for(int innerCounter = 0; innerCounter < arr.length-1; innerCounter++)
+				
+			{
+				
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					swap(arr, innerCounter, (innerCounter + 1));
+					
+				}
+			}
+		}
+	}
+	
+
+	////Unnecessary comment
+	private final <T> void swap(T[] arr, int i, int j) {
+		T t = arr[i];
+		
+		arr[i] = arr[j];
+		
+		arr[j] = t;
+	}
+	
+	//Unnecessary comment
+		public void BubbleSortRecursion(Integer arr[], int n) {
+			
+
+			for (int i = 0; i < n - 1; i++)
+			{
+				
+				if (arr[i] > arr[i + 1]) 
+					
+				{ 
+					
+					swap(arr, i , i+1);
+					
+				}
+			}
+			
+			
+			if (n == 2) {
+				
+				return;
+				
+			} else {
+				
+				
+				BubbleSortRecursion(arr, n - 1);
+				
+			}
+			
+		}
+		
+	
+
+}

+ 91 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1_5.java

@@ -0,0 +1,91 @@
+package SortAlgos;
+/*
+ * Unnecessary comment
+ * Unnecessary comment
+ * Unnecessary comment
+ * */
+public class SortAlgo1_5 {
+	
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		
+		switch (n) {
+		
+		case 1:
+			return;
+			
+			
+			
+		}
+	////Unnecessary comment
+	////Unnecessary comment
+	////Unnecessary comment
+		/*
+		 * 
+		 * 
+		 * 
+		 * */
+		int i = 0;
+		
+		while(i < n-1)
+			
+		{
+			var tempBool = arr[i] > arr[i + 1];
+			
+			if (tempBool) {
+				
+				swap(arr, i, i + 1);
+				
+			}
+			
+			i++;
+		}
+		
+		BubbleSortRecursion(arr, n - 1);
+		
+		
+	}
+////Unnecessary comment
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		
+		
+		int i = arr.length;
+		
+	////Unnecessary comment
+		while(i > 1)
+		{
+		////Unnecessary comment
+			int innerCounter = 0;
+			
+			
+			while(innerCounter < arr.length -1)
+			////Unnecessary comment
+			{
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					
+					
+					swap(arr, innerCounter, (innerCounter + 1));
+					
+				}
+				
+				
+				innerCounter++;
+				
+				
+			}
+			i--;
+		}
+	}
+////Unnecessary comment
+	private final <T> void swap(T[] arr, int i, int j) {
+		
+	////Unnecessary comment////Unnecessary comment
+		T t = arr[i];
+		
+		
+	////Unnecessary comment
+		arr[i] = arr[j];
+		
+	////Unnecessary comment
+		arr[j] = t;
+	}
+}

+ 91 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo1_6.java

@@ -0,0 +1,91 @@
+package SortAlgos;
+
+/*
+ * Unnecessary comment
+ * Unnecessary comment
+ * Unnecessary comment
+ * */
+
+
+public class SortAlgo1_6 {
+	
+	//
+	//
+	//
+	//
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		/*
+		 * Unnecessary comment
+		 * Unnecessary comment
+		 * Unnecessary comment
+		 * */
+		if (n != 1) 
+		{
+			//
+			
+			for (int i = 0; !(i >= (n - 1));)
+			{
+				
+				
+				if (!(arr[i] <= arr[i + 1])) 
+				{ 
+					
+					
+					swap(arr, i , i+1);
+				}
+				
+				
+				i = i + 1;
+			}
+			
+			
+			BubbleSortRecursion(arr, n - 1);
+		}
+		else
+			
+			
+		{
+			return;
+		}
+	}
+
+	/*
+	 * Unnecessary comment
+	 * Unnecessary comment
+	 * Unnecessary comment
+	 * */
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		
+		for(int i = arr.length; !(i < 1) ; i--) {
+			
+			////Comment
+			//Comment
+			//Comment
+			
+			for(int innerCounter = 0; innerCounter < arr.length-1; innerCounter++)
+			{
+				
+				//Comment
+				if (!(arr[innerCounter] <= arr[innerCounter + 1])) {
+					
+					
+					swap(arr, innerCounter, (innerCounter + 1));
+					
+					    
+				}
+			}
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		
+		T t = arr[i];
+		
+		
+		arr[i] = arr[j];
+		
+		arr[j] = t;
+		
+		
+	}
+}

+ 38 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo2.java

@@ -0,0 +1,38 @@
+package SortAlgos;
+
+
+public class SortAlgo2 {
+
+	public void ChangeFunctionName(Integer changeVariableArray[], int counter) {
+		if (counter == 1) 
+		{
+			return;
+		}
+
+		for (int i = 0; i < counter - 1; i++)
+		{
+			if (changeVariableArray[i] > changeVariableArray[i + 1]) 
+			{ 
+				paws(changeVariableArray, i , i+1);
+			}
+		}
+		ChangeFunctionName(changeVariableArray, counter - 1);
+	}
+
+	public void ChangeFunctionNameWithoutRecursion(Integer arr[]) {
+		for(int otherVariable = arr.length; otherVariable > 1 ; otherVariable--) {
+			for(int counter = 0; counter < arr.length-1; counter++)
+			{
+				if (arr[counter] > arr[counter + 1]) {
+					paws(arr, counter, (counter + 1));
+				}
+			}
+		}
+	}
+
+	private final <T> void paws(T[] otherArr, int i, int j) {
+		T t = otherArr[i];
+		otherArr[i] = otherArr[j];
+		otherArr[j] = t;
+	}
+}

+ 44 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo2_5.java

@@ -0,0 +1,44 @@
+package SortAlgos;
+
+public class SortAlgo2_5 {
+	public void ChangeFunctionName(Integer changeVariableArray[], int counter) {
+		switch (counter) {
+		case 1:
+			return;
+		}
+
+		int i = 0;
+		while(i < counter-1)
+		{
+			var tempBool = changeVariableArray[i] > changeVariableArray[i + 1];
+			if (tempBool) {
+				paws(changeVariableArray, i, i + 1);
+			}
+			i++;
+		}
+		
+		ChangeFunctionName(changeVariableArray, counter - 1);
+	}
+
+	public void ChangeFunctionNameWithoutRecursion(Integer arr[]) {
+		int otherVariable = arr.length;
+		while(otherVariable > 1)
+		{
+			int innerCounter = 0;
+			while(innerCounter < arr.length -1)
+			{
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					paws(arr, innerCounter, (innerCounter + 1));
+				}
+				innerCounter++;
+			}
+			otherVariable--;
+		}
+	}
+
+	private final <T> void paws(T[] otherArr, int i, int j) {
+		T t = otherArr[i];
+		otherArr[i] = otherArr[j];
+		otherArr[j] = t;
+	}
+}

+ 47 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo3.java

@@ -0,0 +1,47 @@
+package SortAlgos;
+
+public class SortAlgo3 {
+
+	private int _thisIsNotUsed = 0;
+
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		if (_thisIsNotUsed == 0)
+			if (n == 1) {
+				return;
+			}
+
+		var tempVar = 0;
+		tempVar ++;
+		tempVar = tempVar -1;
+		
+		for (int i = 0; i < n - 1; i++) {
+			if (arr[i] > arr[i + 1]) {
+				swap(arr, i, i + 1);
+			}
+		}
+		BubbleSortRecursion(arr, n - 1);
+	}
+
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		var tempVar = 0;
+		for (int i = arr.length; i > 1; i--) {
+			for (int innerCounter = 0; innerCounter < arr.length - 1; innerCounter++) {
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					swap(arr, innerCounter, (innerCounter + 1));
+				}
+			}
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		var tempVar1 = 0;
+		if (true) {
+			T t = arr[i];
+			arr[i] = arr[j];
+			arr[j] = t;
+			var tempVar2 = 0;
+			tempVar2++;
+			tempVar2 = tempVar2 + 1;
+		}
+	}
+}

+ 59 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo3_5.java

@@ -0,0 +1,59 @@
+package SortAlgos;
+
+public class SortAlgo3_5 {
+	private int _thisIsNotUsed = 0;
+
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		if (_thisIsNotUsed == 0)
+			switch (n) {
+			case 1:
+				return;
+			}
+
+		var tempVar = 0;
+		tempVar++;
+		tempVar = tempVar - 1;
+
+		int i = 0;
+		while(i < n-1)
+		{
+			var tempBool = arr[i] > arr[i + 1];
+			if (tempBool) {
+				swap(arr, i, i + 1);
+			}
+			i++;
+		}
+		
+		BubbleSortRecursion(arr, n - 1);
+	}
+
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		int i = arr.length;
+		var tempVar = 0;
+		
+		while(i > 1)
+		{
+			int innerCounter = 0;
+			while(innerCounter < arr.length -1)
+			{
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					swap(arr, innerCounter, (innerCounter + 1));
+				}
+				innerCounter++;
+			}
+			i--;
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		var tempVar1 = 0;
+		if (true) {
+			T t = arr[i];
+			var tempVar2 = 0;
+			arr[i] = arr[j];
+			arr[j] = t;
+			tempVar2++;
+			tempVar2 = tempVar2 + 1;
+		}
+	}
+}

+ 54 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo3_6.java

@@ -0,0 +1,54 @@
+package SortAlgos;
+
+public class SortAlgo3_6 {
+	private int _thisIsNotUsed = 0;
+
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		if (_thisIsNotUsed == 0) {
+			if (n != 1) {
+
+				var tempVar = 0;
+				tempVar++;
+				tempVar = tempVar - 1;
+
+				for (int i = 0; !(i >= (n - 1));)
+				{
+					if (!(arr[i] <= arr[i + 1])) 
+					{ 
+						swap(arr, i , i+1);
+					}
+					i = i + 1;
+				}
+				
+				BubbleSortRecursion(arr, n - 1);
+			} else {
+				return;
+			}
+
+		}
+	}
+
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		var tempVar = 0;
+		for(int i = arr.length; !(i < 1) ; i--) {
+			for(int innerCounter = 0; innerCounter < arr.length-1; innerCounter++)
+			{
+				if (!(arr[innerCounter] <= arr[innerCounter + 1])) {
+					swap(arr, innerCounter, (innerCounter + 1));
+				}
+			}
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		var tempVar1 = 0;
+		if (true) {
+			T t = arr[i];
+			arr[i] = arr[j];
+			arr[j] = t;
+			var tempVar2 = 0;
+			tempVar2++;
+			tempVar2 = tempVar2 + 1;
+		}
+	}
+}

+ 33 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo4.java

@@ -0,0 +1,33 @@
+package SortAlgos;
+
+public class SortAlgo4 {
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		for (int i = arr.length; i > 1; i--) {
+			for (int innerCounter = 0; innerCounter < arr.length - 1; innerCounter++) {
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					swap(arr, innerCounter, (innerCounter + 1));
+				}
+			}
+		}
+	}
+
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		for (int i = 0; i < n - 1; i++) {
+			if (arr[i] > arr[i + 1]) {
+				swap(arr, i, i + 1);
+			}
+		}
+
+		if (n == 2) {
+			return;
+		} else {
+			BubbleSortRecursion(arr, n - 1);
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		T t = arr[i];
+		arr[i] = arr[j];
+		arr[j] = t;
+	}
+}

+ 40 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo4d1.java

@@ -0,0 +1,40 @@
+public class SortAlgo2 {
+	private int firstCounter;
+	private int arrayLenght;
+	private int swapVarI;
+	private int swapVarJ;
+
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		firstCounter = n;
+		if (firstCounter == 1) {
+			return;
+		}
+
+		for (int i = 0; i < firstCounter - 1; i++) {
+			if (arr[i] > arr[i + 1]) {
+				swap(arr, i, i + 1);
+			}
+		}
+		BubbleSortRecursion(arr, firstCounter - 1);
+	}
+
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		arrayLenght = arr.length;
+		for (int i = arrayLenght; i > 1; i--) {
+			for (int innerCounter = 0; innerCounter < arrayLenght - 1; innerCounter++) {
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					swap(arr, innerCounter, (innerCounter + 1));
+				}
+			}
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		swapVarI = i;
+		swapVarJ = j;
+
+		T t = arr[swapVarI];
+		arr[swapVarI] = arr[swapVarJ];
+		arr[swapVarJ] = t;
+	}
+}

+ 39 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo4d2.java

@@ -0,0 +1,39 @@
+package SortAlgos;
+
+public class SortAlgo4d2 {
+	private int firstCounter,swapVarJ,arrayLenght ,swapVarI;
+
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		firstCounter = n;
+		if (firstCounter == 1) {
+			return;
+		}
+
+		for (int i = 0; i < firstCounter - 1; i++) {
+			if (arr[i] > arr[i + 1]) {
+				swap(arr, i, i + 1);
+			}
+		}
+		BubbleSortRecursion(arr, firstCounter - 1);
+	}
+
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		arrayLenght = arr.length;
+		for (int i = arrayLenght; i > 1; i--) {
+			for (int innerCounter = 0; innerCounter < arrayLenght - 1; innerCounter++) {
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					swap(arr, innerCounter, (innerCounter + 1));
+				}
+			}
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		swapVarI = i;
+		swapVarJ = j;
+
+		T t = arr[swapVarI];
+		arr[swapVarI] = arr[swapVarJ];
+		arr[swapVarJ] = t;
+	}
+}

+ 39 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo4d3.java

@@ -0,0 +1,39 @@
+package SortAlgos;
+
+public class SortAlgo4d3 {
+	private int firstCounterAndArrayLenghtAndswapVarJ ,swapVarI;
+
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		firstCounterAndArrayLenghtAndswapVarJ = n;
+		if (firstCounterAndArrayLenghtAndswapVarJ == 1) {
+			return;
+		}
+
+		for (int i = 0; i < firstCounterAndArrayLenghtAndswapVarJ - 1; i++) {
+			if (arr[i] > arr[i + 1]) {
+				swap(arr, i, i + 1);
+			}
+		}
+		BubbleSortRecursion(arr, firstCounterAndArrayLenghtAndswapVarJ - 1);
+	}
+
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		firstCounterAndArrayLenghtAndswapVarJ = arr.length;
+		for (int i = firstCounterAndArrayLenghtAndswapVarJ; i > 1; i--) {
+			for (int innerCounter = 0; innerCounter < firstCounterAndArrayLenghtAndswapVarJ - 1; innerCounter++) {
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					swap(arr, innerCounter, (innerCounter + 1));
+				}
+			}
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		swapVarI = i;
+		firstCounterAndArrayLenghtAndswapVarJ = j;
+
+		T t = arr[swapVarI];
+		arr[swapVarI] = arr[firstCounterAndArrayLenghtAndswapVarJ];
+		arr[firstCounterAndArrayLenghtAndswapVarJ] = t;
+	}
+}

+ 44 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo5.java

@@ -0,0 +1,44 @@
+package SortAlgos;
+
+public class SortAlgo5 {
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		switch (n) {
+		case 1:
+			return;
+		}
+
+		int i = 0;
+		while(i < n-1)
+		{
+			var tempBool = arr[i] > arr[i + 1];
+			if (tempBool) {
+				swap(arr, i, i + 1);
+			}
+			i++;
+		}
+		
+		BubbleSortRecursion(arr, n - 1);
+	}
+
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		int i = arr.length;
+		while(i > 1)
+		{
+			int innerCounter = 0;
+			while(innerCounter < arr.length -1)
+			{
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					swap(arr, innerCounter, (innerCounter + 1));
+				}
+				innerCounter++;
+			}
+			i--;
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		T t = arr[i];
+		arr[i] = arr[j];
+		arr[j] = t;
+	}
+}

+ 45 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo6.java

@@ -0,0 +1,45 @@
+package SortAlgos;
+
+public class SortAlgo6 {
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		if (n != 1) 
+		{
+			for (int i = 0; !(i >= (n - 1));)
+			{
+				if (!(arr[i] <= arr[i + 1])) 
+				{ 
+					swap(arr, i , i+1);
+				}
+				i = i + 1;
+			}
+			BubbleSortRecursion(arr, n - 1);
+		}
+		else
+		{
+			return;
+		}
+	}
+
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		for(int i = arr.length; !(i < 1) ; i--) {
+			for(int innerCounter = 0; innerCounter < arr.length-1; innerCounter++)
+			{
+				if (!(arr[innerCounter] <= arr[innerCounter + 1])) {
+					swap(arr, innerCounter, (innerCounter + 1));
+				}
+			}
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		var tempVar1 = 0;
+		if (true) {
+			T t = arr[i];
+			arr[i] = arr[j];
+			arr[j] = t;
+			var tempVar2 = 0;
+			tempVar2++;
+			tempVar2 = tempVar2 + 1;
+		}
+	}
+}

+ 33 - 0
jplag.endToEndTesting/src/test/resources/java/sortAlgo/SortAlgo7.java

@@ -0,0 +1,33 @@
+package SortAlgos;
+/*
+ * No able changes for (Splitting and merging statements)
+ * */
+public class SortAlgo7 {
+	public void BubbleSortRecursion(Integer arr[], int n) {
+		if (n == 1)
+			return;
+
+		for (int i = 0; i < n - 1; i++) {
+			if (arr[i] > arr[i + 1]) {
+				swap(arr, i, i + 1);
+			}
+		}
+		BubbleSortRecursion(arr, n - 1);
+	}
+
+	public void BubbleSortWithoutRecursion(Integer arr[]) {
+		for (int i = arr.length; i > 1; i--) {
+			for (int innerCounter = 0; innerCounter < arr.length - 1; innerCounter++) {
+				if (arr[innerCounter] > arr[innerCounter + 1]) {
+					swap(arr, innerCounter, (innerCounter + 1));
+				}
+			}
+		}
+	}
+
+	private final <T> void swap(T[] arr, int i, int j) {
+		T t = arr[i];
+		arr[i] = arr[j];
+		arr[j] = t;
+	}
+}

+ 36 - 0
jplag.endToEndTesting/src/test/resources/results/JavaResult.json

@@ -0,0 +1,36 @@
+[
+  {
+    "function_name": "normalizationLevelTest",
+    "test_results": [
+      {
+        "result_similarity": 100,
+        "test_identifier": 0
+      },
+      {
+        "result_similarity": 100,
+        "test_identifier": 1
+      },
+      {
+        "result_similarity": 100,
+        "test_identifier": 2
+      }
+    ]
+  },
+  {
+    "function_name": "tokenGenerationLevelTest",
+    "test_results": [
+      {
+        "result_similarity": 64.0,
+        "test_identifier": 0
+      },
+      {
+        "result_similarity": 73.04348,
+        "test_identifier": 1
+      },
+      {
+        "result_similarity": 73.94958,
+        "test_identifier": 2
+      }
+    ]
+  }
+]

+ 14 - 1
pom.xml

@@ -76,6 +76,7 @@
         <maven.compiler.target>17</maven.compiler.target>
         <spotless.version>2.24.0</spotless.version>
         <slf4j.version>1.7.36</slf4j.version>
+        <junit.version>5.9.0</junit.version>
 
         <antlr2.version>2.7.7</antlr2.version>
         <antlr3.version>3.5</antlr3.version>
@@ -192,6 +193,11 @@
                 <artifactId>frontend-testutils</artifactId>
                 <version>${revision}</version>
             </dependency>
+            <dependency>
+                <groupId>de.jplag</groupId>
+                <artifactId>endToEndTesting</artifactId>
+                <version>${revision}</version>
+            </dependency>
             <dependency>
                 <groupId>de.jplag</groupId>
                 <artifactId>jplag</artifactId>
@@ -204,7 +210,13 @@
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-engine</artifactId>
-            <version>5.9.0</version>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-params</artifactId>
+            <version>${junit.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -460,6 +472,7 @@
                 <module>jplag.frontend.rlang</module>
                 <module>jplag.frontend.scheme</module>
                 <module>jplag.frontend.text</module>
+                <module>jplag.endToEndTesting</module>
                 <module>jplag</module>
                 <module>jplag.cli</module>
             </modules>