Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EmbeddableBadgeConfig tests #179

Merged
merged 5 commits into from
Mar 16, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ work
.factorypath
.project
/nbproject/
.DS_Store
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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));
}
}