PatchInstallerUtil { @Nullable static LocalPackage getLatestPatcher(@NotNull RepoManager mgr) { LocalPackage patcher = null; for (LocalPackage p : mgr.getPackages().getLocalPackagesForPrefix(PATCHER_PATH_PREFIX)) { if (patcher == null || comparePatcherPaths(p.getPath(), patcher.getPath()) > 0) { patcher = p; } } return patcher; }  static File generatePatch(PatchOperation patchOp, File destDir, FileOp fop, ProgressIndicator progress); @Nullable static PackageOperation getInProgressDependantPatcherInstall(@NotNull RemotePackage remote, @NotNull RepoManager mgr); static final String PATCHER_PATH_PREFIX; }
@Test public void getLatestPatcher() throws Exception { LocalPackage target = new FakeLocalPackage("patcher;v3"); List<LocalPackage> local = ImmutableList.of(new FakeLocalPackage("patcher;v1"), target, new FakeLocalPackage("patcher;v2")); RepositoryPackages packages = new RepositoryPackages(local, ImmutableList.of()); FakeRepoManager mgr = new FakeRepoManager(new File("/sdk"), packages); LocalPackage patcher = PatchInstallerUtil.getLatestPatcher(mgr); assertEquals(target, patcher); }
@Test public void noLatestPatcher() throws Exception { List<LocalPackage> local = ImmutableList.of(new FakeLocalPackage("foo")); RepositoryPackages packages = new RepositoryPackages(local, ImmutableList.of()); FakeRepoManager mgr = new FakeRepoManager(new File("/sdk"), packages); LocalPackage patcher = PatchInstallerUtil.getLatestPatcher(mgr); assertNull(patcher); }