Skip to content

Commit

Permalink
Close cursor in tests
Browse files Browse the repository at this point in the history
Currently just to suppress IDE warning, but cursor may have some cleanup
in the future.
  • Loading branch information
findepi authored and nineinchnick committed Feb 5, 2024
1 parent c37c1d4 commit 731358e
Showing 1 changed file with 87 additions and 87 deletions.
174 changes: 87 additions & 87 deletions src/test/java/pl/net/was/trino/git/TestGitRecordSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,20 @@ public void testCommitsCursorSimple()
new GitColumnHandle("object_id", createUnboundedVarcharType(), 0),
new GitColumnHandle("author_name", createUnboundedVarcharType(), 1),
new GitColumnHandle("commit_time", TimestampWithTimeZoneType.TIMESTAMP_TZ_SECONDS, 2)));
RecordCursor cursor = recordSet.cursor();

assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(createUnboundedVarcharType());

Map<String, List<Object>> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
data.put(cursor.getSlice(0).toStringUtf8(), List.of(
cursor.getSlice(1).toStringUtf8(),
cursor.getLong(2)));
try (RecordCursor cursor = recordSet.cursor()) {
assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(createUnboundedVarcharType());

Map<String, List<Object>> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
data.put(cursor.getSlice(0).toStringUtf8(), List.of(
cursor.getSlice(1).toStringUtf8(),
cursor.getLong(2)));
}
assertThat(data).isEqualTo(Map.of(
"080dfdf0aac7d302dc31d57f62942bb6533944f7", List.of("test", 6475355394048000L),
"c3b14e59f88d0d6597b98ee93cf61e7556d540a4", List.of("test", 6475355394048000L)));
}
assertThat(data).isEqualTo(Map.of(
"080dfdf0aac7d302dc31d57f62942bb6533944f7", List.of("test", 6475355394048000L),
"c3b14e59f88d0d6597b98ee93cf61e7556d540a4", List.of("test", 6475355394048000L)));
}

@Test
Expand All @@ -102,18 +102,18 @@ public void testBranchesCursorSimple()
RecordSet recordSet = new GitRecordSet(split, table, List.of(
new GitColumnHandle("object_id", createUnboundedVarcharType(), 0),
new GitColumnHandle("name", createUnboundedVarcharType(), 1)));
RecordCursor cursor = recordSet.cursor();

assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(createUnboundedVarcharType());

Map<String, String> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
assertThat(cursor.isNull(0)).isFalse();
assertThat(cursor.isNull(1)).isFalse();
data.put(cursor.getSlice(0).toStringUtf8(), cursor.getSlice(1).toStringUtf8());
try (RecordCursor cursor = recordSet.cursor()) {
assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(createUnboundedVarcharType());

Map<String, String> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
assertThat(cursor.isNull(0)).isFalse();
assertThat(cursor.isNull(1)).isFalse();
data.put(cursor.getSlice(0).toStringUtf8(), cursor.getSlice(1).toStringUtf8());
}
assertThat(data).isEqualTo(Map.of("c3b14e59f88d0d6597b98ee93cf61e7556d540a4", "refs/heads/master"));
}
assertThat(data).isEqualTo(Map.of("c3b14e59f88d0d6597b98ee93cf61e7556d540a4", "refs/heads/master"));
}

@Test
Expand All @@ -124,18 +124,18 @@ public void testTagsCursorSimple()
RecordSet recordSet = new GitRecordSet(split, table, List.of(
new GitColumnHandle("object_id", createUnboundedVarcharType(), 0),
new GitColumnHandle("name", createUnboundedVarcharType(), 1)));
RecordCursor cursor = recordSet.cursor();

assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(createUnboundedVarcharType());

Map<String, String> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
assertThat(cursor.isNull(0)).isFalse();
assertThat(cursor.isNull(1)).isFalse();
data.put(cursor.getSlice(0).toStringUtf8(), cursor.getSlice(1).toStringUtf8());
try (RecordCursor cursor = recordSet.cursor()) {
assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(createUnboundedVarcharType());

Map<String, String> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
assertThat(cursor.isNull(0)).isFalse();
assertThat(cursor.isNull(1)).isFalse();
data.put(cursor.getSlice(0).toStringUtf8(), cursor.getSlice(1).toStringUtf8());
}
assertThat(data).isEqualTo(Map.of("7afcc1aaeab61c3fd7f2b1b5df5178a823cbf77e", "refs/tags/tag_for_testing"));
}
assertThat(data).isEqualTo(Map.of("7afcc1aaeab61c3fd7f2b1b5df5178a823cbf77e", "refs/tags/tag_for_testing"));
}

@Test
Expand All @@ -146,20 +146,20 @@ public void testTreesCursorSimple()
RecordSet recordSet = new GitRecordSet(split, table, List.of(
new GitColumnHandle("commit_id", createUnboundedVarcharType(), 0),
new GitColumnHandle("object_id", createUnboundedVarcharType(), 1)));
RecordCursor cursor = recordSet.cursor();

assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(createUnboundedVarcharType());

Map<String, String> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
assertThat(cursor.isNull(0)).isFalse();
assertThat(cursor.isNull(1)).isFalse();
data.put(cursor.getSlice(0).toStringUtf8(), cursor.getSlice(1).toStringUtf8());
try (RecordCursor cursor = recordSet.cursor()) {
assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(createUnboundedVarcharType());

Map<String, String> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
assertThat(cursor.isNull(0)).isFalse();
assertThat(cursor.isNull(1)).isFalse();
data.put(cursor.getSlice(0).toStringUtf8(), cursor.getSlice(1).toStringUtf8());
}
assertThat(data).isEqualTo(Map.of(
"080dfdf0aac7d302dc31d57f62942bb6533944f7", "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
"c3b14e59f88d0d6597b98ee93cf61e7556d540a4", "5dd01c177f5d7d1be5346a5bc18a569a7410c2ef"));
}
assertThat(data).isEqualTo(Map.of(
"080dfdf0aac7d302dc31d57f62942bb6533944f7", "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
"c3b14e59f88d0d6597b98ee93cf61e7556d540a4", "5dd01c177f5d7d1be5346a5bc18a569a7410c2ef"));
}

@Test
Expand All @@ -170,22 +170,22 @@ public void testObjectsCursorSimple()
RecordSet recordSet = new GitRecordSet(split, table, List.of(
new GitColumnHandle("object_id", createUnboundedVarcharType(), 0),
new GitColumnHandle("contents", VarbinaryType.VARBINARY, 1)));
RecordCursor cursor = recordSet.cursor();

assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(VarbinaryType.VARBINARY);

Map<String, String> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
assertThat(cursor.isNull(0)).isFalse();
assertThat(cursor.isNull(1)).isFalse();
String objectId = cursor.getSlice(0).toStringUtf8();
String contents = cursor.getSlice(1).toStringUtf8();
data.put(objectId, contents);
try (RecordCursor cursor = recordSet.cursor()) {
assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(VarbinaryType.VARBINARY);

Map<String, String> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
assertThat(cursor.isNull(0)).isFalse();
assertThat(cursor.isNull(1)).isFalse();
String objectId = cursor.getSlice(0).toStringUtf8();
String contents = cursor.getSlice(1).toStringUtf8();
data.put(objectId, contents);
}
assertThat(data).isEqualTo(Map.of(
"5dd01c177f5d7d1be5346a5bc18a569a7410c2ef", "Hello, world!",
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", ""));
}
assertThat(data).isEqualTo(Map.of(
"5dd01c177f5d7d1be5346a5bc18a569a7410c2ef", "Hello, world!",
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", ""));
}

@Test
Expand All @@ -198,31 +198,31 @@ public void testDiffStatsCursorSimple()
new GitColumnHandle("old_commit_id", createUnboundedVarcharType(), 1),
new GitColumnHandle("added_lines", IntegerType.INTEGER, 2),
new GitColumnHandle("deleted_lines", IntegerType.INTEGER, 3)));
RecordCursor cursor = recordSet.cursor();

assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(2)).isEqualTo(IntegerType.INTEGER);
assertThat(cursor.getType(3)).isEqualTo(IntegerType.INTEGER);

Map<String, List<Object>> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
assertThat(cursor.isNull(0)).isFalse();
assertThat(cursor.isNull(1)).isFalse();
assertThat(cursor.isNull(2)).isFalse();
assertThat(cursor.isNull(3)).isFalse();
data.put(
cursor.getSlice(0).toStringUtf8(),
try (RecordCursor cursor = recordSet.cursor()) {
assertThat(cursor.getType(0)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(1)).isEqualTo(createUnboundedVarcharType());
assertThat(cursor.getType(2)).isEqualTo(IntegerType.INTEGER);
assertThat(cursor.getType(3)).isEqualTo(IntegerType.INTEGER);

Map<String, List<Object>> data = new LinkedHashMap<>();
while (cursor.advanceNextPosition()) {
assertThat(cursor.isNull(0)).isFalse();
assertThat(cursor.isNull(1)).isFalse();
assertThat(cursor.isNull(2)).isFalse();
assertThat(cursor.isNull(3)).isFalse();
data.put(
cursor.getSlice(0).toStringUtf8(),
List.of(
cursor.getSlice(1).toStringUtf8(),
cursor.getLong(2),
cursor.getLong(3)));
}
assertThat(data).isEqualTo(Map.of(
"c3b14e59f88d0d6597b98ee93cf61e7556d540a4",
List.of(
cursor.getSlice(1).toStringUtf8(),
cursor.getLong(2),
cursor.getLong(3)));
"080dfdf0aac7d302dc31d57f62942bb6533944f7",
1L,
0L)));
}
assertThat(data).isEqualTo(Map.of(
"c3b14e59f88d0d6597b98ee93cf61e7556d540a4",
List.of(
"080dfdf0aac7d302dc31d57f62942bb6533944f7",
1L,
0L)));
}
}

0 comments on commit 731358e

Please sign in to comment.