@Override
  public void publish(ScannerReportWriter writer) {
    List<Map.Entry<String, String>> properties = new ArrayList<>(cache.getAll().entrySet());
    properties.add(constructScmInfo());
    properties.add(constructCiInfo());
    // properties that are automatically included to report so that
    // they can be included to webhook payloads
    properties.addAll(config.getProperties().entrySet()
      .stream()
      .filter(e -> e.getKey().startsWith(CorePropertyDefinitions.SONAR_ANALYSIS))
      .toList());

    writer.writeContextProperties(properties
      .stream()
      .map(e -> ScannerReport.ContextProperty.newBuilder()
        .setKey(e.getKey())
        .setValue(e.getValue())
        .build())
      .toList());
  }
@Test
  public void publish_writes_properties_to_report() {
    cache.put("foo1", "bar1");
    cache.put("foo2", "bar2");

    underTest.publish(writer);

    List<ScannerReport.ContextProperty> expected = Arrays.asList(
      newContextProperty("foo1", "bar1"),
      newContextProperty("foo2", "bar2"),
      newContextProperty("sonar.analysis.detectedscm", "undetected"),
      newContextProperty("sonar.analysis.detectedci", "undetected"));
    expectWritten(expected);
  }