Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<prism-api.version>1.28.0-2</prism-api.version>
<docker-fixtures.version>1.11</docker-fixtures.version>
<testcontainers.version>1.17.3</testcontainers.version>
<job-dsl.version>1.79</job-dsl.version>
</properties>

<developers>
Expand Down Expand Up @@ -273,6 +274,23 @@
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jenkins</groupId>
<artifactId>configuration-as-code</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>job-dsl</artifactId>
<version>${job-dsl.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>xmlunit</artifactId>
<groupId>xmlunit</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand Down
103 changes: 0 additions & 103 deletions plugin/src/main/java/io/jenkins/plugins/coverage/CoverageColumn.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ protected ColorProvider getColorProvider() {
*
* @return the display names
*/
// FIXME: these texts should not be used as IDs
public static List<String> getAvailableCoverageTypeNames() {
return Arrays.asList(
Messages.Project_Coverage_Type(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package io.jenkins.plugins.coverage.model;

import org.junit.jupiter.api.Test;

import hudson.model.View;
import hudson.views.ListViewColumn;

import io.jenkins.plugins.casc.ConfigurationAsCode;
import io.jenkins.plugins.casc.ConfiguratorException;
import io.jenkins.plugins.coverage.model.visualization.dashboard.CoverageColumn;
import io.jenkins.plugins.util.IntegrationTestWithJenkinsPerTest;

import static io.jenkins.plugins.coverage.model.Assertions.*;

/**
* Tests the Job DSL Plugin.
*
* @author Ullrich Hafner
*/
class JobDslITest extends IntegrationTestWithJenkinsPerTest {
/**
* Creates a freestyle job from a YAML file and verifies that issue recorder finds warnings.
*/
@Test
void shouldCreateFreestyleJobUsingJobDslAndVerifyIssueRecorderWithDefaultConfiguration() {
configureJenkins("column-dsl.yaml");

View view = getJenkins().getInstance().getView("dsl-view");

assertThat(view).isNotNull();

assertThat(view.getColumns())
.extracting(ListViewColumn::getColumnCaption)
.contains(new CoverageColumn().getColumnCaption());

assertThat(view.getColumns()).first()
.isInstanceOfSatisfying(CoverageColumn.class,
c -> {
assertThat(c).hasColumnCaption(Messages.Coverage_Column())
.hasCoverageMetric(CoverageMetric.LINE.getName());
});
}

/**
* Helper method to get jenkins configuration file.
*
* @param fileName
* file with configuration.
*/
private void configureJenkins(final String fileName) {
try {
ConfigurationAsCode.get().configure(getResourceAsFile(fileName).toUri().toString());
}
catch (ConfiguratorException e) {
throw new AssertionError(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
jobs:
- script: >
listView("dsl-view") {
jobs {
regex("^bar")
}
recurse(true)
columns {
coverageColumn()
status()
weather()
name()
lastSuccess()
lastFailure()
lastDuration()
testResult(1)
buildButton()
}
}