You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by greghogan <gi...@git.apache.org> on 2017/06/22 16:55:13 UTC

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

GitHub user greghogan opened a pull request:

    https://github.com/apache/flink/pull/4169

    [FLINK-6357] [java] ParameterTool get unrequested parameters

    Adds ParameterTool#getUnrequestedParameters returning a Set<String> of parameter arguments names not yet requested by ParameterTool#has or any of the ParameterTool#get methods.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/greghogan/flink 6357_parametertool_get_unrequested_parameters

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/4169.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #4169
    
----
commit c981ad4ffe828396d5c038465ace17637b585f8f
Author: Greg Hogan <co...@greghogan.com>
Date:   2017-06-21T12:18:55Z

    [FLINK-6357] [java] ParameterTool get unrequested parameters
    
    Adds ParameterTool#getUnrequestedParameters returning a Set<String> of
    parameter arguments names not yet requested by ParameterTool#has or any
    of the ParameterTool#get methods.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126401183
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -34,8 +36,7 @@
     
     	@Test(expected = RuntimeException.class)
     	public void testIllegalArgs() {
    -		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"berlin"});
    -		Assert.assertEquals(0, parameter.getNumberOfParameters());
    --- End diff --
    
    oh, totally overlooked that


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by greghogan <gi...@git.apache.org>.
Github user greghogan commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126318967
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -34,8 +36,7 @@
     
     	@Test(expected = RuntimeException.class)
     	public void testIllegalArgs() {
    -		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"berlin"});
    -		Assert.assertEquals(0, parameter.getNumberOfParameters());
    --- End diff --
    
    The tests are throwing exceptions when creating the `ParameterTool` so the assertions are never tested.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by greghogan <gi...@git.apache.org>.
Github user greghogan commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126374745
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedShort() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedInt() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-int", "4"});
    +		Assert.assertEquals(Sets.newHashSet("int"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedLong() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-long", "8"});
    +		Assert.assertEquals(Sets.newHashSet("long"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedFloat() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-float", "4"});
    +		Assert.assertEquals(Sets.newHashSet("float"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedDouble() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-double", "8"});
    +		Assert.assertEquals(Sets.newHashSet("double"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedString() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-string", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("string"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals("∞", parameter.get("string"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals("∞", parameter.get("string"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedHas() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.has("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.has("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedRequired() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-required", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("required"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals("∞", parameter.getRequired("required"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals("∞", parameter.getRequired("required"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedUnknown() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{});
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		Assert.assertTrue(parameter.getBoolean("boolean", true));
    +		Assert.assertEquals(0, parameter.getByte("byte", (byte) 0));
    +		Assert.assertEquals(0, parameter.getShort("short", (short) 0));
    +		Assert.assertEquals(0, parameter.getInt("int", 0));
    +		Assert.assertEquals(0, parameter.getLong("long", 0));
    +		Assert.assertEquals(0, parameter.getFloat("float", 0), 0.00001);
    +		Assert.assertEquals(0, parameter.getDouble("double", 0), 0.00001);
    +		Assert.assertEquals("0", parameter.get("string", "0"));
    +	}
    --- End diff --
    
    I've added tests with multiple existing parameters, accessors with default values, and testing after the parse exception as you have given.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by greghogan <gi...@git.apache.org>.
Github user greghogan commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126318935
  
    --- Diff: flink-java/src/main/java/org/apache/flink/api/java/utils/ParameterTool.java ---
    @@ -548,6 +565,7 @@ protected Object clone() throws CloneNotSupportedException {
     	public ParameterTool mergeWith(ParameterTool other) {
     		ParameterTool ret = new ParameterTool(this.data);
     		ret.data.putAll(other.data);
    +		ret.unrequestedParameters.addAll(other.data.keySet());
    --- End diff --
    
    This original behaviors was incorrect and I've changed this to `ret.unrequestedParameters.addAll(other.unrequestedParameters);`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126413188
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -278,6 +518,26 @@ public void testUnrequestedRequired() {
     
     		// test repeated access
     		Assert.assertEquals("∞", parameter.getRequired("required"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +	}
    +
    +	@Test
    +	public void testUnrequestedMultiple() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true", "-byte", "1",
    +			"-short", "2", "-int", "4", "-long", "8", "-float", "4.0", "-double", "8.0", "-string", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("boolean", "byte", "short", "int", "long", "float", "double", "string"),
    +			parameter.getUnrequestedParameters());
    +
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    --- End diff --
    
    can you add some `assert`s for the unrequested parameters in between the getters?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by greghogan <gi...@git.apache.org>.
Github user greghogan commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126645324
  
    --- 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 --
    
    Ah, thanks for persisting on this issue. I see now that I had checked that the following command was executed but that was the command throwing the exception. I've removed these lines are requested.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126413856
  
    --- 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 --
    
    this code is not executed anymore, isn't it? `getByte()` will throw and JUnit will check for the expected exception but the following `Assert.assertEquals()` will (unfortunately) be ignored


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125912201
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedShort() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedInt() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-int", "4"});
    +		Assert.assertEquals(Sets.newHashSet("int"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedLong() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-long", "8"});
    +		Assert.assertEquals(Sets.newHashSet("long"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedFloat() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-float", "4"});
    +		Assert.assertEquals(Sets.newHashSet("float"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedDouble() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-double", "8"});
    +		Assert.assertEquals(Sets.newHashSet("double"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedString() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-string", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("string"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals("∞", parameter.get("string"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals("∞", parameter.get("string"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedHas() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.has("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.has("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedRequired() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-required", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("required"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals("∞", parameter.getRequired("required"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals("∞", parameter.getRequired("required"));
    --- End diff --
    
    same here: add the check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125910930
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -78,18 +79,12 @@ public void testMultipleNoValMixed() {
     
     	@Test(expected = IllegalArgumentException.class)
     	public void testEmptyVal() {
    -		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"--a", "-b", "--"});
    -		Assert.assertEquals(2, parameter.getNumberOfParameters());
    -		Assert.assertTrue(parameter.has("a"));
    -		Assert.assertTrue(parameter.has("b"));
    --- End diff --
    
    why are the checks removed?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125911372
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    --- End diff --
    
    maybe add `Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());` here, too?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125914354
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedShort() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedInt() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-int", "4"});
    +		Assert.assertEquals(Sets.newHashSet("int"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedLong() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-long", "8"});
    +		Assert.assertEquals(Sets.newHashSet("long"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedFloat() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-float", "4"});
    +		Assert.assertEquals(Sets.newHashSet("float"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedDouble() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-double", "8"});
    +		Assert.assertEquals(Sets.newHashSet("double"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedString() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-string", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("string"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals("∞", parameter.get("string"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals("∞", parameter.get("string"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedHas() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.has("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.has("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedRequired() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-required", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("required"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals("∞", parameter.getRequired("required"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals("∞", parameter.getRequired("required"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedUnknown() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{});
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		Assert.assertTrue(parameter.getBoolean("boolean", true));
    +		Assert.assertEquals(0, parameter.getByte("byte", (byte) 0));
    +		Assert.assertEquals(0, parameter.getShort("short", (short) 0));
    +		Assert.assertEquals(0, parameter.getInt("int", 0));
    +		Assert.assertEquals(0, parameter.getLong("long", 0));
    +		Assert.assertEquals(0, parameter.getFloat("float", 0), 0.00001);
    +		Assert.assertEquals(0, parameter.getDouble("double", 0), 0.00001);
    +		Assert.assertEquals("0", parameter.get("string", "0"));
    +	}
    --- End diff --
    
    * how about also testing more complex scenarios with multiple (existing) parameters?
    * or adding tests that verify the non-default, i.e. `getRequired()`, versions of the accessors - independent of the `RuntimeException` being thrown, the `unrequestedParamaters` field should correctly reflect the requests
    * what happens for
    ```
    ParameterTool parameter = ParameterTool.fromArgs(new String[]{"int"});
    try {
      parameter.getInt("int");
    } catch (RuntimeException e) {
      Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125911637
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedShort() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedInt() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-int", "4"});
    +		Assert.assertEquals(Sets.newHashSet("int"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedLong() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-long", "8"});
    +		Assert.assertEquals(Sets.newHashSet("long"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    --- End diff --
    
    same here: add the check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126412849
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -187,35 +252,122 @@ public void testUnrequestedShort() {
     
     		// test repeated access
     		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +	}
    +
    +	@Test
    +	public void testUnrequestedShortWithDefaultValue() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short", (short) 0));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short", (short) 0));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
     	}
     
     	@Test
    +	public void testUnrequestedShortWithMissingValue() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		exception.expect(RuntimeException.class);
    +		exception.expectMessage("For input string: \"__NO_VALUE_KEY\"");
    +
    +		parameter.getShort("short");
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +	}
    +
    +	// Int
    +
    +	@Test
     	public void testUnrequestedInt() {
     		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-int", "4"});
     		Assert.assertEquals(Sets.newHashSet("int"), parameter.getUnrequestedParameters());
     
     		// test parameter access
    -		Assert.assertEquals(4, parameter.getByte("int"));
    +		Assert.assertEquals(4, parameter.getInt("int"));
    --- End diff --
    
    nice catch, didn't see this one before


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125911839
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedShort() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedInt() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-int", "4"});
    +		Assert.assertEquals(Sets.newHashSet("int"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedLong() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-long", "8"});
    +		Assert.assertEquals(Sets.newHashSet("long"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedFloat() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-float", "4"});
    +		Assert.assertEquals(Sets.newHashSet("float"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedDouble() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-double", "8"});
    +		Assert.assertEquals(Sets.newHashSet("double"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedString() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-string", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("string"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals("∞", parameter.get("string"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals("∞", parameter.get("string"));
    --- End diff --
    
    same here: add the check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by greghogan <gi...@git.apache.org>.
Github user greghogan commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126452583
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -278,6 +518,26 @@ public void testUnrequestedRequired() {
     
     		// test repeated access
     		Assert.assertEquals("∞", parameter.getRequired("required"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +	}
    +
    +	@Test
    +	public void testUnrequestedMultiple() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true", "-byte", "1",
    +			"-short", "2", "-int", "4", "-long", "8", "-float", "4.0", "-double", "8.0", "-string", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("boolean", "byte", "short", "int", "long", "float", "double", "string"),
    +			parameter.getUnrequestedParameters());
    +
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    --- End diff --
    
    Done.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #4169: [FLINK-6357] [java] ParameterTool get unrequested paramet...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on the issue:

    https://github.com/apache/flink/pull/4169
  
    thanks for the code and the additions
    +1 if/when the tests pass :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125911011
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -78,18 +79,12 @@ public void testMultipleNoValMixed() {
     
     	@Test(expected = IllegalArgumentException.class)
     	public void testEmptyVal() {
    -		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"--a", "-b", "--"});
    -		Assert.assertEquals(2, parameter.getNumberOfParameters());
    -		Assert.assertTrue(parameter.has("a"));
    -		Assert.assertTrue(parameter.has("b"));
    +		ParameterTool.fromArgs(new String[]{"--a", "-b", "--"});
     	}
     
     	@Test(expected = IllegalArgumentException.class)
     	public void testEmptyValShort() {
    -		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"--a", "-b", "-"});
    -		Assert.assertEquals(2, parameter.getNumberOfParameters());
    -		Assert.assertTrue(parameter.has("a"));
    -		Assert.assertTrue(parameter.has("b"));
    --- End diff --
    
    same here, please add the checks again


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125911520
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    --- End diff --
    
    same here: add the check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125910462
  
    --- Diff: flink-java/src/main/java/org/apache/flink/api/java/utils/ParameterTool.java ---
    @@ -548,6 +565,7 @@ protected Object clone() throws CloneNotSupportedException {
     	public ParameterTool mergeWith(ParameterTool other) {
     		ParameterTool ret = new ParameterTool(this.data);
     		ret.data.putAll(other.data);
    +		ret.unrequestedParameters.addAll(other.data.keySet());
    --- End diff --
    
    The docs should probably state how unrequested parameters are handles here, i.e. the returned `ParameterTool` will have have its unrequested parameters reset. An alternative idiom may be to actually keep the old `unrequestedParameters` in `ret` and merge them with `other.unrequestedParameters`. What do you thinks makes most sense?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125911852
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedShort() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedInt() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-int", "4"});
    +		Assert.assertEquals(Sets.newHashSet("int"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedLong() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-long", "8"});
    +		Assert.assertEquals(Sets.newHashSet("long"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedFloat() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-float", "4"});
    +		Assert.assertEquals(Sets.newHashSet("float"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedDouble() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-double", "8"});
    +		Assert.assertEquals(Sets.newHashSet("double"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedString() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-string", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("string"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals("∞", parameter.get("string"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals("∞", parameter.get("string"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedHas() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.has("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.has("boolean"));
    --- End diff --
    
    same here: add the check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125911613
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedShort() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedInt() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-int", "4"});
    +		Assert.assertEquals(Sets.newHashSet("int"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    --- End diff --
    
    same here: add the check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by greghogan <gi...@git.apache.org>.
Github user greghogan commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126450338
  
    --- 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 --
    
    No, the expected exception is checked and does not terminate the test.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
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`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125911549
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedShort() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    --- End diff --
    
    same here: add the check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125912602
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedShort() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedInt() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-int", "4"});
    +		Assert.assertEquals(Sets.newHashSet("int"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedLong() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-long", "8"});
    +		Assert.assertEquals(Sets.newHashSet("long"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedFloat() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-float", "4"});
    +		Assert.assertEquals(Sets.newHashSet("float"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedDouble() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-double", "8"});
    +		Assert.assertEquals(Sets.newHashSet("double"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedString() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-string", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("string"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals("∞", parameter.get("string"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals("∞", parameter.get("string"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedHas() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.has("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.has("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedRequired() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-required", "∞"});
    +		Assert.assertEquals(Sets.newHashSet("required"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals("∞", parameter.getRequired("required"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals("∞", parameter.getRequired("required"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedUnknown() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{});
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		Assert.assertTrue(parameter.getBoolean("boolean", true));
    +		Assert.assertEquals(0, parameter.getByte("byte", (byte) 0));
    +		Assert.assertEquals(0, parameter.getShort("short", (short) 0));
    +		Assert.assertEquals(0, parameter.getInt("int", 0));
    +		Assert.assertEquals(0, parameter.getLong("long", 0));
    +		Assert.assertEquals(0, parameter.getFloat("float", 0), 0.00001);
    +		Assert.assertEquals(0, parameter.getDouble("double", 0), 0.00001);
    +		Assert.assertEquals("0", parameter.get("string", "0"));
    --- End diff --
    
    add `Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());` ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/flink/pull/4169


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125910799
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -34,8 +36,7 @@
     
     	@Test(expected = RuntimeException.class)
     	public void testIllegalArgs() {
    -		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"berlin"});
    -		Assert.assertEquals(0, parameter.getNumberOfParameters());
    --- End diff --
    
    why is the check removed?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125911804
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedShort() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedInt() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-int", "4"});
    +		Assert.assertEquals(Sets.newHashSet("int"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedLong() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-long", "8"});
    +		Assert.assertEquals(Sets.newHashSet("long"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedFloat() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-float", "4"});
    +		Assert.assertEquals(Sets.newHashSet("float"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +	}
    +
    +	@Test
    +	public void testUnrequestedDouble() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-double", "8"});
    +		Assert.assertEquals(Sets.newHashSet("double"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8.0, parameter.getDouble("double"), 0.00001);
    --- End diff --
    
    same here: add the check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by greghogan <gi...@git.apache.org>.
Github user greghogan commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r126319040
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    --- End diff --
    
    Done, and in the following tests.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request #4169: [FLINK-6357] [java] ParameterTool get unrequested ...

Posted by NicoK <gi...@git.apache.org>.
Github user NicoK commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4169#discussion_r125911760
  
    --- Diff: flink-java/src/test/java/org/apache/flink/api/java/utils/ParameterToolTest.java ---
    @@ -154,4 +149,149 @@ public void testFromGenericOptionsParser() throws IOException {
     		ParameterTool parameter = ParameterTool.fromGenericOptionsParser(new String[]{"-D", "input=myInput", "-DexpectedCount=15"});
     		validate(parameter);
     	}
    +
    +	@Test
    +	public void testUnrequestedBoolean() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-boolean", "true"});
    +		Assert.assertEquals(Sets.newHashSet("boolean"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertTrue(parameter.getBoolean("boolean"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedByte() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-byte", "1"});
    +		Assert.assertEquals(Sets.newHashSet("byte"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(1, parameter.getByte("byte"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedShort() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-short", "2"});
    +		Assert.assertEquals(Sets.newHashSet("short"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(2, parameter.getShort("short"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedInt() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-int", "4"});
    +		Assert.assertEquals(Sets.newHashSet("int"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4, parameter.getByte("int"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedLong() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-long", "8"});
    +		Assert.assertEquals(Sets.newHashSet("long"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(8, parameter.getByte("long"));
    +	}
    +
    +	@Test
    +	public void testUnrequestedFloat() {
    +		ParameterTool parameter = ParameterTool.fromArgs(new String[]{"-float", "4"});
    +		Assert.assertEquals(Sets.newHashSet("float"), parameter.getUnrequestedParameters());
    +
    +		// test parameter access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    +		Assert.assertEquals(Collections.emptySet(), parameter.getUnrequestedParameters());
    +
    +		// test repeated access
    +		Assert.assertEquals(4.0, parameter.getFloat("float"), 0.00001);
    --- End diff --
    
    same here: add the check?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---