Code development platform for open source projects from the European Union institutions

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

automated EDTRES-06

parent afb93f30
No related branches found
No related tags found
No related merge requests found
Pipeline #256195 failed
......@@ -110,6 +110,12 @@ public class CommonEditDocumentPage extends DomiSMPPage {
public void clickOnSave() {
weToDButton(saveBtn).click();
}
public void clickOnCancelAndConfirm() {
weToDButton(cancelBtn).click();
new ConfirmationDialog(driver).confirm();
}
public DButton getRequestReviewBtn() {
......
package utils;
import org.apache.xerces.dom.DeferredElementNSImpl;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
import org.slf4j.Logger;
......@@ -50,12 +51,18 @@ public class XMLUtils {
return nList.getLength() != 0;
}
public void setContextValueForNode(String nodeName, String attributeName, String attributeValue) {
public void setContextValueForNode(String nodeName, String attributeValue) {
NodeList nList = doc.getElementsByTagName(nodeName);
Node nNode = nList.item(0);
nNode.setTextContent(attributeValue);
}
public void setAttributeValueForNode(String nodeName, String attributeName, String attributeValue) {
NodeList nList = doc.getElementsByTagName(nodeName);
Node nNode = nList.item(0);
((DeferredElementNSImpl) nNode).setAttribute(attributeName, attributeValue);
}
public String getNodeValue(String nodeName) {
NodeList nList = doc.getElementsByTagName(nodeName);
if (nList.getLength() > 0) {
......
......@@ -274,6 +274,49 @@ public class EditResourcePgTests extends SeleniumTest {
soft.assertAll();
}
@Test(description = "EDTRES-06 Resource admin is not able to Save invalid documents", priority = 1)
public void resourceAdminIsNotAbleToSaveInvalidDocuments() throws Exception {
//Generate resource Oasis 3
ResourceModel resourceModel = ResourceModel.generatePublicResourceUnregisteredToSML();
resourceModel.setResourceTypeIdentifier(ResourceTypes.OASIS1.getName());
resourceModel = rest.resources().createResourceForGroup(domainModel, groupModel, resourceModel);
rest.resources().addMembersToResource(domainModel, groupModel, resourceModel, adminMember);
editResourcePage.refreshPage();
editResourcePage.selectDomain(domainModel, groupModel, resourceModel);
editResourcePage.goToTab("Resource details");
EditResourceDocumentPage editResourceDocumentPage = editResourcePage.getResourceDetailsTab().clickOnEditDocument();
editResourceDocumentPage.clickOnNewVersion();
String currentGeneratedValue = editResourceDocumentPage.getDocumentValue();
XMLUtils documentXML = new XMLUtils(currentGeneratedValue);
//set invalid value for scheme
String invalidScheme = "wrong-scheme";
documentXML.setAttributeValueForNode("ParticipantIdentifier", "scheme", invalidScheme);
editResourceDocumentPage.setDocumentValue(documentXML.printDoc());
editResourceDocumentPage.clickOnSave();
String error = editResourceDocumentPage.getAlertArea().getAlertMessage();
soft.assertEquals(error, "Invalid Identifier: [" + invalidScheme + "::" + resourceModel.getIdentifierValue() + "]. Invalid scheme [" + invalidScheme + "]!", "Wrong error message for invalid scheme: ");
editResourceDocumentPage.clickOnCancelAndConfirm();
editResourceDocumentPage.clickOnNewVersion();
documentXML = new XMLUtils(currentGeneratedValue);
//set invalid value for scheme
String invalidParticipant = "wrong-participant";
documentXML.setContextValueForNode("ParticipantIdentifier", invalidParticipant);
editResourceDocumentPage.setDocumentValue(documentXML.printDoc());
editResourceDocumentPage.clickOnSave();
error = editResourceDocumentPage.getAlertArea().getAlertMessage();
soft.assertTrue(error.startsWith("Invalid request [StoreResourceValidation]. Error: ResourceException: Participant identifiers don't match between URL parameter [ResourceIdentifier"), "Wrong error message for invalid participant identifier: ");
soft.assertAll();
}
@Test(description = "EDTRES-08 Resource admin is able to add subresources with valid document", priority = 1)
public void resourceAdminIsAbleToAddSubresourceWithValidDocument() throws Exception {
......
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