Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some sonar findings #168

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
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 @@ -43,10 +43,10 @@
@ExtendWith(MockitoExtension.class)
class DataSourceXAResourceRecoveryHelperTests {

@Mock(lenient = true)
@Mock(strictness = Mock.Strictness.LENIENT)
private XADataSource mockXaDataSource;

@Mock(lenient = true)
@Mock(strictness = Mock.Strictness.LENIENT)
private XAConnection mockXaConnection;

@Mock
Expand All @@ -65,7 +65,7 @@ void before() throws SQLException {
@Test
void shouldCreateConnectionAndGetXAResource() throws SQLException {
XAResource[] xaResources = this.recoveryHelper.getXAResources();
assertThat(xaResources.length).isEqualTo(1);
assertThat(xaResources).hasSize(1);
assertThat(xaResources[0]).isSameAs(this.recoveryHelper);
verify(this.mockXaDataSource).getXAConnection();
}
Expand All @@ -75,7 +75,7 @@ void shouldCreateConnectionWithCredentialsAndGetXAResource() throws SQLException
given(this.mockXaDataSource.getXAConnection(anyString(), anyString())).willReturn(this.mockXaConnection);
this.recoveryHelper = new DataSourceXAResourceRecoveryHelper(this.mockXaDataSource, "username", "password");
XAResource[] xaResources = this.recoveryHelper.getXAResources();
assertThat(xaResources.length).isEqualTo(1);
assertThat(xaResources).hasSize(1);
assertThat(xaResources[0]).isSameAs(this.recoveryHelper);
verify(this.mockXaDataSource).getXAConnection("username", "password");
}
Expand All @@ -84,7 +84,7 @@ void shouldCreateConnectionWithCredentialsAndGetXAResource() throws SQLException
void shouldFailToCreateConnectionAndNotGetXAResource() throws SQLException {
given(this.mockXaDataSource.getXAConnection()).willThrow(new SQLException("Test exception"));
XAResource[] xaResources = this.recoveryHelper.getXAResources();
assertThat(xaResources.length).isEqualTo(0);
assertThat(xaResources).isEmpty();
verify(this.mockXaDataSource).getXAConnection();
verify(this.mockXaConnection, times(0)).getXAResource();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ void testCrashBeforeCommit() throws Exception {
protected void assertEntriesAfterCrash(List<Entry> entries) {
assertThat(entries)
.as("No entry should exist")
.hasSize(0);
.isEmpty();
}

protected void assertMessagesAfterCrash(List<String> messages) {
assertThat(messages)
.as("No message should exist")
.hasSize(0);
.isEmpty();
}

protected void assertEntriesAfterRecovery(List<Entry> entries) {
Expand Down