FINRAOS / JTAF-XCore

XCore is a framework to define and execute automated tests. It enables automation code development in Java, test script development in XML via domain specific language, and execution & reporting via JUnit.
http://finraos.github.io/JTAF-XCore/
Apache License 2.0
10 stars 17 forks source link

PMD Issues: OverrideBothEqualsAndHashcode #33

Open mmlinford opened 8 years ago

mmlinford commented 8 years ago

The below locations (class:line number) violate the OverrideBothEqualsAndHashcode rule:

org.finra.jtaf.core.model.test.TestScript:199 org.finra.jtaf.core.model.test.digraph.DiNode:46 org.finra.jtaf.core.model.test.TestScript:199 org.finra.jtaf.core.model.test.digraph.DiNode:46

mibrahim commented 8 years ago

So there are two files here: TestScript and DiNode. Fixed TestScript in #35, however, when tried to override hashCode in DiNode tests failed. One of the failed tests is: RandomGeneratorTest - all tests fail

When the setup() runs, the call: testAgenda.getTestScripts()

returns an empty list - and so, none of the tests get initialized, throwing a NullPointerException later.

mibrahim commented 8 years ago

So here's the reason: DiGraph.hashCode is being called due to the call of TestDigraph#addVertex . A call to hashCode should necessitate DiGraph be an immutable class. The case here, is that DiGraph is a mutable class since the testScript is stored as a reference from the called testScript in the constructor and not copied. That means that the caller can still modify the testScript and so the old hashes will fail.