This is an automated email from the ASF dual-hosted git repository. jiangmaolin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push: new 96b7d58be7a Remove useless InUsedStorageUnitRetriever of encrypt and mask (#35163) 96b7d58be7a is described below commit 96b7d58be7ae779d3f4a87ba05cd67295f6374a7 Author: Raigor <raigor.ji...@gmail.com> AuthorDate: Fri Apr 11 10:43:07 2025 +0800 Remove useless InUsedStorageUnitRetriever of encrypt and mask (#35163) --- .../query/InUsedEncryptStorageUnitRetriever.java | 40 ----------------- ...xecutor.rql.resource.InUsedStorageUnitRetriever | 18 -------- .../InUsedEncryptStorageUnitRetrieverTest.java | 50 --------------------- .../query/InUsedMaskStorageUnitRetriever.java | 42 ----------------- ...xecutor.rql.resource.InUsedStorageUnitRetriever | 18 -------- .../query/InUsedMaskStorageUnitRetrieverTest.java | 52 ---------------------- 6 files changed, 220 deletions(-) diff --git a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/InUsedEncryptStorageUnitRetriever.java b/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/InUsedEncryptStorageUnitRetriever.java deleted file mode 100644 index b4cdd4c5ceb..00000000000 --- a/features/encrypt/distsql/handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/InUsedEncryptStorageUnitRetriever.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.encrypt.distsql.handler.query; - -import org.apache.shardingsphere.distsql.handler.executor.rql.resource.InUsedStorageUnitRetriever; -import org.apache.shardingsphere.distsql.statement.rql.rule.database.ShowRulesUsedStorageUnitStatement; -import org.apache.shardingsphere.encrypt.rule.EncryptRule; - -import java.util.Collection; - -/** - * In used encrypt storage unit retriever. - */ -public final class InUsedEncryptStorageUnitRetriever implements InUsedStorageUnitRetriever<EncryptRule> { - - @Override - public Collection<String> getInUsedResources(final ShowRulesUsedStorageUnitStatement sqlStatement, final EncryptRule rule) { - return rule.getAllTableNames(); - } - - @Override - public Class<EncryptRule> getType() { - return EncryptRule.class; - } -} diff --git a/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.rql.resource.InUsedStorageUnitRetriever b/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.rql.resource.InUsedStorageUnitRetriever deleted file mode 100644 index e80d6304a5a..00000000000 --- a/features/encrypt/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.rql.resource.InUsedStorageUnitRetriever +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -org.apache.shardingsphere.encrypt.distsql.handler.query.InUsedEncryptStorageUnitRetriever diff --git a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/InUsedEncryptStorageUnitRetrieverTest.java b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/InUsedEncryptStorageUnitRetrieverTest.java deleted file mode 100644 index a269bde6282..00000000000 --- a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/InUsedEncryptStorageUnitRetrieverTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.encrypt.distsql.handler.query; - -import org.apache.shardingsphere.distsql.handler.executor.rql.resource.InUsedStorageUnitRetriever; -import org.apache.shardingsphere.distsql.statement.rql.rule.database.ShowRulesUsedStorageUnitStatement; -import org.apache.shardingsphere.encrypt.rule.EncryptRule; -import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.junit.jupiter.api.Test; - -import java.util.Collections; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -class InUsedEncryptStorageUnitRetrieverTest { - - @SuppressWarnings("unchecked") - private final InUsedStorageUnitRetriever<EncryptRule> retriever = TypedSPILoader.getService(InUsedStorageUnitRetriever.class, EncryptRule.class); - - @Test - void assertGetInUsedResources() { - ShowRulesUsedStorageUnitStatement sqlStatement = new ShowRulesUsedStorageUnitStatement(null, null); - EncryptRule rule = mockRule(); - assertThat(retriever.getInUsedResources(sqlStatement, rule), is(Collections.singleton("foo_tbl"))); - } - - private EncryptRule mockRule() { - EncryptRule rule = mock(EncryptRule.class); - when(rule.getAllTableNames()).thenReturn(Collections.singleton("foo_tbl")); - return rule; - } -} diff --git a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/InUsedMaskStorageUnitRetriever.java b/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/InUsedMaskStorageUnitRetriever.java deleted file mode 100644 index 46e036a29be..00000000000 --- a/features/mask/distsql/handler/src/main/java/org/apache/shardingsphere/mask/distsql/handler/query/InUsedMaskStorageUnitRetriever.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.mask.distsql.handler.query; - -import org.apache.shardingsphere.distsql.handler.executor.rql.resource.InUsedStorageUnitRetriever; -import org.apache.shardingsphere.distsql.statement.rql.rule.database.ShowRulesUsedStorageUnitStatement; -import org.apache.shardingsphere.mask.config.rule.MaskTableRuleConfiguration; -import org.apache.shardingsphere.mask.rule.MaskRule; - -import java.util.Collection; -import java.util.stream.Collectors; - -/** - * In used mask storage unit retriever. - */ -public final class InUsedMaskStorageUnitRetriever implements InUsedStorageUnitRetriever<MaskRule> { - - @Override - public Collection<String> getInUsedResources(final ShowRulesUsedStorageUnitStatement sqlStatement, final MaskRule rule) { - return rule.getConfiguration().getTables().stream().map(MaskTableRuleConfiguration::getName).collect(Collectors.toList()); - } - - @Override - public Class<MaskRule> getType() { - return MaskRule.class; - } -} diff --git a/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.rql.resource.InUsedStorageUnitRetriever b/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.rql.resource.InUsedStorageUnitRetriever deleted file mode 100644 index ca4a1e52b5f..00000000000 --- a/features/mask/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.executor.rql.resource.InUsedStorageUnitRetriever +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -org.apache.shardingsphere.mask.distsql.handler.query.InUsedMaskStorageUnitRetriever diff --git a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/InUsedMaskStorageUnitRetrieverTest.java b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/InUsedMaskStorageUnitRetrieverTest.java deleted file mode 100644 index 4589a17ddcf..00000000000 --- a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/InUsedMaskStorageUnitRetrieverTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.mask.distsql.handler.query; - -import org.apache.shardingsphere.distsql.handler.executor.rql.resource.InUsedStorageUnitRetriever; -import org.apache.shardingsphere.distsql.statement.rql.rule.database.ShowRulesUsedStorageUnitStatement; -import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.mask.config.rule.MaskTableRuleConfiguration; -import org.apache.shardingsphere.mask.rule.MaskRule; -import org.junit.jupiter.api.Test; - -import java.util.Collections; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.RETURNS_DEEP_STUBS; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -class InUsedMaskStorageUnitRetrieverTest { - - @SuppressWarnings("unchecked") - private final InUsedStorageUnitRetriever<MaskRule> retriever = TypedSPILoader.getService(InUsedStorageUnitRetriever.class, MaskRule.class); - - @Test - void assertGetInUsedResources() { - ShowRulesUsedStorageUnitStatement sqlStatement = new ShowRulesUsedStorageUnitStatement(null, null); - MaskRule rule = mockRule(); - assertThat(retriever.getInUsedResources(sqlStatement, rule), is(Collections.singletonList("foo_tbl"))); - } - - private MaskRule mockRule() { - MaskRule result = mock(MaskRule.class, RETURNS_DEEP_STUBS); - when(result.getConfiguration().getTables()).thenReturn(Collections.singleton(new MaskTableRuleConfiguration("foo_tbl", Collections.emptyList()))); - return result; - } -}