Skip to content

Commit

Permalink
Add tests for the parse and compare hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
olmokramer committed Sep 15, 2023
1 parent 40364e7 commit 1ed2cc6
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions core/src/test/java/de/jplag/HooksTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package de.jplag;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.concurrent.atomic.AtomicInteger;

import org.junit.jupiter.api.Test;

import de.jplag.exceptions.ExitException;

public class HooksTest extends TestBase {
private static final String ROOT = "NoDuplicate";
private static final int SUBMISSION_COUNT = 3;
private static final int COMPARISON_COUNT = 3;

@Test
void testPreParseHook() throws ExitException {
final AtomicInteger totalSubmissions = new AtomicInteger(0);
runJPlag(ROOT, it -> it.withPreParseHook(submissions -> {
totalSubmissions.set(submissions.size());
}));
assertEquals(SUBMISSION_COUNT, totalSubmissions.get());
}

@Test
void testParseHook() throws ExitException {
final AtomicInteger totalSubmissions = new AtomicInteger(0);
runJPlag(ROOT, it -> it.withParseHook(submission -> {
totalSubmissions.incrementAndGet();
}));
assertEquals(SUBMISSION_COUNT, totalSubmissions.get());
}

@Test
void testPreCompareHook() throws ExitException {
final AtomicInteger totalComparisons = new AtomicInteger(0);
runJPlag(ROOT, it -> it.withPreCompareHook(comparisons -> {
totalComparisons.incrementAndGet();
}));
assertEquals(COMPARISON_COUNT, totalComparisons.get());
}

@Test
void testCompareHook() throws ExitException {
final AtomicInteger totalComparisons = new AtomicInteger(0);
runJPlag(ROOT, it -> it.withCompareHook(comparison -> {
totalComparisons.incrementAndGet();
}));
assertEquals(COMPARISON_COUNT, totalComparisons.get());
}
}

0 comments on commit 1ed2cc6

Please sign in to comment.