Search in sources :

Example 1 with DefaultExtensionScm

use of org.xwiki.extension.DefaultExtensionScm 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));
}
Also used : ExtensionLicense(org.xwiki.extension.ExtensionLicense) DefaultExtensionScmConnection(org.xwiki.extension.DefaultExtensionScmConnection) ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) DefaultExtensionIssueManagement(org.xwiki.extension.DefaultExtensionIssueManagement) ExtensionId(org.xwiki.extension.ExtensionId) TestExtension(org.xwiki.repository.test.TestExtension) ExtensionDescriptionPane(org.xwiki.extension.test.po.ExtensionDescriptionPane) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) WebElement(org.openqa.selenium.WebElement) Date(java.util.Date) DefaultExtensionAuthor(org.xwiki.extension.DefaultExtensionAuthor) SimpleDateFormat(java.text.SimpleDateFormat) DefaultExtensionScm(org.xwiki.extension.DefaultExtensionScm) Test(org.junit.Test)

Aggregations

SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Test (org.junit.Test)1 WebElement (org.openqa.selenium.WebElement)1 DefaultExtensionAuthor (org.xwiki.extension.DefaultExtensionAuthor)1 DefaultExtensionIssueManagement (org.xwiki.extension.DefaultExtensionIssueManagement)1 DefaultExtensionScm (org.xwiki.extension.DefaultExtensionScm)1 DefaultExtensionScmConnection (org.xwiki.extension.DefaultExtensionScmConnection)1 ExtensionId (org.xwiki.extension.ExtensionId)1 ExtensionLicense (org.xwiki.extension.ExtensionLicense)1 ExtensionAdministrationPage (org.xwiki.extension.test.po.ExtensionAdministrationPage)1 ExtensionDescriptionPane (org.xwiki.extension.test.po.ExtensionDescriptionPane)1 ExtensionPane (org.xwiki.extension.test.po.ExtensionPane)1 TestExtension (org.xwiki.repository.test.TestExtension)1