GJL commented on a change in pull request #7883: [FLINK-11781][yarn] Remove 
"DISABLED" as possible value for yarn.per-job-cluster.include-user-jar
URL: https://github.com/apache/flink/pull/7883#discussion_r262569305
 
 

 ##########
 File path: 
flink-core/src/test/java/org/apache/flink/configuration/ConfigurationTest.java
 ##########
 @@ -403,4 +405,43 @@ public void testRemove(){
                assertEquals("Wrong expectation about size", 
cfg.keySet().size(), 0);
                assertFalse("Expected 'unexistedOption' is not removed", 
cfg.removeConfig(unexistedOption));
        }
+
+       @Test
+       public void testShouldParseValidStringToEnum() {
+               final ConfigOption<String> validOption = ConfigOptions
+                       .key("test-string-key")
+                       .noDefaultValue();
+
+               final Configuration configuration = new Configuration();
+               configuration.setString(validOption.key(), 
TestEnum.VALUE1.toString());
+
+               final TestEnum parsedEnumValue = 
configuration.getAsEnum(TestEnum.class, validOption);
+               assertEquals(TestEnum.VALUE1, parsedEnumValue);
+       }
+
+       @Test
+       public void testThrowsExceptionIfTryingToParseInvalidStringForEnum() {
+               final ConfigOption<String> validOption = ConfigOptions
+                       .key("test-string-key")
+                       .noDefaultValue();
+
+               final Configuration configuration = new Configuration();
+               final String invalidValueForTestEnum = 
"InvalidValueForTestEnum";
+               configuration.setString(validOption.key(), 
invalidValueForTestEnum);
+
+               try {
+                       configuration.getAsEnum(TestEnum.class, validOption);
+                       fail("Expected exception not thrown");
+               } catch (IllegalArgumentException e) {
+                       final String expectedMessage = "Value for config option 
" +
 
 Review comment:
   Current solution is legible, and frequently used in Flink and elsewhere. 
I'll leave it as is.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to