Skip to content

Commit

Permalink
Add test for <until> element
Browse files Browse the repository at this point in the history
References #313.
  • Loading branch information
gaul committed Jan 18, 2025
1 parent 7a52ccc commit 9460d8b
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,20 @@ public void testAnnotationViolation() throws Exception {
.isEqualTo(name);
}

@Test
public void testUntil() throws Exception {
ClassReader cr = new ClassReader(UntilTest.class.getName());
Collection<ViolationOccurrence> occurrences = createModernizer("10").check(cr);
assertThat(occurrences).hasSize(1);
assertThat(occurrences.iterator().next().getViolation().getComment())
.isEqualTo("Prefer java.nio.file.Files.newInputStream(java.nio.file.Paths.get(String))");

occurrences = createModernizer("11").check(cr);
assertThat(occurrences).hasSize(1);
assertThat(occurrences.iterator().next().getViolation().getComment())
.isEqualTo("Prefer java.nio.file.Files.newInputStream(java.nio.file.Path.of(String))");
}

@Test
public void testAllViolations() throws Exception {
Modernizer modernizer = createModernizer("24");
Expand Down Expand Up @@ -583,6 +597,12 @@ public Object get() {
}
}

private static class UntilTest {
public static void method() throws Exception {
new FileInputStream("");
}
}

private static class AllViolations {
@SuppressWarnings(value = {
"BoxedPrimitiveConstructor",
Expand Down

0 comments on commit 9460d8b

Please sign in to comment.