Skip to content

Commit

Permalink
Cleanup previous changes.
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
  • Loading branch information
currantw committed Dec 9, 2024
1 parent 54c7346 commit 0ca7f2b
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@

package org.opensearch.sql.correctness.tests;

import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -83,7 +81,7 @@ public void testFailureDueToInconsistency() {
TestReport expected = new TestReport();
expected.addTestCase(
new FailedTestCase(
1, "SELECT * FROM accounts", asList(openSearchResult, otherDbResult), ""));
1, "SELECT * FROM accounts", List.of(openSearchResult, otherDbResult), ""));
TestReport actual = correctnessTest.verify(querySet("SELECT * FROM accounts"));
assertEquals(expected, actual);
}
Expand Down Expand Up @@ -147,7 +145,7 @@ public void testFailureDueToEventualInconsistency() {
new FailedTestCase(
1,
"SELECT * FROM accounts",
asList(openSearchResult, otherDbResult, anotherDbResult),
List.of(openSearchResult, otherDbResult, anotherDbResult),
""));
TestReport actual = correctnessTest.verify(querySet("SELECT * FROM accounts"));
assertEquals(expected, actual);
Expand Down Expand Up @@ -226,8 +224,7 @@ public void testFailureDueToInconsistencyAndExceptionMixed() {
"OpenSearch",
List.of(new Type("firstname", "text")),
List.of(new Row(List.of("John"))));
DBResult otherResult =
new DBResult("Other", List.of(new Type("firstname", "text")), Collections.emptyList());
DBResult otherResult = new DBResult("Other", List.of(new Type("firstname", "text")), List.of());

when(openSearchConnection.select(anyString())).thenReturn(openSearchResult);
when(otherDbConnection.select(anyString())).thenReturn(otherResult);
Expand All @@ -239,7 +236,7 @@ public void testFailureDueToInconsistencyAndExceptionMixed() {
new FailedTestCase(
1,
"SELECT * FROM accounts",
asList(openSearchResult, otherResult),
List.of(openSearchResult, otherResult),
"Unsupported feature;"));
TestReport actual = correctnessTest.verify(querySet("SELECT * FROM accounts"));
assertEquals(expected, actual);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.opensearch.sql.correctness.runner.resultset.DBResult;
Expand Down Expand Up @@ -76,12 +75,10 @@ public void dbResultWithDifferentColumnTypeShouldNotEqual() {
public void shouldExplainColumnTypeDifference() {
DBResult result1 =
new DBResult(
"DB 1",
Arrays.asList(new Type("name", "VARCHAR"), new Type("age", "FLOAT")),
List.of());
"DB 1", List.of(new Type("name", "VARCHAR"), new Type("age", "FLOAT")), List.of());
DBResult result2 =
new DBResult(
"DB 2", Arrays.asList(new Type("name", "VARCHAR"), new Type("age", "INT")), List.of());
"DB 2", List.of(new Type("name", "VARCHAR"), new Type("age", "INT")), List.of());

assertEquals(
"Schema type at [1] is different: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package org.opensearch.sql.correctness.tests;

import static java.util.Arrays.asList;
import static java.util.Collections.singleton;
import static org.junit.Assert.fail;

import java.util.List;
Expand Down Expand Up @@ -57,15 +55,15 @@ public void testFailedReport() {
new FailedTestCase(
1,
"SELECT * FROM accounts",
asList(
List.of(
new DBResult(
"OpenSearch",
singleton(new Type("firstName", "text")),
singleton(new Row(List.of("hello")))),
List.of(new Type("firstName", "text")),
List.of(new Row(List.of("hello")))),
new DBResult(
"H2",
singleton(new Type("firstName", "text")),
singleton(new Row(List.of("world"))))),
List.of(new Type("firstName", "text")),
List.of(new Row(List.of("world"))))),
"[SQLITE_ERROR] SQL error or missing database;"));
JSONObject actual = new JSONObject(report);
JSONObject expected =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.hamcrest.Matcher;
Expand Down Expand Up @@ -70,7 +69,7 @@ public void buildDataRowsFromBindingTupleIncludeDateShouldPass() {
Arrays.asList(
ColumnNode.builder().alias("dateValue").type(Schema.Type.DATE).build(),
ColumnNode.builder().alias("gender").type(Schema.Type.TEXT).build()),
Collections.singletonList(
List.of(
BindingTuple.from(ImmutableMap.of("dateValue", 1529712000000L, "gender", "m")))),
containsInAnyOrder(
rowContents(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.opensearch.sql.data.model.ExprTupleValue;
Expand All @@ -38,7 +37,7 @@ void formatResponse() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("name", "John", "age", 20)),
tupleValue(ImmutableMap.of("name", "Smith", "age", 30))));
CsvResponseFormatter formatter = new CsvResponseFormatter();
Expand Down Expand Up @@ -81,7 +80,7 @@ void sanitizeData() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("city", "Seattle")),
tupleValue(ImmutableMap.of("city", "=Seattle")),
tupleValue(ImmutableMap.of("city", "+Seattle")),
Expand Down Expand Up @@ -109,7 +108,7 @@ void quoteIfRequired() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("na,me", "John,Smith", ",,age", "30,,,")),
tupleValue(ImmutableMap.of("na,me", "\"Janice Jones", ",,age", "26\""))));
String expected =
Expand All @@ -134,7 +133,7 @@ void escapeSanitize() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("city", "=Seattle")),
tupleValue(ImmutableMap.of("city", ",,Seattle"))));
String expected = "city%n=Seattle%n\",,Seattle\"";
Expand All @@ -151,7 +150,7 @@ void replaceNullValues() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("name", "John", "city", "Seattle")),
ExprTupleValue.fromExprValueMap(
ImmutableMap.of("firstname", LITERAL_NULL, "city", stringValue("Seattle"))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.opensearch.sql.data.model.ExprTupleValue;
Expand All @@ -37,7 +36,7 @@ void formatResponse() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("name", "John", "age", 20)),
tupleValue(ImmutableMap.of("name", "Smith", "age", 30))));
String expected = "name|age%n" + "John|20%n" + "Smith|30";
Expand Down Expand Up @@ -84,7 +83,7 @@ void sanitizeData() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("city", "Seattle")),
tupleValue(ImmutableMap.of("city", "=Seattle")),
tupleValue(ImmutableMap.of("city", "+Seattle")),
Expand Down Expand Up @@ -121,7 +120,7 @@ void quoteIfRequired() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("na|me", "John|Smith", "||age", "30|||")),
tupleValue(ImmutableMap.of("na|me", "Ja\"ne J\"ones", "||age", "\"40\""))));
String expected =
Expand Down Expand Up @@ -153,7 +152,7 @@ void escapeSanitize() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("city", "=Seattle")),
tupleValue(ImmutableMap.of("city", "||Seattle"))));
String expected = "city%n" + "=Seattle%n" + "\"||Seattle\"";
Expand All @@ -170,7 +169,7 @@ void senstiveCharater() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("city", "@Seattle")),
tupleValue(ImmutableMap.of("city", "++Seattle"))));
String expected = "city%n" + "@Seattle%n" + "++Seattle";
Expand All @@ -187,7 +186,7 @@ void senstiveCharaterWithSanitize() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("city", "@Seattle")),
tupleValue(ImmutableMap.of("city", "++Seattle|||"))));
String expected = "city%n" + "@Seattle%n" + "\"++Seattle|||\"";
Expand All @@ -206,7 +205,7 @@ void replaceNullValues() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("name", "John", "city", "Seattle")),
ExprTupleValue.fromExprValueMap(
ImmutableMap.of("firstname", LITERAL_NULL, "city", stringValue("Seattle"))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.opensearch.sql.data.model.ExprTupleValue;
Expand All @@ -36,7 +35,7 @@ void formatResponse() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("firstname", "John", "age", 20)),
tupleValue(ImmutableMap.of("firstname", "Smith", "age", 30))));
SimpleJsonResponseFormatter formatter = new SimpleJsonResponseFormatter(COMPACT);
Expand All @@ -52,7 +51,7 @@ void formatResponsePretty() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
tupleValue(ImmutableMap.of("firstname", "John", "age", 20)),
tupleValue(ImmutableMap.of("firstname", "Smith", "age", 30))));
SimpleJsonResponseFormatter formatter = new SimpleJsonResponseFormatter(PRETTY);
Expand Down Expand Up @@ -104,7 +103,7 @@ void formatResponseWithMissingValue() {
QueryResult response =
new QueryResult(
schema,
Arrays.asList(
List.of(
ExprTupleValue.fromExprValueMap(
ImmutableMap.of("firstname", stringValue("John"), "age", LITERAL_MISSING)),
tupleValue(ImmutableMap.of("firstname", "Smith", "age", 30))));
Expand Down Expand Up @@ -150,7 +149,7 @@ void formatResponseWithArrayValue() {
"name",
"Smith",
"address",
Arrays.asList(
List.of(
ImmutableMap.of("state", "WA"), ImmutableMap.of("state", "NYC"))))));
SimpleJsonResponseFormatter formatter = new SimpleJsonResponseFormatter(COMPACT);
assertEquals(
Expand Down
Loading

0 comments on commit 0ca7f2b

Please sign in to comment.