You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by GitBox <gi...@apache.org> on 2022/09/05 08:28:08 UTC

[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #199: [IMPROVEMENT] Introduce the enumType in ConfigOptions

jerqi commented on code in PR #199:
URL: https://github.com/apache/incubator-uniffle/pull/199#discussion_r962629516


##########
common/src/test/java/org/apache/uniffle/common/config/ConfigOptionTest.java:
##########
@@ -56,6 +56,34 @@ public void testSetKVWithStringTypeDirectly() {
     assertFalse(conf.get(booleanConfig));
   }
 
+  enum TestType {
+    TYPE_1,
+    TYPE_2,
+  }
+
+  @Test
+  public void testEnumType() {
+    final ConfigOption<TestType> enumConfigOption = ConfigOptions
+        .key("rss.enum")
+        .enumType(TestType.class)
+        .defaultValue(TestType.TYPE_1)
+        .withDescription("enum test");
+
+    RssBaseConf conf = new RssBaseConf();
+
+    // case1: default value
+    assertEquals(TestType.TYPE_1, conf.get(enumConfigOption));
+
+    // case2: return the user specified value
+    conf.set(enumConfigOption, TestType.TYPE_2);
+    assertEquals(TestType.TYPE_2, conf.get(enumConfigOption));
+
+    // case3: set enum val with string
+    conf = new RssBaseConf();
+    conf.setString("rss.enum", "TYPE_2");
+    assertEquals(TestType.TYPE_2, conf.get(enumConfigOption));

Review Comment:
   Should we add a case about wrong type?



-- 
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: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org