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

 ##########
 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:
   nit: Personally prefer the approach with `@Rule`
   
   ```
        @Rule
        public ExpectedException thrown = ExpectedException.none();
   
       @Test
        public testMethod() {
          ...
          thrown.expect(IllegalArgumentException.class);
          thrown.message(....);
         }
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to