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, "3")); patchHunk.addLine(new PatchLine(PatchLine.Type.REMOVE, "4")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "5")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "6")); patchHunk.addLine(new PatchLine(PatchLine.Type.REMOVE, "7")); patchHunk.addLine(new PatchLine(PatchLine.Type.REMOVE, "8")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "9")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "10")); patchHunk.addLine(new PatchLine(PatchLine.Type.CONTEXT, "11")); patchHunk.addLine(new PatchLine(PatchLine.Type.CONTEXT, "12")); AppliedPatch result = GenericPatchApplier.apply("0\nmmm\n2\n3\n4\n7\n8\n11\naaa", Collections.singletonList(patchHunk)); Assert.assertNotNull(result); Assert.assertEquals(ApplyPatchStatus.SUCCESS, result.status); Assert.assertEquals("0\nmmm\n2\n5\n6\n9\n10\n11\naaa", result.patchedText); }