protected @Override List<PR> _call() { IntStream ids = configDatabase().getAllSubsections("pr").stream() .mapToInt(s -> Integer.valueOf(s)).sorted(); Stream<PR> prstream = ids.parallel() .mapToObj(prId -> command(PRFindOp.class).setId(prId).call().orElse(null)) .filter(r -> r != null); List<PR> prs = prstream.collect(Collectors.toList()); return prs; }
List<String> allRemotes = config.getAllSubsections("remote"); if (allRemotes.contains(name)) {
/** * Executes the remote-list operation. * * @return {@code List<Remote>} of all remotes found in the config database, may be empty. */ @Override protected ImmutableList<Remote> _call() { ConfigDatabase config = configDatabase(); List<String> remotes = config.getAllSubsections("remote"); List<Remote> allRemotes = new ArrayList<Remote>(); for (String remoteName : remotes) { String remoteSection = "remote." + remoteName; Optional<String> remoteFetchURL = config.get(remoteSection + ".url"); Optional<String> remoteFetch = config.get(remoteSection + ".fetch"); Optional<String> remoteMapped = config.get(remoteSection + ".mapped"); Optional<String> remoteMappedBranch = config.get(remoteSection + ".mappedBranch"); Optional<String> remoteUserName = config.get(remoteSection + ".username"); Optional<String> remotePassword = config.get(remoteSection + ".password"); if (remoteFetchURL.isPresent() && remoteFetch.isPresent()) { Optional<String> remotePushURL = config.get(remoteSection + ".pushurl"); allRemotes.add(new Remote(remoteName, remoteFetchURL.get(), remotePushURL.or(remoteFetchURL.get()), remoteFetch.get(), remoteMapped.or("false").equals("true"), remoteMappedBranch.orNull(), remoteUserName.orNull(), remotePassword.orNull())); } } return ImmutableList.copyOf(allRemotes); } }
/** * Executes the remote-list operation. * * @return {@code List<Remote>} of all remotes found in the config database, may be empty. */ @Override protected ImmutableList<Remote> _call() { ConfigDatabase config = configDatabase(); List<String> remotes = config.getAllSubsections("remote"); List<Remote> allRemotes = new ArrayList<Remote>(); for (String remoteName : remotes) { String remoteSection = "remote." + remoteName; Optional<String> remoteFetchURL = config.get(remoteSection + ".url"); Optional<String> remoteFetch = config.get(remoteSection + ".fetch"); Optional<String> remoteMapped = config.get(remoteSection + ".mapped"); Optional<String> remoteMappedBranch = config.get(remoteSection + ".mappedBranch"); Optional<String> remoteUserName = config.get(remoteSection + ".username"); Optional<String> remotePassword = config.get(remoteSection + ".password"); if (remoteFetchURL.isPresent() && remoteFetch.isPresent()) { Optional<String> remotePushURL = config.get(remoteSection + ".pushurl"); allRemotes.add(new Remote(remoteName, remoteFetchURL.get(), remotePushURL.or(remoteFetchURL.get()), remoteFetch.get(), remoteMapped.or("false").equals("true"), remoteMappedBranch.orNull(), remoteUserName.orNull(), remotePassword.orNull())); } } return ImmutableList.copyOf(allRemotes); } }
List<String> allRemotes = config.getAllSubsections("remote"); if (allRemotes.contains(name)) {
List<String> allRemotes = config.getAllSubsections("remote"); if (!allRemotes.contains(name)) { throw new RemoteException(StatusCode.REMOTE_NOT_FOUND);
List<String> allRemotes = config.getAllSubsections("remote"); if (allRemotes.contains(name)) { throw new RemoteException(StatusCode.REMOTE_ALREADY_EXISTS);
List<String> allRemotes = config.getAllSubsections("remote"); if (allRemotes.contains(name)) { throw new RemoteException(StatusCode.REMOTE_ALREADY_EXISTS);
@Test public void testGetAllSubsections() { // Test integer and string config.put("section1.subsection1.int", 1); config.put("section1.subsection2.string", "2"); config.put("section1.subsection1.subsub1.int", 1); config.put("section1.subsection2.subsub2.string", "2"); config.put("section2.subsection3.int", 3); config.put("section2.subsection4.string", "4"); List<String> allSubsections = config.getAllSubsections("section1"); Set<String> expected = ImmutableSet.of("subsection1", "subsection2", "subsection1.subsub1", "subsection2.subsub2"); assertEquals(expected, new HashSet<String>(allSubsections)); }
@Test public void testGetAllSubsections() { // Test integer and string config.put("section1.subsection1.int", 1); config.put("section1.subsection2.string", "2"); config.put("section1.subsection1.subsub1.int", 1); config.put("section1.subsection2.subsub2.string", "2"); config.put("section2.subsection3.int", 3); config.put("section2.subsection4.string", "4"); List<String> allSubsections = config.getAllSubsections("section1"); Set<String> expected = ImmutableSet.of("subsection1", "subsection2", "subsection1.subsub1", "subsection2.subsub2"); assertEquals(expected, new HashSet<String>(allSubsections)); }
@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")); }