Skip to content
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
2 changes: 1 addition & 1 deletion lib/src/main/java/io/cloudquery/scalar/Binary.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ public boolean equals(Object other) {
return false;
}

return (this.valid && o.valid) && Arrays.equals(this.value, o.value);
return (this.valid == o.valid) && Arrays.equals(this.value, o.value);
}
}
18 changes: 17 additions & 1 deletion lib/src/main/java/io/cloudquery/scalar/LargeBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,33 @@

import org.apache.arrow.vector.types.pojo.ArrowType;

import java.util.Arrays;

public class LargeBinary extends Binary {

public LargeBinary() {
super();
}

public LargeBinary(Object value) throws ValidationException {
this.set(value);
super(value);
}

@Override
public ArrowType dataType() {
return ArrowType.LargeBinary.INSTANCE;
}

@Override
public boolean equals(Object other) {
if (other == null) {
return false;
}

if (!(other instanceof LargeBinary o)) {
return false;
}

return (this.valid == o.valid) && Arrays.equals(this.value, o.value);
}
}
3 changes: 1 addition & 2 deletions lib/src/test/java/io/cloudquery/glob/GlobTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import java.util.List;

import static io.cloudquery.glob.Glob.GLOB;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

public class GlobTest {
@Test
Expand Down
128 changes: 126 additions & 2 deletions lib/src/test/java/io/cloudquery/scalar/BinaryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import io.cloudquery.scalar.Binary;
import io.cloudquery.scalar.ValidationException;

import org.apache.arrow.vector.types.pojo.ArrowType;
import org.junit.Assert;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Arrays;

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


public class BinaryTest {
Expand All @@ -20,7 +23,12 @@ public void testNew() {
@Test
public void testNewWithValidParam() {
assertDoesNotThrow(() -> {
new Binary(new byte[]{'a', 'b', 'c'});
new Binary("abc");
new Binary(new char[]{'a', 'b', 'c'});

Scalar s = new Binary(new char[]{'a', 'b', 'c'});
new Binary(s);
});
}

Expand All @@ -30,4 +38,120 @@ public void testNewWithInvalidParam() {
new Binary(false);
});
}

@Test
public void testToString() {
Binary b = new Binary();
assertEquals(Scalar.NULL_VALUE_STRING, b.toString());

assertDoesNotThrow(() -> {
b.set("abc");
});
assertEquals("abc=", b.toString());

assertDoesNotThrow(() -> {
b.set(new byte[]{0, 1, 2, 3, 4, 5});
});
assertEquals("AAECAwQF", b.toString());
}

@Test
public void testDataType() {
Binary b = new Binary();
assertEquals(ArrowType.Binary.INSTANCE, b.dataType());
assertEquals(new ArrowType.Binary(), b.dataType());
}

@Test
public void testIsValid() {
Binary b = new Binary();
assertFalse(b.isValid());

assertDoesNotThrow(() -> {
b.set("abc");
});
assertTrue(b.isValid());
}

@Test
public void testSet() {
Binary b = new Binary();
assertDoesNotThrow(() -> {
b.set(new byte[]{'a', 'b', 'c'});
b.set("abc");
b.set(new char[]{'a', 'b', 'c'});

Scalar s = new Binary(new char[]{'a', 'b', 'c'});
b.set(s);
});
}

@Test
public void testSetWithInvalidParam() {
Binary b = new Binary();
assertThrows(ValidationException.class, () -> {
b.set(false);
});
}

@Test
public void testGet() {
Binary b = new Binary();
assertFalse(b.isValid());
assertNull(b.get());

assertDoesNotThrow(() -> {
b.set(new byte[]{'a', 'b', 'c'});
});
assertTrue(b.isValid());
assertArrayEquals(new byte[]{'a', 'b', 'c'}, (byte[]) b.get());

assertDoesNotThrow(() -> {
b.set("abc");
});
assertTrue(b.isValid());
assertArrayEquals(new byte[]{105, -73}, (byte[]) b.get());

assertDoesNotThrow(() -> {
b.set(new char[]{'a', 'b', 'c'});
});
assertTrue(b.isValid());
assertArrayEquals(new byte[]{105, -73}, (byte[]) b.get());

assertDoesNotThrow(() -> {
Scalar s = new Binary(new char[]{'a', 'b', 'c'});
b.set(s);
});
assertTrue(b.isValid());
assertArrayEquals(new byte[]{105, -73}, (byte[]) b.get());

assertDoesNotThrow(() -> {
Scalar s = new Binary(new byte[]{'a', 'b', 'c'});
b.set(s);
});
assertTrue(b.isValid());
assertArrayEquals(new byte[]{'a', 'b', 'c'}, (byte[]) b.get());
}

@Test
public void testEquals() {
Binary a = new Binary();
Binary b = new Binary();
assertEquals(a, b);
assertNotEquals(a, null);
assertEquals(a, new LargeBinary()); // we can cast LargeBinary to Binary
assertNotEquals(null, a);

assertDoesNotThrow(() -> {
a.set(new byte[]{'a', 'b', 'c'});
});
assertNotEquals(a, b);

assertDoesNotThrow(() -> {
for (Object obj : new Object[]{null, new byte[]{'a', 'b', 'c'}, new char[]{'a', 'b', 'c'}, "abc", new Binary("abc"),}) {
a.set(obj);
assertEquals(a, new Binary(obj));
}
});
}
}
156 changes: 156 additions & 0 deletions lib/src/test/java/io/cloudquery/scalar/LargeBinaryTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
package io.cloudquery.scalar;

import org.apache.arrow.vector.types.pojo.ArrowType;
import org.junit.jupiter.api.Test;

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


public class LargeBinaryTest {
@Test
public void testNew() {
assertDoesNotThrow(() -> {
new LargeBinary();
});
}

@Test
public void testNewWithValidParam() {
assertDoesNotThrow(() -> {
new LargeBinary(new byte[]{'a', 'b', 'c'});
new LargeBinary("abc");
new LargeBinary(new char[]{'a', 'b', 'c'});

Scalar s = new LargeBinary(new char[]{'a', 'b', 'c'});
new LargeBinary(s);
});
}

@Test
public void testNewWithInvalidParam() {
assertThrows(ValidationException.class, () -> {
new LargeBinary(false);
});
}

@Test
public void testToString() {
LargeBinary b = new LargeBinary();
assertEquals(Scalar.NULL_VALUE_STRING, b.toString());

assertDoesNotThrow(() -> {
b.set("abc");
});
assertEquals("abc=", b.toString());

assertDoesNotThrow(() -> {
b.set(new byte[]{0, 1, 2, 3, 4, 5});
});
assertEquals("AAECAwQF", b.toString());
}

@Test
public void testDataType() {
LargeBinary b = new LargeBinary();
assertEquals(ArrowType.LargeBinary.INSTANCE, b.dataType());
assertEquals(new ArrowType.LargeBinary(), b.dataType());
}

@Test
public void testIsValid() {
LargeBinary b = new LargeBinary();
assertFalse(b.isValid());

assertDoesNotThrow(() -> {
b.set("abc");
});
assertTrue(b.isValid());
}

@Test
public void testSet() {
LargeBinary b = new LargeBinary();
assertDoesNotThrow(() -> {
b.set(new byte[]{'a', 'b', 'c'});
b.set("abc");
b.set(new char[]{'a', 'b', 'c'});

Scalar s = new LargeBinary(new char[]{'a', 'b', 'c'});
b.set(s);
});
}

@Test
public void testSetWithInvalidParam() {
LargeBinary b = new LargeBinary();
assertThrows(ValidationException.class, () -> {
b.set(false);
});
}

@Test
public void testGet() {
LargeBinary b = new LargeBinary();
assertFalse(b.isValid());
assertNull(b.get());

assertDoesNotThrow(() -> {
b.set(new byte[]{'a', 'b', 'c'});
});
assertTrue(b.isValid());
assertArrayEquals(new byte[]{'a', 'b', 'c'}, (byte[]) b.get());

assertDoesNotThrow(() -> {
b.set("abc");
});
assertTrue(b.isValid());
assertArrayEquals(new byte[]{105, -73}, (byte[]) b.get());

assertDoesNotThrow(() -> {
b.set(new char[]{'a', 'b', 'c'});
});
assertTrue(b.isValid());
assertArrayEquals(new byte[]{105, -73}, (byte[]) b.get());

assertDoesNotThrow(() -> {
Scalar s = new LargeBinary(new char[]{'a', 'b', 'c'});
b.set(s);
});
assertTrue(b.isValid());
assertArrayEquals(new byte[]{105, -73}, (byte[]) b.get());

assertDoesNotThrow(() -> {
Scalar s = new LargeBinary(new byte[]{'a', 'b', 'c'});
b.set(s);
});
assertTrue(b.isValid());
assertArrayEquals(new byte[]{'a', 'b', 'c'}, (byte[]) b.get());
}
@Test
public void testEquals() {
LargeBinary a = new LargeBinary();
LargeBinary b = new LargeBinary();
assertEquals(a, b);
assertNotEquals(a,null);
assertNotEquals(a,new Binary()); // we can't cast Binary to LargeBinary
assertNotEquals(null, a);

assertDoesNotThrow(() -> {
a.set(new byte[]{'a', 'b', 'c'});
});
assertNotEquals(a,b);

assertDoesNotThrow(() -> {
for (Object obj: new Object[]{
null,
new byte[]{'a', 'b', 'c'},
new char[]{'a', 'b', 'c'},
"abc",
new LargeBinary("abc"),
}) {
a.set(obj);
assertEquals(a, new LargeBinary(obj));
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import java.util.stream.Stream;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.*;

public class TableFilterDFSTest {
public static final List<Table> BASIC_TABLES = Stream.of("table1", "table2", "table3").map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import java.util.List;

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

public class TableFlattenTest {

Expand Down
2 changes: 1 addition & 1 deletion lib/src/test/java/io/cloudquery/schema/TableMaxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Collections;
import java.util.List;

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

public class TableMaxTest {

Expand Down
3 changes: 1 addition & 2 deletions lib/src/test/java/io/cloudquery/server/AddressTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

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

public class AddressTest {

Expand Down
Loading