Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from daniel-beck/JENKINS-18534
[FIXED JENKINS-18534] equals()/hashCode() for parameter value
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 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
78 changes: 78 additions & 0 deletions
78
src/test/java/hudson/scm/listtagsparameter/ListSubversionTagsParameterValueTest.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,78 @@ | ||
package hudson.scm.listtagsparameter; | ||
|
||
import org.junit.Test; | ||
import org.jvnet.hudson.test.Bug; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotEquals; | ||
|
||
/** | ||
* Created by schristou88 on 6/24/14. | ||
*/ | ||
public class ListSubversionTagsParameterValueTest { | ||
String expectedName = "name"; | ||
String expectedTag = "tag"; | ||
String expectedTagsDir = "/tmp"; | ||
/** | ||
* Since we are overriding the equals method, we should write a test unit. | ||
*/ | ||
@Test | ||
@Bug(18534) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jglick
Member
|
||
public void testEquality() { | ||
ListSubversionTagsParameterValue parameterValue = new ListSubversionTagsParameterValue(expectedName, | ||
expectedTag, | ||
expectedTagsDir); | ||
|
||
assertEquals(parameterValue, parameterValue); | ||
|
||
// When name is different | ||
ListSubversionTagsParameterValue otherParameterValue = new ListSubversionTagsParameterValue("different", | ||
expectedTag, | ||
expectedTagsDir); | ||
assertNotEquals("Two parameter values should NOT be equal if the only difference is the name.", | ||
parameterValue, | ||
otherParameterValue); | ||
|
||
// When tag is different | ||
otherParameterValue = new ListSubversionTagsParameterValue(expectedName, | ||
"tag2", | ||
expectedTagsDir); | ||
assertNotEquals("Two parameter values should NOT be equal if the difference is the tag.", | ||
parameterValue, | ||
otherParameterValue); | ||
|
||
// When tagsdir is different | ||
otherParameterValue = new ListSubversionTagsParameterValue(expectedName, | ||
expectedTag, | ||
"/tmp1"); | ||
assertNotEquals("Two parameter values should NOT be equal if the difference is the tagsDir.", | ||
parameterValue, | ||
otherParameterValue); | ||
|
||
otherParameterValue = new ListSubversionTagsParameterValue(expectedName, | ||
expectedTag, | ||
expectedTagsDir); | ||
assertEquals("Two parameters with the same value should also be equal.", | ||
parameterValue, | ||
otherParameterValue); | ||
} | ||
|
||
/** | ||
* Since we are overriding the hashcode method, we should write a test unit. | ||
*/ | ||
@Test | ||
@Bug(18534) | ||
public void testHashCode() { | ||
ListSubversionTagsParameterValue parameterValue = new ListSubversionTagsParameterValue(expectedName, | ||
expectedTag, | ||
expectedTagsDir); | ||
|
||
assertEquals(parameterValue.hashCode(), parameterValue.hashCode()); | ||
|
||
ListSubversionTagsParameterValue otherParameterValue = new ListSubversionTagsParameterValue(expectedName, | ||
expectedTag, | ||
expectedTagsDir); | ||
|
||
assertEquals(parameterValue.hashCode(), otherParameterValue.hashCode()); | ||
} | ||
} |
https://wiki.jenkins-ci.org/display/JENKINS/Unit+Test#UnitTest-@Issue%28%22JENKINS12345%22%29