-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
End To End Test Suite extended #583
Merged
dfuchss
merged 61 commits into
jplag:master
from
SuyDesignz:feature/endToEndTestingComparativeValueExtension
Aug 26, 2022
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
8089a0a
comparative values expanded
SuyDesignz 36bdb44
Merge branch 'feature/EndToEndTesting' into feature/endToEndTestingCo…
SuyDesignz 6616335
adding language specific mapper for the json result paths
SuyDesignz ab47b27
changed static identifier to hashCode. Resources loading made dynamic…
SuyDesignz 36db863
implemented save temporary results with jackson json
SuyDesignz 55191a9
Merge branch 'feature/EndToEndTesting' into feature/endToEndTestingCo…
SuyDesignz 0ec54ed
Merge branch 'feature/EndToEndTesting' into feature/endToEndTestingCo…
SuyDesignz 5485b5f
saving the temporary json results for comparison implemented
SuyDesignz 207b28f
change test identifier from an int to string as SHA256 hash
SuyDesignz f511e61
mapper implemented for the paths
SuyDesignz 373342e
implementation of storage testing
SuyDesignz 4f633d6
Merge remote-tracking branch 'origin/master' into feature/endToEndTes…
SuyDesignz 87b1133
insert comments and documentation for functions
SuyDesignz 72e4042
Add comments
SuyDesignz 19b9547
Code cleaned up and comments written. New mapper class implemented fo…
SuyDesignz f418266
removed unused code and functions
SuyDesignz 7e06ab4
ReadMe file extended by "how to add new languages".
SuyDesignz a5833bd
Merge branch 'endToEndComparativeValueExtension' into feature/endToEn…
SuyDesignz ef789b7
fixed README file
SuyDesignz 9249ef8
Changing the json format without DefaultPrettyPrinter() to exclude li…
SuyDesignz 71a81e9
fixed formatting
SuyDesignz 4f0080f
changed identifier to tested plagiatism file name
SuyDesignz 7823d89
removed sonar cloud RELIABILITY Bugs
SuyDesignz c790015
Merge branch 'master' into feature/endToEndTestingComparativeValueExt…
SuyDesignz 4fc1973
removed code smells detected from sonarcloud
SuyDesignz 2f368a7
changed mapper class from HashMap to EnumMap
SuyDesignz 280cec0
removed unused code and added commants for better maintainability
SuyDesignz cd0ed1b
implemented DynamicTests for OverAllTestCase
SuyDesignz 4cef78e
Rework started over complete endToEndTestSuite
SuyDesignz 3af1e95
added temporary save json and read json to module
SuyDesignz 1a750b8
Merge remote-tracking branch 'origin/master' into feature/endToEndTes…
SuyDesignz e76365e
removed "result_" from json object
SuyDesignz d74b362
compare with results implemented.
SuyDesignz b9d6f51
cleaned code
SuyDesignz 8120219
created comments for new classes and functions
SuyDesignz 2be5a55
removed code smells and Bugs from code detected by sonarcloud
SuyDesignz 96a4b47
changed code format
SuyDesignz 2203e77
Removal of unused code and revision of the naming convention
SuyDesignz 2fcb740
Changed testRun to add compaire errors to the list instead of assertE…
SuyDesignz 9a64147
changed code formatting
SuyDesignz 77e3ad4
removed record constructors and fixed jackson deserialization
SuyDesignz 0fe94b1
added comments for public and private classes
SuyDesignz f38b95b
removed unnecessary code
SuyDesignz d0a1699
Merge remote-tracking branch 'origin/master' into feature/endToEndTes…
SuyDesignz 25f7a09
removed code-smells and changed dokumentation in README.md file for n…
SuyDesignz 4c23475
added comment
SuyDesignz 893b264
removed code-smell
SuyDesignz 9d4a120
Made name changes and removed code-smells
SuyDesignz f12b6b1
changed return type for helper function
SuyDesignz 8a1fee7
Update jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testin…
SuyDesignz c3c7f5d
Update jplag.endToEndTesting/src/test/java/de/jplag/end_to_end_testin…
SuyDesignz 4c24b9d
Update jplag.endToEndTesting/src/test/java/de/jplag/end_to_end_testin…
SuyDesignz 8b24abd
Update jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testin…
SuyDesignz 718c94b
Update jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testin…
SuyDesignz d51f7ac
Change Proposed Adjustments. Improvement of the code and readability
SuyDesignz a5084b5
Merge remote-tracking branch 'origin/master' into feature/endToEndTes…
SuyDesignz bb7316b
Modified language options class included in the endToEnd testing suite
SuyDesignz 963f341
Changed README file
SuyDesignz 4e87efb
fixed result path
SuyDesignz b657b4e
removed code smells detected by sonarcloud
SuyDesignz 1efbf81
Functions improved and comments adjusted
SuyDesignz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
jplag.endToEndTesting/src/main/java/de/jplag/end_to_end_testing/helper/FileHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
package de.jplag.end_to_end_testing.helper; | ||
|
||
import java.io.File; | ||
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.Collection; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
|
||
import de.jplag.end_to_end_testing.constants.TestDirectoryConstants; | ||
|
||
/** | ||
* Helper class to perform all necessary operations or functions on files or folders. | ||
*/ | ||
public class FileHelper { | ||
|
||
private FileHelper() { | ||
// private constructor to prevent instantiation | ||
} | ||
|
||
/** | ||
* Merges all contained filenames together without extension | ||
* @param files whose names are to be merged | ||
* @return merged filenames | ||
*/ | ||
public static String getEnclosedFileNamesFromCollection(Collection<File> files) { | ||
|
||
return files.stream().map(File::getName).map(fileName -> fileName.substring(0, fileName.lastIndexOf('.'))).collect(Collectors.joining()); | ||
} | ||
|
||
/** | ||
* Load all possible languages in resource path | ||
* @param directoryNames folder names for which the language options should be listed. | ||
* @return list of all LanguageOptions included in the resource path | ||
*/ | ||
public static List<String> getLanguageOptionsFromPath(String[] directoryNames) { | ||
return Arrays.stream(directoryNames).map(language -> language).filter(Objects::nonNull).toList(); | ||
} | ||
|
||
/** | ||
* @param directorieRoot path from which all folders should be loaded | ||
* @return all folders found in the specified path | ||
*/ | ||
public static String[] getAllDirectoriesInPath(Path directorieRoot) { | ||
return directorieRoot.toFile().list((dir, name) -> new File(dir, name).isDirectory()); | ||
} | ||
|
||
/** | ||
* Copies the passed filenames to a temporary path to use them in the tests | ||
* @param classNames for which the test case is to be created | ||
* @return paths created to the test submissions | ||
* @throws IOException Exception can be thrown in cases that involve reading, copying or locating files. | ||
*/ | ||
public static String[] createNewTestCaseDirectory(String[] classNames) throws IOException { | ||
// Copy the resources data to the temporary path | ||
String[] returnSubmissionPath = new String[classNames.length]; | ||
for (int counter = 0; counter < classNames.length; counter++) { | ||
Path originalPath = Path.of(classNames[counter]); | ||
returnSubmissionPath[counter] = Path | ||
.of(TestDirectoryConstants.TEMPORARY_SUBMISSION_DIRECTORY_NAME.toString(), "submission" + (counter + 1)).toAbsolutePath() | ||
.toString(); | ||
Path copyPath = Path.of(TestDirectoryConstants.TEMPORARY_SUBMISSION_DIRECTORY_NAME.toString(), "submission" + (counter + 1), | ||
originalPath.getFileName().toString()); | ||
|
||
File directory = new File(copyPath.toString()); | ||
if (!directory.exists()) { | ||
directory.mkdirs(); | ||
} | ||
Files.copy(originalPath, copyPath, StandardCopyOption.REPLACE_EXISTING); | ||
} | ||
return returnSubmissionPath; | ||
} | ||
|
||
/** | ||
* Delete directory with including files | ||
* @param folder Path to a folder or file to be deleted. This happens recursively to the path | ||
* @throws IOException if an I/O error occurs | ||
*/ | ||
public static void deleteCopiedFiles(File folder) throws IOException { | ||
if (!folder.exists()) { | ||
return; | ||
} | ||
File[] files = folder.listFiles(); | ||
if (files == null) { // some JVMs return null for empty dirs | ||
return; | ||
} | ||
for (File file : files) { | ||
if (file.isDirectory()) { | ||
deleteCopiedFiles(file); | ||
} else { | ||
Files.delete(file.toPath()); | ||
} | ||
} | ||
Files.delete(folder.toPath()); | ||
} | ||
|
||
/** | ||
* Creates directory if it dose not exist | ||
* @param directory to be created | ||
* @throws IOException if the directory could not be created | ||
*/ | ||
public static void createDirectoryIfItDoesNotExist(File directory) throws IOException { | ||
if (!directory.exists() && !directory.mkdirs()) { | ||
throw new IOException(createNewIOExceptionStringForFileOrFOlderCreation(directory)); | ||
} | ||
} | ||
|
||
/** | ||
* Creates file if it dose not exist | ||
* @param file to be created | ||
* @throws IOException if the file could not be created | ||
*/ | ||
public static void createFileIfItDoesNotExist(File file) throws IOException { | ||
if (!file.exists() && !file.createNewFile()) { | ||
throw new IOException(createNewIOExceptionStringForFileOrFOlderCreation(file)); | ||
} | ||
} | ||
|
||
/** | ||
* @param resourcenPaths list of paths that lead to test resources | ||
* @return all filenames contained in the paths | ||
*/ | ||
public static String[] loadAllTestFileNames(Path resourcenPaths) { | ||
var files = resourcenPaths.toFile().listFiles(); | ||
String[] fileNames = new String[files.length]; | ||
for (int i = 0; i < files.length; i++) { | ||
fileNames[i] = files[i].getName(); | ||
} | ||
return fileNames; | ||
} | ||
|
||
/** | ||
* @param file for which the exception text is to be created | ||
* @return exception text for the specified file | ||
*/ | ||
private static String createNewIOExceptionStringForFileOrFOlderCreation(File file) { | ||
return "The file/folder at the location [" + file.toString() + "] could not be created!"; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.