void () { int[] beforeAppliedExpected = {2, 5, 6, 8}; int[] endAppliedExpected = {4, 5, 7, 10}; final PatchHunk patchHunk = new PatchHunk(2, 12, 2, 12); 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.CONTEXT, "7")); patchHunk.addLine(new PatchLine(PatchLine.Type.REMOVE, "8")); patchHunk.addLine(new PatchLine(PatchLine.Type.CONTEXT, "9")); patchHunk.addLine(new PatchLine(PatchLine.Type.REMOVE, "10")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "11")); patchHunk.addLine(new PatchLine(PatchLine.Type.CONTEXT, "12")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "13")); patchHunk.addLine(new PatchLine(PatchLine.Type.ADD, "13")); patchHunk.addLine(new PatchLine(PatchLine.Type.CONTEXT, "14")); patchHunk.addLine(new PatchLine(PatchLine.Type.CONTEXT, "15")); GenericPatchApplier gap = new GenericPatchApplier("1\n2\n5\n6\n7\n9\n11\n12\n13\n13\n14\n", Collections.singletonList(patchHunk)); assertTrue(gap.execute()); List<AppliedTextPatch.AppliedSplitPatchHunk> appliedInfo = gap.getAppliedInfo(); ContainerUtil.sort(appliedInfo, Comparator.comparingInt(o -> o.getAppliedTo().start)); checkAppliedPositions(beforeAppliedExpected, endAppliedExpected, HunkStatus.ALREADY_APPLIED, appliedInfo); gap = new GenericPatchApplier("f\nd\n1768678\n2\n5\n6\n7\n9\n11\n12\n13\n13\n14\n", Collections.singletonList(patchHunk)); assertTrue(gap.execute()); appliedInfo = gap.getAppliedInfo(); ContainerUtil.sort(appliedInfo, Comparator.comparingInt(o -> o.getAppliedTo().start)); int[] beforeAppliedExpected2 = {4, 7, 8, 10}; int[] endAppliedExpected2 = {6, 7, 9, 12}; checkAppliedPositions(beforeAppliedExpected2, endAppliedExpected2, HunkStatus.ALREADY_APPLIED, appliedInfo); }