use of org.xwiki.extension.DefaultExtensionIssueManagement in project xwiki-platform by xwiki.
the class ExtensionIT method testShowDetails.
/**
* Tests the extension details (license, web site).
*/
@Test
public void testShowDetails() throws Exception {
// Setup the extension.
ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
TestExtension extension = getRepositoryTestUtils().getTestExtension(extensionId, "xar");
extension.setName("Alice Wiki Macro");
extension.setSummary("A **useless** macro");
extension.addAuthor(new DefaultExtensionAuthor("Thomas", (String) null));
extension.addAuthor(new DefaultExtensionAuthor("Marius", (String) null));
extension.addFeature("alice-extension");
extension.addLicense(new ExtensionLicense("My own license", null));
extension.setWebsite("http://www.alice.com");
extension.setScm(new DefaultExtensionScm("https://github.com/xwiki-contrib/alice-xar-extension", new DefaultExtensionScmConnection("git", "git://github.com/xwiki-contrib/alice-xar-extension.git"), new DefaultExtensionScmConnection("git", "git:git@github.com:xwiki-contrib/alice-xar-extension.git")));
extension.setIssueManagement(new DefaultExtensionIssueManagement("jira", "https://jira.xwiki.org/browse/ALICE"));
getRepositoryTestUtils().addExtension(extension);
// Search the extension and assert the displayed information.
ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
assertEquals("remote", extensionPane.getStatus());
assertNull(extensionPane.getStatusMessage());
assertEquals(extension.getName(), extensionPane.getName());
assertEquals(extensionId.getVersion().getValue(), extensionPane.getVersion());
List<WebElement> authors = extensionPane.getAuthors();
assertEquals(2, authors.size());
assertEquals("Thomas", authors.get(0).getText());
assertEquals("Marius", authors.get(1).getText());
assertEquals(extension.getSummary(), extensionPane.getSummary());
// Check the extension details.
ExtensionDescriptionPane descriptionPane = extensionPane.openDescriptionSection();
assertEquals(extension.getLicenses().iterator().next().getName(), descriptionPane.getLicense());
assertEquals(extension.getId().getId(), descriptionPane.getId());
assertEquals(extension.getFeatures().iterator().next(), descriptionPane.getFeatures().get(0));
assertEquals(extension.getType(), descriptionPane.getType());
WebElement webSiteLink = descriptionPane.getWebSite();
assertEquals(extension.getWebSite().substring("http://".length()), webSiteLink.getText());
assertEquals(extension.getWebSite() + '/', webSiteLink.getAttribute("href"));
// Install the extension to check the details that are specific to installed extensions.
Date beforeInstall = new Date();
descriptionPane = extensionPane.install().confirm().openDescriptionSection();
Date afterInstall = new Date();
List<String> namespaces = descriptionPane.getNamespaces();
assertEquals(1, namespaces.size());
String prefix = "Home, by superadmin on ";
assertTrue(namespaces.get(0).startsWith(prefix));
Date installDate = new SimpleDateFormat("yyyy/MM/dd HH:mm").parse(namespaces.get(0).substring(prefix.length()));
// Ignore the seconds as they are not displayed.
assertTrue(String.format("Install date [%s] should be after [%s].", installDate, beforeInstall), installDate.getTime() / 60000 >= beforeInstall.getTime() / 60000);
assertTrue(String.format("Install date [%s] should be before [%s].", installDate, afterInstall), installDate.before(afterInstall));
}
Aggregations