Skip to content

Commit

Permalink
[JENKINS-37477] Add a test for lack of failures in doc generation.
Browse files Browse the repository at this point in the history
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 c8494c0
Showing 1 changed file with 49 additions and 0 deletions.
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -298,6 +307,46 @@ public class JobPropertyStepTest {
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 {
Expand Down

0 comments on commit c8494c0

Please sign in to comment.