-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve 'AddEmbeddableBadgeConfigStepTest' test coverage (#288)
Co-authored-by: Mark Waite <mark.earl.waite@gmail.com>
- Loading branch information
1 parent
d38681f
commit 44a466e
Showing
1 changed file
with
54 additions
and
18 deletions.
There are no files selected for viewing
72 changes: 54 additions & 18 deletions
72
src/test/java/org/jenkinsci/plugins/badge/dsl/AddEmbeddableBadgeConfigStepTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,64 @@ | ||
package org.jenkinsci.plugins.badge.dsl; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.Is.is; | ||
import static org.hamcrest.core.IsNull.nullValue; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import org.junit.Test; | ||
import hudson.model.TaskListener; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class AddEmbeddableBadgeConfigStepTest { | ||
|
||
@Test | ||
void testConstructorAndGetID() { | ||
AddEmbeddableBadgeConfigStep step = new AddEmbeddableBadgeConfigStep("testId"); | ||
assertEquals("testId", step.getID()); | ||
} | ||
|
||
@Test | ||
void testGetSubjectAndSetSubject() { | ||
AddEmbeddableBadgeConfigStep step = new AddEmbeddableBadgeConfigStep("testId"); | ||
assertNull(step.getSubject()); | ||
step.setSubject("testSubject"); | ||
assertEquals("testSubject", step.getSubject()); | ||
} | ||
|
||
@Test | ||
void testGetStatusAndSetStatus() { | ||
AddEmbeddableBadgeConfigStep step = new AddEmbeddableBadgeConfigStep("testId"); | ||
assertNull(step.getStatus()); | ||
step.setStatus("testStatus"); | ||
assertEquals("testStatus", step.getStatus()); | ||
} | ||
|
||
@Test | ||
void testGetColorAndSetColor() { | ||
AddEmbeddableBadgeConfigStep step = new AddEmbeddableBadgeConfigStep("testId"); | ||
assertNull(step.getColor()); | ||
step.setColor("testColor"); | ||
assertEquals("testColor", step.getColor()); | ||
} | ||
|
||
@Test | ||
void testGetAnimatedOverlayColorAndSetAnimatedOverlayColor() { | ||
AddEmbeddableBadgeConfigStep step = new AddEmbeddableBadgeConfigStep("testId"); | ||
assertNull(step.getAnimatedOverlayColor()); | ||
step.setAnimatedOverlayColor("testOverlayColor"); | ||
assertEquals("testOverlayColor", step.getAnimatedOverlayColor()); | ||
} | ||
|
||
public class AddEmbeddableBadgeConfigStepTest { | ||
@Test | ||
public void testConstructor() { | ||
AddEmbeddableBadgeConfigStep addEmbeddableBadgeConfigStep = | ||
new AddEmbeddableBadgeConfigStep("test-Id-constructor"); | ||
assertThat(addEmbeddableBadgeConfigStep.getID(), is("test-Id-constructor")); | ||
assertThat(addEmbeddableBadgeConfigStep.getSubject(), is(nullValue())); | ||
assertThat(addEmbeddableBadgeConfigStep.getStatus(), is(nullValue())); | ||
assertThat(addEmbeddableBadgeConfigStep.getColor(), is(nullValue())); | ||
assertThat(addEmbeddableBadgeConfigStep.getAnimatedOverlayColor(), is(nullValue())); | ||
assertThat(addEmbeddableBadgeConfigStep.getLink(), is(nullValue())); | ||
void testGetLinkAndSetLink() { | ||
AddEmbeddableBadgeConfigStep step = new AddEmbeddableBadgeConfigStep("testId"); | ||
assertNull(step.getLink()); | ||
step.setLink("testLink"); | ||
assertEquals("testLink", step.getLink()); | ||
} | ||
|
||
@Test | ||
public void testGetAnimatedOverlayColor() { | ||
AddEmbeddableBadgeConfigStep addEmbeddableBadgeConfigStep = | ||
new AddEmbeddableBadgeConfigStep("test-animated-overlay-color"); | ||
assertThat(addEmbeddableBadgeConfigStep.getColor(), is(nullValue())); | ||
void testDescriptor() { | ||
AddEmbeddableBadgeConfigStep.DescriptorImpl descriptor = new AddEmbeddableBadgeConfigStep.DescriptorImpl(); | ||
assertEquals("addEmbeddableBadgeConfiguration", descriptor.getFunctionName()); | ||
assertEquals("Add an Embeddable Badge Configuration", descriptor.getDisplayName()); | ||
assertEquals(1, descriptor.getRequiredContext().size()); | ||
assertTrue(descriptor.getRequiredContext().contains(TaskListener.class)); | ||
} | ||
} |