Skip to content
Permalink
Browse files

Merge pull request #4 from finalspy/master

Fix for Jira JENKINS-11041
Thanks !
  • Loading branch information...
olamy committed Apr 18, 2012
2 parents fb30db1 + 8d7af4a commit 4bdb6194ed2b54b51b96e599d4b5ddc07e48ec97
@@ -3,8 +3,8 @@
import hudson.maven.MavenBuild;
import hudson.maven.MavenModule;
import hudson.maven.MavenModuleSetBuild;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.AbstractBuild;
import hudson.plugins.cigame.util.BuildUtil;

import java.util.ArrayList;
@@ -38,18 +38,23 @@ public void record(AbstractBuild<?, ?> build, RuleSet ruleset, BuildListener lis

List<Score> scoresForBuild = new LinkedList<Score>();
for (Rule rule : ruleset.getRules()) {
if (listener != null) {
listener.getLogger().append("[ci-game] evaluating rule: " + rule.getName() + "\n");
}
RuleResult<?> result = evaluate(build, rule);
if ((result != null) && (result.getPoints() != 0)) {
Score score = new Score(ruleset.getName(), rule.getName(), result.getPoints(), result.getDescription());
scoresForBuild.add(score);

if (listener != null) {
listener.getLogger().append("[ci-game] scored: " + score.getValue() + "\n");
}
}
if (null != rule){
if (listener != null) {
listener.getLogger().append("[ci-game] evaluating rule: " + rule.getName() + "\n");
}
RuleResult<?> result = evaluate(build, rule);
if ((result != null) && (result.getPoints() != 0)) {
Score score = new Score(ruleset.getName(), rule.getName(), result.getPoints(), result.getDescription());
scoresForBuild.add(score);
if (listener != null) {
listener.getLogger().append("[ci-game] scored: " + score.getValue() + "\n");
}
}
} else {
if (listener != null) {
listener.getLogger().append("[ci-game] null rule encountered\n");
}
}
}

// prevent ConcurrentModificationExceptions for e.g. matrix builds (see JENKINS-11498):
@@ -1,12 +1,15 @@
package hudson.plugins.cigame.model;

import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import hudson.model.AbstractBuild;

import java.util.ArrayList;
import java.util.Arrays;

import hudson.model.AbstractBuild;
import java.util.List;

import org.junit.Test;

@@ -27,6 +30,14 @@ public void assertThatEmptyRuleResultIsNotUsed() {
assertThat(card.getScores().size(), is(0));
}

@Test
public void assertRuleNull(){
List<Rule> liste = new ArrayList<Rule>();
liste.add(null);
ScoreCard card = new ScoreCard();
card.record(mock(AbstractBuild.class), new RuleSet("test", liste), null);
}

@Test
public void assertEmptyRuleBookDoesNotThrowIllegalException() {
ScoreCard scoreCard = new ScoreCard();

0 comments on commit 4bdb619

Please sign in to comment.
You can’t perform that action at this time.