Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If you add a class, consider adding the following basic tests for it first:

Use EqualsTester for equality and string conversion tests

Any class that defines equals(), hashCode(), or toString() must test these methods.  The Google Guava EqualsTester class provides full coverage for these methods:

Code Block
languagejava
titleUsing EqualsTester
final FlowId flowId1 = FlowId.valueOf(1);
final FlowId sameAsFlowId1 = FlowId.valueOf(1);
final FlowId flowId2 = FlowId.valueOf(2);


/**
* Checks the operation of equals(), hashCode() and toString() methods.
*/
@Test
public void testEquals() {
   new EqualsTester()
      .addEqualityGroup(flowId1, sameAsFlowId1)
      .addEqualityGroup(flowId2)
      .testEquals();
}

...