-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/test/java/com/sonyericsson/jenkins/plugins/jcasc/ConfigurationAsCodeLocalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.sonyericsson.jenkins.plugins.jcasc; | ||
|
||
import com.sonyericsson.jenkins.plugins.bfa.PluginImpl; | ||
import com.sonyericsson.jenkins.plugins.bfa.sod.ScanOnDemandVariables; | ||
import io.jenkins.plugins.casc.ConfigurationContext; | ||
import io.jenkins.plugins.casc.ConfiguratorRegistry; | ||
import io.jenkins.plugins.casc.misc.ConfiguredWithCode; | ||
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule; | ||
import io.jenkins.plugins.casc.model.CNode; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
|
||
import static io.jenkins.plugins.casc.misc.Util.getUnclassifiedRoot; | ||
import static io.jenkins.plugins.casc.misc.Util.toStringFromYamlFile; | ||
import static io.jenkins.plugins.casc.misc.Util.toYamlString; | ||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class ConfigurationAsCodeLocalTest { | ||
|
||
private static final String NO_CAUSES_MESSAGE = "No problems were identified. If you know why this problem " + | ||
"occurred, please add a suitable Cause for it."; | ||
|
||
@ClassRule | ||
@ConfiguredWithCode("jcasc-local.yml") | ||
public static JenkinsConfiguredWithCodeRule j = new JenkinsConfiguredWithCodeRule(); | ||
|
||
@Test | ||
public void should_support_configuration_as_code() { | ||
PluginImpl plugin = PluginImpl.getInstance(); | ||
|
||
assertThat(plugin.isDoNotAnalyzeAbortedJob(), is(true)); | ||
assertThat(plugin.isGerritTriggerEnabled(), is(true)); | ||
assertThat(plugin.isGlobalEnabled(), is(true)); | ||
assertThat(plugin.isGraphsEnabled(), is(false)); | ||
assertThat(plugin.getKnowledgeBase(), is("localFile")); | ||
assertThat(plugin.getNoCausesMessage(), is(NO_CAUSES_MESSAGE)); | ||
|
||
assertThat(plugin.getNrOfScanThreads(), is(6)); | ||
ScanOnDemandVariables sodVariables = plugin.getSodVariables(); | ||
assertThat(sodVariables.getMaximumSodWorkerThreads(), is(4)); | ||
assertThat(sodVariables.getMinimumSodWorkerThreads(), is(2)); | ||
assertThat(sodVariables.getSodCorePoolNumberOfThreads(), is(6)); | ||
assertThat(sodVariables.getSodThreadKeepAliveTime(), is(17)); | ||
assertThat(sodVariables.getSodWaitForJobShutdownTimeout(), is(32)); | ||
|
||
assertThat(plugin.getTestResultCategories(), is("hgjghhlllllaa")); | ||
assertThat(plugin.isTestResultParsingEnabled(), is(true)); | ||
} | ||
|
||
@Test | ||
public void should_support_configuration_export() throws Exception { | ||
ConfiguratorRegistry registry = ConfiguratorRegistry.get(); | ||
ConfigurationContext context = new ConfigurationContext(registry); | ||
CNode yourAttribute = getUnclassifiedRoot(context).get("buildFailureAnalyzer"); | ||
|
||
String exported = toYamlString(yourAttribute); | ||
|
||
String expected = toStringFromYamlFile(this, "expected_output.yaml"); | ||
|
||
assertThat(exported, is(expected)); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/resources/com/sonyericsson/jenkins/plugins/bfa/jcasc/jcasc-local-expected.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
buildFailureAnalyzer: | ||
doNotAnalyzeAbortedJob: true | ||
gerritTriggerEnabled: true | ||
globalEnabled: true | ||
graphsEnabled: false | ||
knowledgeBase: "localFile" | ||
maxLogSize: 10 | ||
noCausesMessage: "No problems were identified. If you know why this problem occurred,\ | ||
\ please add a suitable Cause for it." | ||
nrOfScanThreads: 6 | ||
sodVariables: | ||
maximumSodWorkerThreads: 4 | ||
minimumSodWorkerThreads: 2 | ||
sodCorePoolNumberOfThreads: 6 | ||
sodThreadKeepAliveTime: 17 | ||
sodWaitForJobShutdownTimeout: 32 | ||
testResultCategories: "hgjghhlllllaa" | ||
testResultParsingEnabled: true |
19 changes: 19 additions & 0 deletions
19
src/test/resources/com/sonyericsson/jenkins/plugins/bfa/jcasc/jcasc-local.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
unclassified: | ||
buildFailureAnalyzer: | ||
doNotAnalyzeAbortedJob: true | ||
gerritTriggerEnabled: true | ||
globalEnabled: true | ||
graphsEnabled: false | ||
knowledgeBase: "localFile" | ||
maxLogSize: 10 | ||
noCausesMessage: "No problems were identified. If you know why this problem occurred,\ | ||
\ please add a suitable Cause for it." | ||
nrOfScanThreads: 6 | ||
sodVariables: | ||
maximumSodWorkerThreads: 4 | ||
minimumSodWorkerThreads: 2 | ||
sodCorePoolNumberOfThreads: 6 | ||
sodThreadKeepAliveTime: 17 | ||
sodWaitForJobShutdownTimeout: 32 | ||
testResultCategories: "hgjghhlllllaa" | ||
testResultParsingEnabled: true |