Author: jjamrich
Date: 2011-09-05 17:07:07 -0400 (Mon, 05 Sep 2011)
New Revision: 22685
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFiltering.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableScroller.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSimple.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSorting.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSelection.java
Log:
RFPL-1439: change dataTable to use unified way to setting attributes
There are some abstrations classes used in more tests and classes for setting facests (not
directly component attributes) - which was updated as well.
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -26,7 +26,10 @@
import java.util.List;
+import org.jboss.test.selenium.GuardRequest;
+import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.request.RequestType;
import org.richfaces.tests.metamer.bean.Model;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
@@ -58,12 +61,13 @@
protected DataTable model;
protected EmployeeTableModel employees = new EmployeeTableModel();
- protected DataTableAttributes attributes = new DataTableAttributes();
- protected DataTableFacets facets = new DataTableFacets();
+ // protected DataTableFacets facets = new DataTableFacets();
protected DataScroller dataScroller1 = new
AssertingDataScroller("outside-table",
pjq("span.rf-ds[id$=scroller1]"));
protected DataScroller dataScroller2 = new
AssertingDataScroller("inside-table-footer",
pjq("span.rf-ds[id$=scroller2]"));
+
+ JQueryLocator showDataLocator = pjq("input[id$=noDataCheckbox]");
public class EmployeeTableModel {
public Sex getSex(int row) {
@@ -84,4 +88,14 @@
return
Integer.valueOf(selenium.getText(model.getElement(COLUMN_NUMBER_OF_KIDS1, row)));
}
}
+
+ protected void enableShowData(final boolean showData) {
+ new GuardRequest(RequestType.XHR) {
+ public void command() {
+ selenium.check(showDataLocator, showData);
+ selenium.fireEvent(showDataLocator, Event.CLICK);
+ selenium.fireEvent(showDataLocator, Event.CHANGE);
+ }
+ }.waitRequest();
+ }
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -21,69 +21,19 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.abstractions;
-import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedList;
-
-import org.apache.commons.lang.StringUtils;
-import org.jboss.test.selenium.GuardRequest;
-import org.jboss.test.selenium.dom.Event;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.request.RequestType;
-import org.richfaces.model.SortMode;
-import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
-
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class DataTableAttributes extends AbstractComponentAttributes {
+public enum DataTableAttributes implements AttributeEnum {
- JQueryLocator showDataLocator = pjq("input[id$=noDataCheckbox]");
-
- public void setShowData(final boolean showData) {
- new GuardRequest(RequestType.XHR) {
- public void command() {
- selenium.check(showDataLocator, showData);
- selenium.fireEvent(showDataLocator, Event.CLICK);
- selenium.fireEvent(showDataLocator, Event.CHANGE);
- }
- }.waitRequest();
- }
-
- public void setFirst(Integer first) {
- setProperty("first", first);
- }
-
- public void setNoDataLabel(String noDataLabel) {
- setProperty("noDataLabel", noDataLabel);
- }
-
- public void setRendered(Boolean rendered) {
- setProperty("rendered", rendered);
- }
-
- public void setRows(Integer rows) {
- setProperty("rows", rows);
- }
-
- public int getRows() {
- return Integer.valueOf(getProperty("rows"));
- }
-
- public void setSortMode(SortMode sortMode) {
- setProperty("sortMode", sortMode);
- }
-
- public void setSortPriority(Collection<String> sortPriority) {
- setProperty("sortPriority", sortPriority);
- }
-
- public Collection<String> getSortPriority() {
- String string = getProperty("sortPriority");
- return new LinkedList<String>(Arrays.asList(StringUtils.split(string,
"[], ")));
-
- }
+ first,
+ noDataLabel,
+ rendered,
+ rows,
+ sortMode,
+ sortPriority,
+
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -21,47 +21,20 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.abstractions;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
-import org.jboss.test.selenium.locator.ElementLocator;
-import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
-
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class DataTableFacets extends AbstractComponentAttributes {
-
- public void setNoData(String noData) {
- setProperty("noData", noData);
- }
-
- public void setHeader(String header) {
- setProperty("header", header);
- }
+public enum DataTableFacets implements AttributeEnum {
- public void setFooter(String footer) {
- setProperty("footer", footer);
- }
+ noData,
+ header,
+ footer,
+ stateHeader,
+ stateFooter,
+ capitalHeader,
+ capitalFooter
- public void setStateHeader(String stateHeader) {
- setProperty("stateHeader", stateHeader);
- }
-
- public void setStateFooter(String stateFooter) {
- setProperty("stateFooter", stateFooter);
- }
-
- public void setCapitalHeader(String capitalHeader) {
- setProperty("capitalHeader", capitalHeader);
- }
-
- public void setCapitalFooter(String capitalFooter) {
- setProperty("capitalFooter", capitalFooter);
- }
-
- @Override
- protected void applyText(ElementLocator<?> locator, String value) {
- guardXhr(selenium).type(locator, value);
- }
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -21,8 +21,11 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.abstractions;
+import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.dataTableFacets;
import static org.testng.Assert.assertEquals;
+import static org.richfaces.tests.metamer.ftest.abstractions.DataTableFacets.*;
+
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
@@ -33,70 +36,70 @@
private static final String EMPTY_STRING = "";
public void testNoDataInstantChange() {
- attributes.setShowData(false);
- facets.setNoData(SAMPLE_STRING);
+ enableShowData(false);
+ dataTableFacets.set(noData, SAMPLE_STRING);
assertEquals(selenium.getText(model.getNoData()), SAMPLE_STRING);
}
public void testNoDataEmpty() {
- attributes.setShowData(false);
- facets.setNoData(EMPTY_STRING);
+ enableShowData(false);
+ dataTableFacets.set(noData, EMPTY_STRING);
assertEquals(selenium.getText(model.getNoData()), EMPTY_STRING);
}
public void testHeaderInstantChange() {
- facets.setHeader(SAMPLE_STRING);
+ dataTableFacets.set(header, SAMPLE_STRING);
assertEquals(selenium.getText(model.getHeader()), SAMPLE_STRING);
}
public void testHeaderEmpty() {
- facets.setHeader(EMPTY_STRING);
+ dataTableFacets.set(header, EMPTY_STRING);
if (selenium.isElementPresent(model.getHeader())) {
assertEquals(selenium.getText(model.getHeader()), EMPTY_STRING);
} else {
- facets.setHeader(SAMPLE_STRING);
+ dataTableFacets.set(header, SAMPLE_STRING);
assertEquals(selenium.getText(model.getHeader()), SAMPLE_STRING);
}
}
public void testStateHeaderInstantChange() {
- facets.setStateHeader(SAMPLE_STRING);
+ dataTableFacets.set(stateHeader, SAMPLE_STRING);
assertEquals(selenium.getText(model.getColumnHeader(COLUMN_STATE)),
SAMPLE_STRING);
}
public void testStateHeaderEmpty() {
- facets.setStateHeader(EMPTY_STRING);
+ dataTableFacets.set(stateHeader, EMPTY_STRING);
assertEquals(selenium.getText(model.getColumnHeader(COLUMN_STATE)),
EMPTY_STRING);
}
public void testStateFooterInstantChange() {
- facets.setStateFooter(SAMPLE_STRING);
+ dataTableFacets.set(stateFooter, SAMPLE_STRING);
assertEquals(selenium.getText(model.getColumnFooter(COLUMN_STATE)),
SAMPLE_STRING);
}
public void testStateFooterEmpty() {
- facets.setStateFooter(EMPTY_STRING);
+ dataTableFacets.set(stateFooter, EMPTY_STRING);
assertEquals(selenium.getText(model.getColumnFooter(COLUMN_STATE)),
EMPTY_STRING);
}
public void testCapitalHeaderInstantChange() {
- facets.setCapitalHeader(SAMPLE_STRING);
+ dataTableFacets.set(capitalHeader, SAMPLE_STRING);
assertEquals(selenium.getText(model.getColumnHeader(COLUMN_CAPITAL)),
SAMPLE_STRING);
}
public void testCapitalHeaderEmpty() {
- facets.setCapitalHeader(EMPTY_STRING);
+ dataTableFacets.set(capitalHeader, EMPTY_STRING);
assertEquals(selenium.getText(model.getColumnHeader(COLUMN_CAPITAL)),
EMPTY_STRING);
}
public void testCapitalFooterInstantChange() {
- facets.setCapitalFooter(SAMPLE_STRING);
+ dataTableFacets.set(capitalHeader, SAMPLE_STRING);
assertEquals(selenium.getText(model.getColumnFooter(COLUMN_CAPITAL)),
SAMPLE_STRING);
}
public void testCapitalFooterEmpty() {
- facets.setCapitalFooter(EMPTY_STRING);
+ dataTableFacets.set(capitalFooter, EMPTY_STRING);
assertEquals(selenium.getText(model.getColumnFooter(COLUMN_CAPITAL)),
EMPTY_STRING);
}
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -22,6 +22,7 @@
package org.richfaces.tests.metamer.ftest.abstractions;
import static org.testng.Assert.assertEquals;
+import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.dataTableAttributes;
import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Templates;
@@ -49,11 +50,11 @@
private void testRowCount(DataScroller dataScroller) {
if (rows != null) {
- attributes.setRows(rows);
+ dataTableAttributes.set(DataTableAttributes.rows, rows);
}
dataScroller.gotoFirstPage();
- int rowCountPreset = attributes.getRows();
+ int rowCountPreset =
Integer.parseInt(dataTableAttributes.get(DataTableAttributes.rows));
int rowCountActual = model.getRows();
assertEquals(rowCountActual, Math.min(ELEMENTS_TOTAL, rowCountPreset));
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -24,6 +24,7 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.dataTableAttributes;
import java.util.List;
@@ -57,8 +58,8 @@
@BeforeMethod
public void setup() {
- attributes.setFirst(first);
- attributes.setRows(rows);
+ dataTableAttributes.set(DataTableAttributes.first, first);
+ dataTableAttributes.set(DataTableAttributes.rows, rows);
if (first == null) {
expectedFirst = 0;
@@ -84,7 +85,7 @@
public void testRendered() {
assertTrue(model.isVisible());
- attributes.setRendered(false);
+ dataTableAttributes.set(DataTableAttributes.rendered, false);
assertFalse(model.isVisible());
assertFalse(model.isNoData());
@@ -96,8 +97,8 @@
assertTrue(model.isVisible());
assertFalse(model.isNoData());
- attributes.setNoDataLabel(NO_DATA);
- attributes.setShowData(false);
+ dataTableAttributes.set(DataTableAttributes.noDataLabel, NO_DATA);
+ enableShowData(false);
assertTrue(model.isVisible());
assertTrue(model.isNoData());
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -24,6 +24,8 @@
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+import static
org.richfaces.tests.metamer.ftest.abstractions.DataTableAttributes.sortMode;
+import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.dataTableAttributes;
import static org.testng.Assert.assertEquals;
import java.lang.reflect.Method;
@@ -48,7 +50,7 @@
List<Employee> sortedEmployees;
public void testSortModeSingle() {
- attributes.setSortMode(SortMode.single);
+ dataTableAttributes.set(sortMode, SortMode.single);
sortByColumn(COLUMN_TITLE);
verifySortingByColumns("title");
@@ -64,7 +66,7 @@
}
public void testSortModeSingleReverse() {
- attributes.setSortMode(SortMode.single);
+ dataTableAttributes.set(sortMode, SortMode.single);
sortByColumn(COLUMN_SEX);
sortByColumn(COLUMN_SEX);
@@ -84,7 +86,7 @@
}
public void testSortModeSingleDoesntRememberOrder() {
- attributes.setSortMode(SortMode.single);
+ dataTableAttributes.set(sortMode, SortMode.single);
sortByColumn(COLUMN_NAME);
sortByColumn(COLUMN_TITLE);
@@ -93,7 +95,7 @@
}
public void testSortModeSingleRerenderAll() {
- attributes.setSortMode(SortMode.single);
+ dataTableAttributes.set(sortMode, SortMode.single);
sortByColumn(COLUMN_NAME);
verifySortingByColumns("name");
@@ -106,7 +108,7 @@
}
public void testSortModeSingleFullPageRefresh() {
- attributes.setSortMode(SortMode.single);
+ dataTableAttributes.set(sortMode, SortMode.single);
sortByColumn(COLUMN_NUMBER_OF_KIDS1);
verifySortingByColumns("numberOfKids");
@@ -119,7 +121,7 @@
}
public void testSortModeMulti() {
- attributes.setSortMode(SortMode.multi);
+ dataTableAttributes.set(sortMode, SortMode.multi);
sortByColumn(COLUMN_TITLE);
verifySortingByColumns("title");
@@ -135,7 +137,7 @@
}
public void testSortModeMultiReverse() {
- attributes.setSortMode(SortMode.multi);
+ dataTableAttributes.set(sortMode, SortMode.multi);
sortByColumn(COLUMN_TITLE);
sortByColumn(COLUMN_TITLE);
@@ -155,7 +157,7 @@
}
public void testSortModeMultiReplacingOldOccurences() {
- attributes.setSortMode(SortMode.multi);
+ dataTableAttributes.set(sortMode, SortMode.multi);
sortByColumn(COLUMN_TITLE);
verifySortingByColumns("title");
@@ -169,7 +171,7 @@
}
public void testSortModeMultiRerenderAll() {
- attributes.setSortMode(SortMode.multi);
+ dataTableAttributes.set(sortMode, SortMode.multi);
sortByColumn(COLUMN_TITLE);
verifySortingByColumns("title");
@@ -186,7 +188,7 @@
}
public void testSortModeMultiFullPageRefresh() {
- attributes.setSortMode(SortMode.multi);
+ dataTableAttributes.set(sortMode, SortMode.multi);
sortByColumn(COLUMN_TITLE);
verifySortingByColumns("title");
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -5,6 +5,8 @@
import org.richfaces.tests.metamer.ftest.a4jQueue.QueueAttributes;
import org.richfaces.tests.metamer.ftest.a4jRepeat.RepeatAttributes;
import org.richfaces.tests.metamer.ftest.a4jStatus.StatusAttributes;
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableAttributes;
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableFacets;
import org.richfaces.tests.metamer.ftest.richTooltip.TooltipAttributes;
import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
@@ -17,5 +19,7 @@
public static Attributes<PollAttributes> pollAttributes = new
Attributes<PollAttributes>();
public static Attributes<RepeatAttributes> repeatAttributes = new
Attributes<RepeatAttributes>();
public static Attributes<StatusAttributes> statusAttributes = new
Attributes<StatusAttributes>();
+ public static Attributes<DataTableAttributes> dataTableAttributes = new
Attributes<DataTableAttributes>();
+ public static Attributes<DataTableFacets> dataTableFacets = new
Attributes<DataTableFacets>();
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -47,6 +47,10 @@
public Attributes() { }
+ public Attributes(RequestType reqType) {
+ this.requestType = reqType;
+ }
+
public void set(T attribute, String string) {
setProperty(attribute.toString(), string);
}
@@ -68,6 +72,15 @@
setProperty(attribute.toString(), item.toString());
}
+ /**
+ * Retrieve current attribute value
+ * @param attribute
+ * @return
+ */
+ public String get(T attribute) {
+ return getProperty(attribute.toString());
+ }
+
/*protected void set(String propertyName, Object value) {
}*/
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -24,6 +24,9 @@
import java.util.LinkedList;
import java.util.List;
+import org.jboss.test.selenium.GuardRequest;
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.request.RequestType;
import org.richfaces.ExpandMode;
import org.richfaces.tests.metamer.bean.Model;
@@ -31,6 +34,7 @@
import org.richfaces.tests.metamer.ftest.abstractions.DataTableFacets;
import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.attributes.Attributes;
import org.richfaces.tests.metamer.ftest.model.CollapsibleSubTable;
import org.richfaces.tests.metamer.ftest.model.CollapsibleSubTableToggler;
import org.richfaces.tests.metamer.ftest.model.DataTable;
@@ -48,9 +52,11 @@
private static final List<Employee> EMPLOYEES = Model.unmarshallEmployees();
- CollapsibleSubTableAttributes attributes = new CollapsibleSubTableAttributes();
+ Attributes<CollapsibleSubTableAttributes> collapsibleSubTabAttributes = new
Attributes<CollapsibleSubTableAttributes>();
DataTable dataTable = new DataTable(pjq("table[id$=richDataTable]"));;
- DataTableFacets facets = new DataTableFacets();
+ Attributes<DataTableFacets> dataTableFacets = new
Attributes<DataTableFacets>(RequestType.XHR);
+
+ JQueryLocator showDataLocator = pjq("input[id$=noDataCheckbox]");
@Inject
@Use(value = "configuration*")
@@ -123,4 +129,15 @@
return RequestType.NONE;
}
}
+
+ public void enableShowData(final boolean showData) {
+ new GuardRequest(RequestType.XHR) {
+ public void command() {
+ selenium.check(showDataLocator, showData);
+ selenium.fireEvent(showDataLocator, Event.CLICK);
+ selenium.fireEvent(showDataLocator, Event.CHANGE);
+ }
+ }.waitRequest();
+ }
+
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -21,89 +21,26 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.richCollapsibleSubTable;
-import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
-import java.util.Collection;
-
-import org.jboss.test.selenium.GuardRequest;
-import org.jboss.test.selenium.dom.Event;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.request.RequestType;
-import org.richfaces.ExpandMode;
-import org.richfaces.model.SortMode;
-import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
-
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class CollapsibleSubTableAttributes extends AbstractComponentAttributes {
+public enum CollapsibleSubTableAttributes implements AttributeEnum {
+
+ columnClasses,
+ expandMode,
+ expanded,
+ first,
+ footerClass,
+ headerClass,
+ noDataLabel,
+ rendered,
+ rowClasses,
+ rowClass,
+ rows,
+ sortMode,
+ sortPriority,
- JQueryLocator showDataLocator = pjq("input[id$=noDataCheckbox]");
-
- public void setShowData(final boolean showData) {
- new GuardRequest(RequestType.XHR) {
- public void command() {
- selenium.check(showDataLocator, showData);
- selenium.fireEvent(showDataLocator, Event.CLICK);
- selenium.fireEvent(showDataLocator, Event.CHANGE);
- }
- }.waitRequest();
- }
-
- public void setExpandMode(ExpandMode expandMode) {
- setProperty("expandMode", expandMode);
- }
-
- public void setExpanded(Boolean expanded) {
- setProperty("expanded", expanded);
- }
-
- public void setFirst(Integer first) {
- setProperty("first", first);
- }
-
- public void setNoDataLabel(String noDataLabel) {
- setProperty("noDataLabel", noDataLabel);
- }
-
- public void setRendered(Boolean rendered) {
- setProperty("rendered", rendered);
- }
-
- public void setRows(Integer rows) {
- setProperty("rows", rows);
- }
-
- public Integer getRows() {
- return Integer.valueOf(getProperty("rows"));
- }
-
- public void setSortMode(SortMode sortMode) {
- setProperty("sortMode", sortMode);
- }
-
- public void setSortPriority(Collection<String> sortPriority) {
- setProperty("sortPriority", sortPriority);
- }
-
- public void setColumnClasses(String columnClasses) {
- setProperty("columnClasses", columnClasses);
- }
-
- public void setRowClasses(String rowClasses) {
- setProperty("rowClasses", rowClasses);
- }
-
- public void setRowClass(String rowClass) {
- setProperty("rowClass", rowClass);
- }
-
- public void setHeaderClass(String headerClass) {
- setProperty("headerClass", headerClass);
- }
-
- public void setFooterClass(String footerClass) {
- setProperty("footerClass", footerClass);
- }
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -25,6 +25,7 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import static org.richfaces.tests.metamer.ftest.abstractions.DataTableFacets.*;
import java.net.URL;
@@ -56,7 +57,7 @@
return subtable.hasVisibleRows();
}
});
- attributes.setShowData(false);
+ enableShowData(false);
assertFalse(subtable.hasVisibleRows());
JQueryLocator noDataFacet = pjq("table[id$=richDataTable] >
tbody.rf-cst:eq(0) > tr.rf-cst-nd > td.rf-cst-nd-c");
@@ -64,12 +65,12 @@
assertFalse(selenium.isVisible(noDataFacet));
assertTrue(selenium.getText(noDataFacet).isEmpty());
- facets.setNoData(SAMPLE_STRING);
+ dataTableFacets.set(noData, SAMPLE_STRING);
- attributes.setShowData(true);
+ enableShowData(true);
assertTrue(subtable.hasVisibleRows());
- attributes.setShowData(false);
+ enableShowData(false);
assertFalse(subtable.hasVisibleRows());
assertTrue(subtable.isNoData());
@@ -78,29 +79,29 @@
@Test
public void testHeaderInstantChange() {
- facets.setHeader(SAMPLE_STRING);
+ dataTableFacets.set(header, SAMPLE_STRING);
assertEquals(selenium.getText(subtable.getHeader()), SAMPLE_STRING);
- facets.setHeader(EMPTY_STRING);
+ dataTableFacets.set(header, EMPTY_STRING);
if (selenium.isElementPresent(subtable.getHeader())) {
assertEquals(selenium.getText(subtable.getHeader()), EMPTY_STRING);
}
- facets.setHeader(SAMPLE_STRING);
+ dataTableFacets.set(header, SAMPLE_STRING);
assertEquals(selenium.getText(subtable.getHeader()), SAMPLE_STRING);
}
@Test
public void testFooterInstantChange() {
- facets.setFooter(SAMPLE_STRING);
+ dataTableFacets.set(footer, SAMPLE_STRING);
assertEquals(selenium.getText(subtable.getFooter()), SAMPLE_STRING);
- facets.setFooter(EMPTY_STRING);
+ dataTableFacets.set(footer, EMPTY_STRING);
if (selenium.isElementPresent(subtable.getFooter())) {
assertEquals(selenium.getText(subtable.getFooter()), EMPTY_STRING);
}
- facets.setFooter(SAMPLE_STRING);
+ dataTableFacets.set(footer, SAMPLE_STRING);
assertEquals(selenium.getText(subtable.getFooter()), SAMPLE_STRING);
}
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFiltering.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFiltering.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFiltering.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -57,7 +57,7 @@
@BeforeMethod
public void prepare() {
- attributes.setRows(rows);
+ collapsibleSubTabAttributes.set(CollapsibleSubTableAttributes.rows, rows);
Column.resetAll();
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableScroller.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableScroller.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableScroller.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -71,14 +71,14 @@
paginationTester = new BasicPaginationTester();
}
- attributes.setExpandMode(expandMode);
+ collapsibleSubTabAttributes.set(CollapsibleSubTableAttributes.expandMode,
expandMode);
dataScroller = new
DataScroller(subtable.getFooter().getChild(jq("span.rf-ds")));
secondDataScroller = new
DataScroller(secondSubtable.getFooter().getChild(jq("span.rf-ds")));
paginationTester.setDataScroller(dataScroller);
- attributes.setRows(rows);
+ collapsibleSubTabAttributes.set(CollapsibleSubTableAttributes.rows, rows);
int lastPage = dataScroller.obtainLastPage();
dataScroller.setLastPage(lastPage);
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSimple.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSimple.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSimple.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -28,6 +28,7 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import static
org.richfaces.tests.metamer.ftest.richCollapsibleSubTable.CollapsibleSubTableAttributes.*;
import java.net.URL;
import java.util.List;
@@ -56,7 +57,7 @@
public void testExpandMode() {
final RequestType requestType = getRequestTypeForExpandMode();
- attributes.setExpandMode(expandMode);
+ collapsibleSubTabAttributes.set(CollapsibleSubTableAttributes.expandMode,
expandMode);
assertTrue(subtable.hasVisibleRows());
assertTrue(secondSubtable.hasVisibleRows());
@@ -80,7 +81,7 @@
@Test
public void testFirst() {
- attributes.setFirst(2);
+ collapsibleSubTabAttributes.set(first, 2);
List<Employee> visibleEmployees = employees.subList(2,
subtable.getRowCount());
@@ -96,7 +97,7 @@
@Test
@Use(field = "configuration", empty = true)
public void testRendered() {
- attributes.setRendered(false);
+ collapsibleSubTabAttributes.set(rendered, false);
assertFalse(configurationMen.subtable.hasVisibleRows());
assertFalse(configurationWomen.subtable.hasVisibleRows());
@@ -104,7 +105,7 @@
selenium.click(configurationMen.toggler);
assertFalse(configurationMen.subtable.hasVisibleRows());
- attributes.setRendered(true);
+ collapsibleSubTabAttributes.set(rendered, true);
assertTrue(configurationMen.subtable.hasVisibleRows());
assertTrue(configurationWomen.subtable.hasVisibleRows());
@@ -112,7 +113,7 @@
@Test
public void testRows() {
- attributes.setRows(11);
+ collapsibleSubTabAttributes.set(rows, 11);
List<Employee> visibleEmployees = employees.subList(0, 11);
@@ -129,7 +130,7 @@
@Test
public void testColumnClasses() {
- attributes.setColumnClasses("col1,col2,col3");
+ collapsibleSubTabAttributes.set(columnClasses, "col1,col2,col3");
for (int i = 1; i <= 3; i++) {
JQueryLocator anyCellInColumn = subtable.getAnyCellInColumn(i);
JQueryLocator haveClassSet = append(anyCellInColumn, ".col" + i);
@@ -141,8 +142,8 @@
@Test
public void testRowClasses() {
- attributes.setRows(13);
- attributes.setRowClasses("row1,row2,row3");
+ collapsibleSubTabAttributes.set(rows, 13);
+ collapsibleSubTabAttributes.set(rowClasses, "row1,row2,row3");
int rowCount = subtable.getRowCount();
assertEquals(rowCount, 13);
@@ -156,8 +157,8 @@
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-10212")
public void testRowClass() {
- attributes.setRows(13);
- attributes.setRowClass("rowClass");
+ collapsibleSubTabAttributes.set(rows, 13);
+ collapsibleSubTabAttributes.set(rowClass, "rowClass");
JQueryLocator anyRow = subtable.getAnyRow();
JQueryLocator haveClassSet = append(anyRow, ".rowClass");
JQueryLocator haveNotClassSet = not(append(anyRow, ":visible"),
".rowClass");
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSorting.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSorting.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSorting.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -71,8 +71,8 @@
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11302")
public void testSorting() {
- attributes.setRows(rows);
- attributes.setSortMode(sortMode);
+ collapsibleSubTabAttributes.set(CollapsibleSubTableAttributes.rows, rows);
+ collapsibleSubTabAttributes.set(CollapsibleSubTableAttributes.sortMode,
sortMode);
sortBy(Column.NAME);
verifySorting();
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSelection.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSelection.java 2011-09-05
08:52:27 UTC (rev 22684)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSelection.java 2011-09-05
21:07:07 UTC (rev 22685)
@@ -25,6 +25,8 @@
import static
org.richfaces.tests.metamer.ftest.richExtendedDataTable.TestExtendedDataTableSelection.Modifier.CTRL;
import static
org.richfaces.tests.metamer.ftest.richExtendedDataTable.TestExtendedDataTableSelection.Modifier.SHIFT;
import static org.testng.Assert.assertEquals;
+import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.dataTableAttributes;
+import static org.richfaces.tests.metamer.ftest.abstractions.DataTableAttributes.*;
import java.net.URL;
import java.util.Arrays;
@@ -40,6 +42,7 @@
import org.jboss.test.selenium.utils.array.ArrayTransform;
import org.jboss.test.selenium.waiting.retrievers.Retriever;
import org.richfaces.tests.metamer.ftest.abstractions.AbstractDataTableTest;
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableAttributes;
import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
import org.richfaces.tests.metamer.ftest.model.ExtendedDataTable;
import org.testng.annotations.BeforeClass;
@@ -67,7 +70,7 @@
@BeforeMethod
public void setupAttributes() {
- attributes.setRows(10);
+ dataTableAttributes.set(rows, 10);
selected = new TreeSet<Integer>();
}
@@ -213,12 +216,13 @@
}
private int getPageForIndex(int index) {
- int rows = attributes.getRows();
+ int rows =
Integer.parseInt(dataTableAttributes.get(DataTableAttributes.rows));
return (index / rows) + 1;
}
private int getRowForIndex(int index) {
- return 1 + index - ((dataScroller2.getCurrentPage() - 1) *
attributes.getRows());
+ int rows =
Integer.parseInt(dataTableAttributes.get(DataTableAttributes.rows));
+ return 1 + index - ((dataScroller2.getCurrentPage() - 1) * rows);
}
}