diff --git a/lib/trino-array/pom.xml b/lib/trino-array/pom.xml
index b7ee81554aab..a95f8628dad7 100644
--- a/lib/trino-array/pom.xml
+++ b/lib/trino-array/pom.xml
@@ -38,6 +38,12 @@
test
+
+ org.assertj
+ assertj-core
+ test
+
+
org.openjdk.jmh
jmh-core
diff --git a/lib/trino-array/src/test/java/io/trino/array/TestBlockBigArray.java b/lib/trino-array/src/test/java/io/trino/array/TestBlockBigArray.java
index 8e047bfe9fad..edb9ffaac6d1 100644
--- a/lib/trino-array/src/test/java/io/trino/array/TestBlockBigArray.java
+++ b/lib/trino-array/src/test/java/io/trino/array/TestBlockBigArray.java
@@ -18,7 +18,7 @@
import org.testng.annotations.Test;
import static io.airlift.slice.SizeOf.instanceSize;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestBlockBigArray
{
@@ -47,6 +47,6 @@ public void testRetainedSizeWithOverlappingBlocks()
+ referenceCountMap.sizeOf()
+ (new ObjectBigArray<>()).sizeOf()
+ block.getRetainedSizeInBytes() + (arraySize - 1) * instanceSize(block.getClass());
- assertEquals(blockBigArray.sizeOf(), expectedSize);
+ assertThat(blockBigArray.sizeOf()).isEqualTo(expectedSize);
}
}
diff --git a/lib/trino-array/src/test/java/io/trino/array/TestBooleanBigArray.java b/lib/trino-array/src/test/java/io/trino/array/TestBooleanBigArray.java
index a9a53063de5e..6906ccfa8464 100644
--- a/lib/trino-array/src/test/java/io/trino/array/TestBooleanBigArray.java
+++ b/lib/trino-array/src/test/java/io/trino/array/TestBooleanBigArray.java
@@ -17,7 +17,7 @@
import java.util.Arrays;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestBooleanBigArray
{
@@ -38,7 +38,7 @@ private static void assertFillCapacity(BooleanBigArray array, long capacity, boo
array.fill(value);
for (int i = 0; i < capacity; i++) {
- assertEquals(array.get(i), value);
+ assertThat(array.get(i)).isEqualTo(value);
}
}
@@ -74,13 +74,13 @@ private static void assertCopyTo(BooleanBigArray source, long sourceIndex, Boole
source.copyTo(sourceIndex, destination, destinationIndex, length);
for (long i = 0; i < destinationIndex; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
for (long i = 0; i < length; i++) {
- assertEquals(source.get(sourceIndex + i), destination.get(destinationIndex + i));
+ assertThat(source.get(sourceIndex + i)).isEqualTo(destination.get(destinationIndex + i));
}
for (long i = destinationIndex + length; i < destinationCapacity; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
}
}
diff --git a/lib/trino-array/src/test/java/io/trino/array/TestByteBigArray.java b/lib/trino-array/src/test/java/io/trino/array/TestByteBigArray.java
index 1bc07302f5fe..adb2a9a2ca45 100644
--- a/lib/trino-array/src/test/java/io/trino/array/TestByteBigArray.java
+++ b/lib/trino-array/src/test/java/io/trino/array/TestByteBigArray.java
@@ -17,7 +17,7 @@
import java.util.Arrays;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestByteBigArray
{
@@ -38,7 +38,7 @@ private static void assertFillCapacity(ByteBigArray array, long capacity, byte v
array.fill(value);
for (int i = 0; i < capacity; i++) {
- assertEquals(array.get(i), value);
+ assertThat(array.get(i)).isEqualTo(value);
}
}
@@ -75,13 +75,13 @@ private static void assertCopyTo(ByteBigArray source, long sourceIndex, ByteBigA
source.copyTo(sourceIndex, destination, destinationIndex, length);
for (long i = 0; i < destinationIndex; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
for (long i = 0; i < length; i++) {
- assertEquals(source.get(sourceIndex + i), destination.get(destinationIndex + i));
+ assertThat(source.get(sourceIndex + i)).isEqualTo(destination.get(destinationIndex + i));
}
for (long i = destinationIndex + length; i < destinationCapacity; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
}
}
diff --git a/lib/trino-array/src/test/java/io/trino/array/TestDoubleBigArray.java b/lib/trino-array/src/test/java/io/trino/array/TestDoubleBigArray.java
index 733aad3cad89..65b2aab95b2e 100644
--- a/lib/trino-array/src/test/java/io/trino/array/TestDoubleBigArray.java
+++ b/lib/trino-array/src/test/java/io/trino/array/TestDoubleBigArray.java
@@ -17,7 +17,7 @@
import java.util.Arrays;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestDoubleBigArray
{
@@ -38,7 +38,7 @@ private static void assertFillCapacity(DoubleBigArray array, long capacity, doub
array.fill(value);
for (int i = 0; i < capacity; i++) {
- assertEquals(array.get(i), value);
+ assertThat(array.get(i)).isEqualTo(value);
}
}
@@ -75,13 +75,13 @@ private static void assertCopyTo(DoubleBigArray source, long sourceIndex, Double
source.copyTo(sourceIndex, destination, destinationIndex, length);
for (long i = 0; i < destinationIndex; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
for (long i = 0; i < length; i++) {
- assertEquals(source.get(sourceIndex + i), destination.get(destinationIndex + i));
+ assertThat(source.get(sourceIndex + i)).isEqualTo(destination.get(destinationIndex + i));
}
for (long i = destinationIndex + length; i < destinationCapacity; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
}
}
diff --git a/lib/trino-array/src/test/java/io/trino/array/TestIntBigArray.java b/lib/trino-array/src/test/java/io/trino/array/TestIntBigArray.java
index 96ae28e0e4d5..1880733c4f28 100644
--- a/lib/trino-array/src/test/java/io/trino/array/TestIntBigArray.java
+++ b/lib/trino-array/src/test/java/io/trino/array/TestIntBigArray.java
@@ -17,7 +17,7 @@
import java.util.Arrays;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestIntBigArray
{
@@ -38,7 +38,7 @@ private static void assertFillCapacity(IntBigArray array, long capacity, int val
array.fill(value);
for (int i = 0; i < capacity; i++) {
- assertEquals(array.get(i), value);
+ assertThat(array.get(i)).isEqualTo(value);
}
}
@@ -75,13 +75,13 @@ private static void assertCopyTo(IntBigArray source, long sourceIndex, IntBigArr
source.copyTo(sourceIndex, destination, destinationIndex, length);
for (long i = 0; i < destinationIndex; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
for (long i = 0; i < length; i++) {
- assertEquals(source.get(sourceIndex + i), destination.get(destinationIndex + i));
+ assertThat(source.get(sourceIndex + i)).isEqualTo(destination.get(destinationIndex + i));
}
for (long i = destinationIndex + length; i < destinationCapacity; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
}
}
diff --git a/lib/trino-array/src/test/java/io/trino/array/TestLongBigArray.java b/lib/trino-array/src/test/java/io/trino/array/TestLongBigArray.java
index 2404416907e0..a76c2f4f9d4f 100644
--- a/lib/trino-array/src/test/java/io/trino/array/TestLongBigArray.java
+++ b/lib/trino-array/src/test/java/io/trino/array/TestLongBigArray.java
@@ -17,7 +17,7 @@
import java.util.Arrays;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestLongBigArray
{
@@ -38,7 +38,7 @@ private static void assertFillCapacity(LongBigArray array, long capacity, long v
array.fill(value);
for (int i = 0; i < capacity; i++) {
- assertEquals(array.get(i), value);
+ assertThat(array.get(i)).isEqualTo(value);
}
}
@@ -75,13 +75,13 @@ private static void assertCopyTo(LongBigArray source, long sourceIndex, LongBigA
source.copyTo(sourceIndex, destination, destinationIndex, length);
for (long i = 0; i < destinationIndex; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
for (long i = 0; i < length; i++) {
- assertEquals(source.get(sourceIndex + i), destination.get(destinationIndex + i));
+ assertThat(source.get(sourceIndex + i)).isEqualTo(destination.get(destinationIndex + i));
}
for (long i = destinationIndex + length; i < destinationCapacity; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
}
}
diff --git a/lib/trino-array/src/test/java/io/trino/array/TestObjectBigArray.java b/lib/trino-array/src/test/java/io/trino/array/TestObjectBigArray.java
index 8f5bf4bad7dc..d659e368610a 100644
--- a/lib/trino-array/src/test/java/io/trino/array/TestObjectBigArray.java
+++ b/lib/trino-array/src/test/java/io/trino/array/TestObjectBigArray.java
@@ -17,7 +17,7 @@
import java.util.Arrays;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestObjectBigArray
{
@@ -38,7 +38,7 @@ private static void assertFillCapacity(ObjectBigArray array, long capacit
array.fill(value);
for (int i = 0; i < capacity; i++) {
- assertEquals(array.get(i), value);
+ assertThat(array.get(i)).isEqualTo(value);
}
}
@@ -75,13 +75,13 @@ private static void assertCopyTo(ObjectBigArray source, long sourceIndex
source.copyTo(sourceIndex, destination, destinationIndex, length);
for (long i = 0; i < destinationIndex; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
for (long i = 0; i < length; i++) {
- assertEquals(source.get(sourceIndex + i), destination.get(destinationIndex + i));
+ assertThat(source.get(sourceIndex + i)).isEqualTo(destination.get(destinationIndex + i));
}
for (long i = destinationIndex + length; i < destinationCapacity; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
}
}
diff --git a/lib/trino-array/src/test/java/io/trino/array/TestShortBigArray.java b/lib/trino-array/src/test/java/io/trino/array/TestShortBigArray.java
index 3d39c9b0328f..056846d14ace 100644
--- a/lib/trino-array/src/test/java/io/trino/array/TestShortBigArray.java
+++ b/lib/trino-array/src/test/java/io/trino/array/TestShortBigArray.java
@@ -17,7 +17,7 @@
import java.util.Arrays;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestShortBigArray
{
@@ -38,7 +38,7 @@ private static void assertFillCapacity(ShortBigArray array, long capacity, short
array.fill(value);
for (int i = 0; i < capacity; i++) {
- assertEquals(array.get(i), value);
+ assertThat(array.get(i)).isEqualTo(value);
}
}
@@ -75,13 +75,13 @@ private static void assertCopyTo(ShortBigArray source, long sourceIndex, ShortBi
source.copyTo(sourceIndex, destination, destinationIndex, length);
for (long i = 0; i < destinationIndex; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
for (long i = 0; i < length; i++) {
- assertEquals(source.get(sourceIndex + i), destination.get(destinationIndex + i));
+ assertThat(source.get(sourceIndex + i)).isEqualTo(destination.get(destinationIndex + i));
}
for (long i = destinationIndex + length; i < destinationCapacity; i++) {
- assertEquals(destination.get(i), destinationFillValue);
+ assertThat(destination.get(i)).isEqualTo(destinationFillValue);
}
}
}
diff --git a/lib/trino-array/src/test/java/io/trino/array/TestSliceBigArray.java b/lib/trino-array/src/test/java/io/trino/array/TestSliceBigArray.java
index 46f4a0afa33c..250d33e89c8f 100644
--- a/lib/trino-array/src/test/java/io/trino/array/TestSliceBigArray.java
+++ b/lib/trino-array/src/test/java/io/trino/array/TestSliceBigArray.java
@@ -19,7 +19,7 @@
import static io.airlift.slice.SizeOf.instanceSize;
import static io.airlift.slice.SizeOf.sizeOf;
import static io.airlift.slice.Slices.wrappedBuffer;
-import static org.testng.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
@Test
public class TestSliceBigArray
@@ -40,13 +40,13 @@ public void testSameSliceRetainedSize()
Slice slice = wrappedBuffer(secondBytes, 201, 1501);
for (int i = 0; i < CAPACITY; i++) {
sliceBigArray.set(i, slice);
- assertEquals(sliceBigArray.sizeOf(), BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE);
+ assertThat(sliceBigArray.sizeOf()).isEqualTo(BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE);
}
// adding a new slice will increase the size
slice = wrappedBuffer(secondBytes, 201, 1501);
sliceBigArray.set(3, slice);
- assertEquals(sliceBigArray.sizeOf(), BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 2);
+ assertThat(sliceBigArray.sizeOf()).isEqualTo(BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 2);
}
@Test
@@ -57,19 +57,19 @@ public void testNullSlicesRetainedSize()
// add null values
sliceBigArray.set(0, null);
- assertEquals(sliceBigArray.sizeOf(), BIG_ARRAY_INSTANCE_SIZE);
+ assertThat(sliceBigArray.sizeOf()).isEqualTo(BIG_ARRAY_INSTANCE_SIZE);
// replace null with a slice
sliceBigArray.set(0, wrappedBuffer(secondBytes, 201, 1501));
- assertEquals(sliceBigArray.sizeOf(), BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE);
+ assertThat(sliceBigArray.sizeOf()).isEqualTo(BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE);
// add another slice
sliceBigArray.set(1, wrappedBuffer(secondBytes, 201, 1501));
- assertEquals(sliceBigArray.sizeOf(), BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 2);
+ assertThat(sliceBigArray.sizeOf()).isEqualTo(BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 2);
// replace slice with null
sliceBigArray.set(1, null);
- assertEquals(sliceBigArray.sizeOf(), BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE);
+ assertThat(sliceBigArray.sizeOf()).isEqualTo(BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE);
}
@Test
@@ -81,21 +81,21 @@ public void testRetainedSize()
// add two elements
sliceBigArray.set(0, wrappedBuffer(firstBytes, 0, 100));
sliceBigArray.set(1, wrappedBuffer(secondBytes, 0, 100));
- assertEquals(sliceBigArray.sizeOf(), BIG_ARRAY_INSTANCE_SIZE + sizeOf(firstBytes) + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 2);
+ assertThat(sliceBigArray.sizeOf()).isEqualTo(BIG_ARRAY_INSTANCE_SIZE + sizeOf(firstBytes) + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 2);
// add two more
sliceBigArray.set(2, wrappedBuffer(firstBytes, 100, 200));
sliceBigArray.set(3, wrappedBuffer(secondBytes, 20, 150));
- assertEquals(sliceBigArray.sizeOf(), BIG_ARRAY_INSTANCE_SIZE + sizeOf(firstBytes) + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 4);
+ assertThat(sliceBigArray.sizeOf()).isEqualTo(BIG_ARRAY_INSTANCE_SIZE + sizeOf(firstBytes) + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 4);
// replace with different slices but the same base
sliceBigArray.set(2, wrappedBuffer(firstBytes, 11, 1200));
sliceBigArray.set(3, wrappedBuffer(secondBytes, 201, 1501));
- assertEquals(sliceBigArray.sizeOf(), BIG_ARRAY_INSTANCE_SIZE + sizeOf(firstBytes) + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 4);
+ assertThat(sliceBigArray.sizeOf()).isEqualTo(BIG_ARRAY_INSTANCE_SIZE + sizeOf(firstBytes) + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 4);
// replace with a different slice with a different base
sliceBigArray.set(0, wrappedBuffer(secondBytes, 11, 1200));
sliceBigArray.set(2, wrappedBuffer(secondBytes, 201, 1501));
- assertEquals(sliceBigArray.sizeOf(), BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 4);
+ assertThat(sliceBigArray.sizeOf()).isEqualTo(BIG_ARRAY_INSTANCE_SIZE + sizeOf(secondBytes) + SLICE_INSTANCE_SIZE * 4);
}
}
diff --git a/plugin/trino-teradata-functions/src/test/java/io/trino/plugin/teradata/functions/dateformat/TestDateFormatParser.java b/plugin/trino-teradata-functions/src/test/java/io/trino/plugin/teradata/functions/dateformat/TestDateFormatParser.java
index 6cd117553a73..576d58e8a792 100644
--- a/plugin/trino-teradata-functions/src/test/java/io/trino/plugin/teradata/functions/dateformat/TestDateFormatParser.java
+++ b/plugin/trino-teradata-functions/src/test/java/io/trino/plugin/teradata/functions/dateformat/TestDateFormatParser.java
@@ -22,6 +22,7 @@
import java.util.stream.Collectors;
import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.testng.Assert.assertEquals;
public class TestDateFormatParser
@@ -50,16 +51,18 @@ public void testInvalidTokenTokenize()
asList(DateFormat.UNRECOGNIZED, DateFormat.UNRECOGNIZED, DateFormat.UNRECOGNIZED));
}
- @Test(expectedExceptions = TrinoException.class)
+ @Test
public void testInvalidTokenCreate1()
{
- DateFormatParser.createDateTimeFormatter("ala");
+ assertThatThrownBy(() -> DateFormatParser.createDateTimeFormatter("ala"))
+ .isInstanceOf(TrinoException.class);
}
- @Test(expectedExceptions = TrinoException.class)
+ @Test
public void testInvalidTokenCreate2()
{
- DateFormatParser.createDateTimeFormatter("yyym/mm/dd");
+ assertThatThrownBy(() -> DateFormatParser.createDateTimeFormatter("yyym/mm/dd"))
+ .isInstanceOf(TrinoException.class);
}
@Test