### Question:
AppliedFix { public static Applier fromSource(CharSequence source, EndPosTable endPositions) { return new Applier(source, endPositions); } private  AppliedFix(String snippet, boolean isRemoveLine); CharSequence getNewCodeSnippet(); boolean isRemoveLine(); static Applier fromSource(CharSequence source, EndPosTable endPositions);  }### Answer:
@Test public void shouldReturnNullOnEmptyFix() { AppliedFix fix = AppliedFix.fromSource("public class Foo {}", endPositions) .apply(SuggestedFix.builder().build()); assertThat(fix).isNull(); }
@Test public void shouldReturnNullOnImportOnlyFix() { AppliedFix fix = AppliedFix.fromSource("public class Foo {}", endPositions) .apply(SuggestedFix.builder().addImport("foo.bar.Baz").build()); assertThat(fix).isNull(); }
@Test public void shouldApplyFixesInReverseOrder() { Set<Replacement> replacements = new LinkedHashSet<>(); replacements.add(Replacement.create(0, 1, "")); replacements.add(Replacement.create(1, 1, "")); Fix mockFix = mock(Fix.class); when(mockFix.getReplacements(any())).thenReturn(replacements); AppliedFix.fromSource(" ", endPositions).apply(mockFix); }
@Test public void shouldThrowIfReplacementOutsideSource() { AppliedFix.Applier applier = AppliedFix.fromSource("Hello", endPositions); SuggestedFix fix = SuggestedFix.replace(0, 6, "World!"); assertThrows(IllegalArgumentException.class, () -> applier.apply(fix)); }