Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spotless] Applying Google Code Format for integ-tests #9 #1966

Merged
merged 12 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions integ-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ repositories {
}
}

// Being ignored as a temporary measure before being removed in favour of
// spotless https://github.com/opensearch-project/sql/issues/1101
checkstyleTest.ignoreFailures = true
checkstyleMain.ignoreFailures = true

ext {
projectSubstitutions = [:]
licenseFile = rootProject.file('LICENSE.TXT')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.bwc;


import static org.opensearch.sql.legacy.TestUtils.createIndexByRestClient;
import static org.opensearch.sql.legacy.TestUtils.isIndexExist;
import static org.opensearch.sql.legacy.TestUtils.loadDataByRestClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.correctness.runner.connection;

import java.io.IOException;
Expand All @@ -16,18 +15,15 @@
import org.opensearch.sql.correctness.runner.resultset.DBResult;

/**
* OpenSearch database connection for insertion. This class wraps JDBCConnection to delegate query method.
* OpenSearch database connection for insertion. This class wraps JDBCConnection to delegate query
* method.
*/
public class OpenSearchConnection implements DBConnection {

/**
* Connection via our OpenSearch JDBC driver
*/
/** Connection via our OpenSearch JDBC driver */
private final DBConnection connection;

/**
* Native OpenSearch REST client for operation unsupported by driver such as CREATE/INSERT
*/
/** Native OpenSearch REST client for operation unsupported by driver such as CREATE/INSERT */
private final RestClient client;

public OpenSearchConnection(String connectionUrl, RestClient client) {
Expand Down Expand Up @@ -112,10 +108,8 @@ private String buildBulkBody(String[] columnNames, List<Object[]> batch) {
}
}

body.append("{\"index\":{}}\n").
append(json).append("\n");
body.append("{\"index\":{}}\n").append(json).append("\n");
}
return body.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.correctness.runner.resultset;

import java.math.BigDecimal;
Expand All @@ -15,9 +14,7 @@
import lombok.Getter;
import lombok.ToString;

/**
* Row in result set.
*/
/** Row in result set. */
@EqualsAndHashCode
@ToString
@Getter
Expand Down Expand Up @@ -77,5 +74,4 @@ public int compareTo(Row other) {
}
return 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.correctness.tests;

import static org.junit.Assert.assertEquals;
Expand All @@ -30,14 +29,11 @@
import org.opensearch.client.RestClient;
import org.opensearch.sql.correctness.runner.connection.OpenSearchConnection;

/**
* Tests for {@link OpenSearchConnection}
*/
/** Tests for {@link OpenSearchConnection} */
@RunWith(MockitoJUnitRunner.class)
public class OpenSearchConnectionTest {

@Mock
private RestClient client;
@Mock private RestClient client;

private OpenSearchConnection conn;

Expand All @@ -63,36 +59,30 @@ public void testCreateTable() throws IOException {

@Test
public void testInsertData() throws IOException {
conn.insert("test", new String[] {"name"},
Arrays.asList(new String[] {"John"}, new String[] {"Hank"}));
conn.insert(
"test", new String[] {"name"}, Arrays.asList(new String[] {"John"}, new String[] {"Hank"}));

Request actual = captureActualArg();
assertEquals("POST", actual.getMethod());
assertEquals("/test/_bulk?refresh=true", actual.getEndpoint());
assertEquals(
"{\"index\":{}}\n"
+ "{\"name\":\"John\"}\n"
+ "{\"index\":{}}\n"
+ "{\"name\":\"Hank\"}\n",
getBody(actual)
);
"{\"index\":{}}\n{\"name\":\"John\"}\n{\"index\":{}}\n{\"name\":\"Hank\"}\n",
getBody(actual));
}

@Test
public void testInsertNullData() throws IOException {
conn.insert("test", new String[] {"name", "age"},
conn.insert(
"test",
new String[] {"name", "age"},
Arrays.asList(new Object[] {null, 30}, new Object[] {"Hank", null}));

Request actual = captureActualArg();
assertEquals("POST", actual.getMethod());
assertEquals("/test/_bulk?refresh=true", actual.getEndpoint());
assertEquals(
"{\"index\":{}}\n"
+ "{\"age\":30}\n"
+ "{\"index\":{}}\n"
+ "{\"name\":\"Hank\"}\n",
getBody(actual)
);
"{\"index\":{}}\n{\"age\":30}\n{\"index\":{}}\n{\"name\":\"Hank\"}\n",
getBody(actual));
}

@Test
Expand All @@ -114,5 +104,4 @@ private String getBody(Request request) throws IOException {
InputStream inputStream = request.getEntity().getContent();
return CharStreams.toString(new InputStreamReader(inputStream));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.correctness.tests;

import static org.junit.Assert.assertEquals;
Expand All @@ -12,9 +11,7 @@
import org.junit.Test;
import org.opensearch.sql.correctness.runner.resultset.Row;

/**
* Unit test {@link Row}
*/
/** Unit test {@link Row} */
public class RowTest {

@Test
Expand Down Expand Up @@ -47,5 +44,4 @@ public void shouldConsiderNullGreater() {
row2.add("world");
assertEquals(1, row1.compareTo(row2));
}

}
Loading