PagedResult { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PagedResult that = (PagedResult) o; if (cookie != null ? !cookie.equals(that.cookie) : that.cookie != null) return false; if (resultList != null ? !resultList.equals(that.resultList) : that.resultList != null) return false; return true; } PagedResult(List<?> resultList, PagedResultsCookie cookie); PagedResultsCookie getCookie(); List<?> getResultList(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testEquals() throws Exception { List expectedList = new LinkedList(); expectedList.add("dummy"); List otherList = new LinkedList(); otherList.add("different"); PagedResult originalObject = new PagedResult(expectedList, new PagedResultsCookie(null)); PagedResult identicalObject = new PagedResult(expectedList, new PagedResultsCookie(null)); PagedResult differentObject = new PagedResult(otherList, new PagedResultsCookie(null)); PagedResult subclassObject = new PagedResult(expectedList, new PagedResultsCookie(null)) { }; new EqualsTester(originalObject, identicalObject, differentObject, subclassObject); }