|
|
@@ -16,28 +16,25 @@ public class BaseCodeTest extends TestBase {
|
|
|
|
|
|
@Test
|
|
|
void testBasecodeUserSubmissionComparison() throws ExitException {
|
|
|
- JPlagResult result = runJPlag("basecode", it -> it.withBaseCodeSubmissionName("base"));
|
|
|
+ JPlagResult result = runJPlag("basecode",
|
|
|
+ it -> it.withBaseCodeSubmissionDirectory(new File(it.submissionDirectories().iterator().next(), "base")));
|
|
|
verifyResults(result);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void testTinyBasecode() {
|
|
|
- assertThrows(BasecodeException.class, () -> runJPlag("TinyBasecode", it -> it.withBaseCodeSubmissionName("base")));
|
|
|
+ assertThrows(BasecodeException.class, () -> runJPlag("TinyBasecode",
|
|
|
+ it -> it.withBaseCodeSubmissionDirectory(new File(it.submissionDirectories().iterator().next(), "base"))));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void testEmptySubmission() throws ExitException {
|
|
|
- JPlagResult result = runJPlag("emptysubmission", it -> it.withBaseCodeSubmissionName("base"));
|
|
|
+ JPlagResult result = runJPlag("emptysubmission",
|
|
|
+ it -> it.withBaseCodeSubmissionDirectory(new File(it.submissionDirectories().iterator().next(), "base")));
|
|
|
verifyResults(result);
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
- void testAutoTrimFileSeparators() throws ExitException {
|
|
|
- JPlagResult result = runJPlag("basecode", it -> it.withBaseCodeSubmissionName(File.separator + "base" + File.separator));
|
|
|
- verifyResults(result);
|
|
|
- }
|
|
|
-
|
|
|
- private void verifyResults(JPlagResult result) {
|
|
|
+ protected void verifyResults(JPlagResult result) {
|
|
|
assertEquals(2, result.getNumberOfSubmissions());
|
|
|
assertEquals(1, result.getAllComparisons().size());
|
|
|
assertEquals(1, result.getAllComparisons().get(0).matches().size());
|
|
|
@@ -47,7 +44,7 @@ public class BaseCodeTest extends TestBase {
|
|
|
|
|
|
@Test
|
|
|
void testBasecodePathComparison() throws ExitException {
|
|
|
- JPlagResult result = runJPlag("basecode", it -> it.withBaseCodeSubmissionName(getBasePath("basecode-base")));
|
|
|
+ JPlagResult result = runJPlag("basecode", it -> it.withBaseCodeSubmissionDirectory(new File(BASE_PATH, "basecode-base")));
|
|
|
assertEquals(3, result.getNumberOfSubmissions()); // "basecode/base" is now a user submission.
|
|
|
}
|
|
|
|
|
|
@@ -58,12 +55,8 @@ public class BaseCodeTest extends TestBase {
|
|
|
|
|
|
@Test
|
|
|
void testInvalidBasecode() {
|
|
|
- assertThrows(BasecodeException.class, () -> runJPlag("basecode", it -> it.withBaseCodeSubmissionName("WrongBasecode")));
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- void testBasecodeUserSubmissionWithDots() {
|
|
|
- assertThrows(IllegalArgumentException.class, () -> runJPlag("basecode", it -> it.withBaseCodeSubmissionName("base.ext")));
|
|
|
+ assertThrows(BasecodeException.class, () -> runJPlag("basecode",
|
|
|
+ it -> it.withBaseCodeSubmissionDirectory(new File(it.submissionDirectories().iterator().next(), "WrongBasecode"))));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -72,7 +65,8 @@ public class BaseCodeTest extends TestBase {
|
|
|
@Test
|
|
|
void testSubdirectoryGlobalBasecode() throws ExitException {
|
|
|
String basecode = getBasePath("SubdirectoryBase");
|
|
|
- JPlagResult result = runJPlag("SubdirectoryDuplicate", it -> it.withSubdirectoryName("src").withBaseCodeSubmissionName(basecode));
|
|
|
+ JPlagResult result = runJPlag("SubdirectoryDuplicate",
|
|
|
+ it -> it.withSubdirectoryName("src").withBaseCodeSubmissionDirectory(new File(basecode)));
|
|
|
verifySimpleSubdirectoryDuplicate(result, 3, 3);
|
|
|
}
|
|
|
|
|
|
@@ -81,11 +75,12 @@ public class BaseCodeTest extends TestBase {
|
|
|
*/
|
|
|
@Test
|
|
|
void testSubdirectoryLocalBasecode() throws ExitException {
|
|
|
- JPlagResult result = runJPlag("SubdirectoryDuplicate", it -> it.withSubdirectoryName("src").withBaseCodeSubmissionName("Base"));
|
|
|
+ JPlagResult result = runJPlag("SubdirectoryDuplicate",
|
|
|
+ it -> it.withSubdirectoryName("src").withBaseCodeSubmissionDirectory(new File(it.submissionDirectories().iterator().next(), "Base")));
|
|
|
verifySimpleSubdirectoryDuplicate(result, 2, 1);
|
|
|
}
|
|
|
|
|
|
- private void verifySimpleSubdirectoryDuplicate(JPlagResult result, int submissions, int comparisons) {
|
|
|
+ protected void verifySimpleSubdirectoryDuplicate(JPlagResult result, int submissions, int comparisons) {
|
|
|
result.getSubmissions().getSubmissions().forEach(this::hasSubdirectoryRoot);
|
|
|
hasSubdirectoryRoot(result.getSubmissions().getBaseCode());
|
|
|
|
|
|
@@ -93,7 +88,7 @@ public class BaseCodeTest extends TestBase {
|
|
|
assertEquals(comparisons, result.getAllComparisons().size());
|
|
|
assertEquals(1, result.getAllComparisons().get(0).matches().size());
|
|
|
assertEquals(1, result.getSimilarityDistribution()[3]);
|
|
|
- assertEquals(62.07, result.getAllComparisons().get(0).similarity(), DELTA);
|
|
|
+ assertEquals(0.6207, result.getAllComparisons().get(0).similarity(), DELTA);
|
|
|
}
|
|
|
|
|
|
private void hasSubdirectoryRoot(Submission submission) {
|