Skip to content

Commit

Permalink
Use strict equality for timestamp comparison in JDBC tests
Browse files Browse the repository at this point in the history
This is possible because of the update to HSQLDB 2.6.0
This reverts commit eb7b276.

Closes gh-8782
  • Loading branch information
eleftherias committed Jun 8, 2021
1 parent 7ed38f1 commit 09a0670
Showing 1 changed file with 18 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.sql.Timestamp;
import java.sql.Types;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -56,7 +55,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.within;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.BDDMockito.given;
Expand Down Expand Up @@ -176,15 +174,14 @@ public void loadAuthorizedClientWhenExistsThenReturnAuthorizedClient() {
.isEqualTo(expected.getAccessToken().getTokenType());
assertThat(authorizedClient.getAccessToken().getTokenValue())
.isEqualTo(expected.getAccessToken().getTokenValue());
assertThat(authorizedClient.getAccessToken().getIssuedAt()).isCloseTo(expected.getAccessToken().getIssuedAt(),
within(1, ChronoUnit.MILLIS));
assertThat(authorizedClient.getAccessToken().getExpiresAt()).isCloseTo(expected.getAccessToken().getExpiresAt(),
within(1, ChronoUnit.MILLIS));
assertThat(authorizedClient.getAccessToken().getIssuedAt()).isEqualTo(expected.getAccessToken().getIssuedAt());
assertThat(authorizedClient.getAccessToken().getExpiresAt())
.isEqualTo(expected.getAccessToken().getExpiresAt());
assertThat(authorizedClient.getAccessToken().getScopes()).isEqualTo(expected.getAccessToken().getScopes());
assertThat(authorizedClient.getRefreshToken().getTokenValue())
.isEqualTo(expected.getRefreshToken().getTokenValue());
assertThat(authorizedClient.getRefreshToken().getIssuedAt()).isCloseTo(expected.getRefreshToken().getIssuedAt(),
within(1, ChronoUnit.MILLIS));
assertThat(authorizedClient.getRefreshToken().getIssuedAt())
.isEqualTo(expected.getRefreshToken().getIssuedAt());
}

@Test
Expand Down Expand Up @@ -231,15 +228,14 @@ public void saveAuthorizedClientWhenSaveThenLoadReturnsSaved() {
.isEqualTo(expected.getAccessToken().getTokenType());
assertThat(authorizedClient.getAccessToken().getTokenValue())
.isEqualTo(expected.getAccessToken().getTokenValue());
assertThat(authorizedClient.getAccessToken().getIssuedAt()).isCloseTo(expected.getAccessToken().getIssuedAt(),
within(1, ChronoUnit.MILLIS));
assertThat(authorizedClient.getAccessToken().getExpiresAt()).isCloseTo(expected.getAccessToken().getExpiresAt(),
within(1, ChronoUnit.MILLIS));
assertThat(authorizedClient.getAccessToken().getIssuedAt()).isEqualTo(expected.getAccessToken().getIssuedAt());
assertThat(authorizedClient.getAccessToken().getExpiresAt())
.isEqualTo(expected.getAccessToken().getExpiresAt());
assertThat(authorizedClient.getAccessToken().getScopes()).isEqualTo(expected.getAccessToken().getScopes());
assertThat(authorizedClient.getRefreshToken().getTokenValue())
.isEqualTo(expected.getRefreshToken().getTokenValue());
assertThat(authorizedClient.getRefreshToken().getIssuedAt()).isCloseTo(expected.getRefreshToken().getIssuedAt(),
within(1, ChronoUnit.MILLIS));
assertThat(authorizedClient.getRefreshToken().getIssuedAt())
.isEqualTo(expected.getRefreshToken().getIssuedAt());
// Test save/load of NOT NULL attributes only
principal = createPrincipal();
expected = createAuthorizedClient(principal, this.clientRegistration, true);
Expand All @@ -253,10 +249,9 @@ public void saveAuthorizedClientWhenSaveThenLoadReturnsSaved() {
.isEqualTo(expected.getAccessToken().getTokenType());
assertThat(authorizedClient.getAccessToken().getTokenValue())
.isEqualTo(expected.getAccessToken().getTokenValue());
assertThat(authorizedClient.getAccessToken().getIssuedAt()).isCloseTo(expected.getAccessToken().getIssuedAt(),
within(1, ChronoUnit.MILLIS));
assertThat(authorizedClient.getAccessToken().getExpiresAt()).isCloseTo(expected.getAccessToken().getExpiresAt(),
within(1, ChronoUnit.MILLIS));
assertThat(authorizedClient.getAccessToken().getIssuedAt()).isEqualTo(expected.getAccessToken().getIssuedAt());
assertThat(authorizedClient.getAccessToken().getExpiresAt())
.isEqualTo(expected.getAccessToken().getExpiresAt());
assertThat(authorizedClient.getAccessToken().getScopes()).isEmpty();
assertThat(authorizedClient.getRefreshToken()).isNull();
}
Expand All @@ -280,15 +275,14 @@ public void saveAuthorizedClientWhenSaveClientWithExistingPrimaryKeyThenUpdate()
.isEqualTo(updatedClient.getAccessToken().getTokenType());
assertThat(savedClient.getAccessToken().getTokenValue())
.isEqualTo(updatedClient.getAccessToken().getTokenValue());
assertThat(savedClient.getAccessToken().getIssuedAt()).isCloseTo(updatedClient.getAccessToken().getIssuedAt(),
within(1, ChronoUnit.MILLIS));
assertThat(savedClient.getAccessToken().getExpiresAt()).isCloseTo(updatedClient.getAccessToken().getExpiresAt(),
within(1, ChronoUnit.MILLIS));
assertThat(savedClient.getAccessToken().getIssuedAt()).isEqualTo(updatedClient.getAccessToken().getIssuedAt());
assertThat(savedClient.getAccessToken().getExpiresAt())
.isEqualTo(updatedClient.getAccessToken().getExpiresAt());
assertThat(savedClient.getAccessToken().getScopes()).isEqualTo(updatedClient.getAccessToken().getScopes());
assertThat(savedClient.getRefreshToken().getTokenValue())
.isEqualTo(updatedClient.getRefreshToken().getTokenValue());
assertThat(savedClient.getRefreshToken().getIssuedAt()).isCloseTo(updatedClient.getRefreshToken().getIssuedAt(),
within(1, ChronoUnit.MILLIS));
assertThat(savedClient.getRefreshToken().getIssuedAt())
.isEqualTo(updatedClient.getRefreshToken().getIssuedAt());
}

@Test
Expand Down

0 comments on commit 09a0670

Please sign in to comment.