LegacyBaseCodeParallelComparisonTest.java 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package de.jplag;
  2. import static org.junit.jupiter.api.Assertions.assertEquals;
  3. import static org.junit.jupiter.api.Assertions.assertThrows;
  4. import java.util.List;
  5. import org.junit.jupiter.api.Test;
  6. import de.jplag.exceptions.ExitException;
  7. /**
  8. * Tests for the legacy behaviour of the String-based base code initializer.
  9. */
  10. @Deprecated(since = "4.0.0", forRemoval = true)
  11. class LegacyBaseCodeParallelComparisonTest extends ParallelComparisonTest {
  12. @Test
  13. void testMultiRootDirSeparateBasecode() throws ExitException {
  14. String basecodePath = getBasePath("basecode-base");
  15. List<String> paths = List.of(getBasePath("basecode"), getBasePath("SimpleDuplicate")); // 3 + 2 submissions.
  16. JPlagResult result = runJPlag(paths, it -> it.withBaseCodeSubmissionName(basecodePath));
  17. assertEquals(5, result.getNumberOfSubmissions());
  18. }
  19. @Test
  20. void testMultiRootDirBasecodeInSubmissionDir() throws ExitException {
  21. String basecodePath = getBasePath("basecode", "base");
  22. List<String> paths = List.of(getBasePath("basecode"), getBasePath("SimpleDuplicate")); // 2 + 2 submissions.
  23. JPlagResult result = runJPlag(paths, it -> it.withBaseCodeSubmissionName(basecodePath));
  24. assertEquals(4, result.getNumberOfSubmissions());
  25. }
  26. @Test
  27. void testMultiRootDirBasecodeName() {
  28. List<String> paths = List.of(getBasePath("basecode"), getBasePath("SimpleDuplicate"));
  29. String basecodePath = "base"; // Should *not* find basecode/base
  30. assertThrows(IllegalArgumentException.class, () -> runJPlag(paths, it -> it.withBaseCodeSubmissionName(basecodePath)));
  31. }
  32. @Test
  33. void testBasecodeInOldDirectory() throws ExitException {
  34. String basecodePath = getBasePath("basecode", "base");
  35. List<String> newDirectories = List.of(getBasePath("SimpleDuplicate")); // 2 submissions
  36. List<String> oldDirectories = List.of(getBasePath("basecode")); // 3 - 1 submissions
  37. JPlagResult result = runJPlag(newDirectories, oldDirectories, it -> it.withBaseCodeSubmissionName(basecodePath));
  38. int numberOfExpectedComparison = 1 + 2 * 2;
  39. assertEquals(numberOfExpectedComparison, result.getAllComparisons().size());
  40. }
  41. }