### Question:
ModelAndViewArtifact { @Override public int hashCode() { final int prime = 31; int result = prime + this.viewArtifact.hashCode(); result = prime * result + ObjectUtils.nullSafeHashCode(this.model); return result; } ModelAndViewArtifact(ViewArtifact viewArtifact, Map<String, Object> model);  ModelAndViewArtifact(String artifact, Map<String, Object> model);  ModelAndViewArtifact(String artifact); ViewArtifact getViewArtifact(); Map<String, Object> getModel(); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test public void shouldImplementHashCodeAndEquals() throws Exception { ModelAndViewArtifact m1 = new ModelAndViewArtifact(this.viewArtifact, this.model); ModelAndViewArtifact m2 = new ModelAndViewArtifact(this.viewArtifact, this.model); ModelAndViewArtifact m3 = new ModelAndViewArtifact(this.viewArtifact, null); assertThat(m1, is(equalTo(m1))); assertThat(m1, is(equalTo(m2))); assertThat(m1, is(not(equalTo(m3)))); assertThat(m1.hashCode(), is(equalTo(m1.hashCode()))); assertThat(m1.hashCode(), is(equalTo(m2.hashCode()))); assertThat(m1.hashCode(), is(not(equalTo(m3.hashCode())))); }