summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-21 08:02:09 (EST)
committer Winston Prakash2011-12-01 20:46:50 (EST)
commit81d716b74be1b82047b861c46f37e5052a31225f (patch)
tree897c22f7bea66e2e5777aa50d175cd6dc4f3545b
parent26a2ae1eaca65e200d3ec5f18a48f05a58271084 (diff)
downloadorg.eclipse.hudson.core-81d716b74be1b82047b861c46f37e5052a31225f.zip
org.eclipse.hudson.core-81d716b74be1b82047b861c46f37e5052a31225f.tar.gz
org.eclipse.hudson.core-81d716b74be1b82047b861c46f37e5052a31225f.tar.bz2
Implement getters and setters for jdkName, quietPeriod based on template project. Improve unit-tests
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/matrix/IMatrixProject.java11
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractProject.java31
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java7
-rw-r--r--hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java2
4 files changed, 37 insertions, 14 deletions
diff --git a/hudson-core/src/main/java/hudson/matrix/IMatrixProject.java b/hudson-core/src/main/java/hudson/matrix/IMatrixProject.java
index c49fd02..623bf66 100644
--- a/hudson-core/src/main/java/hudson/matrix/IMatrixProject.java
+++ b/hudson-core/src/main/java/hudson/matrix/IMatrixProject.java
@@ -143,7 +143,7 @@ public interface IMatrixProject extends IAbstractProject {
/**
* Returns list of active {@link Builder}s configured for this project.
*
- * @return listof active {@link Builder}s configured for this project.
+ * @return list of active {@link Builder}s configured for this project.
*/
List<Builder> getBuilders();
@@ -155,10 +155,9 @@ public interface IMatrixProject extends IAbstractProject {
Map<Descriptor<Publisher>, Publisher> getPublishers();
/**
- * Returns {@link DescribableList} of active {@link BuildWrapper} configured for this project.
+ * Returns map of active {@link BuildWrapper} configured for this project.
*
- * @return @link DescribableList} of active {@link BuildWrapper} configured for this project.
+ * @return map of active {@link BuildWrapper} configured for this project.
*/
- DescribableList<BuildWrapper, Descriptor<BuildWrapper>> getBuildWrappersList();
-
-}
+ Map<Descriptor<BuildWrapper>,BuildWrapper> getBuildWrappers();
+} \ No newline at end of file
diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java
index 1e5d03f..a47c2d6 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractProject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java
@@ -522,11 +522,34 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
}
public int getScmCheckoutRetryCount() {
- return scmCheckoutRetryCount !=null ? scmCheckoutRetryCount : Hudson.getInstance().getScmCheckoutRetryCount();
+ if (null != scmCheckoutRetryCount) {
+ return scmCheckoutRetryCount;
+ }
+ return hasParentTemplate() ?
+ getTemplate().getScmCheckoutRetryCount() : Hudson.getInstance().getScmCheckoutRetryCount();
+ }
+
+ public void setScmCheckoutRetryCount(Integer retryCount) {
+ if (!(hasParentTemplate() && ObjectUtils.equals(getTemplate().getScmCheckoutRetryCount(), retryCount))) {
+ this.scmCheckoutRetryCount = retryCount;
+ } else {
+ this.scmCheckoutRetryCount = null;
+ }
}
- public void setScmCheckoutRetryCount(Integer scmCheckoutRetryCount) {
- this.scmCheckoutRetryCount = scmCheckoutRetryCount;
+ /**
+ * Sets scmCheckoutRetryCount, Uses {@link NumberUtils#isNumber(String)} for checking retryCount param.
+ * If it is not valid number, null will be set.
+ *
+ * @param scmCheckoutRetryCount retry count.
+ * @throws IOException if any.
+ */
+ protected void setScmCheckoutRetryCount(String scmCheckoutRetryCount) throws IOException {
+ Integer retryCount = null;
+ if (NumberUtils.isNumber(scmCheckoutRetryCount)) {
+ retryCount = NumberUtils.createInteger(scmCheckoutRetryCount);
+ }
+ setScmCheckoutRetryCount(retryCount);
}
// ugly name because of EL
@@ -1725,7 +1748,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
setJDK(req.getParameter("jdk"));
setQuietPeriod(null != req.getParameter("hasCustomQuietPeriod") ? req.getParameter("quiet_period") : null);
setScmCheckoutRetryCount(null != req.getParameter("hasCustomScmCheckoutRetryCount")
- ? Integer.parseInt(req.getParameter("scmCheckoutRetryCount")) : null);
+ ? req.getParameter("scmCheckoutRetryCount") : null);
setBlockBuildWhenDownstreamBuilding(null != req.getParameter("blockBuildWhenDownstreamBuilding"));
setBlockBuildWhenUpstreamBuilding(null != req.getParameter("blockBuildWhenUpstreamBuilding"));
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index 4aea26d..61512f6 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -1245,9 +1245,10 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
*/
@SuppressWarnings({"unchecked"})
public JobT getTemplate() {
- if (template == null) {
- template = (JobT) Functions.getItemByName(Hudson.getInstance().getAllItems(this.getClass()), templateName);
- }
+//TODO enable me
+// if (template == null) {
+// template = (JobT) Functions.getItemByName(Hudson.getInstance().getAllItems(this.getClass()), templateName);
+// }
return template;
}
diff --git a/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java b/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java
index 6017ba4..5599c0a 100644
--- a/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java
+++ b/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java
@@ -385,7 +385,7 @@ public class FreeStyleProjectTest {
mockStatic(Hudson.class);
expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
replayAll();
- assertEquals( childProject.getQuietPeriod(), Integer.parseInt(childQuietPeriod));
+ assertEquals(childProject.getQuietPeriod(), Integer.parseInt(childQuietPeriod));
verifyAll();
}