Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added tests for equalsandhashcode and doNotUseGetters config parameter
- fixed equalsandhashcode and doNotUseGetters config parameter for hashcode Configuration keys #53
- Loading branch information
Michail Plushnikov
committed
Mar 27, 2016
1 parent
1c8529e
commit b782d76
Showing
8 changed files
with
285 additions
and
9 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
34 changes: 34 additions & 0 deletions
34
src/test/java/de/plushnikov/intellij/plugin/configsystem/EqualsAndHashCodeTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
package de.plushnikov.intellij.plugin.configsystem; | |||
|
|||
import java.io.IOException; | |||
|
|||
/** | |||
* Unit tests for IntelliJPlugin for Lombok with activated config system | |||
*/ | |||
public class EqualsAndHashCodeTest extends AbstractLombokConfigSystemTestCase { | |||
|
|||
protected boolean shouldCompareAnnotations() { | |||
return true; | |||
} | |||
|
|||
@Override | |||
protected String getBasePath() { | |||
return super.getBasePath() + "/configsystem/equalsandhashcode"; | |||
} | |||
|
|||
public void testDoNotUseGetters$SomeTest() throws IOException { | |||
doTest(); | |||
} | |||
|
|||
public void testDoNotUseGetters$AnnotationOverwriteTest() throws IOException { | |||
doTest(); | |||
} | |||
|
|||
public void testCallSuper$WithSuperTest() throws IOException { | |||
doTest(); | |||
} | |||
|
|||
public void testCallSuper$WithoutSuperTest() throws IOException { | |||
doTest(); | |||
} | |||
} |
75 changes: 67 additions & 8 deletions
75
test-manual/src/main/java/de/plushnikov/test/SomeTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,15 +1,74 @@ | |||
package de.plushnikov.test; | package de.plushnikov.test; | ||
|
|
||
import lombok.Getter; | |||
|
|||
@Getter | |||
public class SomeTest { | public class SomeTest { | ||
|
|
||
private int a; | private int intProperty; | ||
private boolean booleanProperty; | |||
private double doubleProperty; | |||
private String stringProperty; | |||
|
|||
public int getIntProperty() { | |||
return intProperty; | |||
} | |||
|
|||
public boolean isBooleanProperty() { | |||
return booleanProperty; | |||
} | |||
|
|||
public double getDoubleProperty() { | |||
return doubleProperty; | |||
} | |||
|
|
||
public static void main(String[] args) { | public String getStringProperty() { | ||
SomeTest someTest = new SomeTest(); | return stringProperty; | ||
someTest.a = 1; | } | ||
System.out.println(someTest.a); |
|
||
public static void main(String[] args) { | |||
final SomeTest test = new SomeTest(); | |||
System.out.println(test.hashCode()); | |||
} | |||
|
|||
public boolean equals(Object o) { | |||
if (o == this) { | |||
return true; | |||
} | |||
if (!(o instanceof SomeTest)) { | |||
return false; | |||
} | } | ||
final SomeTest other = (SomeTest) o; | |||
if (!other.canEqual((Object) this)) { | |||
return false; | |||
} | |||
if (this.intProperty != other.intProperty) { | |||
return false; | |||
} | |||
if (this.booleanProperty != other.booleanProperty) { | |||
return false; | |||
} | |||
if (Double.compare(this.doubleProperty, other.doubleProperty) != 0) { | |||
return false; | |||
} | |||
final Object this$stringProperty = this.stringProperty; | |||
final Object other$stringProperty = other.stringProperty; | |||
if (this$stringProperty == null ? other$stringProperty != null : !this$stringProperty.equals(other$stringProperty)) { | |||
return false; | |||
} | |||
return true; | |||
} | |||
|
|||
public int hashCode() { | |||
final int PRIME = 59; | |||
int result = 1; | |||
result = result * PRIME + this.intProperty; | |||
result = result * PRIME + (this.booleanProperty ? 79 : 97); | |||
final long $doubleProperty = Double.doubleToLongBits(this.doubleProperty); | |||
result = result * PRIME + (int) ($doubleProperty >>> 32 ^ $doubleProperty); | |||
final Object $stringProperty = this.stringProperty; | |||
result = result * PRIME + ($stringProperty == null ? 0 : $stringProperty.hashCode()); | |||
return result; | |||
} | |||
|
|||
protected boolean canEqual(Object other) { | |||
return other instanceof SomeTest; | |||
} | |||
} | } |
31 changes: 31 additions & 0 deletions
31
testData/configsystem/equalsandhashcode/doNotUseGetters/AnnotationOverwriteTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
import lombok.EqualsAndHashCode; | |||
|
|||
@EqualsAndHashCode(doNotUseGetters = false) | |||
public class AnnotationOverwriteTest { | |||
|
|||
private int intProperty; | |||
private boolean booleanProperty; | |||
private double doubleProperty; | |||
private String stringProperty; | |||
|
|||
public int getIntProperty() { | |||
return intProperty; | |||
} | |||
|
|||
public boolean isBooleanProperty() { | |||
return booleanProperty; | |||
} | |||
|
|||
public double getDoubleProperty() { | |||
return doubleProperty; | |||
} | |||
|
|||
public String getStringProperty() { | |||
return stringProperty; | |||
} | |||
|
|||
public static void main(String[] args) { | |||
final AnnotationOverwriteTest test = new AnnotationOverwriteTest(); | |||
System.out.println(test.hashCode()); | |||
} | |||
} |
31 changes: 31 additions & 0 deletions
31
testData/configsystem/equalsandhashcode/doNotUseGetters/SomeTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
import lombok.EqualsAndHashCode; | |||
|
|||
@EqualsAndHashCode | |||
public class SomeTest { | |||
|
|||
private int intProperty; | |||
private boolean booleanProperty; | |||
private double doubleProperty; | |||
private String stringProperty; | |||
|
|||
public int getIntProperty() { | |||
return intProperty; | |||
} | |||
|
|||
public boolean isBooleanProperty() { | |||
return booleanProperty; | |||
} | |||
|
|||
public double getDoubleProperty() { | |||
return doubleProperty; | |||
} | |||
|
|||
public String getStringProperty() { | |||
return stringProperty; | |||
} | |||
|
|||
public static void main(String[] args) { | |||
final SomeTest test = new SomeTest(); | |||
System.out.println(test.hashCode()); | |||
} | |||
} |
59 changes: 59 additions & 0 deletions
59
testData/configsystem/equalsandhashcode/doNotUseGetters/after/AnnotationOverwriteTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,59 @@ | |||
public class AnnotationOverwriteTest { | |||
|
|||
private int intProperty; | |||
private boolean booleanProperty; | |||
private double doubleProperty; | |||
private String stringProperty; | |||
|
|||
public int getIntProperty() { | |||
return intProperty; | |||
} | |||
|
|||
public boolean isBooleanProperty() { | |||
return booleanProperty; | |||
} | |||
|
|||
public double getDoubleProperty() { | |||
return doubleProperty; | |||
} | |||
|
|||
public String getStringProperty() { | |||
return stringProperty; | |||
} | |||
|
|||
public static void main(String[] args) { | |||
final AnnotationOverwriteTest test = new AnnotationOverwriteTest(); | |||
System.out.println(test.hashCode()); | |||
} | |||
|
|||
public boolean equals(Object o) { | |||
if (o == this) return true; | |||
if (!(o instanceof AnnotationOverwriteTest)) return false; | |||
final AnnotationOverwriteTest other = (AnnotationOverwriteTest) o; | |||
if (!other.canEqual((java.lang.Object) this)) return false; | |||
if (this.getIntProperty() != other.getIntProperty()) return false; | |||
if (this.isBooleanProperty() != other.isBooleanProperty()) return false; | |||
if (java.lang.Double.compare(this.getDoubleProperty(), other.getDoubleProperty()) != 0) return false; | |||
final java.lang.Object this$stringProperty = this.getStringProperty(); | |||
final java.lang.Object other$stringProperty = other.getStringProperty(); | |||
if (this$stringProperty == null ? other$stringProperty != null : !this$stringProperty.equals(other$stringProperty)) | |||
return false; | |||
return true; | |||
} | |||
|
|||
public int hashCode() { | |||
final int PRIME = 59; | |||
int result = 1; | |||
result = result * PRIME + this.getIntProperty(); | |||
result = result * PRIME + (this.isBooleanProperty() ? 79 : 97); | |||
final long $doubleProperty = java.lang.Double.doubleToLongBits(this.getDoubleProperty()); | |||
result = result * PRIME + (int) ($doubleProperty >>> 32 ^ $doubleProperty); | |||
final java.lang.Object $stringProperty = this.getStringProperty(); | |||
result = result * PRIME + ($stringProperty == null ? 0 : $stringProperty.hashCode()); | |||
return result; | |||
} | |||
|
|||
protected boolean canEqual(java.lang.Object other) { | |||
return other instanceof AnnotationOverwriteTest; | |||
} | |||
} |
59 changes: 59 additions & 0 deletions
59
testData/configsystem/equalsandhashcode/doNotUseGetters/after/SomeTest.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,59 @@ | |||
public class SomeTest { | |||
|
|||
private int intProperty; | |||
private boolean booleanProperty; | |||
private double doubleProperty; | |||
private String stringProperty; | |||
|
|||
public int getIntProperty() { | |||
return intProperty; | |||
} | |||
|
|||
public boolean isBooleanProperty() { | |||
return booleanProperty; | |||
} | |||
|
|||
public double getDoubleProperty() { | |||
return doubleProperty; | |||
} | |||
|
|||
public String getStringProperty() { | |||
return stringProperty; | |||
} | |||
|
|||
public static void main(String[] args) { | |||
final SomeTest test = new SomeTest(); | |||
System.out.println(test.hashCode()); | |||
} | |||
|
|||
public boolean equals(Object o) { | |||
if (o == this) return true; | |||
if (!(o instanceof SomeTest)) return false; | |||
final SomeTest other = (SomeTest) o; | |||
if (!other.canEqual((java.lang.Object) this)) return false; | |||
if (this.intProperty != other.intProperty) return false; | |||
if (this.booleanProperty != other.booleanProperty) return false; | |||
if (java.lang.Double.compare(this.doubleProperty, other.doubleProperty) != 0) return false; | |||
final java.lang.Object this$stringProperty = this.stringProperty; | |||
final java.lang.Object other$stringProperty = other.stringProperty; | |||
if (this$stringProperty == null ? other$stringProperty != null : !this$stringProperty.equals(other$stringProperty)) | |||
return false; | |||
return true; | |||
} | |||
|
|||
public int hashCode() { | |||
final int PRIME = 59; | |||
int result = 1; | |||
result = result * PRIME + this.intProperty; | |||
result = result * PRIME + (this.booleanProperty ? 79 : 97); | |||
final long $doubleProperty = java.lang.Double.doubleToLongBits(this.doubleProperty); | |||
result = result * PRIME + (int) ($doubleProperty >>> 32 ^ $doubleProperty); | |||
final java.lang.Object $stringProperty = this.stringProperty; | |||
result = result * PRIME + ($stringProperty == null ? 0 : $stringProperty.hashCode()); | |||
return result; | |||
} | |||
|
|||
protected boolean canEqual(java.lang.Object other) { | |||
return other instanceof SomeTest; | |||
} | |||
} |
3 changes: 3 additions & 0 deletions
3
testData/configsystem/equalsandhashcode/doNotUseGetters/lombok.config
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
lombok.equalsAndHashCode.doNotUseGetters = true | |||
|
|||
config.stopBubbling = true |