private void expectDiagnostic( Kind kind, String message, @Nullable String source, long start, long end, long col) throws IOException { expect(diagnostic.getKind()).andReturn(kind); expect(diagnostic.getMessage(EasyMock.<Locale>notNull())).andReturn(message); expect(diagnostic.getSource()).andReturn(file).anyTimes(); expect(diagnostic.getStartPosition()).andReturn(start).anyTimes(); expect(diagnostic.getEndPosition()).andReturn(end).anyTimes(); expect(diagnostic.getColumnNumber()).andReturn(col).anyTimes(); expect(file.getCharContent(anyBoolean())).andReturn(source).anyTimes(); }
void assertFileContent(String relPath, String expectedContent) { try { FileObject fo = processingEnv.getFiler().getResource(StandardLocation.CLASS_PATH, "", relPath); String actualContent = fo.getCharContent(false).toString(); if (!expectedContent.equals(actualContent)) { throw new AssertionError( "Actual content not matching the expected content: " + actualContent); } } catch (IOException ex) { throw new AssertionError("Unexpected exception: ", ex); } }