@Test
  public void shouldWorkFineWithNoPropertiesFile() {
    // Given
    File propertiesFile = null;

    // When
    PropertyFileConfigurator configurator = new PropertyFileConfigurator(propertiesFile);

    // Then
    assertFalse(configurator.getDatabaseTuningProperties().isEmpty());
  }
  @Test
  public void shouldWorkFineWhenSpecifiedPropertiesFileDoesNotExist() {
    // Given
    File nonExistentFilePropertiesFile = new File("/tmp/" + System.currentTimeMillis());

    // When
    PropertyFileConfigurator configurator =
        new PropertyFileConfigurator(nonExistentFilePropertiesFile);

    // Then
    assertFalse(configurator.getDatabaseTuningProperties().isEmpty());
  }
  @Test
  public void whenDatabaseTuningFilePresentInDefaultLocationShouldLoadItEvenIfNotSpecified()
      throws IOException {
    File emptyPropertyFile = PropertyFileBuilder.builder(folder.getRoot()).build();
    DatabaseTuningPropertyFileBuilder.builder(folder.getRoot()).build();

    PropertyFileConfigurator configurator = new PropertyFileConfigurator(emptyPropertyFile);

    assertEquals(
        "25M",
        configurator
            .getDatabaseTuningProperties()
            .get(GraphDatabaseSettings.nodestore_mapped_memory_size.name()));
  }
  @Test
  public void shouldSetStoreDirSetting() throws Exception {
    // Given
    String dbLocation = new File("/tmp/does_not_matter").getAbsolutePath();
    File propertyFile =
        PropertyFileBuilder.builder(folder.getRoot())
            .withNameValue(Configurator.DATABASE_LOCATION_PROPERTY_KEY, dbLocation)
            .build();
    PropertyFileConfigurator serverConfig = new PropertyFileConfigurator(propertyFile);

    // When
    Map<String, String> properties = serverConfig.getDatabaseTuningProperties();

    // Then
    assertThat(properties.get(GraphDatabaseSettings.store_dir.name()), equalTo(dbLocation));
  }
  @Test
  public void shouldRetainRegistrationOrderOfThirdPartyJaxRsPackages() throws IOException {
    File propertyFile =
        PropertyFileBuilder.builder(folder.getRoot())
            .withNameValue(
                Configurator.THIRD_PARTY_PACKAGES_KEY,
                "org.neo4j.extension.extension1=/extension1,org.neo4j.extension.extension2=/extension2,"
                    + "org.neo4j.extension.extension3=/extension3")
            .build();
    PropertyFileConfigurator propertyFileConfigurator = new PropertyFileConfigurator(propertyFile);

    List<ThirdPartyJaxRsPackage> thirdpartyJaxRsPackages =
        propertyFileConfigurator.configuration().get(ServerSettings.third_party_packages);

    assertEquals(3, thirdpartyJaxRsPackages.size());
    assertEquals("/extension1", thirdpartyJaxRsPackages.get(0).getMountPoint());
    assertEquals("/extension2", thirdpartyJaxRsPackages.get(1).getMountPoint());
    assertEquals("/extension3", thirdpartyJaxRsPackages.get(2).getMountPoint());
  }
  @Test
  public void whenDatabaseTuningFilePresentInDefaultLocationShouldNotLoadIfAnotherSpecified()
      throws IOException {
    int unlikelyDefaultMemoryMappedValue = 8351;
    File databaseTuningPropertyFileWeWantToUse =
        DatabaseTuningPropertyFileBuilder.builder(folder.getRoot())
            .mappedMemory(unlikelyDefaultMemoryMappedValue)
            .build();
    File emptyPropertyFile =
        PropertyFileBuilder.builder(folder.getRoot())
            .withDbTuningPropertyFile(databaseTuningPropertyFileWeWantToUse)
            .build();
    // The tuning properties we want to ignore, in the same dir as the neo
    // server properties
    DatabaseTuningPropertyFileBuilder.builder(folder.newFolder()).build();

    PropertyFileConfigurator configurator = new PropertyFileConfigurator(emptyPropertyFile);

    assertEquals(
        String.valueOf(unlikelyDefaultMemoryMappedValue) + "M",
        configurator
            .getDatabaseTuningProperties()
            .get(GraphDatabaseSettings.nodestore_mapped_memory_size.name()));
  }