Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0ED76200CC1 for ; Mon, 10 Jul 2017 15:03:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0D4301660AE; Mon, 10 Jul 2017 13:03:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5302B1660AB for ; Mon, 10 Jul 2017 15:03:05 +0200 (CEST) Received: (qmail 86162 invoked by uid 500); 10 Jul 2017 13:03:04 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 86153 invoked by uid 99); 10 Jul 2017 13:03:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Jul 2017 13:03:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id F2E02193683 for ; Mon, 10 Jul 2017 13:03:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 5f_vJQ2go73Q for ; Mon, 10 Jul 2017 13:03:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id B746762BEF for ; Mon, 10 Jul 2017 13:03:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id A44C6E01D8 for ; Mon, 10 Jul 2017 13:03:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 603DA24695 for ; Mon, 10 Jul 2017 13:03:00 +0000 (UTC) Date: Mon, 10 Jul 2017 13:03:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLINK-6357) ParameterTool get unrequested parameters MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 10 Jul 2017 13:03:06 -0000 [ https://issues.apache.org/jira/browse/FLINK-6357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16080293#comment-16080293 ] 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_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 > 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 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)