Search in sources :

Example 1 with DefaultExtensionAuthor

use of org.xwiki.extension.DefaultExtensionAuthor 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)

Example 2 with DefaultExtensionAuthor

use of org.xwiki.extension.DefaultExtensionAuthor in project xwiki-platform by xwiki.

the class RepositoryTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    // base extension informations
    this.baseExtension = getRepositoryTestUtils().getTestExtension(new ExtensionId(IDPREFIX + "macro-jar-extension", "1.0"), "jar");
    this.baseExtension.setName("Macro JAR extension");
    this.baseExtension.setDescription("extension description");
    this.baseExtension.setSummary("extension summary, **not bold**");
    this.baseLicense = new ExtensionLicense("Do What The Fuck You Want To Public License 2", null);
    this.baseExtension.addLicense(this.baseLicense);
    this.baseAuthor = new DefaultExtensionAuthor("User Name", getUtil().getURL("XWiki", USER_CREDENTIALS.getUserName()));
    this.baseExtension.addAuthor(this.baseAuthor);
    this.baseExtension.addDependency(new DefaultExtensionDependency("dependencyid1", new DefaultVersionConstraint("1.0")));
    this.baseExtension.addDependency(new DefaultExtensionDependency("dependencyid2", new DefaultVersionConstraint("2.0")));
    this.sizeOfFile = FileUtils.sizeOf(this.baseExtension.getFile().getFile());
}
Also used : ExtensionLicense(org.xwiki.extension.ExtensionLicense) DefaultExtensionAuthor(org.xwiki.extension.DefaultExtensionAuthor) DefaultVersionConstraint(org.xwiki.extension.version.internal.DefaultVersionConstraint) ExtensionId(org.xwiki.extension.ExtensionId) DefaultExtensionDependency(org.xwiki.extension.DefaultExtensionDependency) Before(org.junit.Before)

Aggregations

DefaultExtensionAuthor (org.xwiki.extension.DefaultExtensionAuthor)2 ExtensionId (org.xwiki.extension.ExtensionId)2 ExtensionLicense (org.xwiki.extension.ExtensionLicense)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Before (org.junit.Before)1 Test (org.junit.Test)1 WebElement (org.openqa.selenium.WebElement)1 DefaultExtensionDependency (org.xwiki.extension.DefaultExtensionDependency)1 DefaultExtensionIssueManagement (org.xwiki.extension.DefaultExtensionIssueManagement)1 DefaultExtensionScm (org.xwiki.extension.DefaultExtensionScm)1 DefaultExtensionScmConnection (org.xwiki.extension.DefaultExtensionScmConnection)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 DefaultVersionConstraint (org.xwiki.extension.version.internal.DefaultVersionConstraint)1 TestExtension (org.xwiki.repository.test.TestExtension)1