Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ public void allOptionsAbsent() {
assertThat(options.equals(null)).isFalse();
assertThat(options.equals(this)).isFalse();
assertNull(options.isolationLevel());
assertThat(options.hashCode()).isEqualTo(31);
// Verify hashCode contract: equal objects must have equal hashCodes, and hashCode is stable.
Options options2 = Options.fromReadOptions();
assertThat(options.equals(options2)).isTrue();
assertThat(options.hashCode()).isEqualTo(options2.hashCode());
assertThat(options.hashCode()).isEqualTo(options.hashCode());
Comment on lines +155 to +159
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assertion assertThat(options.hashCode()).isEqualTo(options.hashCode()) is a tautology and provides little value in a unit test for a value-like object. Additionally, using assertThat(options).isEqualTo(options2) is more idiomatic and provides better failure messages than assertThat(options.equals(options2)).isTrue().

Suggested change
// Verify hashCode contract: equal objects must have equal hashCodes, and hashCode is stable.
Options options2 = Options.fromReadOptions();
assertThat(options.equals(options2)).isTrue();
assertThat(options.hashCode()).isEqualTo(options2.hashCode());
assertThat(options.hashCode()).isEqualTo(options.hashCode());
// Verify hashCode contract: equal objects must have equal hashCodes.
Options options2 = Options.fromReadOptions();
assertThat(options).isEqualTo(options2);
assertThat(options.hashCode()).isEqualTo(options2.hashCode());

}

@Test
Expand All @@ -175,7 +179,13 @@ public void listOptionsTest() {
assertThat(options.pageSize()).isEqualTo(pageSize);
assertThat(options.pageToken()).isEqualTo(pageToken);
assertThat(options.filter()).isEqualTo(filter);
assertThat(options.hashCode()).isEqualTo(108027089);
// Verify hashCode contract: equal objects must have equal hashCodes, and hashCode is stable.
Options options2 =
Options.fromListOptions(
Options.pageSize(pageSize), Options.pageToken(pageToken), Options.filter(filter));
assertThat(options.equals(options2)).isTrue();
assertThat(options.hashCode()).isEqualTo(options2.hashCode());
assertThat(options.hashCode()).isEqualTo(options.hashCode());
Comment on lines +182 to +188
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assertion assertThat(options.hashCode()).isEqualTo(options.hashCode()) is a tautology and provides little value in a unit test for a value-like object. Additionally, using assertThat(options).isEqualTo(options2) is more idiomatic and provides better failure messages than assertThat(options.equals(options2)).isTrue().

Suggested change
// Verify hashCode contract: equal objects must have equal hashCodes, and hashCode is stable.
Options options2 =
Options.fromListOptions(
Options.pageSize(pageSize), Options.pageToken(pageToken), Options.filter(filter));
assertThat(options.equals(options2)).isTrue();
assertThat(options.hashCode()).isEqualTo(options2.hashCode());
assertThat(options.hashCode()).isEqualTo(options.hashCode());
// Verify hashCode contract: equal objects must have equal hashCodes.
Options options2 =
Options.fromListOptions(
Options.pageSize(pageSize), Options.pageToken(pageToken), Options.filter(filter));
assertThat(options).isEqualTo(options2);
assertThat(options.hashCode()).isEqualTo(options2.hashCode());

}

@Test
Expand Down Expand Up @@ -696,7 +706,11 @@ public void updateOptionsTest() {
assertEquals("tag: " + tag + " ", options.toString());
assertTrue(options.hasTag());
assertThat(options.tag()).isEqualTo(tag);
assertThat(options.hashCode()).isEqualTo(-2118248262);
// Verify hashCode contract: equal objects must have equal hashCodes, and hashCode is stable.
Options options2 = Options.fromUpdateOptions(Options.tag(tag));
assertThat(options.equals(options2)).isTrue();
assertThat(options.hashCode()).isEqualTo(options2.hashCode());
assertThat(options.hashCode()).isEqualTo(options.hashCode());
Comment on lines +709 to +713
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assertion assertThat(options.hashCode()).isEqualTo(options.hashCode()) is a tautology and provides little value in a unit test for a value-like object. Additionally, using assertThat(options).isEqualTo(options2) is more idiomatic and provides better failure messages than assertThat(options.equals(options2)).isTrue().

Suggested change
// Verify hashCode contract: equal objects must have equal hashCodes, and hashCode is stable.
Options options2 = Options.fromUpdateOptions(Options.tag(tag));
assertThat(options.equals(options2)).isTrue();
assertThat(options.hashCode()).isEqualTo(options2.hashCode());
assertThat(options.hashCode()).isEqualTo(options.hashCode());
// Verify hashCode contract: equal objects must have equal hashCodes.
Options options2 = Options.fromUpdateOptions(Options.tag(tag));
assertThat(options).isEqualTo(options2);
assertThat(options.hashCode()).isEqualTo(options2.hashCode());

}

@Test
Expand Down Expand Up @@ -728,7 +742,11 @@ public void transactionOptionsTest() {
assertEquals("tag: " + tag + " ", options.toString());
assertTrue(options.hasTag());
assertThat(options.tag()).isEqualTo(tag);
assertThat(options.hashCode()).isEqualTo(-2118248262);
// Verify hashCode contract: equal objects must have equal hashCodes, and hashCode is stable.
Options options2 = Options.fromTransactionOptions(Options.tag(tag));
assertThat(options.equals(options2)).isTrue();
assertThat(options.hashCode()).isEqualTo(options2.hashCode());
assertThat(options.hashCode()).isEqualTo(options.hashCode());
Comment on lines +745 to +749
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assertion assertThat(options.hashCode()).isEqualTo(options.hashCode()) is a tautology and provides little value in a unit test for a value-like object. Additionally, using assertThat(options).isEqualTo(options2) is more idiomatic and provides better failure messages than assertThat(options.equals(options2)).isTrue().

Suggested change
// Verify hashCode contract: equal objects must have equal hashCodes, and hashCode is stable.
Options options2 = Options.fromTransactionOptions(Options.tag(tag));
assertThat(options.equals(options2)).isTrue();
assertThat(options.hashCode()).isEqualTo(options2.hashCode());
assertThat(options.hashCode()).isEqualTo(options.hashCode());
// Verify hashCode contract: equal objects must have equal hashCodes.
Options options2 = Options.fromTransactionOptions(Options.tag(tag));
assertThat(options).isEqualTo(options2);
assertThat(options.hashCode()).isEqualTo(options2.hashCode());

}

@Test
Expand Down
Loading