You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/07/23 12:44:03 UTC
[GitHub] [shardingsphere] lushaorong opened a new pull request, #19491: Add more unit test for ClassBasedShardingAlgorithmFactory
lushaorong opened a new pull request, #19491:
URL: https://github.com/apache/shardingsphere/pull/19491
Fixes #16284.
Changes proposed in this pull request:
- Add more unit test for ClassBasedShardingAlgorithmFactory
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu commented on a diff in pull request #19491: Add more unit test for ClassBasedShardingAlgorithmFactory
Posted by GitBox <gi...@apache.org>.
terrymanu commented on code in PR #19491:
URL: https://github.com/apache/shardingsphere/pull/19491#discussion_r928138517
##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactoryTest.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.sharding.algorithm.sharding.classbased;
+
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+import org.apache.shardingsphere.sharding.fixture.ClassBasedHintShardingAlgorithmFixture;
+import org.apache.shardingsphere.sharding.fixture.ClassBasedStandardShardingAlgorithmFixture;
+import org.junit.Test;
+
+import java.util.Properties;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+public final class ClassBasedShardingAlgorithmFactoryTest {
+
+ @SuppressWarnings("rawtypes")
+ @Test(expected = ShardingSphereException.class)
+ public void assertNewInstanceWithUnAssignableFrom() {
+ StandardShardingAlgorithm algorithm =
+ ClassBasedShardingAlgorithmFactory.newInstance(ClassBasedHintShardingAlgorithmFixture.class.getName(), StandardShardingAlgorithm.class, new Properties());
+ assertThat(algorithm, instanceOf(ClassBasedStandardShardingAlgorithmFixture.class));
Review Comment:
assertThat is unnecessary if expected exception
##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactoryTest.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.sharding.algorithm.sharding.classbased;
+
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+import org.apache.shardingsphere.sharding.fixture.ClassBasedHintShardingAlgorithmFixture;
+import org.apache.shardingsphere.sharding.fixture.ClassBasedStandardShardingAlgorithmFixture;
+import org.junit.Test;
+
+import java.util.Properties;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+public final class ClassBasedShardingAlgorithmFactoryTest {
+
+ @SuppressWarnings("rawtypes")
+ @Test(expected = ShardingSphereException.class)
+ public void assertNewInstanceWithUnAssignableFrom() {
+ StandardShardingAlgorithm algorithm =
+ ClassBasedShardingAlgorithmFactory.newInstance(ClassBasedHintShardingAlgorithmFixture.class.getName(), StandardShardingAlgorithm.class, new Properties());
+ assertThat(algorithm, instanceOf(ClassBasedStandardShardingAlgorithmFixture.class));
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void assertNewInstance() {
+ StandardShardingAlgorithm algorithm =
+ ClassBasedShardingAlgorithmFactory.newInstance(ClassBasedStandardShardingAlgorithmFixture.class.getName(), StandardShardingAlgorithm.class, new Properties());
+ assertThat(algorithm, instanceOf(ClassBasedStandardShardingAlgorithmFixture.class));
+ }
+
Review Comment:
Please remove useless blank line
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu merged pull request #19491: Add more unit test for ClassBasedShardingAlgorithmFactory
Posted by GitBox <gi...@apache.org>.
terrymanu merged PR #19491:
URL: https://github.com/apache/shardingsphere/pull/19491
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] codecov-commenter commented on pull request #19491: Add more unit test for ClassBasedShardingAlgorithmFactory
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #19491:
URL: https://github.com/apache/shardingsphere/pull/19491#issuecomment-1193125293
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/19491?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#19491](https://codecov.io/gh/apache/shardingsphere/pull/19491?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b99e010) into [master](https://codecov.io/gh/apache/shardingsphere/commit/5de38e4cf324b91e0db931312a050b5314e74ad4?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5de38e4) will **not change** coverage.
> The diff coverage is `n/a`.
```diff
@@ Coverage Diff @@
## master #19491 +/- ##
=========================================
Coverage 60.07% 60.07%
Complexity 2385 2385
=========================================
Files 3823 3823
Lines 54433 54433
Branches 7610 7610
=========================================
Hits 32701 32701
Misses 18928 18928
Partials 2804 2804
```
Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org