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/05/13 17:06:43 UTC

[GitHub] [shardingsphere] terrymanu commented on a diff in pull request #17641: Upgrade to CosId 1.10.0

terrymanu commented on code in PR #17641:
URL: https://github.com/apache/shardingsphere/pull/17641#discussion_r872609268


##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-plugin/shardingsphere-sharding-cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithmTest.java:
##########
@@ -72,12 +75,14 @@ public void assertGenerateKeyWhenIdProviderIsEmpty() {
     @Test
     public void assertGenerateKeyAsString() {
         String idName = "test-cosid-as-string";
-        DefaultIdGeneratorProvider.INSTANCE.set(idName, MockIdGenerator.INSTANCE);
+        String prefix = "test_";
+        IdGenerator stringIdGen = new StringIdGenerator(new MillisecondSnowflakeId(1, 0), new PrefixIdConverter(prefix, Radix62IdConverter.INSTANCE));
+        DefaultIdGeneratorProvider.INSTANCE.set(idName, stringIdGen);
         KeyGenerateAlgorithm algorithm = KeyGenerateAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration("COSID", createAsStringProperties(idName)));
         Comparable<?> actual = algorithm.generateKey();
         assertThat(actual, instanceOf(String.class));
-        assertThat(actual.toString(), startsWith("test_"));
-        assertTrue(actual.toString().length() <= 16);
+        assertThat(actual.toString(), startsWith(prefix));
+        assertThat(actual.toString().length(), Matchers.lessThanOrEqualTo(16));

Review Comment:
   Please use static import in `Matchers.lessThanOrEqualTo`



-- 
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