HaloServerVersion { @Override public int hashCode() { int result = mMinHaloVersion != null ? mMinHaloVersion.hashCode() : 0; result = 31 * result + (mChangeLogUrl != null ? mChangeLogUrl.hashCode() : 0); return result; } HaloServerVersion();  HaloServerVersion(@Nullable String changelogUrl, @Nullable String minAndroidVersion); @Api(1.2) @Nullable String getHaloVersion(); @Api(1.2) @Nullable String getChangeLogUrl(); @Api(1.2) boolean isOutdated(@NonNull String version); @Override boolean equals(Object o); @Override int hashCode(); static final int VALID; static final int OUTDATED; static final int NOT_CHECKED; }
@Test public void thatVersionAreEquals() { HaloServerVersion version = new HaloServerVersion("changelog", "1.1"); HaloServerVersion version2 = new HaloServerVersion("changelog", "1.1"); assertThat(version2).isEqualTo(version); HaloServerVersion version3 = new HaloServerVersion("changelog2", "1.1"); assertThat(version3).isNotEqualTo(version2); HaloServerVersion version4 = new HaloServerVersion("changelog", "1"); assertThat(version3).isNotEqualTo(version4); assertThat(1).isNotEqualTo(version); assertThat(version).isNotNull(); assertThat(new HaloServerVersion(null, "1.1")).isNotEqualTo(version); assertThat(version).isNotEqualTo(new HaloServerVersion(null, "1.1")); assertThat(new HaloServerVersion(null, null)).isNotEqualTo(version); assertThat(new HaloServerVersion("changelog", null)).isNotEqualTo(version); assertThat(version).isNotEqualTo(new HaloServerVersion("changelog", null)); assertThat(version).isEqualTo(version); assertThat(version2.hashCode()).isEqualTo(version.hashCode()); assertThat(new HaloServerVersion(null, null).hashCode() == 0).isTrue(); assertThat(new HaloServerVersion(null, null).hashCode()).isNotEqualTo(version.hashCode()); assertThat(version3.hashCode()).isNotEqualTo(version.hashCode()); }