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

Fix for #364 #365

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion build-monitor-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>groovy-postbuild</artifactId>
<version>2.3.1</version>
<version>2.4</version>
<optional>true</optional>
</dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for the suggestion from @dcendents .
This should be replaced with:

        <dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>badge</artifactId>
            <version>1.2</version>
            <optional>true</optional>
        </dependency>

(adding optional=true to the dcendents's comment)

And the plugin name to test should be also replaced to badge:
https://github.com/jan-molak/jenkins-build-monitor-plugin/blob/v1.11%2Bbuild.201701152243/build-monitor-plugin/src/main/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/viewmodel/JobViews.java#L18

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonValue;
import org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildAction;
import com.jenkinsci.plugins.badge.action.BadgeAction;

/**
* @author Daniel Beland
Expand All @@ -33,7 +33,7 @@ public HasBadges of(JobView jobView) {

@Override
public Badges asJson() {
Iterator<GroovyPostbuildAction> badges = Iterables.filter(job.lastBuild().allDetailsOf(GroovyPostbuildAction.class), filter).iterator();
Iterator<BadgeAction> badges = Iterables.filter(job.lastBuild().allDetailsOf(BadgeAction.class), filter).iterator();

return badges.hasNext()
? new Badges(badges)
Expand All @@ -43,25 +43,25 @@ public Badges asJson() {
public static class Badges {
private final List<Badge> badges = newArrayList();

public Badges(Iterator<GroovyPostbuildAction> badgeActions) {
public Badges(Iterator<BadgeAction> badgeActions) {
while (badgeActions.hasNext()) {
badges.add(new Badge(badgeActions.next()));
}
}

@JsonValue
public List<Badge> value() {
return ImmutableList.copyOf(badges);
}
}

public static class Badge {
private final GroovyPostbuildAction badge;
public Badge(GroovyPostbuildAction badge) {
private final BadgeAction badge;

public Badge(BadgeAction badge) {
this.badge = badge;
}

@JsonProperty
public final String text() {
return badge.getText();
Expand All @@ -87,10 +87,10 @@ public final String borderColor() {
return badge.getBorderColor();
}
}
private static class ActionFilter implements Predicate<GroovyPostbuildAction> {

private static class ActionFilter implements Predicate<BadgeAction> {
@Override
public boolean apply(GroovyPostbuildAction action) {
public boolean apply(BadgeAction action) {
return action.getIconPath() == null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import com.google.common.base.Supplier;

import org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildAction;
import com.jenkinsci.plugins.badge.action.BadgeAction;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

/**
* @author Daniel Beland
*/
public class BadgeRecipe implements Supplier<GroovyPostbuildAction> {
private GroovyPostbuildAction badge;
public class BadgeRecipe implements Supplier<BadgeAction> {
private BadgeAction badge;

public BadgeRecipe() {
badge = mock(GroovyPostbuildAction.class);
badge = mock(BadgeAction.class);
}

public BadgeRecipe withText(String text) throws Exception {
Expand All @@ -30,7 +30,7 @@ public BadgeRecipe withIcon(String icon, String text) throws Exception {
}

@Override
public GroovyPostbuildAction get() {
public BadgeAction get() {
return badge;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import jenkins.model.CauseOfInterruption;
import jenkins.model.InterruptedBuildAction;

import org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildAction;
import com.jenkinsci.plugins.badge.action.BadgeAction;
import org.powermock.api.mockito.PowerMockito;

import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -198,14 +198,14 @@ private FoundFailureCause failure(String name) {
when(failure.getName()).thenReturn(name);
return failure;
}

public BuildStateRecipe hasBadges(BadgeRecipe... badges) {
List<GroovyPostbuildAction> actions = new ArrayList<GroovyPostbuildAction>();
List<BadgeAction> actions = new ArrayList<BadgeAction>();
for (int i = 0; i < badges.length; i++) {
actions.add(badges[i].get());
}
when(build.getActions(GroovyPostbuildAction.class)).thenReturn(actions);
when(build.getActions(BadgeAction.class)).thenReturn(actions);

return this;
}

Expand Down