protected @Override Optional<PR> _call() { Preconditions.checkArgument(id != null, "Pull request id not set"); final String section = String.format("pr.%d", id); final Map<String, String> props = configDatabase().getAllSection(section); if (props.isEmpty()) { return Optional.empty(); } PR pr = PR.createFromProperties(id, props); return Optional.of(pr); }
@Test public void testPutSection() { // Test integer and string ImmutableMap<String, String> map = ImmutableMap.of(// "k1", "v1", // "subsection.string", "2", // "subsection.int", "1", // "subsection.long", "4"// ); config.putSection("section1", map); assertEquals(ImmutableMap.of("k1", "v1"), config.getAllSection("section1")); assertEquals(ImmutableMap.of("string", "2", "int", "1", "long", "4"), config.getAllSection("section1.subsection")); }
@Test public void testGetAllSection() { // Test integer and string config.put("section1.int", 1); config.put("section1.subsection.string", "2"); config.put("section1.subsection.subsub.int", 1); config.put("section1.subsection.subsub.string", "4"); config.put("section2.int", 3); assertEquals(ImmutableMap.of("int", "1"), config.getAllSection("section1")); assertEquals(ImmutableMap.of("string", "2"), config.getAllSection("section1.subsection")); assertEquals(ImmutableMap.of("int", "1", "string", "4"), config.getAllSection("section1.subsection.subsub")); }
Map<String, String> all = db.getAllSection(section); remoteName = all.get("remote"); remoteBranch = all.get("merge");
@Test public void testGetAllSection() { // Test integer and string config.put("section1.int", 1); config.put("section1.subsection.string", "2"); config.put("section1.subsection.subsub.int", 1); config.put("section1.subsection.subsub.string", "4"); config.put("section2.int", 3); assertEquals(ImmutableMap.of("int", "1"), config.getAllSection("section1")); assertEquals(ImmutableMap.of("string", "2"), config.getAllSection("section1.subsection")); assertEquals(ImmutableMap.of("int", "1", "string", "4"), config.getAllSection("section1.subsection.subsub")); }
@Test public void testGlobalOnly() { ConfigDatabase globalOnly = IniFileConfigDatabase.globalOnly(platform); testGlobalOnly(() -> globalOnly.get("section.key")); testGlobalOnly(() -> globalOnly.getAll()); testGlobalOnly(() -> globalOnly.get("section.key", String.class)); testGlobalOnly(() -> globalOnly.getAllSection("section")); testGlobalOnly(() -> globalOnly.getAllSubsections("section.sub")); testGlobalOnly(() -> globalOnly.put("section.key", "val")); testGlobalOnly(() -> globalOnly.remove("section.key")); testGlobalOnly(() -> globalOnly.removeSection("section")); }
@Test public void testGlobalOnly() { ConfigDatabase globalOnly = IniFileConfigDatabase.globalOnly(platform); testGlobalOnly(() -> globalOnly.get("section.key")); testGlobalOnly(() -> globalOnly.getAll()); testGlobalOnly(() -> globalOnly.get("section.key", String.class)); testGlobalOnly(() -> globalOnly.getAllSection("section")); testGlobalOnly(() -> globalOnly.getAllSubsections("section.sub")); testGlobalOnly(() -> globalOnly.put("section.key", "val")); testGlobalOnly(() -> globalOnly.remove("section.key")); testGlobalOnly(() -> globalOnly.removeSection("section")); }