RankableObjectWithFields implements Rankable, Serializable { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof RankableObjectWithFields)) { return false; } RankableObjectWithFields other = (RankableObjectWithFields) o; return obj.equals(other.obj) && count == other.count; } RankableObjectWithFields(Object obj, long count, Object... otherFields); static RankableObjectWithFields from(Tuple tuple); Object getObject(); long getCount(); List<Object> getFields(); @Override int compareTo(Rankable other); @Override boolean equals(Object o); @Override int hashCode(); String toString(); @Override Rankable copy();  }
@Test(dataProvider = "otherClassesData") public void shouldNotBeEqualToInstancesOfOtherClasses(Object notARankable) { RankableObjectWithFields r = new RankableObjectWithFields(ANY_OBJECT, ANY_COUNT); assertFalse(r.equals(notARankable), r + " is equal to " + notARankable + " but it should not be"); }
@Test(dataProvider = "falseDuplicatesData") public void shouldNotBeEqualToFalseDuplicates(RankableObjectWithFields r, RankableObjectWithFields falseDuplicate) { assertFalse(r.equals(falseDuplicate), r + " is equal to " + falseDuplicate + " but it should not be"); }
@Test(dataProvider = "trueDuplicatesData") public void shouldBeEqualToTrueDuplicates(RankableObjectWithFields r, RankableObjectWithFields trueDuplicate) { assertTrue(r.equals(trueDuplicate), r + " is not equal to " + trueDuplicate + " but it should be"); }