flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-6357) ParameterTool get unrequested parameters
Date Tue, 11 Jul 2017 09:10:00 GMT

    [ https://issues.apache.org/jira/browse/FLINK-6357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16081929#comment-16081929
] 

ASF GitHub Bot commented on FLINK-6357:
---------------------------------------

Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126634784
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java
---
    @@ -174,9 +210,38 @@ public void testUnrequestedByte() {
     
     		// test repeated access
     		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +	}
    +
    +	@Test
    +	public void testUnrequestedByteWithDefaultValue() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte", (byte) 0));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte", (byte) 0));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
     	}
     
     	@Test
    +	public void testUnrequestedByteWithMissingValue() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		exception.expect(RuntimeException.class);
    +		exception.expectMessage("For input string: \"__NO_VALUE_KEY\"");
    +
    +		parameter.getByte("byte");
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    --- End diff --
    
    I just tried myself with this little example:
    ```
    	@Rule
    	public final ExpectedException exception = ExpectedException.none();
    
    	@Test
    	public void testExpectedException() {
    		exception.expect(RuntimeException.class);
    		if (true) {
    			throw new RuntimeException();
    		}
    
    		throw new NullPointerException();
    	}
    ```
    
    as expected, the `NullPointerException` is **not** thrown since the test already ends
with the `RuntimeException`


> ParameterTool get unrequested parameters
> ----------------------------------------
>
>                 Key: FLINK-6357
>                 URL: https://issues.apache.org/jira/browse/FLINK-6357
>             Project: Flink
>          Issue Type: Improvement
>          Components: Java API
>    Affects Versions: 1.3.0
>            Reporter: Greg Hogan
>            Assignee: Greg Hogan
>            Priority: Minor
>
> The Gelly examples use {{ParameterTool}} to parse required and optional parameters. In
the latter case we should detect if a user mistypes a parameter name. I would like to add
a {{Set<String> getUnrequestedParameters()}} method returning parameter names not requested
by {{has}} or any of the {{get}} methods.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message