summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorRemo Arpagaus2013-03-19 09:05:10 (EDT)
committer Judith Gull2013-03-19 09:05:10 (EDT)
commit57e75149fd40107bfb3455fbc5c237ccfb4563c1 (patch)
treee6b1f47050a9a9642ecb149727811d051d8d3006
parentd361d7e1066510abb9b6d299216918766978a3bb (diff)
downloadorg.eclipse.scout.rt-57e75149fd40107bfb3455fbc5c237ccfb4563c1.zip
org.eclipse.scout.rt-57e75149fd40107bfb3455fbc5c237ccfb4563c1.tar.gz
org.eclipse.scout.rt-57e75149fd40107bfb3455fbc5c237ccfb4563c1.tar.bz2
Bug 403176 - AbstractPlannerField: The resourceId should be of type
java.lang.Object instead of long Adds tests
-rw-r--r--org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityMapTest.java66
-rw-r--r--org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/PlannerFieldTest.java74
2 files changed, 140 insertions, 0 deletions
diff --git a/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityMapTest.java b/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityMapTest.java
new file mode 100644
index 0000000..ea574f9
--- /dev/null
+++ b/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/basic/activitymap/ActivityMapTest.java
@@ -0,0 +1,66 @@
+package org.eclipse.scout.rt.client.ui.basic.activitymap;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Date;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test for {@link org.eclipse.scout.rt.client.ui.basic.activitymap.AbstractActivityMap<RI, AI>}
+ */
+public class ActivityMapTest {
+
+ private ActivityMap activityMap = null;
+
+ @Before
+ public void setUp() {
+ activityMap = new ActivityMap();
+ }
+
+ @Test(expected = ClassCastException.class)
+ public void testActivityCellResourceIdCast() {
+ final int invalidResourceId = 6;
+ final Double activityId = 5.0;
+ new ActivityCell<String, Double>(new Object[]{invalidResourceId, activityId}).getResourceId().toString();
+ }
+
+ @Test(expected = ClassCastException.class)
+ public void testActivityCellActivityIdCast() {
+ new ActivityCell<String, Double>(new Object[]{"id1", "invalid type"}).getActivityId().doubleValue();
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void testSetAndGetActivityCells() {
+ ActivityCell<String, Double> cell = getTestCell();
+
+ activityMap.addActivityCells(new ActivityCell[]{cell});
+ activityMap.setSelectedActivityCell(cell);
+
+ assertEquals(cell.getResourceId(), activityMap.getSelectedActivityCell().getResourceId());
+ assertEquals(cell.getActivityId().intValue(), activityMap.getSelectedActivityCell().getActivityId().intValue());
+ }
+
+ private ActivityCell<String, Double> getTestCell() {
+ final String resourceId = "id1";
+ final Double activityId = 5.0;
+ final Date startTime = new Date(5000);
+ final Date endTime = new Date(6000);
+ String text = "text1";
+ return new ActivityCell<String, Double>(new Object[]{resourceId, activityId, startTime, endTime, text});
+ }
+
+ @Test
+ public void testSetAndGetResourceIds() {
+ activityMap.setResourceIds(null);
+ assertEquals(activityMap.getResourceIds().getClass(), String[].class);
+ }
+
+ /**
+ * Test activity map with generics
+ */
+ static class ActivityMap extends AbstractActivityMap<String, Double> {
+ }
+}
diff --git a/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/PlannerFieldTest.java b/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/PlannerFieldTest.java
new file mode 100644
index 0000000..04e91fe
--- /dev/null
+++ b/org.eclipse.scout.rt.client.test/src/org/eclipse/scout/rt/client/ui/form/fields/plannerfield/PlannerFieldTest.java
@@ -0,0 +1,74 @@
+package org.eclipse.scout.rt.client.ui.form.fields.plannerfield;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Date;
+
+import org.eclipse.scout.commons.annotations.Order;
+import org.eclipse.scout.commons.exception.ProcessingException;
+import org.eclipse.scout.rt.client.ui.basic.activitymap.AbstractActivityMap;
+import org.eclipse.scout.rt.client.ui.basic.activitymap.ActivityCell;
+import org.eclipse.scout.rt.client.ui.basic.table.AbstractTable;
+import org.eclipse.scout.rt.client.ui.basic.table.ITableRow;
+import org.eclipse.scout.rt.client.ui.basic.table.columns.AbstractStringColumn;
+import org.eclipse.scout.rt.client.ui.form.fields.plannerfield.PlannerFieldTest.PlannerField.ActivityMap;
+import org.eclipse.scout.rt.client.ui.form.fields.plannerfield.PlannerFieldTest.PlannerField.ResourceTable;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test for {@link org.eclipse.scout.rt.client.ui.form.fields.plannerfield.AbstractPlannerField<T, P, RI, AI>}
+ */
+public class PlannerFieldTest {
+ private PlannerField plannerField = null;
+
+ @Before
+ public void setUp() {
+ plannerField = new PlannerField();
+ }
+
+ /**
+ * @throws ProcessingException
+ */
+ @Test
+ public void testActivityCellToResourceRow() throws ProcessingException {
+ plannerField.loadResourceTableData();
+ ITableRow row = plannerField.activityCellToResourceRow(new ActivityCell<String, Integer>("id1", null));
+ String value = plannerField.getResourceTable().getResourceIdColumn().getValue(row);
+
+ assertEquals("id1", value);
+ }
+
+ /**
+ * Test field
+ */
+ public class PlannerField extends AbstractPlannerField<ResourceTable, ActivityMap, String, Integer> {
+
+ @Override
+ protected Object[][] execLoadResourceTableData() throws ProcessingException {
+ return new Object[][]{{"id1", 5, new Date(500), new Date(600), "text"}};
+ }
+
+ @Override
+ protected Object[][] execLoadActivityMapData(String[] resourceIds, ITableRow[] resourceRows) throws ProcessingException {
+ return new Object[0][];
+ }
+
+ public class ResourceTable extends AbstractTable {
+ public ResourceIdColumn getResourceIdColumn() throws ProcessingException {
+ return getColumnSet().getColumnByClass(ResourceIdColumn.class);
+ }
+
+ @Order(10.0f)
+ public class ResourceIdColumn extends AbstractStringColumn {
+ @Override
+ protected boolean getConfiguredPrimaryKey() {
+ return true;
+ }
+ }
+ }
+
+ public class ActivityMap extends AbstractActivityMap<String, Integer> {
+ }
+ }
+}