diff --git a/src/test/java/diffutils/DiffUtilsTest.java b/src/test/java/diffutils/DiffUtilsTest.java index 3db84ac..c445704 100644 --- a/src/test/java/diffutils/DiffUtilsTest.java +++ b/src/test/java/diffutils/DiffUtilsTest.java @@ -7,6 +7,7 @@ import difflib.patch.ChangeDelta; import difflib.patch.Patch; import difflib.patch.DeleteDelta; import difflib.*; +import difflib.algorithm.DiffException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -19,7 +20,7 @@ import org.junit.Test; public class DiffUtilsTest { @Test - public void testDiff_Insert() { + public void testDiff_Insert() throws DiffException { final Patch patch = DiffUtils.diff(Arrays.asList("hhh"), Arrays. asList("hhh", "jjj", "kkk")); assertNotNull(patch); @@ -31,7 +32,7 @@ public class DiffUtilsTest { } @Test - public void testDiff_Delete() { + public void testDiff_Delete() throws DiffException { final Patch patch = DiffUtils.diff(Arrays.asList("ddd", "fff", "ggg"), Arrays. asList("ggg")); assertNotNull(patch); @@ -43,7 +44,7 @@ public class DiffUtilsTest { } @Test - public void testDiff_Change() { + public void testDiff_Change() throws DiffException { final List changeTest_from = Arrays.asList("aaa", "bbb", "ccc"); final List changeTest_to = Arrays.asList("aaa", "zzz", "ccc"); @@ -57,14 +58,14 @@ public class DiffUtilsTest { } @Test - public void testDiff_EmptyList() { + public void testDiff_EmptyList() throws DiffException { final Patch patch = DiffUtils.diff(new ArrayList<>(), new ArrayList<>()); assertNotNull(patch); assertEquals(0, patch.getDeltas().size()); } @Test - public void testDiff_EmptyListWithNonEmpty() { + public void testDiff_EmptyListWithNonEmpty() throws DiffException { final Patch patch = DiffUtils.diff(new ArrayList<>(), Arrays.asList("aaa")); assertNotNull(patch); assertEquals(1, patch.getDeltas().size()); @@ -73,7 +74,7 @@ public class DiffUtilsTest { } @Test - public void testDiffInline() { + public void testDiffInline() throws DiffException { final Patch patch = DiffUtils.diffInline("", "test"); assertEquals(1, patch.getDeltas().size()); assertTrue(patch.getDeltas().get(0) instanceof InsertDelta); @@ -83,7 +84,7 @@ public class DiffUtilsTest { } @Test - public void testDiffInline2() { + public void testDiffInline2() throws DiffException { final Patch patch = DiffUtils.diffInline("es", "fest"); assertEquals(2, patch.getDeltas().size()); assertTrue(patch.getDeltas().get(0) instanceof InsertDelta); diff --git a/src/test/java/diffutils/GenerateUnifiedDiffTest.java b/src/test/java/diffutils/GenerateUnifiedDiffTest.java index 48b507c..4f2e2b8 100644 --- a/src/test/java/diffutils/GenerateUnifiedDiffTest.java +++ b/src/test/java/diffutils/GenerateUnifiedDiffTest.java @@ -1,6 +1,7 @@ package diffutils; import difflib.DiffUtils; +import difflib.algorithm.DiffException; import difflib.patch.Patch; import difflib.patch.PatchFailedException; import java.io.BufferedReader; @@ -42,7 +43,7 @@ public class GenerateUnifiedDiffTest { } @Test - public void testGenerateUnified() { + public void testGenerateUnified() throws DiffException { List origLines = fileToLines(TestConstants.MOCK_FOLDER + "original.txt"); List revLines = fileToLines(TestConstants.MOCK_FOLDER + "revised.txt"); @@ -50,7 +51,7 @@ public class GenerateUnifiedDiffTest { } @Test - public void testGenerateUnifiedWithOneDelta() { + public void testGenerateUnifiedWithOneDelta() throws DiffException { List origLines = fileToLines(TestConstants.MOCK_FOLDER + "one_delta_test_original.txt"); List revLines = fileToLines(TestConstants.MOCK_FOLDER + "one_delta_test_revised.txt"); @@ -58,7 +59,7 @@ public class GenerateUnifiedDiffTest { } @Test - public void testGenerateUnifiedDiffWithoutAnyDeltas() { + public void testGenerateUnifiedDiffWithoutAnyDeltas() throws DiffException { List test = Arrays.asList("abc"); Patch patch = DiffUtils.diff(test, test); DiffUtils.generateUnifiedDiff("abc", "abc", test, patch, 0); @@ -80,14 +81,14 @@ public class GenerateUnifiedDiffTest { * Issue 12 */ @Test - public void testPatchWithNoDeltas() { + public void testPatchWithNoDeltas() throws DiffException { final List lines1 = fileToLines(TestConstants.MOCK_FOLDER + "issue11_1.txt"); final List lines2 = fileToLines(TestConstants.MOCK_FOLDER + "issue11_2.txt"); verify(lines1, lines2, "issue11_1.txt", "issue11_2.txt"); } @Test - public void testDiff5() { + public void testDiff5() throws DiffException { final List lines1 = fileToLines(TestConstants.MOCK_FOLDER + "5A.txt"); final List lines2 = fileToLines(TestConstants.MOCK_FOLDER + "5B.txt"); verify(lines1, lines2, "5A.txt", "5B.txt"); @@ -97,7 +98,7 @@ public class GenerateUnifiedDiffTest { * Issue 19 */ @Test - public void testDiffWithHeaderLineInText() { + public void testDiffWithHeaderLineInText() throws DiffException { List original = new ArrayList<>(); List revised = new ArrayList<>(); @@ -119,7 +120,7 @@ public class GenerateUnifiedDiffTest { } private void verify(List origLines, List revLines, - String originalFile, String revisedFile) { + String originalFile, String revisedFile) throws DiffException { Patch patch = DiffUtils.diff(origLines, revLines); List unifiedDiff = DiffUtils.generateUnifiedDiff(originalFile, revisedFile, origLines, patch, 10); diff --git a/src/test/java/diffutils/patch/PatchTest.java b/src/test/java/diffutils/patch/PatchTest.java index ce2d8b7..9919176 100644 --- a/src/test/java/diffutils/patch/PatchTest.java +++ b/src/test/java/diffutils/patch/PatchTest.java @@ -1,6 +1,7 @@ package diffutils.patch; import difflib.DiffUtils; +import difflib.algorithm.DiffException; import difflib.patch.Patch; import difflib.patch.PatchFailedException; import java.util.Arrays; @@ -12,7 +13,7 @@ import org.junit.Test; public class PatchTest { @Test - public void testPatch_Insert() { + public void testPatch_Insert() throws DiffException { final List insertTest_from = Arrays.asList("hhh"); final List insertTest_to = Arrays.asList("hhh", "jjj", "kkk", "lll"); @@ -25,7 +26,7 @@ public class PatchTest { } @Test - public void testPatch_Delete() { + public void testPatch_Delete() throws DiffException { final List deleteTest_from = Arrays.asList("ddd", "fff", "ggg", "hhh"); final List deleteTest_to = Arrays.asList("ggg"); @@ -38,7 +39,7 @@ public class PatchTest { } @Test - public void testPatch_Change() { + public void testPatch_Change() throws DiffException { final List changeTest_from = Arrays.asList("aaa", "bbb", "ccc", "ddd"); final List changeTest_to = Arrays.asList("aaa", "bxb", "cxc", "ddd"); diff --git a/src/test/java/diffutils/rows/DiffRowGeneratorTest.java b/src/test/java/diffutils/rows/DiffRowGeneratorTest.java index 9c88d82..effdc8b 100644 --- a/src/test/java/diffutils/rows/DiffRowGeneratorTest.java +++ b/src/test/java/diffutils/rows/DiffRowGeneratorTest.java @@ -1,5 +1,6 @@ package diffutils.rows; +import difflib.algorithm.DiffException; import difflib.text.DiffRow; import difflib.text.DiffRowGenerator; import java.util.Arrays; @@ -11,7 +12,7 @@ import org.junit.Test; public class DiffRowGeneratorTest { @Test - public void testGenerator_Default() { + public void testGenerator_Default() throws DiffException { String first = "anything \n \nother"; String second = "anything\n\nother"; @@ -25,7 +26,7 @@ public class DiffRowGeneratorTest { } @Test - public void testGenerator_InlineDiff() { + public void testGenerator_InlineDiff() throws DiffException { String first = "anything \n \nother"; String second = "anything\n\nother"; @@ -41,7 +42,7 @@ public class DiffRowGeneratorTest { } @Test - public void testGenerator_IgnoreWhitespaces() { + public void testGenerator_IgnoreWhitespaces() throws DiffException { String first = "anything \n \nother\nmore lines"; String second = "anything\n\nother\nsome more lines";