knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject [knox] branch master updated: KNOX-2025 - KnoxShellTable - Join Builder on Method should accept Col Names (#172)
Date Sat, 02 Nov 2019 17:34:48 GMT
This is an automated email from the ASF dual-hosted git repository.

lmccay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
     new 8bc8991  KNOX-2025 - KnoxShellTable - Join Builder on Method should accept Col Names
(#172)
8bc8991 is described below

commit 8bc8991a83fe959a815e1fcbc801e1cc5576578e
Author: Larry McCay IV <46705753+lmccay4@users.noreply.github.com>
AuthorDate: Sat Nov 2 13:34:39 2019 -0400

    KNOX-2025 - KnoxShellTable - Join Builder on Method should accept Col Names (#172)
---
 .../knox/gateway/shell/table/JoinKnoxShellTableBuilder.java    |  6 ++++++
 .../apache/knox/gateway/shell/table/KnoxShellTableTest.java    | 10 ++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/table/JoinKnoxShellTableBuilder.java
b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/table/JoinKnoxShellTableBuilder.java
index 3f070e8..68e44ac 100644
--- a/gateway-shell/src/main/java/org/apache/knox/gateway/shell/table/JoinKnoxShellTableBuilder.java
+++ b/gateway-shell/src/main/java/org/apache/knox/gateway/shell/table/JoinKnoxShellTableBuilder.java
@@ -52,6 +52,12 @@ public class JoinKnoxShellTableBuilder extends KnoxShellTableBuilder {
     return on(leftIndex, rightIndex);
   }
 
+  public KnoxShellTable on(String columnName, String columnName2) {
+      final int leftIndex = left.headers.indexOf(columnName);
+      final int rightIndex = right.headers.indexOf(columnName2);
+      return on(leftIndex, rightIndex);
+    }
+
   public KnoxShellTable on(int leftIndex, int rightIndex) {
     if (title != null) {
       this.table.title(title);
diff --git a/gateway-shell/src/test/java/org/apache/knox/gateway/shell/table/KnoxShellTableTest.java
b/gateway-shell/src/test/java/org/apache/knox/gateway/shell/table/KnoxShellTableTest.java
index 5a7b282..64fcd4d 100644
--- a/gateway-shell/src/test/java/org/apache/knox/gateway/shell/table/KnoxShellTableTest.java
+++ b/gateway-shell/src/test/java/org/apache/knox/gateway/shell/table/KnoxShellTableTest.java
@@ -278,14 +278,20 @@ public class KnoxShellTableTest {
     assertEquals(joined.cell(0, 0).value, "123");
     String json = joined.toJSON();
 
+    KnoxShellTable joined2 = KnoxShellTable.builder().join().title("Joined Table").left(table).right(table2).on("Column
A", "Column D");
+
+    assertEquals(joined2.getRows().size(), 1);
+    assertEquals(joined2.getTitle(), "Joined Table");
+    assertEquals(joined2.cell(0, 0).value, "123");
+
     KnoxShellTable zombie = KnoxShellTable.builder().json().fromJson(json);
     zombie.title("Zombie Table");
 
     assertEquals(zombie.getRows().size(), 1);
     assertEquals(zombie.getTitle(), "Zombie Table");
     assertEquals(zombie.cell(0, 0).value, "123");
-    KnoxShellTable joined2 = KnoxShellTable.builder().join().title("Joined Table 2").left(table).right(table2).on(1,
3);
-    assertEquals(1, joined2.getRows().size());
+    KnoxShellTable joined3 = KnoxShellTable.builder().join().title("Joined Table 3").left(table).right(table2).on(1,
3);
+    assertEquals(1, joined3.getRows().size());
   }
 
   @Test


Mime
View raw message