Java Code Examples for hudson.util.DescribableList#get()

The following examples show how to use hudson.util.DescribableList#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobDslITest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
/**
 * Creates a freestyle job from a YAML file and verifies that issue recorder finds warnings.
 */
@Test
public void shouldCreateFreestyleJobUsingJobDslAndVerifyIssueRecorderWithDefaultConfiguration() {
    configureJenkins("job-dsl-warnings-ng-default.yaml");

    TopLevelItem project = getJenkins().jenkins.getItem("dsl-freestyle-job");

    assertThat(project).isNotNull();
    assertThat(project).isInstanceOf(FreeStyleProject.class);

    DescribableList<Publisher, Descriptor<Publisher>> publishers = ((FreeStyleProject) project).getPublishersList();
    assertThat(publishers).hasSize(1);

    Publisher publisher = publishers.get(0);
    assertThat(publisher).isInstanceOf(IssuesRecorder.class);

    HealthReport healthReport = ((FreeStyleProject) project).getBuildHealth();
    assertThat(healthReport.getScore()).isEqualTo(100);

    IssuesRecorder recorder = (IssuesRecorder) publisher;

    assertThat(recorder.getAggregatingResults()).isFalse();
    assertThat(recorder.getTrendChartType()).isEqualTo(TrendChartType.AGGREGATION_TOOLS);
    assertThat(recorder.getBlameDisabled()).isFalse();
    assertThat(recorder.getForensicsDisabled()).isFalse();
    assertThat(recorder.getEnabledForFailure()).isFalse();
    assertThat(recorder.getHealthy()).isEqualTo(0);
    assertThat(recorder.getId()).isNull();
    assertThat(recorder.getIgnoreFailedBuilds()).isTrue();
    assertThat(recorder.getIgnoreQualityGate()).isFalse();
    assertThat(recorder.getMinimumSeverity()).isEqualTo("LOW");
    assertThat(recorder.getName()).isNull();
    assertThat(recorder.getQualityGates()).hasSize(0);
    assertThat(recorder.getSourceCodeEncoding()).isEmpty();
    assertThat(recorder.getUnhealthy()).isEqualTo(0);

    List<Tool> tools = recorder.getTools();
    assertThat(tools).hasSize(2);
    assertThat(tools.get(0)).isInstanceOf(Java.class);
}
 
Example 2
Source File: KubernetesTest.java    From kubernetes-plugin with Apache License 2.0 5 votes vote down vote up
@Test
@LocalData()
public void upgradeFrom_0_10() throws Exception {
    List<PodTemplate> templates = cloud.getTemplates();
    PodTemplate template = templates.get(0);
    DescribableList<NodeProperty<?>,NodePropertyDescriptor> nodeProperties = template.getNodeProperties();
    assertEquals(1, nodeProperties.size());
    ToolLocationNodeProperty property = (ToolLocationNodeProperty) nodeProperties.get(0);
    assertEquals(1, property.getLocations().size());
    ToolLocation location = property.getLocations().get(0);
    assertEquals("Default", location.getName());
    assertEquals("/custom/path", location.getHome());
    assertEquals(GitTool.class, location.getType().clazz);
    assertEquals(cloud.DEFAULT_WAIT_FOR_POD_SEC, cloud.getWaitForPodSec());
}
 
Example 3
Source File: DslIntegrationTest.java    From github-integration-plugin with MIT License 5 votes vote down vote up
private void verifyPublishers(DescribableList<Publisher, Descriptor<Publisher>> publishers) {
    assertThat("Should add publisher", publishers, hasSize(2));

    assertThat("Should add status publisher", publishers.get(0), instanceOf(GitHubPRBuildStatusPublisher.class));
    assertThat("Should add 2 packages",
            ((GitHubPRBuildStatusPublisher) publishers.get(0)).getStatusMsg().getContent(),
            equalTo(JOB_DSL_PUBLISHER_TEXT_CONTENT));

    assertThat("Has comment publisher", publishers.get(1), instanceOf(GitHubPRCommentPublisher.class));
    GitHubPRCommentPublisher commentPublisher = (GitHubPRCommentPublisher) publishers.get(1);

    assertThat("Comment matches", commentPublisher.getComment().getContent(), equalTo("comment"));
    assertThat("Only failed builds", commentPublisher.getStatusVerifier().getBuildStatus(), equalTo(Result.FAILURE));
    assertThat("Publish marked as failure", commentPublisher.getErrorHandler().getBuildStatus(), equalTo(Result.FAILURE));
}
 
Example 4
Source File: JobDslITest.java    From warnings-ng-plugin with MIT License 4 votes vote down vote up
/**
 * Creates a freestyle job from a YAML file and verifies that all fields in issue recorder are set correct.
 */
@Test
public void shouldCreateFreestyleJobUsingJobDslAndVerifyIssueRecorderWithValuesSet() {
    configureJenkins("job-dsl-warnings-ng.yaml");

    TopLevelItem project = getJenkins().jenkins.getItem("dsl-freestyle-job");

    assertThat(project).isNotNull();
    assertThat(project).isInstanceOf(FreeStyleProject.class);

    DescribableList<Publisher, Descriptor<Publisher>> publishers = ((FreeStyleProject) project).getPublishersList();
    assertThat(publishers).hasSize(1);

    Publisher publisher = publishers.get(0);
    assertThat(publisher).isInstanceOf(IssuesRecorder.class);

    HealthReport healthReport = ((FreeStyleProject) project).getBuildHealth();
    assertThat(healthReport.getScore()).isEqualTo(100);

    IssuesRecorder recorder = (IssuesRecorder) publisher;

    assertThat(recorder.getAggregatingResults()).isTrue();
    assertThat(recorder.getTrendChartType()).isEqualTo(TrendChartType.NONE);
    assertThat(recorder.getBlameDisabled()).isTrue();
    assertThat(recorder.getForensicsDisabled()).isTrue();
    assertThat(recorder.getEnabledForFailure()).isTrue();
    assertThat(recorder.getHealthy()).isEqualTo(10);
    assertThat(recorder.getId()).isEqualTo("test-id");
    assertThat(recorder.getIgnoreFailedBuilds()).isFalse();
    assertThat(recorder.getIgnoreQualityGate()).isTrue();
    assertThat(recorder.getMinimumSeverity()).isEqualTo("ERROR");
    assertThat(recorder.getName()).isEqualTo("test-name");
    assertThat(recorder.getSourceCodeEncoding()).isEqualTo("UTF-8");
    assertThat(recorder.getUnhealthy()).isEqualTo(50);
    assertThat(recorder.getReferenceJobName()).isEqualTo("test-job");
    assertThat(recorder.getQualityGates()).hasSize(1);

    List<Tool> tools = recorder.getTools();
    assertThat(tools).hasSize(2);
    assertThat(tools.get(0)).isInstanceOf(Java.class);

}
 
Example 5
Source File: JcascTest.java    From git-client-plugin with MIT License 4 votes vote down vote up
@Override
protected void assertConfiguredAsExpected(RestartableJenkinsRule restartableJenkinsRule, String s) {
    final ToolDescriptor descriptor = (ToolDescriptor) restartableJenkinsRule.j.jenkins.getDescriptor(GitTool.class);
    final ToolInstallation[] installations = descriptor.getInstallations();
    assertThat(installations, arrayWithSize(4));
    assertThat(installations, arrayContainingInAnyOrder(
            allOf(
                    instanceOf(JGitTool.class),
                    hasProperty("name", equalTo(JGitTool.MAGIC_EXENAME))
            ),
            allOf(
                    instanceOf(JGitApacheTool.class),
                    hasProperty("name", equalTo(JGitApacheTool.MAGIC_EXENAME))
            ),
            allOf(
                    instanceOf(GitTool.class),
                    not(instanceOf(JGitTool.class)),
                    not(instanceOf(JGitApacheTool.class)),
                    hasProperty("name", equalTo("Default")),
                    hasProperty("home", equalTo("git"))
            ),
            allOf(
                    instanceOf(GitTool.class),
                    not(instanceOf(JGitTool.class)),
                    not(instanceOf(JGitApacheTool.class)),
                    hasProperty("name", equalTo("optional")),
                    hasProperty("home", equalTo("/opt/git/git"))
            ))
    );
    final DescribableList<ToolProperty<?>, ToolPropertyDescriptor> properties = Arrays.stream(installations).filter(t -> t.getName().equals("optional")).findFirst().get().getProperties();
    assertThat(properties, iterableWithSize(1));
    final ToolProperty<?> property = properties.get(0);
    assertThat(property, instanceOf(InstallSourceProperty.class));
    assertThat(((InstallSourceProperty)property).installers,
            containsInAnyOrder(
                    allOf(
                            instanceOf(BatchCommandInstaller.class),
                            hasProperty("command", equalTo("echo \"got git\""))
                    ),
                    allOf(
                            instanceOf(ZipExtractionInstaller.class),
                            hasProperty("url", equalTo("file://some/path.zip"))
                    )
            )
    );
}