diff --git a/.gitignore b/.gitignore index 411536455..22fe6a733 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ work .factorypath .project /nbproject/ +.DS_Store \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 89c28a29b..8f62214e4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,6 +50,15 @@ Run automated tests with multiple Java virtual machines in a development with th $ mvn clean -DforkCount=1C verify ``` +## Code formatting + +Code formatting is maintained by the `spotless` plugin. +Format the code with the command: + +``` +$ mvn spotless:apply +``` + ## Report an Issue Use the ["Report an issue" page](https://www.jenkins.io/participate/report-issue/redirect/#17120) to submit bug reports. diff --git a/src/test/java/org/jenkinsci/plugins/badge/EmbeddableBadgeConfigTest.java b/src/test/java/org/jenkinsci/plugins/badge/EmbeddableBadgeConfigTest.java new file mode 100644 index 000000000..f2b82e694 --- /dev/null +++ b/src/test/java/org/jenkinsci/plugins/badge/EmbeddableBadgeConfigTest.java @@ -0,0 +1,44 @@ +package org.jenkinsci.plugins.badge; + +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.*; + +import org.hamcrest.core.IsNull; +import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +public class EmbeddableBadgeConfigTest { + @Test + public void testConstructor() { + String id = "testId-constructor"; + EmbeddableBadgeConfig embeddableBadgeConfig = new EmbeddableBadgeConfig(id); + assertThat(embeddableBadgeConfig.getID(), is(id)); + assertThat(embeddableBadgeConfig.getSubject(), is(nullValue())); + assertThat(embeddableBadgeConfig.getStatus(), is(nullValue())); + assertThat(embeddableBadgeConfig.getAnimatedOverlayColor(), is(nullValue())); + assertThat(embeddableBadgeConfig.getLink(), is(nullValue())); + assertThat(embeddableBadgeConfig.getColor(), is(nullValue())); + } + + @Test + public void testGetAnimatedOverlayColorBlueForRunning() { + EmbeddableBadgeConfig embeddableBadgeConfig = new EmbeddableBadgeConfig("testId-running-blue"); + embeddableBadgeConfig.setStatus("running"); + assertThat(embeddableBadgeConfig.getAnimatedOverlayColor(), is("blue")); + } + + @ParameterizedTest + @CsvSource({ + "failing,red", + "passing,brightgreen", + "unstable,yellow", + "aborted,aborted", + "running,blue" + }) + public void testGetColor(String status, String expected) { + EmbeddableBadgeConfig embeddableBadgeConfig = new EmbeddableBadgeConfig("testId-status-" + status); + embeddableBadgeConfig.setStatus(status); + assertThat(embeddableBadgeConfig.getColor(), is(expected)); + } +}