| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.test.ui; |
| 21 |
|
|
| 22 |
|
import org.junit.Assert; |
| 23 |
|
import org.junit.Before; |
| 24 |
|
import org.junit.Rule; |
| 25 |
|
import org.junit.Test; |
| 26 |
|
import org.openqa.selenium.By; |
| 27 |
|
import org.xwiki.test.ui.browser.IgnoreBrowser; |
| 28 |
|
import org.xwiki.test.ui.po.FormElement; |
| 29 |
|
import org.xwiki.test.ui.po.ViewPage; |
| 30 |
|
import org.xwiki.test.ui.po.editor.ClassEditPage; |
| 31 |
|
import org.xwiki.test.ui.po.editor.ObjectEditPage; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
@version |
| 37 |
|
@since |
| 38 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (40) |
Complexity: 4 |
Complexity Density: 0.11 |
|
| 39 |
|
public class EditClassTest extends AbstractTest |
| 40 |
|
{ |
| 41 |
|
@Rule |
| 42 |
|
public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil()); |
| 43 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 44 |
3 |
@Before... |
| 45 |
|
public void setUp() throws Exception |
| 46 |
|
{ |
| 47 |
3 |
getUtil().rest().deletePage("Test", "EditObjectsTestClass"); |
| 48 |
3 |
getUtil().rest().deletePage("Test", "EditObjectsTestObject"); |
| 49 |
|
} |
| 50 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
| 51 |
1 |
@Test... |
| 52 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146") |
| 53 |
|
public void testAddProperty() |
| 54 |
|
{ |
| 55 |
|
|
| 56 |
|
|
| 57 |
1 |
getUtil().gotoPage("Test", "EditObjectsTestClass", "view", "spaceRedirect=false"); |
| 58 |
1 |
ClassEditPage cep = new ViewPage().editClass(); |
| 59 |
|
|
| 60 |
|
|
| 61 |
1 |
cep.addProperty("prop", "String"); |
| 62 |
1 |
cep.clickSaveAndView(); |
| 63 |
|
|
| 64 |
|
|
| 65 |
1 |
ViewPage vp = getUtil().createPage("Test", "EditObjectsTestObject", |
| 66 |
|
"this is the content: {{velocity}}$doc.display('prop'){{/velocity}}", getTestMethodName()); |
| 67 |
|
|
| 68 |
|
|
| 69 |
1 |
ObjectEditPage oep = vp.editObjects(); |
| 70 |
1 |
FormElement objectForm = oep.addObject("Test.EditObjectsTestClass"); |
| 71 |
1 |
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "testing value"); |
| 72 |
1 |
vp = oep.clickSaveAndView(); |
| 73 |
|
|
| 74 |
1 |
Assert.assertEquals("this is the content: testing value", vp.getContent()); |
| 75 |
|
} |
| 76 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 77 |
1 |
@Test... |
| 78 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146") |
| 79 |
|
public void testDeleteProperty() |
| 80 |
|
{ |
| 81 |
|
|
| 82 |
1 |
getUtil().addClassProperty("Test", "EditObjectsTestClass", "prop1", "String"); |
| 83 |
1 |
getUtil().addClassProperty("Test", "EditObjectsTestClass", "prop2", "String"); |
| 84 |
|
|
| 85 |
|
|
| 86 |
1 |
ViewPage vp = getUtil().createPage("Test", "EditObjectsTestObject", |
| 87 |
|
"this is the content: {{velocity}}$doc.display('prop1')/$doc.display('prop2')/" + |
| 88 |
|
"$!doc.getObject('Test.EditObjectsTestClass').getProperty('prop1').value{{/velocity}}", |
| 89 |
|
getTestMethodName()); |
| 90 |
|
|
| 91 |
|
|
| 92 |
1 |
ObjectEditPage oep = vp.editObjects(); |
| 93 |
1 |
FormElement objectForm = oep.addObject("Test.EditObjectsTestClass"); |
| 94 |
1 |
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop1"), "testing value 1"); |
| 95 |
1 |
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop2"), "testing value 2"); |
| 96 |
1 |
vp = oep.clickSaveAndView(); |
| 97 |
|
|
| 98 |
1 |
Assert.assertEquals("this is the content: testing value 1/testing value 2/testing value 1", vp.getContent()); |
| 99 |
|
|
| 100 |
|
|
| 101 |
1 |
ClassEditPage cep = getUtil().editClass("Test", "EditObjectsTestClass"); |
| 102 |
1 |
cep.deleteProperty("prop1"); |
| 103 |
1 |
cep.clickSaveAndView(); |
| 104 |
|
|
| 105 |
1 |
vp = getUtil().gotoPage("Test", "EditObjectsTestObject"); |
| 106 |
1 |
Assert.assertEquals("this is the content: /testing value 2/testing value 1", vp.getContent()); |
| 107 |
|
|
| 108 |
1 |
oep = vp.editObjects(); |
| 109 |
1 |
Assert.assertNotNull(getDriver().findElement(By.className("deprecatedProperties"))); |
| 110 |
1 |
Assert.assertNotNull(getDriver().findElement(By.cssSelector(".deprecatedProperties label"))); |
| 111 |
1 |
Assert.assertEquals("prop1:", getDriver().findElement(By.cssSelector(".deprecatedProperties label")).getText()); |
| 112 |
|
|
| 113 |
|
|
| 114 |
1 |
oep.removeAllDeprecatedProperties(); |
| 115 |
1 |
vp = oep.clickSaveAndView(); |
| 116 |
1 |
Assert.assertEquals("this is the content: /testing value 2/", vp.getContent()); |
| 117 |
|
} |
| 118 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 119 |
1 |
@Test... |
| 120 |
|
public void addInvalidProperty() |
| 121 |
|
{ |
| 122 |
1 |
ClassEditPage cep = getUtil().editClass("Test", "EditObjectsTestClass"); |
| 123 |
1 |
cep.addPropertyWithoutWaiting("a<b c", "String"); |
| 124 |
1 |
cep.waitForNotificationErrorMessage("Failed: Property names must follow these naming rules:"); |
| 125 |
|
} |
| 126 |
|
} |