Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static org.apache.parquet.schema.PrimitiveStringifier.TIME_UTC_STRINGIFIER;
import static org.apache.parquet.schema.PrimitiveStringifier.UNSIGNED_STRINGIFIER;
import static org.apache.parquet.schema.PrimitiveStringifier.UTF8_STRINGIFIER;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

Expand All @@ -51,7 +52,6 @@
import java.util.Set;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import org.apache.parquet.TestUtils;
import org.apache.parquet.io.api.Binary;
import org.junit.Test;

Expand Down Expand Up @@ -416,11 +416,9 @@ public void testUUIDStringifier() {
0x00, 0x00, 0x00)));

// As there is no validation implemented, if the 16 bytes is not available, the array will be over-indexed
TestUtils.assertThrows(
"Expected exception for over-indexing",
ArrayIndexOutOfBoundsException.class,
() -> stringifier.stringify(toBinary(
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee)));
assertThatThrownBy(() -> stringifier.stringify(toBinary(
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee)))
.isInstanceOf(ArrayIndexOutOfBoundsException.class);

checkThrowingUnsupportedException(stringifier, Binary.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,29 @@
*/
package org.apache.parquet;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;
import org.junit.Test;

public class SemanticVersionTest {
@Test
public void testCompare() {
assertTrue(new SemanticVersion(1, 8, 1).compareTo(new SemanticVersion(1, 8, 1)) == 0);
assertTrue(new SemanticVersion(1, 8, 0).compareTo(new SemanticVersion(1, 8, 1)) < 0);
assertTrue(new SemanticVersion(1, 8, 2).compareTo(new SemanticVersion(1, 8, 1)) > 0);
assertThat(new SemanticVersion(1, 8, 1)).isEqualByComparingTo(new SemanticVersion(1, 8, 1));
assertThat(new SemanticVersion(1, 8, 0)).isLessThan(new SemanticVersion(1, 8, 1));
assertThat(new SemanticVersion(1, 8, 2)).isGreaterThan(new SemanticVersion(1, 8, 1));

assertTrue(new SemanticVersion(1, 8, 1).compareTo(new SemanticVersion(1, 8, 1)) == 0);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these 3 checks were checking the same thing and were duplicates

assertTrue(new SemanticVersion(1, 8, 0).compareTo(new SemanticVersion(1, 8, 1)) < 0);
assertTrue(new SemanticVersion(1, 8, 2).compareTo(new SemanticVersion(1, 8, 1)) > 0);
assertThat(new SemanticVersion(1, 7, 0)).isLessThan(new SemanticVersion(1, 8, 0));
assertThat(new SemanticVersion(1, 9, 0)).isGreaterThan(new SemanticVersion(1, 8, 0));

assertTrue(new SemanticVersion(1, 7, 0).compareTo(new SemanticVersion(1, 8, 0)) < 0);
assertTrue(new SemanticVersion(1, 9, 0).compareTo(new SemanticVersion(1, 8, 0)) > 0);
assertThat(new SemanticVersion(0, 0, 0)).isLessThan(new SemanticVersion(1, 0, 0));
assertThat(new SemanticVersion(2, 0, 0)).isGreaterThan(new SemanticVersion(1, 0, 0));

assertTrue(new SemanticVersion(0, 0, 0).compareTo(new SemanticVersion(1, 0, 0)) < 0);
assertTrue(new SemanticVersion(2, 0, 0).compareTo(new SemanticVersion(1, 0, 0)) > 0);
assertThat(new SemanticVersion(1, 8, 100)).isLessThan(new SemanticVersion(1, 9, 0));

assertTrue(new SemanticVersion(1, 8, 100).compareTo(new SemanticVersion(1, 9, 0)) < 0);

assertTrue(new SemanticVersion(1, 8, 0).compareTo(new SemanticVersion(1, 8, 0, true)) > 0);
assertTrue(new SemanticVersion(1, 8, 0, true).compareTo(new SemanticVersion(1, 8, 0, true)) == 0);
assertTrue(new SemanticVersion(1, 8, 0, true).compareTo(new SemanticVersion(1, 8, 0)) < 0);
assertThat(new SemanticVersion(1, 8, 0)).isGreaterThan(new SemanticVersion(1, 8, 0, true));
assertThat(new SemanticVersion(1, 8, 0, true)).isEqualByComparingTo(new SemanticVersion(1, 8, 0, true));
assertThat(new SemanticVersion(1, 8, 0, true)).isLessThan(new SemanticVersion(1, 8, 0));
}

@Test
Expand Down Expand Up @@ -97,19 +92,24 @@ public void testDistributionVersions() throws Exception {

@Test
public void testParse() throws Exception {
assertEquals(new SemanticVersion(1, 8, 0), SemanticVersion.parse("1.8.0"));
assertEquals(new SemanticVersion(1, 8, 0, true), SemanticVersion.parse("1.8.0rc3"));
assertEquals(new SemanticVersion(1, 8, 0, "rc3", "SNAPSHOT", null), SemanticVersion.parse("1.8.0rc3-SNAPSHOT"));
assertEquals(new SemanticVersion(1, 8, 0, null, "SNAPSHOT", null), SemanticVersion.parse("1.8.0-SNAPSHOT"));
assertEquals(new SemanticVersion(1, 5, 0, null, "cdh5.5.0", null), SemanticVersion.parse("1.5.0-cdh5.5.0"));
assertThat(SemanticVersion.parse("1.8.0")).isEqualTo(new SemanticVersion(1, 8, 0));
assertThat(SemanticVersion.parse("1.8.0rc3")).isEqualTo(new SemanticVersion(1, 8, 0, true));
assertThat(SemanticVersion.parse("1.8.0rc3-SNAPSHOT"))
.isEqualTo(new SemanticVersion(1, 8, 0, "rc3", "SNAPSHOT", null));
assertThat(SemanticVersion.parse("1.8.0-SNAPSHOT"))
.isEqualTo(new SemanticVersion(1, 8, 0, null, "SNAPSHOT", null));
assertThat(SemanticVersion.parse("1.5.0-cdh5.5.0"))
.isEqualTo(new SemanticVersion(1, 5, 0, null, "cdh5.5.0", null));
}

private static void assertLessThan(String a, String b) throws SemanticVersion.SemanticVersionParseException {
assertTrue(a + " should be < " + b, SemanticVersion.parse(a).compareTo(SemanticVersion.parse(b)) < 0);
assertTrue(b + " should be > " + a, SemanticVersion.parse(b).compareTo(SemanticVersion.parse(a)) > 0);
assertThat(SemanticVersion.parse(a)).as(a + " should be < " + b).isLessThan(SemanticVersion.parse(b));
assertThat(SemanticVersion.parse(b)).as(b + " should be > " + a).isGreaterThan(SemanticVersion.parse(a));
}

private static void assertEqualTo(String a, String b) throws SemanticVersion.SemanticVersionParseException {
assertTrue(a + " should equal " + b, SemanticVersion.parse(a).compareTo(SemanticVersion.parse(b)) == 0);
assertThat(SemanticVersion.parse(a))
.as(a + " should equal " + b)
.isEqualByComparingTo(SemanticVersion.parse(b));
}
}
Loading
Loading