Search in sources :

Example 1 with ConfigValue

use of org.neo4j.configuration.ConfigValue in project neo4j by neo4j.

the class ServerSettingsTest method connectorSettingHasItsOwnValues.

@Test
public void connectorSettingHasItsOwnValues() throws Exception {
    Config config = Config.serverDefaults(stringMap("dbms.connector.http.address", "localhost:123"));
    ConfigValue address = config.getConfigValues().entrySet().stream().filter(c -> c.getKey().equals("dbms.connector.http.address")).map(Entry::getValue).findAny().orElseThrow(() -> new RuntimeException("Setting not present!"));
    assertTrue(address.deprecated());
    assertEquals(Optional.of("dbms.connector.http.listen_address"), address.replacement());
}
Also used : Assert.assertThat(org.junit.Assert.assertThat) ConfigValue(org.neo4j.configuration.ConfigValue) List(java.util.List) Config(org.neo4j.kernel.configuration.Config) Collectors.toList(java.util.stream.Collectors.toList) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Entry(java.util.Map.Entry) Optional(java.util.Optional) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MapUtil.stringMap(org.neo4j.helpers.collection.MapUtil.stringMap) Assert.assertEquals(org.junit.Assert.assertEquals) ConfigValue(org.neo4j.configuration.ConfigValue) Entry(java.util.Map.Entry) Config(org.neo4j.kernel.configuration.Config) Test(org.junit.Test)

Example 2 with ConfigValue

use of org.neo4j.configuration.ConfigValue in project neo4j-documentation by neo4j.

the class ConfigDocsTool method main.

public static void main(String[] args) throws IOException {
    Args arguments = Args.parse(args);
    printUsage();
    List<String> orphans = arguments.orphans();
    Path outFile = orphans.size() == 1 ? Paths.get(orphans.get(0)) : null;
    String id = arguments.has("id") || warnMissingOption("ID", "--id=my-id", DEFAULT_ID) ? arguments.get("id") : DEFAULT_ID;
    String title = arguments.has("title") || warnMissingOption("title", "--title=my-title", DEFAULT_TITLE) ? arguments.get("title") : DEFAULT_TITLE;
    String idPrefix = arguments.has("id-prefix") || warnMissingOption("ID prefix", "--id-prefix=my-id-prefix", DEFAULT_ID_PREFIX) ? arguments.get("id-prefix") : DEFAULT_ID_PREFIX;
    Predicate<ConfigValue> filter = filters(arguments);
    System.out.printf("[+++] id=%s  title=%s  idPrefix=%s%n", id, title, idPrefix);
    try {
        String doc = new ConfigDocsGenerator().document(filter, id, title, idPrefix);
        if (null != outFile) {
            Path parentDir = outFile.getParent();
            if (!Files.exists(parentDir)) {
                Files.createDirectories(parentDir);
            }
            System.out.println("Saving docs in '" + outFile.toFile().getAbsolutePath() + "'.");
            Files.write(outFile, doc.getBytes());
        } else {
            System.out.println(doc);
        }
    } catch (NoSuchElementException nse) {
        nse.printStackTrace();
        throw nse;
    } catch (NoSuchFileException nsf) {
        nsf.printStackTrace();
        throw nsf;
    }
}
Also used : Path(java.nio.file.Path) Args(org.neo4j.helpers.Args) ConfigValue(org.neo4j.configuration.ConfigValue) NoSuchFileException(java.nio.file.NoSuchFileException) NoSuchElementException(java.util.NoSuchElementException)

Example 3 with ConfigValue

use of org.neo4j.configuration.ConfigValue in project neo4j-documentation by neo4j.

the class ConfigDocsGenerator method document.

public String document(Predicate<ConfigValue> filter, String id, String title, String idPrefix) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    out = new PrintStream(baos);
    settingDescriptions = config.getConfigValues().values().stream().filter(filter).sorted((cv1, cv2) -> cv1.name().compareTo(cv2.name())).map(c -> new DocsConfigValue(idFromName(idPrefix, c.name()), c.name(), c.description(), c.deprecated(), c.valueDescription(), c.documentedDefaultValue().isPresent() ? c.documentedDefaultValue() : valueAsString(c), c.internal(), c.replacement(), c.dynamic())).collect(Collectors.toList());
    out.print(documentSummary(id, title, settingDescriptions));
    settingDescriptions.forEach(this::documentForAllOutputs);
    out.flush();
    return baos.toString();
}
Also used : PrintStream(java.io.PrintStream) Config(org.neo4j.kernel.configuration.Config) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Predicate(java.util.function.Predicate) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) ConfigValue(org.neo4j.configuration.ConfigValue) List(java.util.List) Matcher(java.util.regex.Matcher) Duration(java.time.Duration) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) NoSuchElementException(java.util.NoSuchElementException) PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

ConfigValue (org.neo4j.configuration.ConfigValue)3 List (java.util.List)2 NoSuchElementException (java.util.NoSuchElementException)2 Optional (java.util.Optional)2 Config (org.neo4j.kernel.configuration.Config)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 NoSuchFileException (java.nio.file.NoSuchFileException)1 Path (java.nio.file.Path)1 Duration (java.time.Duration)1 Entry (java.util.Map.Entry)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertThat (org.junit.Assert.assertThat)1