Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: emmacoveragecolumn-0.0.4
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 3 files changed
  • 0 commit comments
  • 4 contributors
Commits on Oct 10, 2011
@danebert danebert [maven-release-plugin] prepare for next development iteration 1cd23b8
Commits on Apr 06, 2012
@ndeloof ndeloof updated maven pom to use repo.jenkins-ci.org repository 6746800
Commits on Dec 04, 2012
@danebert danebert Fix for JENKINS-12123
Fixed bug that caused NPE if there wasn't an EmmaBuildAction for the
lastSuccessfulBuild
Updated EasyMock Version
Updated pom repository sections
8b291ad
Commits on Dec 21, 2012
@danebert danebert [maven-release-plugin] prepare release What is SCM release tag or lab…
…el for "Emma Line Coverage Column"? (org.jenkins-ci.plugins:emmacoveragecolumn) emmacoveragecolumn-0.0.6: : 0.0.6
497c0d5
@danebert danebert Revert "[maven-release-plugin] prepare release What is SCM release ta…
…g or label for "Emma Line Coverage Column"? (org.jenkins-ci.plugins:emmacoveragecolumn) emmacoveragecolumn-0.0.6: : 0.0.6"

This reverts commit 497c0d5.
8501599
Commits on Mar 28, 2013
Antonio Nicolás Pina Fixed NPE when no lastSuccessfulBuild is available. cf0e663
Commits on Jan 02, 2014
@danebert danebert Merge pull request #1 from ANPez/master
Fixed NPE when lastSuccessfulBuild is not available.
8439cc7
View
28 pom.xml
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -7,11 +8,11 @@
</parent>
<artifactId>emmacoveragecolumn</artifactId>
- <version>0.0.4</version>
+ <version>0.0.6-SNAPSHOT</version>
<name>Emma Line Coverage Column</name>
<packaging>hpi</packaging>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Emma+Coverage+Column</url>
-
+
<developers>
<developer>
<id>danebert</id>
@@ -28,24 +29,23 @@
</dependency>
<dependency>
<groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <version>2.2</version>
+ <artifactId>easymock</artifactId>
+ <version>3.1</version>
+ <scope>test</scope>
</dependency>
</dependencies>
- <!-- get every artifact through maven.glassfish.org, which proxies all the
- artifacts that we need -->
<repositories>
<repository>
- <id>m.g.o-public</id>
- <url>http://maven.glassfish.org/content/groups/public/</url>
+ <id>repo.jenkins-ci.org</id>
+ <url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
- <id>m.g.o-public</id>
- <url>http://maven.glassfish.org/content/groups/public/</url>
+ <id>repo.jenkins-ci.org</id>
+ <url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
@@ -54,4 +54,10 @@
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/emmacoveragecolumn-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/emmacoveragecolumn-plugin</url>
</scm>
+ <distributionManagement>
+ <repository>
+ <id>maven.jenkins-ci.org</id>
+ <url>http://maven.jenkins-ci.org:8081/content/repositories/releases/</url>
+ </repository>
+ </distributionManagement>
</project>
View
28 src/main/java/jenkins/plugins/emmacoveragecolumn/EmmaColumn.java
@@ -31,7 +31,8 @@ public String getPercent(final Job<?, ?> job) {
final Run<?, ?> lastSuccessfulBuild = job.getLastSuccessfulBuild();
final StringBuilder stringBuilder = new StringBuilder();
- if (lastSuccessfulBuild == null) {
+ if (lastSuccessfulBuild == null
+ || lastSuccessfulBuild.getAction(EmmaBuildAction.class) == null) {
stringBuilder.append("N/A");
} else {
final Double percent = getLinePercent(lastSuccessfulBuild);
@@ -56,14 +57,25 @@ public String getFillColor(final BigDecimal amount) {
return CoverageRange.colorAsHexString(c);
}
- public BigDecimal getLineCoverage(final Job<?, ?> job) {
+ public String getLineCoverage(final Job<?, ?> job) {
final Run<?, ?> lastSuccessfulBuild = job.getLastSuccessfulBuild();
- return BigDecimal.valueOf(getLinePercent(lastSuccessfulBuild)
- .doubleValue());
+ final StringBuilder stringBuilder = new StringBuilder();
+
+ if (lastSuccessfulBuild == null
+ || lastSuccessfulBuild.getAction(EmmaBuildAction.class) == null) {
+ stringBuilder.append("N/A");
+ } else {
+ final Double percent = getLinePercent(lastSuccessfulBuild);
+ stringBuilder.append(percent);
+ }
+
+ return stringBuilder.toString();
}
private Double getLinePercent(final Run<?, ?> lastSuccessfulBuild) {
- final Float percentageFloat = getPercentageFloat(lastSuccessfulBuild);
+ final EmmaBuildAction action = lastSuccessfulBuild
+ .getAction(EmmaBuildAction.class);
+ final Float percentageFloat = getPercentageFloat(action);
final double doubleValue = percentageFloat.doubleValue();
final int decimalPlaces = 2;
@@ -75,9 +87,7 @@ private Double getLinePercent(final Run<?, ?> lastSuccessfulBuild) {
return bigDecimal.doubleValue();
}
- private Float getPercentageFloat(final Run<?, ?> lastSuccessfulBuild) {
- final EmmaBuildAction action = lastSuccessfulBuild
- .getAction(EmmaBuildAction.class);
+ private Float getPercentageFloat(final EmmaBuildAction action) {
final CoverageReport result = action.getResult();
@@ -106,4 +116,4 @@ public String getDisplayName() {
return "Line Coverage";
}
}
-}
+}
View
22 src/test/java/jenkins/plugins/emmacoveragecolumn/EmmaColumnTest.java
@@ -2,11 +2,13 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import hudson.model.Build;
import hudson.model.Job;
+import hudson.plugins.emma.EmmaBuildAction;
import java.math.BigDecimal;
-import org.easymock.classextension.EasyMock;
+import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
@@ -28,6 +30,22 @@ public void testGetPercentWithNoLastSuccessfulBuild() {
assertEquals("N/A", emmaColumn.getPercent(mockJob));
}
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void testGetPercentWithNoAction() {
+ final Job mockJob = EasyMock.createMock(Job.class);
+ final Build mockLlastSuccessful = EasyMock.createMock(Build.class);
+
+ EasyMock.expect(mockJob.getLastSuccessfulBuild()).andReturn(
+ mockLlastSuccessful);
+
+ EasyMock.expect(mockLlastSuccessful.getAction(EmmaBuildAction.class))
+ .andReturn(null);
+
+ EasyMock.replay(mockJob, mockLlastSuccessful);
+ assertEquals("N/A", emmaColumn.getPercent(mockJob));
+ }
+
@Test
public void testGetLineColorWithNull() throws Exception {
assertNull(emmaColumn.getLineColor(null));
@@ -47,7 +65,5 @@ public void testGetFillColorWithNull() throws Exception {
@Test
public void testGetFillColor100() throws Exception {
assertEquals("008B00", emmaColumn.getFillColor(BigDecimal.valueOf(100)));
-
}
-
}

No commit comments for this range

Something went wrong with that request. Please try again.