Skip to content

Commit 5834c25

Browse files
committed
fmt
1 parent 14e908d commit 5834c25

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

core/src/main/java/com/datastax/oss/driver/api/core/data/CqlVector.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static <V> CqlVector<V> from(@NonNull String str, @NonNull TypeCodec<V> s
9696
if (str.charAt(idx++) != '[')
9797
throw new IllegalArgumentException(
9898
String.format(
99-
"Cannot parse list value from \"%s\", at character %d expecting '[' but got '%c'",
99+
"Cannot parse vector value from \"%s\", at character %d expecting '[' but got '%c'",
100100
str, idx, str.charAt(idx)));
101101

102102
idx = ParseUtils.skipSpaces(str, idx);
@@ -113,7 +113,8 @@ public static <V> CqlVector<V> from(@NonNull String str, @NonNull TypeCodec<V> s
113113
} catch (IllegalArgumentException e) {
114114
throw new IllegalArgumentException(
115115
String.format(
116-
"Cannot parse list value from \"%s\", invalid CQL value at character %d", str, idx),
116+
"Cannot parse vector value from \"%s\", invalid CQL value at character %d",
117+
str, idx),
117118
e);
118119
}
119120

@@ -125,13 +126,13 @@ public static <V> CqlVector<V> from(@NonNull String str, @NonNull TypeCodec<V> s
125126
if (str.charAt(idx++) != ',')
126127
throw new IllegalArgumentException(
127128
String.format(
128-
"Cannot parse list value from \"%s\", at character %d expecting ',' but got '%c'",
129+
"Cannot parse vector value from \"%s\", at character %d expecting ',' but got '%c'",
129130
str, idx, str.charAt(idx)));
130131

131132
idx = ParseUtils.skipSpaces(str, idx);
132133
}
133134
throw new IllegalArgumentException(
134-
String.format("Malformed list value \"%s\", missing closing ']'", str));
135+
String.format("Malformed vector value \"%s\", missing closing ']'", str));
135136
}
136137

137138
private final List<T> list;

core/src/test/java/com/datastax/oss/driver/api/core/data/CqlVectorTest.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
import com.datastax.oss.driver.api.core.type.codec.TypeCodecs;
2626
import com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry;
2727
import com.datastax.oss.driver.internal.SerializationHelper;
28-
import com.datastax.oss.driver.shaded.guava.common.collect.Iterators;
28+
import com.tngtech.java.junit.dataprovider.DataProvider;
29+
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
30+
import com.tngtech.java.junit.dataprovider.UseDataProvider;
2931
import java.io.ByteArrayInputStream;
3032
import java.io.ObjectInputStream;
3133
import java.io.ObjectStreamException;
@@ -37,10 +39,6 @@
3739
import java.util.Iterator;
3840
import java.util.List;
3941
import java.util.stream.Collectors;
40-
41-
import com.tngtech.java.junit.dataprovider.DataProvider;
42-
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
43-
import com.tngtech.java.junit.dataprovider.UseDataProvider;
4442
import org.apache.commons.codec.DecoderException;
4543
import org.apache.commons.codec.binary.Hex;
4644
import org.assertj.core.util.Lists;
@@ -54,11 +52,11 @@ public class CqlVectorTest {
5452

5553
@DataProvider
5654
public static Object[][] dataProvider() {
57-
return new Object[][]{
58-
{new Float[]{1.0f, 2.5f}},
59-
{new LocalTime[]{LocalTime.of(1, 2), LocalTime.of(3, 4)}},
60-
{new List[]{Arrays.asList(1, 2), Arrays.asList(3, 4)}},
61-
{new CqlVector[]{CqlVector.newInstance("a", "bc"), CqlVector.newInstance("d", "ef")}}
55+
return new Object[][] {
56+
{new Float[] {1.0f, 2.5f}},
57+
{new LocalTime[] {LocalTime.of(1, 2), LocalTime.of(3, 4)}},
58+
{new List[] {Arrays.asList(1, 2), Arrays.asList(3, 4)}},
59+
{new CqlVector[] {CqlVector.newInstance("a", "bc"), CqlVector.newInstance("d", "ef")}}
6260
};
6361
}
6462

@@ -143,7 +141,7 @@ public void should_build_empty_vector() {
143141

144142
@Test
145143
@UseDataProvider("dataProvider")
146-
public <T> void should_behave_mostly_like_a_list(T[] vals) {
144+
public <T> void should_behave_mostly_like_a_list(T[] vals) {
147145
CqlVector<T> vector = CqlVector.newInstance(vals);
148146
assertThat(vector.get(0)).isEqualTo(vals[0]);
149147
vector.set(0, vals[1]);

core/src/test/java/com/datastax/oss/driver/internal/core/type/codec/VectorCodecTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import com.datastax.oss.driver.api.core.data.CqlVector;
2525
import com.datastax.oss.driver.api.core.type.DataType;
2626
import com.datastax.oss.driver.api.core.type.DataTypes;
27-
import com.datastax.oss.driver.api.core.type.VectorType;
2827
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
2928
import com.datastax.oss.driver.api.core.type.codec.TypeCodecs;
3029
import com.datastax.oss.driver.api.core.type.codec.registry.CodecRegistry;
@@ -33,8 +32,6 @@
3332
import com.tngtech.java.junit.dataprovider.DataProvider;
3433
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
3534
import com.tngtech.java.junit.dataprovider.UseDataProvider;
36-
37-
import java.nio.Buffer;
3835
import java.nio.ByteBuffer;
3936
import java.time.LocalTime;
4037
import java.util.HashMap;
@@ -43,7 +40,7 @@
4340
import org.junit.runner.RunWith;
4441

4542
@RunWith(DataProviderRunner.class)
46-
public class VectorCodecTest {
43+
public class VectorCodecTest {
4744

4845
@DataProvider
4946
public static Object[][] dataProvider() {
@@ -228,15 +225,17 @@ public void should_accept_generic_type(
228225

229226
@Test
230227
@UseDataProvider("dataProvider")
231-
public void should_accept_raw_type(DataType dataType, Object[] values, String formatted, ByteBuffer bytes) {
228+
public void should_accept_raw_type(
229+
DataType dataType, Object[] values, String formatted, ByteBuffer bytes) {
232230
TypeCodec<CqlVector<Object>> codec = getCodec(dataType);
233231
assertThat(codec.accepts(CqlVector.class)).isTrue();
234232
assertThat(codec.accepts(Integer.class)).isFalse();
235233
}
236234

237235
@Test
238236
@UseDataProvider("dataProvider")
239-
public void should_accept_object(DataType dataType, Object[] values, String formatted, ByteBuffer bytes) {
237+
public void should_accept_object(
238+
DataType dataType, Object[] values, String formatted, ByteBuffer bytes) {
240239
TypeCodec<CqlVector<Object>> codec = getCodec(dataType);
241240
CqlVector<?> vector = CqlVector.newInstance(values);
242241
assertThat(codec.accepts(vector)).isTrue();
@@ -254,8 +253,9 @@ public void should_handle_null_and_empty() {
254253
assertThat(codec.parse("")).isNull();
255254
assertThat(codec.parse(null)).isNull();
256255
assertThatThrownBy(() -> codec.encode(CqlVector.newInstance(), ProtocolVersion.DEFAULT))
257-
.isInstanceOf(IllegalArgumentException.class);
256+
.isInstanceOf(IllegalArgumentException.class);
258257
}
258+
259259
private static TypeCodec<CqlVector<Object>> getCodec(DataType dataType) {
260260
return TypeCodecs.vectorOf(
261261
DataTypes.vectorOf(dataType, 2), CodecRegistry.DEFAULT.codecFor(dataType));

0 commit comments

Comments
 (0)