Skip to content

Commit d1abf29

Browse files
committed
Test NextLabelCause equals contract
The code incorrectly tested the equals contract of the wrong class due to my copy and paste error. Test the correct class. Uses the simple() verifier because the UpstreamCause class seems to have complications related to its superclass and I'd rather not spend the time to investigate further. The simple() verifier detected the null pointer exceptions, so it is still better than not testing. Removes temporary check for null pointers, since equalsverifier performs the same checks.
1 parent 9ac76c0 commit d1abf29

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/test/java/org/jvnet/jenkins/plugins/nodelabelparameter/NextLabelCauseTest.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import hudson.model.FreeStyleBuild;
44
import hudson.model.FreeStyleProject;
55
import nl.jqno.equalsverifier.EqualsVerifier;
6-
import nl.jqno.equalsverifier.Warning;
76
import org.junit.Assert;
87
import org.junit.Rule;
98
import org.junit.Test;
@@ -21,21 +20,12 @@ public void testGetShortDescription() throws Exception {
2120
NextLabelCause cause = new NextLabelCause("dummylabel", build);
2221
String description = cause.getShortDescription();
2322
Assert.assertEquals(description, "A build with label/node [dummylabel] was requested");
24-
25-
NextLabelCause causeA = new NextLabelCause(null, build);
26-
NextLabelCause causeB = new NextLabelCause(null, build);
27-
/* Temporary check that hashCode does not NPE on null label */
28-
Assert.assertEquals(causeA.hashCode(), causeB.hashCode());
29-
/* Temporary check that equals does not NPE on null label */
30-
Assert.assertTrue(causeA.equals(causeB));
3123
}
3224

3325
@Test
3426
public void testEqualsContract() {
35-
EqualsVerifier.forClass(LabelParameterValue.class)
36-
.usingGetClass()
37-
.suppress(Warning.NONFINAL_FIELDS)
38-
.withIgnoredFields("description", "nextLabels")
39-
.verify();
27+
// The UpstreamCause base class of NextLabelCause complicates the equals contract.
28+
// Intentionally use the simple() verifier.
29+
EqualsVerifier.simple().forClass(NextLabelCause.class).verify();
4030
}
4131
}

0 commit comments

Comments
 (0)