Skip to content

Commit

Permalink
[FIXED JENKINS-28439] Some additional changes for joemar1988's work (…
Browse files Browse the repository at this point in the history
…Added a disable drop down).
  • Loading branch information
ikedam committed May 17, 2015
1 parent e1848ba commit ba32648
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 3 deletions.
Expand Up @@ -36,7 +36,7 @@
import org.kohsuke.stapler.DataBoundConstructor;

/**
* Disables the job if the job copied from is disabled.
* Disables the job if the job copied from is enabled.
*/
public class DisableOperation extends AbstractXmlJobcopyOperation implements Serializable
{
Expand Down
Expand Up @@ -28,8 +28,8 @@ AdditionalFileset.DisplayName=\u8ffd\u52a0\u3067\u30b3\u30d4\u30fc\u3059\u308b\u
ReplaceOperation.DisplayName=\u6587\u5b57\u5217\u3092\u7f6e\u304d\u63db\u3048\u308b
# EnableOperation.DisplayName=ジョブを有効にする
EnableOperation.DisplayName=\u30b8\u30e7\u30d6\u3092\u6709\u52b9\u306b\u3059\u308b
# DisableOperation.DisplayName=‚‹
DisableOperation.DisplayName=
# DisableOperation.DisplayName=ジョブを無効にする
DisableOperation.DisplayName=\u30b8\u30e7\u30d6\u3092\u7121\u52b9\u306b\u3059\u308b
# CopiedjobinfoAction.DisplayName=コピーしたジョブ
CopiedjobinfoAction.DisplayName=\u30b3\u30d4\u30fc\u3057\u305f\u30b8\u30e7\u30d6
# JobCopyBuilder.JobName.empty=値を指定してください
Expand Down
@@ -0,0 +1,80 @@
/*
* The MIT License
*
* Copyright (c) 2015 IKEDA Yasuyuki
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package jp.ikedam.jenkins.plugins.jobcopy_builder;

import java.util.Arrays;
import java.util.Collections;

import hudson.model.FreeStyleProject;

import org.jvnet.hudson.test.HudsonTestCase;

/**
* Tests for {@link DisableOperation}
*/
public class DisableOperationJenkinsTest extends HudsonTestCase
{
public void testDisableOperation() throws Exception
{
FreeStyleProject copiee = createFreeStyleProject();
copiee.enable();
copiee.save();

FreeStyleProject copier = createFreeStyleProject();
copier.getBuildersList().add(new JobcopyBuilder(
copiee.getFullName(),
"copied",
false,
Arrays.<JobcopyOperation>asList(
new DisableOperation()
),
Collections.<AdditionalFileset>emptyList()
));
assertBuildStatusSuccess(copier.scheduleBuild2(0));

FreeStyleProject copied = jenkins.getItemByFullName("copied", FreeStyleProject.class);
assertTrue(copied.isDisabled());
}

public void testConfiguration() throws Exception
{
JobcopyBuilder expected = new JobcopyBuilder(
"from",
"to",
false,
Arrays.<JobcopyOperation>asList(
new DisableOperation()
),
Collections.<AdditionalFileset>emptyList()
);

FreeStyleProject p = createFreeStyleProject();
p.getBuildersList().add(expected);
configRoundtrip(p);
JobcopyBuilder actual = p.getBuildersList().get(JobcopyBuilder.class);
// assertEqualDataBoundBeans(expected, actual); // This cause NPE as actual.additionalFilesetList gets null.
assertEqualDataBoundBeans(expected.getJobcopyOperationList(), actual.getJobcopyOperationList());
}
}

0 comments on commit ba32648

Please sign in to comment.