EntityTag { @Override public int hashCode() { return Objects.hash(this.value, this.weak); } EntityTag(final String value);  EntityTag(final String value, final boolean weak); @Deprecated static EntityTag valueOf(final String value); boolean isWeak(); String getValue(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override @Deprecated String toString();  }
@Test public void shouldBeEqualToTheSameInstance() { EntityTag entityTag = new EntityTag("value", true); assertThat(entityTag, equalTo(entityTag)); assertThat(entityTag.hashCode(), equalTo(entityTag.hashCode())); }
@Test public void shouldBeEqualsForSameFieldValues() { EntityTag entityTag = new EntityTag("value", true); EntityTag entityTagWithSameValues = new EntityTag("value", true); assertThat(entityTag, equalTo(entityTagWithSameValues)); assertThat(entityTag.hashCode(), equalTo(entityTagWithSameValues.hashCode())); }
@Test public void shouldNotBeEqualIfValueFieldDiffers() { EntityTag entityTag = new EntityTag("value", true); EntityTag entityTagWithDifferentValue = new EntityTag("differentValue", true); assertThat(entityTag, not(equalTo(entityTagWithDifferentValue))); assertThat(entityTag.hashCode(), not(equalTo(entityTagWithDifferentValue.hashCode()))); }
@Test public void shouldNotBeEqualIfWeekSettingDiffers() { EntityTag entityTag = new EntityTag("value", true); EntityTag entityTagWithDifferentWeakSetting = new EntityTag("value", false); assertThat(entityTag, not(equalTo(entityTagWithDifferentWeakSetting))); assertThat(entityTag.hashCode(), not(equalTo(entityTagWithDifferentWeakSetting.hashCode()))); }