Assert.assertTrue(getUtil().pageExists("ExtensionTest", "Bob"));
// Uninstall the dependency.
ExtensionAdministrationPage adminPage =
ExtensionAdministrationPage.gotoPage().clickInstalledExtensionsSection();
ExtensionPane extensionPane =
adminPage.getSearchBar().clickAdvancedSearch().search(dependencyId).getExtension(0);
extensionPane = extensionPane.uninstall();
// Check the uninstall plan. Both extensions should be included.
List<DependencyPane> uninstallPlan = extensionPane.openProgressSection().getJobPlan();
Assert.assertEquals(2, uninstallPlan.size());
Assert.assertEquals(extensionId, uninstallPlan.get(0).getId());
Assert.assertEquals("installed", uninstallPlan.get(0).getStatus());
Assert.assertEquals("Installed", uninstallPlan.get(0).getStatusMessage());
Assert.assertEquals(dependencyId, uninstallPlan.get(1).getId());
Assert.assertEquals("installed", uninstallPlan.get(1).getStatus());
Assert.assertEquals("Installed", uninstallPlan.get(1).getStatusMessage());
// Check the confirmation to delete the unused wiki pages.
extensionPane = extensionPane.confirm();
UnusedPagesPane unusedPages = extensionPane.openProgressSection().getUnusedPages();
Assert.assertTrue(unusedPages.contains("ExtensionTest", "Alice"));
Assert.assertTrue(unusedPages.contains("ExtensionTest", "Bob"));
// Finish the uninstall and check the log.
extensionPane = extensionPane.confirm();
List<LogItemPane> log = extensionPane.openProgressSection().getJobLog();
Assert.assertTrue(log.size() > 2);
Assert.assertEquals("info", log.get(2).getLevel());
Assert.assertEquals("Resolving extension [bob-xar-extension 2.5-milestone-2] from namespace [Home]", log
.get(2).getMessage());
Assert.assertEquals("info", log.get(log.size() - 1).getLevel());
Assert.assertEquals("Finished job of type [uninstall] with identifier "
+ "[extension/action/bob-xar-extension/wiki:xwiki]", log.get(log.size() - 1).getMessage());
// Check if the uninstalled pages have been deleted.
Assert.assertFalse(getUtil().pageExists("ExtensionTest", "Alice"));
Assert.assertFalse(getUtil().pageExists("ExtensionTest", "Bob"));
// Install both extension again and uninstall only the one with the dependency.
getExtensionTestUtils().install(extensionId);
adminPage = ExtensionAdministrationPage.gotoPage().clickInstalledExtensionsSection();
extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
extensionPane = extensionPane.uninstall();
// Check the uninstall plan. Only one extension should be included.
uninstallPlan = extensionPane.openProgressSection().getJobPlan();
Assert.assertEquals(1, uninstallPlan.size());
Assert.assertEquals(extensionId, uninstallPlan.get(0).getId());
// Check the confirmation to delete the unused wiki pages.
extensionPane = extensionPane.confirm();
unusedPages = extensionPane.openProgressSection().getUnusedPages();
Assert.assertTrue(unusedPages.contains("ExtensionTest", "Alice"));
Assert.assertFalse(unusedPages.contains("ExtensionTest", "Bob"));
// Finish the uninstall and check the log.
log = extensionPane.confirm().openProgressSection().getJobLog();
Assert.assertTrue(log.size() > 2);
Assert.assertEquals("info", log.get(2).getLevel());
Assert.assertEquals("Resolving extension [alice-xar-extension 1.3] from namespace [Home]", log.get(2)
.getMessage());
Assert.assertEquals("info", log.get(log.size() - 1).getLevel());
Assert.assertEquals("Finished job of type [uninstall] with identifier "
+ "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(log.size() - 1).getMessage());
// Check if the uninstalled pages have been deleted.
Assert.assertFalse(getUtil().pageExists("ExtensionTest", "Alice"));
Assert.assertTrue(getUtil().pageExists("ExtensionTest", "Bob"));
// Check the list of installed extensions. It should contain only the second extension.
adminPage = ExtensionAdministrationPage.gotoPage().clickInstalledExtensionsSection();
SearchResultsPane searchResults = adminPage.getSearchBar().search("alice");
Assert.assertEquals(0, searchResults.getDisplayedResultsCount());
Assert.assertNotNull(searchResults.getNoResultsMessage());
searchResults = new SimpleSearchPane().search("bob");
Assert.assertEquals(1, searchResults.getDisplayedResultsCount());
extensionPane = searchResults.getExtension(0);
Assert.assertEquals("installed", extensionPane.getStatus());
Assert.assertEquals(dependencyId, extensionPane.getId());
}