WarningAssert extends AbstractListAssert<WarningAssert, List<Warning>, Warning> { public WarningAssert hasWarnings(int count) { if (actual.size() != count) { failWithMessage("Expected warning's size to be <%d> but was <%d>", count, actual.size()); } return this; } private  WarningAssert(List<Warning> actual); static WarningAssert assertThat(List<Warning> actual); WarningAssert hasWarnings(int count); WarningAssert in(String... filenames); WarningAssert atLine(Integer... lines); WarningAssert withMessage(String... messages);  }
@Test public void testHasWarnings() throws Exception { Warning firstWarning = new Warning(null, "Message 1", null, null); firstWarning.file = new File("File1.java"); firstWarning.line = 8; Warning secondWarning = new Warning(null, "Message 2", null, null); secondWarning.file = new File("File2.xml"); secondWarning.line = 14; List<Warning> lintResult = Arrays.asList(firstWarning, secondWarning); WarningAssert.assertThat(lintResult) .hasWarnings(2) .in("File1.java", "File2.xml") .atLine(8, 14) .withMessage("Message 1", "Message 2"); }