summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-23 03:09:57 (EST)
committer Winston Prakash2011-12-01 20:47:06 (EST)
commit855eeb6d786fbc5e26301bd1ce61f462eadf5fec (patch)
treeb3225c9361858ec487b702792b143a90375566a0
parent676aa16da2d3d432afac6e1da9ff24a269f7e9e9 (diff)
downloadorg.eclipse.hudson.core-855eeb6d786fbc5e26301bd1ce61f462eadf5fec.zip
org.eclipse.hudson.core-855eeb6d786fbc5e26301bd1ce61f462eadf5fec.tar.gz
org.eclipse.hudson.core-855eeb6d786fbc5e26301bd1ce61f462eadf5fec.tar.bz2
Improve IJob interface (extend from Item). Draft implementation of DescribableProjectProperty. Implement unit test for property constructor.
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/org/eclipse/hudson/api/model/IJob.java3
-rw-r--r--hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/DescribableListProjectProperty.java36
-rw-r--r--hudson-core/src/test/java/org/eclipse/hudson/api/model/project/property/ProjectPropertyTest.java23
3 files changed, 51 insertions, 11 deletions
diff --git a/hudson-core/src/main/java/org/eclipse/hudson/api/model/IJob.java b/hudson-core/src/main/java/org/eclipse/hudson/api/model/IJob.java
index 11be85d..fd262b5 100644
--- a/hudson-core/src/main/java/org/eclipse/hudson/api/model/IJob.java
+++ b/hudson-core/src/main/java/org/eclipse/hudson/api/model/IJob.java
@@ -14,6 +14,7 @@
*******************************************************************************/
package org.eclipse.hudson.api.model;
+import hudson.model.Item;
import hudson.model.JobProperty;
import hudson.model.JobPropertyDescriptor;
import hudson.tasks.LogRotator;
@@ -26,7 +27,7 @@ import java.util.Map;
*
* @author Nikita Levyankov
*/
-public interface IJob<T extends IJob> {
+public interface IJob<T extends IJob> extends Item {
/**
* Returns cascading project name.
diff --git a/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/DescribableListProjectProperty.java b/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/DescribableListProjectProperty.java
new file mode 100644
index 0000000..f6c7688
--- /dev/null
+++ b/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/DescribableListProjectProperty.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ *
+ * Copyright (c) 2011 Oracle Corporation.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * Nikita Levyankov
+ *
+ *******************************************************************************/
+package org.eclipse.hudson.api.model.project.property;
+
+import hudson.util.DescribableList;
+import org.eclipse.hudson.api.model.IJob;
+
+/**
+ * Property represents DescribableList object.
+ * <p/>
+ * Date: 10/3/11
+ *
+ * @author Nikita Levyankov
+ */
+public class DescribableListProjectProperty extends BaseProjectProperty<DescribableList> {
+ public DescribableListProjectProperty(IJob job) {
+ super(job);
+ }
+
+ @Override
+ public DescribableList getDefaultValue() {
+ return new DescribableList(getJob());
+ }
+}
diff --git a/hudson-core/src/test/java/org/eclipse/hudson/api/model/project/property/ProjectPropertyTest.java b/hudson-core/src/test/java/org/eclipse/hudson/api/model/project/property/ProjectPropertyTest.java
index 04ba872..992ef96 100644
--- a/hudson-core/src/test/java/org/eclipse/hudson/api/model/project/property/ProjectPropertyTest.java
+++ b/hudson-core/src/test/java/org/eclipse/hudson/api/model/project/property/ProjectPropertyTest.java
@@ -81,6 +81,12 @@ public class ProjectPropertyTest {
} catch (Exception e) {
assertEquals(BaseProjectProperty.INVALID_JOB_EXCEPTION, e.getMessage());
}
+ try {
+ new DescribableListProjectProperty(null);
+ fail("Null should be handled by ProjectProperty constructor.");
+ } catch (Exception e) {
+ assertEquals(BaseProjectProperty.INVALID_JOB_EXCEPTION, e.getMessage());
+ }
BaseProjectProperty property = new BaseProjectProperty(project);
assertNotNull(property.getJob());
assertEquals(project, property.getJob());
@@ -129,18 +135,15 @@ public class ProjectPropertyTest {
*/
@Test
public void testGetDefaultValue() {
- BaseProjectProperty property = new BaseProjectProperty(project);
- assertNull(property.getDefaultValue());
- property = new StringProjectProperty(project);
- assertNull(property.getDefaultValue());
- property = new IntegerProjectProperty(project);
- assertEquals(0, property.getDefaultValue());
- property = new BooleanProjectProperty(project);
- assertFalse((Boolean) property.getDefaultValue());
- property = new LogRotatorProjectProperty(project);
- assertNull(property.getDefaultValue());
+ assertNull(new BaseProjectProperty(project).getDefaultValue());
+ assertNull(new StringProjectProperty(project).getDefaultValue());
+ assertEquals(new Integer(0), new IntegerProjectProperty(project).getDefaultValue());
+ assertFalse(new BooleanProjectProperty(project).getDefaultValue());
+ assertNull(new LogRotatorProjectProperty(project).getDefaultValue());
+ assertNotNull(new DescribableListProjectProperty(project).getDefaultValue());
}
+
/**
* Verify allowOverrideValue method.
*/