public void writeToYmlSettingsFile(File file) {
    DumperOptions dumperOptions = new DumperOptions();
    dumperOptions.setPrettyFlow(true);
    dumperOptions.setDefaultFlowStyle(BLOCK);
    Yaml yaml = new Yaml(dumperOptions);
    String output = ELASTICSEARCH_YML_OPTIONS_HEADER + yaml.dump(elasticsearchSettings);
    try {
      Files.write(file.toPath(), output.getBytes(StandardCharsets.UTF_8));
    } catch (IOException e) {
      throw new IllegalStateException("Cannot write Elasticsearch yml settings file", e);
    }
  }
@Test
  public void test_generation_of_file() throws IOException {
    File yamlFile = temp.newFile();
    new EsYmlSettings(new HashMap<>()).writeToYmlSettingsFile(yamlFile);

    assertThat(yamlFile)
      .exists()
      .hasContent("""
        # This file has been automatically generated by SonarQube during startup.

        # DO NOT EDIT THIS FILE

        {
          }""");
  }

  @Test
  public void if_file_is_not_writable_ISE_must_be_thrown() throws IOException {
    File yamlFile = temp.newFile();
    yamlFile.setReadOnly();

    assertThatThrownBy(() -> new EsYmlSettings(new HashMap<>()).writeToYmlSettingsFile(yamlFile))
      .isInstanceOf(IllegalStateException.class)
      .hasMessage("Cannot write Elasticsearch yml settings file");
  }