Skip to content
Permalink
Browse files

[JENKINS-37477] Add a test for lack of failures in doc generation.

Ignoring errors in re: lack of @DataBoundConstructor for now. That may
change, but those are generally symptomatic of something so deep in
the core that they're not worth worrying about at the moment.

The guts of the test should probably move to workflow-cps for common
usage, a la SnippetizerTester.
  • Loading branch information
abayer committed Aug 22, 2016
1 parent debde51 commit c8494c01368a9641b0f768a37ccc8d57da1e7d6c
Showing with 49 additions and 0 deletions.
  1. +49 −0 src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java
@@ -36,6 +36,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import hudson.triggers.TimerTrigger;
import hudson.triggers.Trigger;
@@ -50,6 +51,13 @@
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMSource;
import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval;
import org.jenkinsci.plugins.structs.describable.ArrayType;
import org.jenkinsci.plugins.structs.describable.DescribableModel;
import org.jenkinsci.plugins.structs.describable.DescribableParameter;
import org.jenkinsci.plugins.structs.describable.ErrorType;
import org.jenkinsci.plugins.structs.describable.HeterogeneousObjectType;
import org.jenkinsci.plugins.structs.describable.HomogeneousObjectType;
import org.jenkinsci.plugins.structs.describable.ParameterType;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.cps.SnippetizerTester;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
@@ -67,6 +75,7 @@
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.kohsuke.stapler.NoStaplerConstructorException;

import static org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProjectTest.scheduleAndFindBranchProject;

@@ -298,6 +307,46 @@
assertEquals("[null, false, null]", MockTrigger.startsAndStops.toString());
}

@Issue("JENKINS-37477")
@Test
public void generateHelpTrigger() throws Exception {
DescribableModel<?> model = new DescribableModel(PipelineTriggersJobProperty.class);

assertNotNull(model);

recurseOnModel(model);
}

/**
* TODO: Move to workflow-cps test classes somewhere.
*/
private void recurseOnTypes(ParameterType type) throws Exception {
// For the moment, only care about types with @DataBoundConstructors.
if (type instanceof ErrorType && !(((ErrorType)type).getError() instanceof NoStaplerConstructorException)) {
throw ((ErrorType)type).getError();
}

if (type instanceof ArrayType) {
recurseOnTypes(((ArrayType)type).getElementType());
} else if (type instanceof HomogeneousObjectType) {
recurseOnModel(((HomogeneousObjectType) type).getSchemaType());
} else if (type instanceof HeterogeneousObjectType) {
for (Map.Entry<String, DescribableModel<?>> entry : ((HeterogeneousObjectType) type).getTypes().entrySet()) {
recurseOnModel(entry.getValue());
}
}
}

/**
* TODO: Move to workflow-cps test classes somewhere.
*/
private void recurseOnModel(DescribableModel<?> model) throws Exception {
for (DescribableParameter param : model.getParameters()) {
recurseOnTypes(param.getType());
}
}


@Issue("JENKINS-37477")
@Test
public void configRoundTripTrigger() throws Exception {

0 comments on commit c8494c0

Please sign in to comment.
You can’t perform that action at this time.