geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GEODE-4035) All converters should disable the default Spring String converter
Date Fri, 01 Dec 2017 14:59:00 GMT

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

ASF GitHub Bot commented on GEODE-4035:
---------------------------------------

pdxrunner commented on a change in pull request #1110: GEODE-4035: Refactor Converter classes
URL: https://github.com/apache/geode/pull/1110#discussion_r154364534
 
 

 ##########
 File path: geode-core/src/test/java/org/apache/geode/management/internal/cli/converters/ClusterMemberIdNameConverterJUnitTest.java
 ##########
 @@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information
regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version
2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain
a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under
the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express
+ * or implied. See the License for the specific language governing permissions and limitations
under
+ * the License.
+ */
+package org.apache.geode.management.internal.cli.converters;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.stream.Collectors;
+
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.management.cli.ConverterHint;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.geode.test.junit.rules.GfshParserRule;
+import org.apache.geode.test.junit.rules.GfshParserRule.CommandCandidate;
+
+@Category(UnitTest.class)
+public class ClusterMemberIdNameConverterJUnitTest {
+  @ClassRule
+  public static GfshParserRule parser = new GfshParserRule();
+  private static ClusterMemberIdNameConverter converter;
+
+  private static String[] allMemberNames = {"server1", "server2"};
+
+  @BeforeClass
+  public static void before() {
+    // this will let the parser use the spied converter instead of creating its own
+    converter = parser.spyConverter(ClusterMemberIdNameConverter.class);
+    when(converter.getCompletionValues())
+        .thenReturn(Arrays.stream(allMemberNames).collect(Collectors.toSet()));
+  }
+
+  @Test
+  public void testSupports() throws Exception {
+    assertThat(converter.supports(String.class, ConverterHint.ALL_MEMBER_IDNAME)).isTrue();
+  }
+
+  @Test
+  public void convert() throws Exception {
+    assertThat(converter.convertFromText("server", String.class, "")).isEqualTo("server");
+  }
+
+  @Test
+  public void complete() throws Exception {
+    CommandCandidate candidate = parser.complete("describe member --name=");
+    assertThat(candidate.size()).isEqualTo(allMemberNames.length);
+    assertThat(candidate.getFirstCandidate()).isEqualTo("describe member --name=server1");
+
+    candidate = parser.complete("describe member --name=");
+    assertThat(candidate.size()).isEqualTo(2);
+    assertThat(candidate.getFirstCandidate()).isEqualTo("describe member --name=server1");
 
 Review comment:
   What coverage does this case add? Only difference between the two cases is the hard-coded
expected value.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> All converters should disable the default Spring String converter
> -----------------------------------------------------------------
>
>                 Key: GEODE-4035
>                 URL: https://issues.apache.org/jira/browse/GEODE-4035
>             Project: Geode
>          Issue Type: Bug
>          Components: gfsh
>            Reporter: Jens Deppe
>            Assignee: Jens Deppe
>
> There are various converters (see {{ConverterHint}}) that don't disable the Spring StringConverter.
This ultimately means that sometimes tab-completion will work and sometimes not, depending
which Converter is picked up first at runtime.



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

Mime
View raw message