Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiyv-improving committed Nov 3, 2023
1 parent 0439598 commit 7ed06b7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ public <T, E extends Exception> T execute(final Class<T> resultClass, final Clas

} catch (final Exception e) {
if (e instanceof FailoverSQLException) {
if (!Objects.equals(this.getWriter(this.pluginService.getHosts()), this.currentWriter)) {
this.checkWriterChanged();
}
this.checkWriterChanged();
}
throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public DefaultConnectionPlugin(
this.pluginManagerService = pluginManagerService;
this.defaultConnProvider = defaultConnProvider;
this.effectiveConnProvider = effectiveConnProvider;
this.connProviderManager = new ConnectionProviderManager(defaultConnProvider);
this.connProviderManager = connProviderManager;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ public void testInvalidateOpenedConnectionsWhenWriterHostNotChange() throws SQLE
.build();

// Host list changes during simulated failover
when(mockPluginService.getHosts())
.thenReturn(Collections.singletonList(originalHost))
.thenReturn(Collections.singletonList(newHost));
when(mockPluginService.getHosts()).thenReturn(Collections.singletonList(originalHost));
doThrow(expectedException).when(mockSqlFunction).call();

final AuroraConnectionTrackerPlugin plugin = new AuroraConnectionTrackerPlugin(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class DefaultConnectionPluginTest {
@Mock TelemetryCounter mockTelemetryCounter;
@Mock TelemetryGauge mockTelemetryGauge;
@Mock ConnectionProviderManager mockConnectionProviderManager;
@Mock ConnectionProvider mockConnectionProvider;
@Mock HostSpec mockHostSpec;


Expand All @@ -88,7 +87,7 @@ void setUp() {
// noinspection unchecked
when(mockTelemetryFactory.createGauge(anyString(), any(GaugeCallable.class))).thenReturn(mockTelemetryGauge);
when(mockConnectionProviderManager.getConnectionProvider(anyString(), any(), any()))
.thenReturn(mockConnectionProvider);
.thenReturn(connectionProvider);

plugin = new DefaultConnectionPlugin(
pluginService, connectionProvider, null, pluginManagerService, mockConnectionProviderManager);
Expand Down Expand Up @@ -123,7 +122,7 @@ void testExecute_closeOldConnection() throws SQLException {
@Test
void testConnect() throws SQLException {
plugin.connect("anyProtocol", mockHostSpec, new Properties(), true, mockConnectFunction);
verify(mockConnectionProvider, atLeastOnce()).connect(anyString(), any(), any(), any(), any());
verify(connectionProvider, atLeastOnce()).connect(anyString(), any(), any(), any(), any());
verify(mockConnectionProviderManager, atLeastOnce()).initConnection(any(), anyString(), any(), any());
}

Expand Down

0 comments on commit 7ed06b7

Please sign in to comment.