Grade implements Serializable { @Override public int hashCode() { return Objects.hash(studentId, date, discipline, grade); } Grade(final String studentId, final Date date, final Discipline discipline, final Integer grade);  Grade(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); final Discipline getDiscipline(); final void setDiscipline(final Discipline pDiscipline); final Integer getGrade(); final void setGrade(final Integer pGrade); final long getId(); String getStudentId(); void setStudentId(String studentId); Date getDate(); void setDate(Date date);  }
@Test public void shouldTestHashCode() { Date date = new Date(); Grade g1 = new Grade("0001", date, Discipline.BIOLOGY, 40); Grade g2 = new Grade("0001", date, Discipline.BIOLOGY, 40); Assert.assertEquals("g1.hashcode=g2.hashcode", g1.hashCode(), g2.hashCode()); }