From add2466e590c73798ba3371cae8ee941070a0451 Mon Sep 17 00:00:00 2001 From: ChenJiaHao Date: Mon, 25 Dec 2023 16:47:34 +0800 Subject: [PATCH] Fix sonar issue (#29538) * Fix sonar issue * Fix code style --- .../ral/updatable/RefreshDatabaseMetaDataUpdaterTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshDatabaseMetaDataUpdaterTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshDatabaseMetaDataUpdaterTest.java index 7852a12648c6d..12f05cd87d56f 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshDatabaseMetaDataUpdaterTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshDatabaseMetaDataUpdaterTest.java @@ -18,6 +18,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable; import org.apache.shardingsphere.distsql.statement.ral.updatable.RefreshDatabaseMetaDataStatement; +import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.database.UnknownDatabaseException; import org.apache.shardingsphere.mode.manager.ContextManager; import org.apache.shardingsphere.proxy.backend.context.ProxyContext; import org.apache.shardingsphere.proxy.backend.session.ConnectionSession; @@ -27,8 +28,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import java.sql.SQLException; - +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -41,9 +41,9 @@ class RefreshDatabaseMetaDataUpdaterTest { private ConnectionSession connectionSession; @Test - void assertExecuteWithNoDatabase() throws SQLException { + void assertExecuteWithNoDatabase() { RefreshDatabaseMetaDataUpdater updater = new RefreshDatabaseMetaDataUpdater(); when(ProxyContext.getInstance().getContextManager()).thenReturn(mock(ContextManager.class, RETURNS_DEEP_STUBS)); - updater.executeUpdate(connectionSession, mock(RefreshDatabaseMetaDataStatement.class)); + assertThrows(UnknownDatabaseException.class, () -> updater.executeUpdate(connectionSession, new RefreshDatabaseMetaDataStatement("foo", true))); } }