void () { final PatchHunk patchHunk = new PatchHunk(1, 8, 1, 8); patchHunk.addLine(new PatchLine(PatchLine.Type.CONTEXT, "1")); patchHunk.addLine(new PatchLine(PatchLine.Type.CONTEXT, "2")); patchHunk.addLine(new PatchLine(PatchLine.Type.REMOVE, "-1")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "-1a")); patchHunk.addLine(new PatchLine(PatchLine.Type.REMOVE, "-2")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "-2a")); patchHunk.addLine(new PatchLine(PatchLine.Type.REMOVE, "-3")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "-3a")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "-3b")); patchHunk.addLine(new PatchLine(PatchLine.Type.REMOVE, "-4")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "-4a")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "-4b")); patchHunk.addLine(new PatchLine(PatchLine.Type.CONTEXT, "11")); patchHunk.addLine(new PatchLine(PatchLine.Type.CONTEXT, "12")); AppliedSomehowPatch result = GenericPatchApplier.applySomehow(""" 0 mmm fjsfsd qwhduhqwude 2 -1 4 9 8 11 aaa 2 -2 -3""", Collections.singletonList(patchHunk)); Assert.assertTrue(result.isAppliedSomehow); Assert.assertEquals(ApplyPatchStatus.SUCCESS, result.status); Assert.assertEquals("0\nmmm\nfjsfsd\nqwhduhqwude\n\n2\n-1\n4\n9\n8\n11\naaa\n2\n-1a\n-2a\n-3a\n-3b\n-4a\n-4b\n", result.patchedText); }