Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 2792595d authored by Mihai BOZ's avatar Mihai BOZ
Browse files

Created test to add new version of subresource document, added necessary components for that

parent 506cc292
No related branches found
No related tags found
No related merge requests found
Pipeline #225186 failed
Showing
with 679 additions and 179 deletions
......@@ -15,6 +15,7 @@ import pages.administration.ReviewTasksPage;
import pages.administration.editDomainsPage.EditDomainsPage;
import pages.administration.editGroupsPage.EditGroupsPage;
import pages.administration.editResourcesPage.EditResourcePage;
import pages.search.ResourcesPage;
import pages.systemSettings.TruststorePage;
import pages.systemSettings.UsersPage;
import pages.systemSettings.domainsPage.DomainsPage;
......@@ -36,7 +37,7 @@ public class SideNavigationComponent extends DomiSMPPage {
private WebElement resourcesLnk;
@FindBy(id = "search-toolsButton")
private WebElement resourcesExpandLnk;
private WebElement searchExpandLnk;
// ----------------------------------------------------
// --------------Administration---------------------------
......@@ -113,12 +114,12 @@ public class SideNavigationComponent extends DomiSMPPage {
LOG.debug("Get link to " + page.name());
// DomiSMP behaviour. Button is not expanded if already focused and not expanded - issue when re-login
// with this we make sure the starting point from Search
openSubmenu(resourcesExpandLnk, null);
openSubmenu(searchExpandLnk, null);
// case SEARCH_RESOURCES:
// expandSection(resourcesExpandLnk);s
// return new DLink(driver, resourcesLnk);
if (page == Pages.SEARCH_RESOURCES) {
openSubmenu(searchExpandLnk, resourcesLnk);
return (T) new ResourcesPage(driver);
}
if (page == Pages.ADMINISTRATION_EDIT_DOMAINS) {
openSubmenu(administrationExpand, editDomainsLnk);
return (T) new EditDomainsPage(driver);
......
......@@ -5,6 +5,7 @@ import ddsl.dcomponents.DComponent;
import ddsl.dcomponents.Grid.MatSmallGrid;
import ddsl.dcomponents.commonComponents.members.InviteMembersWithGridPopup;
import org.openqa.selenium.ElementNotInteractableException;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -15,7 +16,7 @@ import org.openqa.selenium.support.FindBy;
public class SubcategoryTabComponent extends DComponent {
@FindBy(id = "createButton")
private WebElement createBtn;
@FindBy(id = "editButton")
@FindBy(css = "mat-toolbar-row button[id=\"editButton\"]")
private WebElement editBtn;
@FindBy(id = "groupMembersButton")
private WebElement membersBtn;
......@@ -43,9 +44,14 @@ public class SubcategoryTabComponent extends DComponent {
protected void edit(String columnName, String value) throws Exception {
WebElement tobeEdited = getGrid().searchAndGetElementInColumn(columnName, value);
tobeEdited.click();
wait.forElementToBeEnabled(editBtn);
weToDButton(editBtn).click();
try {
tobeEdited.click();
wait.forElementToBeEnabled(editBtn);
weToDButton(editBtn).click();
} catch (NoSuchElementException e) {
throw new NoSuchElementException("Element was not found in the grid: " + value);
}
}
protected void delete(String columnName, String value){
......
......@@ -50,6 +50,7 @@ public class CreateResourceDetailsDialog extends DComponent {
wait.forElementToBeClickable(saveBtn);
if (weToDButton(saveBtn).isEnabled()) {
weToDButton(saveBtn).click();
wait.forElementToBeGone(saveBtn);
return true;
} else {
return false;
......
......@@ -7,16 +7,17 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import rest.models.ResourceModel;
import rest.models.SubresourceModel;
public class CreateSubresourceDetailsDialog extends DComponent {
@FindBy(id = "subresourceTypeIdentifier")
private WebElement subresourceTypeDdl;
@FindBy(id = "identifierValue_id")
private WebElement subresourceIdentifierInput;
@FindBy(id = "identifierScheme_id")
private WebElement subresourceSchemeInput;
@FindBy(id = "createButton")
@FindBy(css = "mat-dialog-actions button[id=\"createButton\"]")
private WebElement createBtn;
private AlertComponent alertComponent = null;
......@@ -34,15 +35,16 @@ public class CreateSubresourceDetailsDialog extends DComponent {
}
public void fillResourceDetails(ResourceModel resourceModel) {
weToDInput(subresourceIdentifierInput).fill(resourceModel.getIdentifierValue());
weToDInput(subresourceSchemeInput).fill(resourceModel.getIdentifierScheme());
public void fillResourceDetails(SubresourceModel subresourceModel) {
weToDInput(subresourceIdentifierInput).fill(subresourceModel.getIdentifierValue());
weToDInput(subresourceSchemeInput).fill(subresourceModel.getIdentifierScheme());
}
public Boolean tryClickOnSave() {
wait.forElementToBeClickable(createBtn);
if (weToDButton(createBtn).isEnabled()) {
weToDButton(createBtn).click();
wait.forElementToBeGone(createBtn);
return true;
} else {
return false;
......
package pages.administration.editResourcesPage;
import ddsl.CommonPageWithTabsAndGrid;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -29,11 +28,6 @@ public class EditResourcePage extends CommonPageWithTabsAndGrid {
super(driver);
LOG.debug("Loading Edit resources page.");
}
public void selectGroup(DomainModel domainModel, GroupModel groupModel) {
weToMatSelect(domainDdl).selectByVisibleText(domainModel.getDomainCode());
}
public ResourcesMembersTab getResourceMembersTab() {
return new ResourcesMembersTab(driver);
}
......@@ -42,22 +36,13 @@ public class EditResourcePage extends CommonPageWithTabsAndGrid {
return new ResourceDetailsTab(driver);
}
public SubresourceTab getSubresourceTab() {
return new SubresourceTab(driver);
}
public void selectDomain(DomainModel domainModel, GroupModel groupModel, ResourceModel resourceModel) {
weToMatSelect(domainDdl).selectByVisibleText(domainModel.getDomainCode());
weToMatSelect(groupDdl).selectByVisibleText(groupModel.getGroupName());
getLeftSideGrid().searchAndClickElementInColumn("Identifier", resourceModel.getIdentifierValue());
}
public boolean isCurrentUserAdministrator() {
try {
if (notAdministratorWarning.isDisplayed()) {
return true;
}
return false;
} catch (NoSuchElementException e) {
return false;
}
}
}
package pages.administration.editResourcesPage;
import ddsl.dcomponents.commonComponents.members.MembersComponent;
import ddsl.dcomponents.commonComponents.subcategoryTab.SubcategoryTabComponent;
import org.openqa.selenium.ElementNotInteractableException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import pages.administration.editResourcesPage.editResourceDocumentPage.EditSubresourceDocumentPage;
import rest.models.SubresourceModel;
/**
* Page object Subresource tab of Edit Resource page. This contains the locators of the page and the methods for the behaviour of the page
*/
public class SubresourceTab extends MembersComponent {
public class SubresourceTab extends SubcategoryTabComponent {
public SubresourceTab(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
}
public CreateSubresourceDetailsDialog createSubresource() throws ElementNotInteractableException {
create();
return new CreateSubresourceDetailsDialog(driver);
}
public EditSubresourceDocumentPage editSubresouceDocument(SubresourceModel subresourceModel) throws Exception {
edit("Identifier", subresourceModel.getIdentifierValue());
return new EditSubresourceDocumentPage(driver);
}
}
package pages.administration.editResourcesPage.editResourceDocumentPage;
import ddsl.DomiSMPPage;
import ddsl.dcomponents.ConfirmationDialog;
import ddsl.dobjects.DButton;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class CommonEditDocumentPage extends DomiSMPPage {
private final static Logger LOG = LoggerFactory.getLogger(CommonEditDocumentPage.class);
@FindBy(id = "documentWizard_id")
public WebElement documentWizardBtn;
@FindBy(id = "document-version_id")
public WebElement versionDdl;
@FindBy(id = "status_id")
public WebElement statusLbl;
@FindBy(id = "newVersion_id")
private WebElement newVersionBtn;
@FindBy(id = "GenerateResource_id")
private WebElement generateBtn;
@FindBy(id = "validateResource_id")
private WebElement validateBtn;
@FindBy(css = "smp-titled-label[title=\"Resource identifier:\"] div.smp-tl-value")
private WebElement resourceIdentifierLbl;
@FindBy(css = "smp-titled-label[title=\"Resource scheme:\"] div.smp-tl-value")
private WebElement resourceSchemeLbl;
@FindBy(css = "smp-titled-label[title=\"Document name:\"] div.smp-tl-value")
private WebElement documentNameLbl;
@FindBy(css = "smp-titled-label[title=\"Document mimeType:\"] div.smp-tl-value")
private WebElement documentMimeTypeLbl;
@FindBy(css = "smp-titled-label[title=\"Current document version:\"] div.smp-tl-value")
private WebElement currentDocumentVersionLbl;
@FindBy(id = "saveResource_id")
private WebElement saveBtn;
@FindBy(id = "cancel_id")
private WebElement cancelBtn;
@FindBy(id = "reviewResource_id")
private WebElement reviewRequestBtn;
@FindBy(css = "button.mat-mdc-tooltip-trigger:nth-child(8)")
private WebElement approveBtn;
@FindBy(css = "button.mat-mdc-tooltip-trigger:nth-child(9)")
private WebElement rejectBtn;
@FindBy(id = "publishResource_id")
private WebElement publishBtn;
@FindBy(css = "ngx-codemirror[formcontrolname= \"payload\"] div textarea")
private WebElement codeEditorSendValueElement;
@FindBy(css = "div.cm-line")
private List<WebElement> codeEditorReadValueElement;
public CommonEditDocumentPage(WebDriver driver) {
super(driver);
LOG.debug("Loading Edit resource document page.");
}
public String getDocumentValue() {
ArrayList<String> document = new ArrayList<>();
for (WebElement el : codeEditorReadValueElement) {
document.add(el.getText());
}
String formatedDoc = document.toString();
formatedDoc
= formatedDoc.replace("[", "")
.replace("]", "")
.replace(",", "");
return formatedDoc;
}
public void clickOnNewVersion() {
weToDButton(newVersionBtn).click();
}
public void clickOnGenerate() {
weToDButton(generateBtn).click();
}
public void clickOnSave() {
weToDButton(saveBtn).click();
}
public DButton getRequestReviewBtn() {
return weToDButton(reviewRequestBtn);
}
public DButton getApproveBtn() {
return weToDButton(approveBtn);
}
public DButton getPublishBtn() {
return weToDButton(publishBtn);
}
public String getStatusValue() {
return weToDInput(statusLbl).getText();
}
public void clickOnValidate() {
weToDButton(validateBtn).click();
}
public void clickOnApproveAndConfirm() {
weToDButton(approveBtn).click();
new ConfirmationDialog(driver).confirm();
}
public void clickOnPublishAndConfirm() {
weToDButton(publishBtn).click();
new ConfirmationDialog(driver).confirm();
}
public void selectVersion(int version) {
weToMatSelect(versionDdl).selectByVisibleText(String.valueOf(version));
}
}
package pages.administration.editResourcesPage.editResourceDocumentPage;
import ddsl.DomiSMPPage;
import ddsl.dcomponents.ConfirmationDialog;
import ddsl.dobjects.DButton;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
/**
* Page object for the Edit resource document page. This contains the locators of the page and the methods for the behaviour of the page
*/
public class EditResourceDocumentPage extends DomiSMPPage {
private final static Logger LOG = LoggerFactory.getLogger(EditResourceDocumentPage.class);
@FindBy(id = "newVersion_id")
private WebElement newVersionBtn;
@FindBy(id = "GenerateResource_id")
private WebElement generateBtn;
@FindBy(id = "validateResource_id")
private WebElement validateBtn;
@FindBy(id = "documentWizard_id")
private WebElement documentWizardBtn;
@FindBy(css = "smp-titled-label[title=\"Resource identifier:\"] div.smp-tl-value")
private WebElement resourceIdentifierLbl;
@FindBy(css = "smp-titled-label[title=\"Resource scheme:\"] div.smp-tl-value")
private WebElement resourceSchemeLbl;
@FindBy(css = "smp-titled-label[title=\"Document name:\"] div.smp-tl-value")
private WebElement documentNameLbl;
@FindBy(css = "smp-titled-label[title=\"Document mimeType:\"] div.smp-tl-value")
private WebElement documentMimeTypeLbl;
@FindBy(css = "smp-titled-label[title=\"Current document version:\"] div.smp-tl-value")
private WebElement currentDocumentVersionLbl;
@FindBy(id = "saveResource_id")
private WebElement saveBtn;
@FindBy(id = "cancel_id")
private WebElement cancelBtn;
@FindBy(id = "document-version_id")
public WebElement versionDdl;
@FindBy(id = "status_id")
public WebElement statusLbl;
@FindBy(id = "reviewResource_id")
private WebElement reviewRequestBtn;
@FindBy(css = "button.mat-mdc-tooltip-trigger:nth-child(8)")
private WebElement approveBtn;
@FindBy(css = "button.mat-mdc-tooltip-trigger:nth-child(9)")
private WebElement rejectBtn;
@FindBy(id = "publishResource_id")
private WebElement publishBtn;
@FindBy(css = "ngx-codemirror[formcontrolname= \"payload\"] div textarea")
private WebElement codeEditorSendValueElement;
@FindBy(css = "div.cm-line")
private List<WebElement> codeEditorReadValueElement;
public class EditResourceDocumentPage extends CommonEditDocumentPage {
public EditResourceDocumentPage(WebDriver driver) {
super(driver);
LOG.debug("Loading Edit resource document page.");
}
public String getDocumentValue() {
ArrayList<String> document = new ArrayList<>();
for (WebElement el : codeEditorReadValueElement) {
document.add(el.getText());
}
String formatedDoc = document.toString();
formatedDoc
= formatedDoc.replace("[", "")
.replace("]", "")
.replace(",", "");
return formatedDoc;
}
public void clickOnNewVersion() {
weToDButton(newVersionBtn).click();
}
public void clickOnGenerate() {
weToDButton(generateBtn).click();
}
public void clickOnSave() {
weToDButton(saveBtn).click();
}
public DButton getRequestReviewBtn() {
return weToDButton(reviewRequestBtn);
}
public DButton getApproveBtn() {
return weToDButton(approveBtn);
}
public DButton getPublishBtn() {
return weToDButton(publishBtn);
}
public String getStatusValue() {
return weToDInput(statusLbl).getText();
}
public void clickOnValidate() {
weToDButton(validateBtn).click();
}
public void clickOnApproveAndConfirm() {
weToDButton(approveBtn).click();
new ConfirmationDialog(driver).confirm();
}
public void clickOnPublishAndConfirm() {
weToDButton(publishBtn).click();
new ConfirmationDialog(driver).confirm();
}
public void selectVersion(int version) {
weToMatSelect(versionDdl).selectByVisibleText(String.valueOf(version));
}
public EditResourceDocumentWizardDialog clickOnDocumentWizard() {
weToDButton(documentWizardBtn).click();
return new EditResourceDocumentWizardDialog(driver);
weToDButton(documentWizardBtn).click();
return new EditResourceDocumentWizardDialog(driver);
}
}
package pages.administration.editResourcesPage.editResourceDocumentPage;
import org.openqa.selenium.WebDriver;
/**
* Page object for the Edit subresource document page. This contains the locators of the page and the methods for the behaviour of the page
*/
public class EditSubresourceDocumentPage extends CommonEditDocumentPage {
public EditSubresourceDocumentPage(WebDriver driver) {
super(driver);
}
public SubresourceWizardDialog clickOnDocumentWizard() {
weToDButton(documentWizardBtn).click();
return new SubresourceWizardDialog(driver);
}
}
package pages.administration.editResourcesPage.editResourceDocumentPage;
import ddsl.dcomponents.DComponent;
import ddsl.dobjects.DInput;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
/**
* Page object of Document wizard for Subresource document. This contains the locators of the page and the methods for the behaviour of the page
*/
public class SubresourceWizardDialog extends DComponent {
@FindBy(id = "processidentifier_id")
private WebElement processIdentifierInput;
@FindBy(id = "processSchema_id")
private WebElement processSchemeInput;
@FindBy(id = "endpointUrl_id")
private WebElement accessPointUrlInput;
@FindBy(id = "uploadCertificateButton")
private WebElement uploadCertificateBtn;
@FindBy(id = "serviceDescription_id")
private WebElement serviceDescriptionInput;
@FindBy(id = "technicalContactUrl_id")
private WebElement technicalContactUrlInput;
@FindBy(id = "certificate-file-upload")
private WebElement uploadInput;
@FindBy(id = "generateSubresourceButton")
private WebElement okBtn;
public SubresourceWizardDialog(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
}
public void clickOK() {
weToDButton(okBtn).click();
}
public DInput processIdentifierInput() {
return weToDInput(processIdentifierInput);
}
public DInput accessPointUrlInput() {
return weToDInput(accessPointUrlInput);
}
public void uploadCertificateBtn(String filepath) {
uploadInput.sendKeys(filepath);
}
}
package pages.search;
import ddsl.dcomponents.DComponent;
import ddsl.dcomponents.Grid.GridPagination;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.NoSuchElementException;
public class ResourcePageGrid extends DComponent {
protected static final By gridHeadersLocator = By.cssSelector("datatable-header div.datatable-row-center datatable-header-cell");
protected static final By gridRowsLocator = By.cssSelector("datatable-body-row > div.datatable-row-center.datatable-row-group");
private final static Logger LOG = LoggerFactory.getLogger(ResourcePageGrid.class);
private final WebElement parentElement;
public ResourcePageGrid(WebDriver driver, WebElement parentElement) {
super(driver);
PageFactory.initElements(driver, this);
this.parentElement = parentElement;
}
public GridPagination getGridPagination() {
return new GridPagination(driver, parentElement);
}
public List<WebElement> getGridHeaders() {
return parentElement.findElements(gridHeadersLocator);
}
public List<WebElement> getRows() {
return parentElement.findElements(gridRowsLocator);
}
public List<WebElement> getCells(WebElement row) {
return row.findElements(By.cssSelector("datatable-body-cell"));
}
public void searchAndClickElementInColumn(String columnName, String value) {
wait.forXMillis(100);
int numOfPages;
try {
numOfPages = getGridPagination().getTotalPageNumber();
} catch (Exception e) {
LOG.debug("No pagination found");
numOfPages = 1;
}
List<WebElement> rowHeaders = getGridHeaders();
int columnIndex = -1;
for (int i = 0; i < rowHeaders.size(); i++) {
if (rowHeaders.get(i).getText().equals(columnName)) {
columnIndex = i;
break;
}
}
if (columnIndex == -1) {
LOG.error("No element found");
throw new NoSuchElementException("Column not found");
}
boolean isElementPresent = false;
for (int pageNr = 0; pageNr < numOfPages + 1; pageNr++) {
List<WebElement> rows = getRows();
for (WebElement row : rows) {
List<WebElement> cells = getCells(row);
WebElement currentCell = cells.get(columnIndex);
if (currentCell.getText().equals(value)) {
LOG.debug("[{}] found on page [{}]", value, pageNr);
isElementPresent = true;
currentCell.click();
}
}
if (isElementPresent) {
return;
}
if (numOfPages > 1) {
getGridPagination().goToNextPage();
}
}
if (!isElementPresent) {
throw new NoSuchElementException("Value [" + value + "] was not found in the grid");
}
}
public void openSubresource(String resourceColumn, String resourceValue, String columnNameSubresouce, String valueSubresource) {
wait.forXMillis(100);
int numOfPages;
try {
numOfPages = getGridPagination().getTotalPageNumber();
} catch (Exception e) {
LOG.debug("No pagination found");
numOfPages = 1;
}
List<WebElement> rowHeaders = getGridHeaders();
int columnIndex = -1;
for (int i = 0; i < rowHeaders.size(); i++) {
if (rowHeaders.get(i).getText().equals(resourceColumn)) {
columnIndex = i;
break;
}
}
if (columnIndex == -1) {
LOG.error("No element found");
throw new NoSuchElementException("Column not found");
}
boolean isElementPresent = false;
for (int pageNr = 0; pageNr < numOfPages + 1; pageNr++) {
List<WebElement> rows = getRows();
for (WebElement row : rows) {
List<WebElement> cells = getCells(row);
WebElement currentCell = cells.get(columnIndex);
if (currentCell.getText().equals(resourceValue)) {
LOG.debug("[{}] found on page [{}]", resourceValue, pageNr);
isElementPresent = true;
currentCell.click();
openURLSubresouce(row, columnNameSubresouce, valueSubresource);
}
}
if (isElementPresent) {
return;
}
if (numOfPages > 1) {
getGridPagination().goToNextPage();
}
}
if (!isElementPresent) {
throw new NoSuchElementException("Value [" + resourceValue + "] was not found in the grid");
}
}
private void openURLSubresouce(WebElement resourceRow, String columnName, String value) {
WebElement parentRowElement = resourceRow.findElement(By.xpath("../following-sibling::*[1]"));
List<WebElement> rowHeaders = parentRowElement.findElements(gridHeadersLocator);
int columnIndex = -1;
for (int i = 0; i < rowHeaders.size(); i++) {
if (rowHeaders.get(i).getText().equals(columnName)) {
columnIndex = i;
break;
}
}
if (columnIndex == -1) {
LOG.error("No element found");
throw new NoSuchElementException("Column not found");
}
boolean isElementPresent = false;
List<WebElement> rows = parentRowElement.findElements(gridRowsLocator);
for (WebElement row : rows) {
List<WebElement> cells = getCells(row);
WebElement currentCell = cells.get(columnIndex);
if (currentCell.getText().equals(value)) {
LOG.debug("[{}] found on page", value);
isElementPresent = true;
WebElement urlCell = cells.get(2);
urlCell.findElement(By.cssSelector("a")).click();
}
}
if (isElementPresent) {
return;
}
if (!isElementPresent) {
throw new NoSuchElementException("Value [" + value + "] was not found in the grid");
}
}
}
package pages.search;
import ddsl.DomiSMPPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import utils.XMLUtils;
import javax.xml.parsers.ParserConfigurationException;
import java.util.Iterator;
import java.util.Set;
public class ResourcesPage extends DomiSMPPage {
private final static Logger LOG = LoggerFactory.getLogger(ResourcesPage.class);
@FindBy(id = "ResourceIdentifier")
private WebElement resourceIdentifierInput;
@FindBy(id = "ResourceScheme")
private WebElement resourceSchemeInput;
@FindBy(id = "Domain")
private WebElement domainDdl;
@FindBy(id = "DocumentType")
private WebElement documentTypeDdl;
@FindBy(id = "searchbutton_id")
private WebElement searchBtn;
@FindBy(css = "smp-search-table")
private WebElement panel;
public ResourcesPage(WebDriver driver) {
super(driver);
}
private ResourcePageGrid getGrid() {
return new ResourcePageGrid(driver, panel);
}
public XMLUtils openURLResouceDocument(String resourceIdentifier, String resourceScheme) {
weToDInput(resourceIdentifierInput).fill(resourceIdentifier);
weToDInput(resourceSchemeInput).fill(resourceScheme);
LOG.debug("Click on Open URL for " + resourceIdentifier);
weToDButton(searchBtn).click();
getGrid().searchAndClickElementInColumn("Resource URL", "Open URL");
Set<String> handles = driver.getWindowHandles();
Iterator<String> iterator = handles.iterator();
// Switch to the new tab
String original = iterator.next();
String newTab = iterator.next();
driver.switchTo().window(newTab);
LOG.debug("Switching to new tab" + newTab);
try {
XMLUtils documentXML = new XMLUtils(driver.getPageSource());
LOG.debug("Reading document value");
return documentXML;
} catch (ParserConfigurationException e) {
LOG.error("Reading document value");
throw new RuntimeException(e);
}
}
public XMLUtils openURLSubResouceDocument(String resourceIdentifier, String resourceScheme, String subresourceIdentifier) {
weToDInput(resourceIdentifierInput).fill(resourceIdentifier);
weToDInput(resourceSchemeInput).fill(resourceScheme);
LOG.debug("Click on Open URL for " + resourceIdentifier);
weToDButton(searchBtn).click();
getGrid().openSubresource("Upd.", "chevron_right", "Subresource identifier", subresourceIdentifier);
Set<String> handles = driver.getWindowHandles();
Iterator<String> iterator = handles.iterator();
// Switch to the new tab
String original = iterator.next();
String newTab = iterator.next();
driver.switchTo().window(newTab);
LOG.debug("Switching to new tab" + newTab);
try {
XMLUtils documentXML = new XMLUtils(driver.getPageSource());
LOG.debug("Reading document value");
return documentXML;
} catch (ParserConfigurationException e) {
LOG.error("Reading document value");
throw new RuntimeException(e);
}
}
}
......@@ -36,8 +36,9 @@ public class InbucketRestClient {
return jsonArray;
}
public JsonObject getlastmessageOfUser(String userName) {
JSONArray getAllMessagesOfUser = getAllMessagesOfUser(userName);
public JsonObject getlastmessageOfUser(String userName, String title) {
JSONArray getAllMessagesOfUser;
getAllMessagesOfUser = getAllMessagesOfUser(userName);
JSONObject lastmessage = (JSONObject) getAllMessagesOfUser.get(getAllMessagesOfUser.length() - 1);
String lastmessageId = lastmessage.get("id").toString();
WebResource.Builder builder = resource.path("serve/mailbox/" + userName + "/" + lastmessageId).getRequestBuilder();
......@@ -49,25 +50,36 @@ public class InbucketRestClient {
public String getResetPasswordTokenFromLastEmailOfUser(String userName) {
JsonObject lastMessageArray = getlastmessageOfUser(userName);
if (lastMessageArray.isEmpty()) {
LOG.error("Last email of user is empty!");
fail();
}
String subject = lastMessageArray.get("subject").toString();
if (subject.contains("Request for reset of the Credential")) {
String text = lastMessageArray.get("text").toString();
String regex = "http://[^\\s\"<>]+(?=\\s|<|$)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
return matcher.group(0);
JsonObject lastMessageArray = null;
int i = 0;
boolean isResetEmail = false;
while (i <= 5 & !isResetEmail) {
lastMessageArray = getlastmessageOfUser(userName, "Request for reset of the Credential");
if (lastMessageArray.isEmpty()) {
LOG.error("Last email of user is empty!");
fail();
}
if (lastMessageArray.get("subject").toString().contains("Request for reset of the Credential")) {
isResetEmail = true;
String text = lastMessageArray.get("text").toString();
String regex = "http://[^\\s\"<>]+(?=\\s|<|$)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
return matcher.group(0);
}
LOG.error("Reset URL found in the email: " + text);
throw new NullPointerException("Reset URL found in the email: " + text);
}
LOG.error("Reset URL found in the email: " + text);
throw new NullPointerException("Reset URL found in the email: " + text);
i++;
}
throw new NullPointerException("Last email is not a reset email. The current subject found is: " + subject);
throw new NullPointerException("Could not find reset email. The current subject found is: " + lastMessageArray.get("subject").toString());
}
}
package rest.models;
import utils.Generator;
public class SubresourceModel {
private String identifierScheme;
private String identifierValue;
private Object actionMessage;
private int index;
private String subresourceId;
private String subresourceTypeIdentifier;
private int status;
public static SubresourceModel generatePublicSubResource() {
SubresourceModel subresourceModel = new SubresourceModel();
subresourceModel.identifierValue = ("AUT_subIdentifier_" + Generator.randomAlphaNumericValue(4)).toLowerCase();
subresourceModel.identifierScheme = ("AUT_subrScheme_" + Generator.randomAlphaNumericValue(4)).toLowerCase();
return subresourceModel;
}
public String getIdentifierScheme() {
return identifierScheme;
}
public String getIdentifierValue() {
return identifierValue;
}
public Object getActionMessage() {
return actionMessage;
}
public int getIndex() {
return index;
}
public String getSubresourceId() {
return subresourceId;
}
public String getSubresourceTypeIdentifier() {
return subresourceTypeIdentifier;
}
public int getStatus() {
return status;
}
}
......@@ -7,6 +7,7 @@ import java.nio.file.Paths;
public class FileUtils {
private static final Path keystoreFolder = Paths.get("src", "main", "resources", "keystore");
private static final Path trustStoreFolder = Paths.get("src", "main", "resources", "truststore");
public static String getAbsolutePath(String relativePath) {
......@@ -23,4 +24,8 @@ public class FileUtils {
return keystoreFolder.resolve(keystoreFileName).toAbsolutePath().toString();
}
public static String getAbsoluteTruststorePath(String truststoreFileName) {
return trustStoreFolder.resolve(truststoreFileName).toAbsolutePath().toString();
}
}
......@@ -9,10 +9,15 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.testng.asserts.SoftAssert;
import pages.LoginPage;
import pages.administration.editResourcesPage.CreateSubresourceDetailsDialog;
import pages.administration.editResourcesPage.EditResourcePage;
import pages.administration.editResourcesPage.editResourceDocumentPage.EditResourceDocumentPage;
import pages.administration.editResourcesPage.editResourceDocumentPage.EditResourceDocumentWizardDialog;
import pages.administration.editResourcesPage.editResourceDocumentPage.EditSubresourceDocumentPage;
import pages.administration.editResourcesPage.editResourceDocumentPage.SubresourceWizardDialog;
import pages.search.ResourcesPage;
import rest.models.*;
import utils.FileUtils;
import utils.Generator;
import utils.TestRunData;
import utils.XMLUtils;
......@@ -283,6 +288,8 @@ public class EditResourcePgTests extends SeleniumTest {
editResourcePage.goToTab("Resource details");
EditResourceDocumentPage editResourceDocumentPage = editResourcePage.getResourceDetailsTab().clickOnEditDocument();
editResourceDocumentPage.clickOnNewVersion();
editResourceDocumentPage.clickOnDocumentWizard().getExtensionAgencyIdnput().fill("NewVersion");
new EditResourceDocumentWizardDialog(driver).clickOK();
editResourceDocumentPage.clickOnSave();
editResourceDocumentPage.getAlertArea().closeAlert();
......@@ -303,12 +310,71 @@ public class EditResourcePgTests extends SeleniumTest {
soft.assertEquals("PUBLISHED", editResourceDocumentPage.getStatusValue());
editResourceDocumentPage.selectVersion(1);
soft.assertEquals("RETIRED", editResourceDocumentPage.getStatusValue());
ResourcesPage resourcesPage = editResourceDocumentPage.getSidebar().navigateTo(Pages.SEARCH_RESOURCES);
XMLUtils documentXML = resourcesPage.openURLResouceDocument(resourceModelOasis1.getIdentifierValue(), resourceModelOasis1.getIdentifierScheme());
soft.assertEquals(documentXML.getNodeValue("ExtensionAgencyID"), "NewVersion", "Document value is wrong");
soft.assertAll();
}
@Test(description = "EDTRES-15 - Resource Administrator can publish subresource documents with approve status", priority = 1)
public void resourceAdministratorsCanPublisSUBResourceDocumentsWithApproveStatus() throws Exception {
ResourceModel resourceModelOasis1 = ResourceModel.generatePublicResourceWithReview(ResourceTypes.OASIS1);
SubresourceModel subresourceModel = SubresourceModel.generatePublicSubResource();
//add resource to group
resourceModelOasis1 = rest.resources().createResourceForGroup(domainModel, groupModel, resourceModelOasis1);
rest.resources().addMembersToResource(domainModel, groupModel, resourceModelOasis1, adminMember);
editResourcePage.refreshPage();
editResourcePage.selectDomain(domainModel, groupModel, resourceModelOasis1);
editResourcePage.goToTab("Subresources");
CreateSubresourceDetailsDialog createSubresourceDetailsDialog = editResourcePage.getSubresourceTab().createSubresource();
createSubresourceDetailsDialog.fillResourceDetails(subresourceModel);
createSubresourceDetailsDialog.tryClickOnSave();
EditSubresourceDocumentPage editSubresourceDocumentPage = editResourcePage.getSubresourceTab().editSubresouceDocument(subresourceModel);
editSubresourceDocumentPage.clickOnNewVersion();
SubresourceWizardDialog subresourceWizardDialog = editSubresourceDocumentPage.clickOnDocumentWizard();
subresourceWizardDialog.processIdentifierInput().fill("123-123-123");
subresourceWizardDialog.accessPointUrlInput().fill("www.domibustest.com");
String path = FileUtils.getAbsoluteTruststorePath("validCertificate.cer");
subresourceWizardDialog.uploadCertificateBtn(path);
subresourceWizardDialog.clickOK();
editSubresourceDocumentPage.clickOnSave();
editSubresourceDocumentPage.getAlertArea().closeAlert();
soft.assertTrue(editSubresourceDocumentPage.getRequestReviewBtn().isEnabled(), "Request review button is not enabled");
soft.assertEquals("DRAFT", editSubresourceDocumentPage.getStatusValue());
//Request review
editSubresourceDocumentPage.getRequestReviewBtn().click();
soft.assertEquals("UNDER_REVIEW", editSubresourceDocumentPage.getStatusValue());
//Self approve
soft.assertTrue(editSubresourceDocumentPage.getApproveBtn().isEnabled(), "Approve button is not enabled");
editSubresourceDocumentPage.clickOnApproveAndConfirm();
soft.assertEquals("APPROVED", editSubresourceDocumentPage.getStatusValue());
soft.assertTrue(editSubresourceDocumentPage.getPublishBtn().isEnabled(), "Publish is not enabled");
editSubresourceDocumentPage.clickOnPublishAndConfirm();
soft.assertEquals("PUBLISHED", editSubresourceDocumentPage.getStatusValue());
editSubresourceDocumentPage.selectVersion(1);
soft.assertEquals("RETIRED", editSubresourceDocumentPage.getStatusValue());
ResourcesPage resourcesPage = editSubresourceDocumentPage.getSidebar().navigateTo(Pages.SEARCH_RESOURCES);
XMLUtils documentXML = resourcesPage.openURLSubResouceDocument(resourceModelOasis1.getIdentifierValue(), resourceModelOasis1.getIdentifierScheme(), subresourceModel.getIdentifierValue());
soft.assertEquals(documentXML.getNodeValue("ParticipantIdentifier"), resourceModelOasis1.getIdentifierValue(), "EndpointURI value is wrong");
soft.assertEquals(documentXML.getNodeValue("DocumentIdentifier"), subresourceModel.getIdentifierValue(), "EndpointURI value is wrong");
soft.assertEquals(documentXML.getNodeValue("EndpointURI"), "www.domibustest.com", "EndpointURI value is wrong");
soft.assertAll();
}
}
......
......@@ -50,7 +50,7 @@ public class UsersPgTests extends SeleniumTest {
soft.assertEquals(usersPage.getEmailValue(), adminNewUserData.getEmailAddress());
soft.assertEquals(usersPage.getSelectedThemeValue(), adminNewUserData.getSmpTheme());
soft.assertEquals(usersPage.getSelectedLocaleValue(), "fr");
soft.assertEquals(usersPage.getSelectedLocaleValue(), "en");
soft.assertAll();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment