From 8acc03a58799b818ae7a60bee7fd4d9bdefba570 Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Thu, 17 Aug 2023 10:41:05 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Guian Gumpac Signed-off-by: Mitchell Gale --- .../format/CommandResponseFormatterTest.java | 2 +- .../response/format/CsvResponseFormatterTest.java | 8 ++++---- .../response/format/RawResponseFormatterTest.java | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CommandResponseFormatterTest.java b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CommandResponseFormatterTest.java index 4b20f6b1dc..8e86e47754 100644 --- a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CommandResponseFormatterTest.java +++ b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CommandResponseFormatterTest.java @@ -49,7 +49,7 @@ public void produces_always_same_output_for_any_query_response() { .build())), new Cursor("test_cursor")); - assertEquals("{\n" + " \"succeeded\": true\n" + "}", formatter.format(response)); + assertEquals("{\n \"succeeded\": true\n}", formatter.format(response)); } @Test diff --git a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CsvResponseFormatterTest.java b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CsvResponseFormatterTest.java index 13670dc7d6..d27ac72373 100644 --- a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CsvResponseFormatterTest.java +++ b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CsvResponseFormatterTest.java @@ -68,7 +68,7 @@ void sanitizeHeaders() { "Seattle", "@age", 20)))); - String expected = "'=firstname,'+lastname,'-city,'@age%n" + "John,Smith,Seattle,20"; + String expected = "'=firstname,'+lastname,'-city,'@age%nJohn,Smith,Seattle,20"; assertEquals(format(expected), formatter.format(response)); } @@ -109,7 +109,7 @@ void quoteIfRequired() { new QueryResult( schema, Arrays.asList(tupleValue(ImmutableMap.of("na,me", "John,Smith", ",,age", "30,,,")))); - String expected = "\"na,me\",\",,age\"%n" + "\"John,Smith\",\"30,,,\""; + String expected = "\"na,me\",\",,age\"%n\"John,Smith\",\"30,,,\""; assertEquals(format(expected), formatter.format(response)); } @@ -133,7 +133,7 @@ void escapeSanitize() { Arrays.asList( tupleValue(ImmutableMap.of("city", "=Seattle")), tupleValue(ImmutableMap.of("city", ",,Seattle")))); - String expected = "city%n" + "=Seattle%n" + "\",,Seattle\""; + String expected = "city%n=Seattle%n\",,Seattle\""; assertEquals(format(expected), escapeFormatter.format(response)); } @@ -153,7 +153,7 @@ void replaceNullValues() { ImmutableMap.of("firstname", LITERAL_NULL, "city", stringValue("Seattle"))), ExprTupleValue.fromExprValueMap( ImmutableMap.of("firstname", stringValue("John"), "city", LITERAL_MISSING)))); - String expected = "name,city%n" + "John,Seattle%n" + ",Seattle%n" + "John,"; + String expected = "name,city%nJohn,Seattle%n,Seattle%nJohn,"; assertEquals(format(expected), formatter.format(response)); } diff --git a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/RawResponseFormatterTest.java b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/RawResponseFormatterTest.java index af0ab1947b..65111bd3b9 100644 --- a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/RawResponseFormatterTest.java +++ b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/RawResponseFormatterTest.java @@ -67,7 +67,7 @@ void sanitizeHeaders() { "Seattle", "@age", 20)))); - String expected = "=firstname|+lastname|-city|@age%n" + "John|Smith|Seattle|20"; + String expected = "=firstname|+lastname|-city|@age%nJohn|Smith|Seattle|20"; assertEquals(format(expected), rawFormatter.format(response)); } @@ -108,7 +108,7 @@ void quoteIfRequired() { new QueryResult( schema, Arrays.asList(tupleValue(ImmutableMap.of("na|me", "John|Smith", "||age", "30|||")))); - String expected = "\"na|me\"|\"||age\"%n" + "\"John|Smith\"|\"30|||\""; + String expected = "\"na|me\"|\"||age\"%n\"John|Smith\"|\"30|||\""; assertEquals(format(expected), rawFormatter.format(response)); } @@ -132,7 +132,7 @@ void escapeSanitize() { Arrays.asList( tupleValue(ImmutableMap.of("city", "=Seattle")), tupleValue(ImmutableMap.of("city", "||Seattle")))); - String expected = "city%n" + "=Seattle%n" + "\"||Seattle\""; + String expected = "city%n=Seattle%n\"||Seattle\""; assertEquals(format(expected), escapeFormatter.format(response)); } @@ -147,7 +147,7 @@ void senstiveCharater() { Arrays.asList( tupleValue(ImmutableMap.of("city", "@Seattle")), tupleValue(ImmutableMap.of("city", "++Seattle")))); - String expected = "city%n" + "@Seattle%n" + "++Seattle"; + String expected = "city%n@Seattle%n++Seattle"; assertEquals(format(expected), rawFormatter.format(response)); } @@ -163,7 +163,7 @@ void senstiveCharaterWithSanitize() { Arrays.asList( tupleValue(ImmutableMap.of("city", "@Seattle")), tupleValue(ImmutableMap.of("city", "++Seattle|||")))); - String expected = "city%n" + "@Seattle%n" + "\"++Seattle|||\""; + String expected = "city%n@Seattle%n\"++Seattle|||\""; assertEquals(format(expected), testFormater.format(response)); } @@ -183,7 +183,7 @@ void replaceNullValues() { ImmutableMap.of("firstname", LITERAL_NULL, "city", stringValue("Seattle"))), ExprTupleValue.fromExprValueMap( ImmutableMap.of("firstname", stringValue("John"), "city", LITERAL_MISSING)))); - String expected = "name|city%n" + "John|Seattle%n" + "|Seattle%n" + "John|"; + String expected = "name|city%nJohn|Seattle%n|Seattle%nJohn|"; assertEquals(format(expected), rawFormatter.format(response)); }