Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpectedly getting NotEqualHashCodeAssertionError #223

Closed
fahim-a opened this issue Mar 16, 2018 · 3 comments
Closed

Unexpectedly getting NotEqualHashCodeAssertionError #223

fahim-a opened this issue Mar 16, 2018 · 3 comments

Comments

@fahim-a
Copy link

fahim-a commented Mar 16, 2018

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
Copy link
Author

fahim-a commented Mar 16, 2018

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
Copy link
Author

fahim-a commented Mar 16, 2018

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
Copy link
Author

fahim-a commented Mar 16, 2018

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.

@fahim-a fahim-a closed this as completed Mar 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant