### Question:
Root { @Override public int hashCode() { return state.hashCode(); } Root(State state); State getState(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void testEqualsHash() { Root root1 = new Root(Root.State.ROOTED); Root root2 = new Root(Root.State.ROOTED); Root root3 = new Root(Root.State.DENIED); assertThat(root1, is(root2)); assertThat(root1.hashCode(), is(root2.hashCode())); assertThat(root1, is(not(root3))); assertThat(root1.hashCode(), is(not(root3.hashCode()))); }