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

[JENKINS-70464] Improve AddEmbeddableBadgeConfigStepTest test coverage #288

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Changes from 1 commit
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
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());
abhishekmaity marked this conversation as resolved.
Show resolved Hide resolved
assertTrue(descriptor.getRequiredContext().contains(TaskListener.class));
abhishekmaity marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading