Unexpectedly getting NotEqualHashCodeAssertionError
fahim-a opened this issue · 3 comments
fahim-a commented
So I'm basically doing the following on 0.7.6
assertPojoMethodsFor(IndexedTPE.class).quickly().areWellImplemented();
When I run the test inside of intelliJ I get this:
pl.pojo.tester.internal.assertion.hashcode.NotEqualHashCodeAssertionError:
Class com.ciena.bp.nsi.indexingservice.model.tpe.IndexedTPE has bad 'hashCode' method implementation.
The hashCode method should return different hash codes for non equal objects.
Current implementation returns same hash codes.
Object:
IndexedTPE{resourcePartitionInfo=[], id=null, usedCapacity=[], active=null, networkConstruct=null, operationState=null, lastUpdatedState=null, expectations=[], userData=[], identifiers=[], deploymentState=null, lifecycleState=null, resourceState=null, bookingData=null, bookingData_lockout=null, plannedCapacity=[], attributePolicies=null, derivedAttributes=null, plannedAttributes=null, discoveredAttributes=null, extraData=IndexedTPEExtraData{usedCapacityPresent=false, eplServicePresent=false, ftpLagIsOnNni=false, ptpIsNniWithIpInterface=false, ftpLagIsOnNniWithIpInterface=false, ftpLagMultiChassis=false, interfaceIp=, clientTpesSize=0, tdmPortCapacity=true}}
and
IndexedTPE{resourcePartitionInfo=[], id=null, usedCapacity=[], active=null, networkConstruct=null, operationState=null, lastUpdatedState=null, expectations=[], userData=[], identifiers=[], deploymentState=null, lifecycleState=null, resourceState=null, bookingData=null, bookingData_lockout=null, plannedCapacity=[], attributePolicies=null, derivedAttributes=null, plannedAttributes=null, discoveredAttributes=null, extraData=IndexedTPEExtraData{usedCapacityPresent=false, eplServicePresent=false, ftpLagIsOnNni=false, ptpIsNniWithIpInterface=false, ftpLagIsOnNniWithIpInterface=false, ftpLagMultiChassis=false, interfaceIp=, clientTpesSize=0, tdmPortCapacity=true}}
should have different hash codes:
-172078917
and
-172078917
Not sure it matters, but when debugging, I get this instead:
pl.pojo.tester.internal.assertion.equals.NotEqualEqualsAssertionError:
Class com.ciena.bp.nsi.indexingservice.model.tpe.IndexedTPE has bad 'equals' method implementation.
The equals method should return false if objects should not be equal.
Current implementation returns true.
Object:
IndexedTPE{resourcePartitionInfo=[], id=null, usedCapacity=[], active=null, networkConstruct=null, operationState=null, lastUpdatedState=null, expectations=[], userData=[], identifiers=[], deploymentState=null, lifecycleState=null, resourceState=null, bookingData=null, bookingData_lockout=null, plannedCapacity=[], attributePolicies=null, derivedAttributes=null, plannedAttributes=null, discoveredAttributes=null, extraData=IndexedTPEExtraData{usedCapacityPresent=false, eplServicePresent=false, ftpLagIsOnNni=false, ptpIsNniWithIpInterface=false, ftpLagIsOnNniWithIpInterface=false, ftpLagMultiChassis=false, interfaceIp=, clientTpesSize=0, tdmPortCapacity=true}}
should not be equal to:
IndexedTPE{resourcePartitionInfo=[], id=null, usedCapacity=[], active=null, networkConstruct=null, operationState=null, lastUpdatedState=null, expectations=[], userData=[], identifiers=[], deploymentState=null, lifecycleState=null, resourceState=null, bookingData=null, bookingData_lockout=null, plannedCapacity=[], attributePolicies=null, derivedAttributes=null, plannedAttributes=null, discoveredAttributes=null, extraData=IndexedTPEExtraData{usedCapacityPresent=false, eplServicePresent=false, ftpLagIsOnNni=false, ptpIsNniWithIpInterface=false, ftpLagIsOnNniWithIpInterface=false, ftpLagMultiChassis=false, interfaceIp=, clientTpesSize=0, tdmPortCapacity=true}}
Any suggestions? As far as I can tell the Objects really should be identical...
fahim-a commented
Maybe a clue
IndexedTPE tpe = new IndexedTPE();
System.out.println("Hash = " + tpe.hashCode());
System.out.println("Equals = " + tpe.equals(new IndexedTPE()));
System.out.println("ToString = " + tpe);
generates
Hash = -172078917
Equals = true
ToString = IndexedTPE{resourcePartitionInfo=[], id=null, usedCapacity=[], active=null, networkConstruct=null, operationState=null, lastUpdatedState=null, expectations=[], userData=[], identifiers=[], deploymentState=null, lifecycleState=null, resourceState=null, bookingData=null, bookingData_lockout=null, plannedCapacity=[], attributePolicies=null, derivedAttributes=null, plannedAttributes=null, discoveredAttributes=null, extraData=IndexedTPEExtraData{usedCapacityPresent=false, eplServicePresent=false, ftpLagIsOnNni=false, ptpIsNniWithIpInterface=false, ftpLagIsOnNniWithIpInterface=false, ftpLagMultiChassis=false, interfaceIp=, clientTpesSize=0, tdmPortCapacity=true}}
fahim-a commented
Starting to think there's a field somewhere that isn't captured by the DefaultFieldValueChanger?
Albeit other than other nested POJOs - it ultimately boils down to Strings, ints, enums, Lists, Sets, etc.
fahim-a commented
Or perhaps because some of the nested POJOs overlap and multiple instances need to be instantiated...
Closing while I figure this out in my spare time.