aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-22 07:41:00 (EST)
committerWinston Prakash2011-12-01 20:46:56 (EST)
commit86bfe05ee4a7fe4ba4129cd4be43184208da16ab (patch)
treec8353d2ab917a7ec3d8ec8c780e06ec89b9f2bf9
parentef80f39fd4e01b6745349ccc580f9ec8753d21ba (diff)
downloadorg.eclipse.hudson.core-86bfe05ee4a7fe4ba4129cd4be43184208da16ab.zip
org.eclipse.hudson.core-86bfe05ee4a7fe4ba4129cd4be43184208da16ab.tar.gz
org.eclipse.hudson.core-86bfe05ee4a7fe4ba4129cd4be43184208da16ab.tar.bz2
Created ResultProjectProperty, fixed Matrix project.
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixProject.java20
-rw-r--r--hudson-core/src/main/java/hudson/model/BaseProjectProperty.java7
-rw-r--r--hudson-core/src/main/java/hudson/model/BooleanProjectProperty.java8
-rw-r--r--hudson-core/src/main/java/hudson/model/IntegerProjectProperty.java6
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java4
-rw-r--r--hudson-core/src/main/java/hudson/model/ResultProjectProperty.java32
-rw-r--r--hudson-core/src/test/java/hudson/matrix/MatrixProjectTest.java2
7 files changed, 47 insertions, 32 deletions
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
index 1851351..5a2ec56 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
@@ -98,7 +98,7 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i
/**
* Configuration axes.
*/
- private volatile AxisList axes; //TODO verify it = new AxisList();
+ private volatile AxisList axes = new AxisList();
/**
* The filter that is applied to combinations. It is a Groovy if condition.
@@ -234,28 +234,14 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i
* @inheritDoc
*/
public Result getTouchStoneResultCondition() {
- //TODO fix this method
-// if (hasCascadingProject()) {
-// return isOverriddenProperty(TOUCH_STONE_RESULT_CONDITION_PROPERTY_NAME) ? touchStoneResultCondition
-// : getCascadingProject().getTouchStoneResultCondition();
-// } else {
- return touchStoneResultCondition;
-// }
+ return getResultProperty(TOUCH_STONE_RESULT_CONDITION_PROPERTY_NAME).getValue();
}
/**
* @inheritDoc
*/
public void setTouchStoneResultCondition(Result touchStoneResultCondition) {
- //TODO fix this method
- if (!hasCascadingProject()) {
- this.touchStoneResultCondition = touchStoneResultCondition;
- } else if (!ObjectUtils.equals(getCascadingProject().getTouchStoneResultCondition(),
- touchStoneCombinationFilter)) {
- this.touchStoneResultCondition = touchStoneResultCondition;
- } else {
- this.touchStoneResultCondition = null;
- }
+ getResultProperty(TOUCH_STONE_RESULT_CONDITION_PROPERTY_NAME).setValue(touchStoneResultCondition);
}
/**
diff --git a/hudson-core/src/main/java/hudson/model/BaseProjectProperty.java b/hudson-core/src/main/java/hudson/model/BaseProjectProperty.java
index 704541a..94da37b 100644
--- a/hudson-core/src/main/java/hudson/model/BaseProjectProperty.java
+++ b/hudson-core/src/main/java/hudson/model/BaseProjectProperty.java
@@ -15,6 +15,7 @@
package hudson.model;
+import org.apache.commons.lang3.ObjectUtils;
import org.eclipse.hudson.api.model.IJob;
import org.eclipse.hudson.api.model.IProjectProperty;
@@ -25,7 +26,7 @@ import org.eclipse.hudson.api.model.IProjectProperty;
*
* @author Nikita Levyankov
*/
-public abstract class BaseProjectProperty<T> implements IProjectProperty<T> {
+public class BaseProjectProperty<T> implements IProjectProperty<T> {
private transient String propertyKey;
private transient IJob job;
@@ -114,7 +115,9 @@ public abstract class BaseProjectProperty<T> implements IProjectProperty<T> {
* @param candidateValue candidate value.
* @return true if cascading value should be replaced by candidate value.
*/
- protected abstract boolean allowOverrideValue(T cascadingValue, T candidateValue);
+ protected boolean allowOverrideValue(T cascadingValue, T candidateValue) {
+ return !ObjectUtils.equals(cascadingValue, candidateValue);
+ }
/**
* Pre-process candidate value.
diff --git a/hudson-core/src/main/java/hudson/model/BooleanProjectProperty.java b/hudson-core/src/main/java/hudson/model/BooleanProjectProperty.java
index 76d06c2..d189042 100644
--- a/hudson-core/src/main/java/hudson/model/BooleanProjectProperty.java
+++ b/hudson-core/src/main/java/hudson/model/BooleanProjectProperty.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package hudson.model;
-import org.apache.commons.lang3.ObjectUtils;
import org.eclipse.hudson.api.model.IJob;
/**
@@ -33,13 +32,6 @@ public class BooleanProjectProperty extends BaseProjectProperty<Boolean> {
/**
* {@inheritDoc}
*/
- protected boolean allowOverrideValue(Boolean cascadingValue, Boolean candidateValue) {
- return !ObjectUtils.equals(cascadingValue, candidateValue);
- }
-
- /**
- * {@inheritDoc}
- */
@Override
public Boolean getOriginalValue() {
Boolean originalValue = super.getOriginalValue();
diff --git a/hudson-core/src/main/java/hudson/model/IntegerProjectProperty.java b/hudson-core/src/main/java/hudson/model/IntegerProjectProperty.java
index cb4a59b..874426e 100644
--- a/hudson-core/src/main/java/hudson/model/IntegerProjectProperty.java
+++ b/hudson-core/src/main/java/hudson/model/IntegerProjectProperty.java
@@ -14,7 +14,6 @@
*******************************************************************************/
package hudson.model;
-import org.apache.commons.lang3.ObjectUtils;
import org.eclipse.hudson.api.model.IJob;
/**
@@ -33,7 +32,8 @@ public class IntegerProjectProperty extends BaseProjectProperty<Integer> {
/**
* {@inheritDoc}
*/
- protected boolean allowOverrideValue(Integer cascadingValue, Integer candidateValue) {
- return !ObjectUtils.equals(cascadingValue, candidateValue);
+ @Override
+ public Integer getDefaultValue() {
+ return 0;
}
}
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index 6fa678f..e1af1b9 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -236,6 +236,10 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return (StringProjectProperty) getProperty(key, StringProjectProperty.class);
}
+ public ResultProjectProperty getResultProperty(String key) {
+ return (ResultProjectProperty) getProperty(key, ResultProjectProperty.class);
+ }
+
public BooleanProjectProperty getBooleanProperty(String key){
return (BooleanProjectProperty) getProperty(key, BooleanProjectProperty.class);
}
diff --git a/hudson-core/src/main/java/hudson/model/ResultProjectProperty.java b/hudson-core/src/main/java/hudson/model/ResultProjectProperty.java
new file mode 100644
index 0000000..f25c241
--- /dev/null
+++ b/hudson-core/src/main/java/hudson/model/ResultProjectProperty.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ *
+ * 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:
+ *
+ * Anton Kozak
+ *
+ *******************************************************************************/
+package hudson.model;
+
+import org.eclipse.hudson.api.model.IJob;
+
+/**
+ * Represents {@link Result} property.
+ * <p/>
+ * Date: 9/23/11
+ *
+ * @author Anton Kozak
+ */
+//TODO try to replace it with generics
+public class ResultProjectProperty extends BaseProjectProperty<Result> {
+
+ public ResultProjectProperty(IJob job) {
+ super(job);
+ }
+} \ No newline at end of file
diff --git a/hudson-core/src/test/java/hudson/matrix/MatrixProjectTest.java b/hudson-core/src/test/java/hudson/matrix/MatrixProjectTest.java
index 8eee863..3f1ddbc 100644
--- a/hudson-core/src/test/java/hudson/matrix/MatrixProjectTest.java
+++ b/hudson-core/src/test/java/hudson/matrix/MatrixProjectTest.java
@@ -223,8 +223,6 @@ public class MatrixProjectTest {
}
@Test
- @Ignore
- //TODO fix method
public void testGetTouchStoneResultConditionParentValue() throws IOException {
Result parentResultCondition = Result.SUCCESS;
MatrixProject parentProject = new MatrixProjectMock("parent");