Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This just fixes the NPE symptoms, but I'm afraid that the reason that an event has a null value has some deeper issue somewhere.
- Loading branch information
Showing
2 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
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
55 changes: 55 additions & 0 deletions
55
...udson/plugins/gerrit/trigger/gerritnotifier/model/GerritTriggeredEventComparatorTest.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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.model; | ||
|
||
import com.sonyericsson.hudson.plugins.gerrit.trigger.mock.Setup; | ||
import com.sonymobile.tools.gerrit.gerritevents.dto.events.ChangeMerged; | ||
import com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent; | ||
import com.sonymobile.tools.gerrit.gerritevents.dto.events.PatchsetCreated; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.util.Arrays; | ||
import java.util.Comparator; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Tests {@link com.sonyericsson.hudson.plugins.gerrit.trigger.gerritnotifier.model.BuildMemory.GerritTriggeredEventComparator}. | ||
* | ||
* @author Robert Sandell <rsandell@cloudbees.com>. | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class GerritTriggeredEventComparatorTest { | ||
|
||
private final GerritTriggeredEvent o1; | ||
private final GerritTriggeredEvent o2; | ||
private final int expected; | ||
private final Comparator<GerritTriggeredEvent> comparator; | ||
|
||
@Parameterized.Parameters(name= "{index}: {0}, {1} == {2}") | ||
public static Iterable<Object[]> permutations() { | ||
PatchsetCreated event = Setup.createPatchsetCreated(); | ||
ChangeMerged merged = Setup.createChangeMerged(); | ||
return Arrays.asList(new Object[][]{ | ||
{null, null, 0}, | ||
{null, event, -1}, | ||
{event, null, 1}, | ||
{event, event, 0}, | ||
{event, merged, new Integer(event.hashCode()).compareTo(merged.hashCode())}, | ||
{merged, event, new Integer(merged.hashCode()).compareTo(event.hashCode())} | ||
}); | ||
} | ||
|
||
public GerritTriggeredEventComparatorTest(GerritTriggeredEvent o1, GerritTriggeredEvent o2, int expected) { | ||
this.o1 = o1; | ||
this.o2 = o2; | ||
this.expected = expected; | ||
comparator = new BuildMemory.GerritTriggeredEventComparator(); | ||
} | ||
|
||
@Test | ||
public void testCompare() throws Exception { | ||
assertEquals(expected, comparator.compare(o1, o2)); | ||
} | ||
} |