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

Remove incorrect imports of transitive dependencies #409

Merged
merged 2 commits into from
Aug 2, 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
6 changes: 3 additions & 3 deletions src/test/java/io/tarantool/driver/TarantoolUtils.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.tarantool.driver;

import io.tarantool.driver.utils.Assert;
import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.Collections;
Expand All @@ -18,7 +17,7 @@ private TarantoolUtils() {
public static boolean versionGreaterOrEqualThen(String tarantoolVersion) {
Assert.notNull(tarantoolVersion, "tarantoolVersion must not be null");
String tarantoolCiVersion = java.lang.System.getenv(TARANTOOL_VERSION);
if (StringUtils.isEmpty(tarantoolCiVersion)) {
if (tarantoolCiVersion == null || tarantoolCiVersion.isEmpty()) {
return true;
}
TarantoolVersion ciVersion = new TarantoolVersion(tarantoolCiVersion);
Expand All @@ -44,7 +43,8 @@ public static class TarantoolVersion {
private Integer minor;

public TarantoolVersion(String stringVersion) {
List<String> majorMinor = StringUtils.isEmpty(stringVersion) ? Collections.emptyList() :
List<String> majorMinor = stringVersion == null || stringVersion.isEmpty() ?
Collections.emptyList() :
Arrays.stream(stringVersion.split("\\."))
.collect(Collectors.toList());
if (majorMinor.size() >= 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.util.ClassUtil;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -364,6 +363,6 @@ public void test_AddressProviderReturnsNull_shouldThrowTarantoolClientException(

// then
TarantoolClientException exception = assertThrows(TarantoolClientException.class, client::getVersion);
assertFalse(ClassUtil.getRootCause(exception) instanceof NullPointerException);
assertFalse(Utils.getRootCause(exception) instanceof NullPointerException);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
import org.testcontainers.shaded.org.apache.commons.lang3.ArrayUtils;

import java.time.Instant;
import java.util.UUID;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;

/**
Expand Down Expand Up @@ -87,7 +85,7 @@ public void test_boxSelect_shouldReturnTupleWithInstant() throws Exception {
public void test_boxOperations_shouldWorkWithVarbinary() throws Exception {
//given
byte[] bytes = "hello".getBytes(StandardCharsets.UTF_8);
List<Byte> byteList = Arrays.asList(ArrayUtils.toObject(bytes));
List<Byte> byteList = Utils.convertBytesToByteList(bytes);
client.space("space_with_varbinary")
.insert(tupleFactory.create(1, bytes)).get();

Expand All @@ -98,7 +96,7 @@ public void test_boxOperations_shouldWorkWithVarbinary() throws Exception {

//then
byte[] bytesFromTarantool = fields.getByteArray("varbinary_field");
List<Byte> byteListFromTarantool = Arrays.asList(ArrayUtils.toObject(bytesFromTarantool));
List<Byte> byteListFromTarantool = Utils.convertBytesToByteList(bytesFromTarantool);
Assertions.assertEquals(byteList, byteListFromTarantool);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
import org.testcontainers.shaded.org.apache.commons.lang3.ArrayUtils;

import java.time.Instant;
import java.util.UUID;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;

/**
Expand Down Expand Up @@ -89,7 +87,7 @@ public void test_crudSelect_shouldReturnTupleWithInstant() throws Exception {
public void test_crudOperations_shouldWorkWithVarbinary() throws Exception {
//given
byte[] bytes = "hello".getBytes(StandardCharsets.UTF_8);
List<Byte> byteList = Arrays.asList(ArrayUtils.toObject(bytes));
List<Byte> byteList = Utils.convertBytesToByteList(bytes);
client.space("space_with_varbinary")
.insert(tupleFactory.create(1, bytes)).get();

Expand All @@ -100,15 +98,15 @@ public void test_crudOperations_shouldWorkWithVarbinary() throws Exception {

//then
byte[] bytesFromTarantool = fields.getByteArray("varbinary_field");
List<Byte> byteListFromTarantool = Arrays.asList(ArrayUtils.toObject(bytesFromTarantool));
List<Byte> byteListFromTarantool = Utils.convertBytesToByteList(bytesFromTarantool);
Assertions.assertEquals(byteList, byteListFromTarantool);
}

@Test
public void test_crudOperations_shouldWorkWithBytesAsString() throws Exception {
//given
byte[] bytes = "hello".getBytes(StandardCharsets.UTF_8);
List<Byte> byteList = Arrays.asList(ArrayUtils.toObject(bytes));
List<Byte> byteList = Utils.convertBytesToByteList(bytes);
client.space("space_with_string")
.insert(tupleFactory.create(1, bytes)).get();

Expand All @@ -119,7 +117,7 @@ public void test_crudOperations_shouldWorkWithBytesAsString() throws Exception {

//then
byte[] bytesFromTarantool = fields.getByteArray("string_field");
List<Byte> byteListFromTarantool = Arrays.asList(ArrayUtils.toObject(bytesFromTarantool));
List<Byte> byteListFromTarantool = Utils.convertBytesToByteList(bytesFromTarantool);
Assertions.assertEquals(byteList, byteListFromTarantool);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.tarantool.driver.core.TarantoolDaemonThreadFactory;
import io.tarantool.driver.exceptions.TarantoolNoSuchProcedureException;
import io.tarantool.driver.mappers.factories.DefaultMessagePackMapperFactory;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
Expand Down Expand Up @@ -369,7 +368,6 @@ private void replaceInstancesInfo(
client.space("instances_info").replace(tuple).join();
}

@NotNull
private List<TarantoolServerAddress> getShuffledTarantoolServerAddresses() {
List<TarantoolServerAddress> addresses = Arrays.asList(
new TarantoolServerAddress(container.getRouterHost(), container.getMappedPort(3301)),
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/io/tarantool/driver/integration/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand Down Expand Up @@ -103,4 +105,26 @@ private static long crc32(byte[] data) {
crc32 = Integer.reverse(crc32); // result reflect
return crc32 & 0x00000000ffffffffL; // the unsigned java problem
}

/**
* Converts a byte array to a list of bytes
*
* @param bytes byte array
*/
static List<Byte> convertBytesToByteList(byte[] bytes) {
return IntStream.range(0, bytes.length).mapToObj(i -> bytes[i]).collect(Collectors.toList());
}

/**
* Find the rootmost non-null cause of an Exception recursively
*
* @param t exception
* @return root cause of the exception or the exception itself
*/
static Throwable getRootCause(Throwable t) {
while (t.getCause() != null) {
t = t.getCause();
}
return t;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.tarantool.driver.api.TarantoolResult;
import io.tarantool.driver.api.tuple.TarantoolTuple;
import io.tarantool.driver.exceptions.TarantoolClientException;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
Expand Down Expand Up @@ -119,7 +118,6 @@ public void test_clientWithSsl_shouldWork() throws SSLException {
assertEquals("test", result.get(0));
}

@NotNull
private static SslContext getSslContext() throws SSLException {
return SslContextBuilder.forClient()
.trustManager(InsecureTrustManagerFactory.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.tarantool.driver.api.TarantoolResult;
import io.tarantool.driver.api.tuple.TarantoolTuple;
import io.tarantool.driver.exceptions.TarantoolClientException;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
Expand Down Expand Up @@ -104,7 +103,6 @@ public void test_clientWithoutCA_shouldThrowException_ifServerWithMTLS() throws
assertThrows(CompletionException.class, () -> clientWithSsl.eval("return 'test'").join());
}

@NotNull
private static SslContext getSslContextWithCA() throws Exception {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
final File keyCertChainFile = new File(classloader
Expand Down
Loading