import com.google.common.base.Optional;
import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
}
}
+ public void uninstall() {
+ Map<String, PluginInfo> pluginInfosByKeys = pluginRepository.getPluginInfosByKeys();
+ Set<String> pluginsToRemove = pluginsToRemove(Collections.emptySet(), pluginInfosByKeys.values());
+ uninstallPlugins(pluginsToRemove);
+ }
+
public boolean isOffline() {
return !updateCenterMatrixFactory.getUpdateCenter(true).isPresent();
}
try {
editionPluginDownloader.downloadEditionPlugins(pluginsToInstall, updateCenter);
- for (String pluginKey : pluginsToRemove) {
- editionPluginUninstaller.uninstall(pluginKey);
- }
+ uninstallPlugins(pluginsToRemove);
editionManagementState.automaticInstallReady();
} finally {
lock.unlock();
}
}
+ private void uninstallPlugins(Set<String> pluginsToRemove) {
+ pluginsToRemove.stream().forEach(editionPluginUninstaller::uninstall);
+ }
+
private Set<String> pluginsToInstall(Set<String> editionPluginKeys, Set<String> installedPluginKeys) {
return editionPluginKeys.stream()
.filter(p -> !installedPluginKeys.contains(p))
verifyNoMoreInteractions(downloader);
}
+ @Test
+ public void uninstall_commercial_plugins() {
+ PluginInfo commercial1 = createPluginInfo("p1", true);
+ PluginInfo commercial2 = createPluginInfo("p2", true);
+ PluginInfo open1 = createPluginInfo("p3", false);
+ mockPluginRepository(commercial1, commercial2, open1);
+
+ installer.uninstall();
+
+ verify(uninstaller).uninstall("p2");
+ verify(uninstaller).uninstall("p1");
+
+ verifyNoMoreInteractions(uninstaller);
+ verifyZeroInteractions(downloader);
+ }
+
@Test
public void do_nothing_if_offline() {
mockPluginRepository(createPluginInfo("p1", true));