@Override
  public void publish(ScannerReportWriter writer) {
    List<DefaultAnalysisWarnings.Message> warnings = defaultAnalysisWarnings.warnings();
    if (warnings.isEmpty()) {
      return;
    }
    writer.writeAnalysisWarnings(warnings.stream()
      .map(AnalysisWarningsPublisher::toProtobufAnalysisWarning)
      .toList());
  }
@Test
  public void publish_warnings() throws IOException {
    ScannerReportWriter writer = new ScannerReportWriter(fileStructure);

    String warning1 = "warning 1";
    String warning2 = "warning 2";
    analysisWarnings.addUnique(warning1);
    analysisWarnings.addUnique(warning1);
    analysisWarnings.addUnique(warning2);

    underTest.publish(writer);

    ScannerReportReader reader = new ScannerReportReader(fileStructure);
    List<ScannerReport.AnalysisWarning> warnings = Lists.newArrayList(reader.readAnalysisWarnings());

    assertThat(warnings)
      .extracting(ScannerReport.AnalysisWarning::getText)
      .containsExactly(warning1, warning2);
  }