use of org.xwiki.repository.test.po.ExtensionsPage in project xwiki-platform by xwiki.
the class RepositoryTest method addExtension.
private void addExtension() throws Exception {
// Create extension
ExtensionsPage extensionsPage = ExtensionsPage.gotoPage();
ExtensionInlinePage extensionInline = extensionsPage.contributeExtension(this.baseExtension.getName());
Assert.assertEquals(this.baseExtension.getName(), extensionInline.getName());
extensionInline.setDescription(this.baseExtension.getDescription());
extensionInline.setInstallation("extension installation");
extensionInline.setLicenseName(this.baseLicense.getName());
extensionInline.setSource("http://source");
extensionInline.setSummary(this.baseExtension.getSummary());
extensionInline.setType(this.baseExtension.getType());
ExtensionPage extensionPage = extensionInline.clickSaveAndView();
// Test summary
getDriver().findElementsWithoutWaiting(By.xpath("//tt[text()=\"" + this.baseExtension.getSummary() + "\"]"));
Assert.assertFalse(extensionPage.isValidExtension());
// Add versions
// TODO: add XR UI to manipulate versions
getRepositoryTestUtils().addVersionObject(this.baseExtension);
getRepositoryTestUtils().addVersionObject(this.baseExtension, "10.0", getUtil().getAttachmentURL("Extension", this.baseExtension.getName(), this.baseExtension.getFile().getName()));
getRepositoryTestUtils().addVersionObject(this.baseExtension, "2.0", "attach:" + this.baseExtension.getFile().getName());
// Add dependencies
// TODO: add XR UI to manipulate dependencies
getRepositoryTestUtils().addDependencies(this.baseExtension, "10.0");
// Add attachment
getRepositoryTestUtils().attachFile(this.baseExtension);
// Wait until all asynchronous tasks are done
getRepositoryTestUtils().waitUntilReady();
// Check livetable
extensionsPage = ExtensionsPage.gotoPage();
ExtensionsLiveTableElement livetable = extensionsPage.getLiveTable();
livetable.filterName(this.baseExtension.getName());
extensionPage = livetable.clickExtensionName(this.baseExtension.getName());
// Validate extension state
Assert.assertTrue(extensionPage.isValidExtension());
// //////////////////////////////////////////
// Validate REST
// //////////////////////////////////////////
// //////////////////////////////////////////
// 1.0
// //////////////////////////////////////////
// Resolve
ExtensionVersion extension = getUtil().rest().getResource(Resources.EXTENSION_VERSION, null, this.baseExtension.getId().getId(), "1.0");
Assert.assertEquals(this.baseExtension.getId().getId(), extension.getId());
Assert.assertEquals(this.baseExtension.getType(), extension.getType());
Assert.assertEquals(this.baseExtension.getSummary(), extension.getSummary());
Assert.assertEquals(this.baseLicense.getName(), extension.getLicenses().get(0).getName());
Assert.assertEquals(this.baseExtension.getDescription(), extension.getDescription());
Assert.assertEquals(this.baseAuthor.getName(), extension.getAuthors().get(0).getName());
Assert.assertEquals(this.baseAuthor.getURL().toString(), extension.getAuthors().get(0).getUrl());
Assert.assertEquals("1.0", extension.getVersion());
Assert.assertEquals(getUtil().getURL(Arrays.asList("Extension", this.baseExtension.getName()), ""), extension.getWebsite());
// File
Assert.assertEquals(this.sizeOfFile, getUtil().rest().getBuffer(Resources.EXTENSION_VERSION_FILE, null, this.baseExtension.getId().getId(), "1.0").length);
// //////////////////////////////////////////
// 2.0
// //////////////////////////////////////////
// Resolve
extension = getUtil().rest().getResource(Resources.EXTENSION_VERSION, null, this.baseExtension.getId().getId(), "2.0");
Assert.assertEquals(this.baseExtension.getId().getId(), extension.getId());
Assert.assertEquals(this.baseExtension.getType(), extension.getType());
Assert.assertEquals(this.baseExtension.getSummary(), extension.getSummary());
Assert.assertEquals(this.baseLicense.getName(), extension.getLicenses().get(0).getName());
Assert.assertEquals(this.baseExtension.getDescription(), extension.getDescription());
Assert.assertEquals(this.baseAuthor.getName(), extension.getAuthors().get(0).getName());
Assert.assertEquals(this.baseAuthor.getURL().toString(), extension.getAuthors().get(0).getUrl());
Assert.assertEquals("2.0", extension.getVersion());
Assert.assertEquals(getUtil().getURL(Arrays.asList("Extension", this.baseExtension.getName()), ""), extension.getWebsite());
// File
Assert.assertEquals(this.sizeOfFile, getUtil().rest().getBuffer(Resources.EXTENSION_VERSION_FILE, null, this.baseExtension.getId().getId(), "2.0").length);
// //////////////////////////////////////////
// 10.0
// //////////////////////////////////////////
// Resolve
extension = getUtil().rest().getResource(Resources.EXTENSION_VERSION, null, this.baseExtension.getId().getId(), "10.0");
Assert.assertEquals(this.baseExtension.getId().getId(), extension.getId());
Assert.assertEquals(this.baseExtension.getType(), extension.getType());
Assert.assertEquals(this.baseExtension.getSummary(), extension.getSummary());
Assert.assertEquals(this.baseLicense.getName(), extension.getLicenses().get(0).getName());
Assert.assertEquals(this.baseAuthor.getName(), extension.getAuthors().get(0).getName());
Assert.assertEquals(this.baseAuthor.getURL().toString(), extension.getAuthors().get(0).getUrl());
Assert.assertEquals("10.0", extension.getVersion());
Assert.assertEquals(getUtil().getURL(Arrays.asList("Extension", this.baseExtension.getName()), ""), extension.getWebsite());
ExtensionDependency dependency1 = extension.getDependencies().get(0);
Assert.assertEquals("dependencyid1", dependency1.getId());
Assert.assertEquals("1.0", dependency1.getConstraint());
ExtensionDependency dependency2 = extension.getDependencies().get(1);
Assert.assertEquals("dependencyid2", dependency2.getId());
Assert.assertEquals("2.0", dependency2.getConstraint());
// File
Assert.assertEquals(this.sizeOfFile, getUtil().rest().getBuffer(Resources.EXTENSION_VERSION_FILE, null, this.baseExtension.getId().getId(), this.baseExtension.getId().getVersion().getValue()).length);
// //////////////////////////////////////////
// Search
// //////////////////////////////////////////
// Empty search
extension = searchExtension(this.baseExtension.getId().getId());
if (extension == null) {
Assert.fail("Could not find extension [" + this.baseExtension.getId().getId() + "]");
}
Assert.assertEquals(this.baseExtension.getId().getId(), extension.getId());
Assert.assertEquals(this.baseExtension.getType(), extension.getType());
Assert.assertEquals(this.baseExtension.getSummary(), extension.getSummary());
Assert.assertEquals(this.baseLicense.getName(), extension.getLicenses().get(0).getName());
Assert.assertEquals(this.baseAuthor.getName(), extension.getAuthors().get(0).getName());
Assert.assertEquals(this.baseAuthor.getURL().toString(), extension.getAuthors().get(0).getUrl());
Assert.assertEquals("10.0", extension.getVersion());
// TODO: add support for dependencies in XR search
// Search pattern
Map<String, Object[]> queryParams = new HashMap<String, Object[]>();
queryParams.put(Resources.QPARAM_SEARCH_QUERY, new Object[] { "macro" });
ExtensionsSearchResult result = getUtil().rest().getResource(Resources.SEARCH, queryParams);
Assert.assertEquals(1, result.getTotalHits());
Assert.assertEquals(0, result.getOffset());
extension = result.getExtensions().get(0);
Assert.assertEquals(this.baseExtension.getId().getId(), extension.getId());
Assert.assertEquals(this.baseExtension.getType(), extension.getType());
Assert.assertEquals(this.baseExtension.getSummary(), extension.getSummary());
Assert.assertEquals(this.baseLicense.getName(), extension.getLicenses().get(0).getName());
Assert.assertEquals(this.baseAuthor.getName(), extension.getAuthors().get(0).getName());
Assert.assertEquals(this.baseAuthor.getURL().toString(), extension.getAuthors().get(0).getUrl());
Assert.assertEquals("10.0", extension.getVersion());
// Wrong search pattern
queryParams.clear();
queryParams.put(Resources.QPARAM_SEARCH_QUERY, new Object[] { "notexisting" });
result = getUtil().rest().getResource(Resources.SEARCH, queryParams);
Assert.assertEquals(0, result.getTotalHits());
Assert.assertEquals(0, result.getOffset());
Assert.assertEquals(0, result.getExtensions().size());
// Search limit offset
queryParams.clear();
queryParams.put(Resources.QPARAM_LIST_START, new Object[] { 1 });
result = getUtil().rest().getResource(Resources.SEARCH, queryParams);
Assert.assertEquals(1, result.getOffset());
Assert.assertEquals(result.getTotalHits() - 1, result.getExtensions().size());
// Search limit nb
queryParams.clear();
queryParams.put(Resources.QPARAM_LIST_NUMBER, new Object[] { 0 });
result = getUtil().rest().getResource(Resources.SEARCH, queryParams);
Assert.assertTrue(result.getTotalHits() >= 1);
Assert.assertEquals(0, result.getOffset());
Assert.assertEquals(0, result.getExtensions().size());
}
use of org.xwiki.repository.test.po.ExtensionsPage in project xwiki-platform by xwiki.
the class RepositoryTest method validateRecommendations.
private void validateRecommendations() throws Exception {
// At this stage we assume that we have 2 Extensions in the Repository app and we'll make one of them
// Recommended.
// Then we'll turn on Recommendations and verify that the home page lists only the Recommended one.
// Then we'll click on the Browse button to list all extensions and verify we have 2 in the list.
// Then we'll click again on the Browse button to list only Recommended extensions and verify we have 1
// in the list.
// Last we'll navigate to an extension and verify that when clicking the breadcrumb we're still on the
// Recommended list.
// Note: We don't yet offer a UI for changing the Recommended flag for an Extension.
getUtil().updateObject(Arrays.asList("Extension", "Macro JAR extension"), "WebHome", "ExtensionCode.ExtensionClass", 0, "recommended", 1);
// Turn on Recommendation. There's also no Admin UI yet for this.
getUtil().updateObject("ExtensionCode", "RepositoryConfig", "ExtensionCode.RepositoryConfigClass", 0, "useRecommendations", 1);
// Verify that the home page now lists only the Recommended extension.
ExtensionsPage extensionsPage = ExtensionsPage.gotoPage();
ExtensionsLiveTableElement livetable = extensionsPage.getLiveTable();
Assert.assertEquals(1, livetable.getRowCount());
// Click on Browse button to list All Extensions
extensionsPage = extensionsPage.clickBrowse();
// Verify that the home page now lists all extensions.
livetable = extensionsPage.getLiveTable();
Assert.assertEquals(2, livetable.getRowCount());
// Click on Browse button to list Recommended Extensions
extensionsPage = extensionsPage.clickBrowse();
// Verify that the home page now lists only Recommended extensions.
livetable = extensionsPage.getLiveTable();
Assert.assertEquals(1, livetable.getRowCount());
// Navigate to the extension and click the breadcrumb and verify that we're listing only Recommended extensions
ExtensionPage extensionPage = livetable.clickExtensionName("Macro JAR extension");
extensionPage.clickBreadcrumbLink("Extensions");
extensionsPage = new ExtensionsPage();
livetable = extensionsPage.getLiveTable();
Assert.assertEquals(1, livetable.getRowCount());
}
use of org.xwiki.repository.test.po.ExtensionsPage in project xwiki-platform by xwiki.
the class RepositoryTest method importExtension.
private ExtensionPage importExtension() throws Exception {
ExtensionsPage extensionsPage = ExtensionsPage.gotoPage();
ExtensionImportPage importPage = extensionsPage.clickImport();
importPage.setExtensionId("maven:extension");
importPage.setSourceRepository("maven-test");
ExtensionPage extensionPage = importPage.clickImport();
// Check
Assert.assertEquals("1.1", extensionPage.getMetaDataValue("version"));
Assert.assertTrue(extensionPage.isValidExtension());
testRestAccessToImportedExtension();
// Import again
extensionPage = extensionPage.updateExtension();
Assert.assertEquals("1.1", extensionPage.getMetaDataValue("version"));
return extensionPage;
}
Aggregations