Skip to content

Commit 3edba12

Browse files
committed
more linting
1 parent abc31d5 commit 3edba12

5 files changed

Lines changed: 85 additions & 100 deletions

File tree

‎src/test/java/io/delta/sharing/java/DeltaSharingTestCase.java‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
package io.delta.sharing.java;
22

3+
34
import io.delta.sharing.java.adaptor.DeltaSharingJsonProvider;
45
import io.delta.sharing.java.mocks.Mocks;
56
import io.delta.sharing.spark.DeltaSharingProfileProvider;
67
import io.delta.sharing.spark.model.Table;
7-
import org.junit.jupiter.api.Assertions;
8-
import org.junit.jupiter.api.Test;
9-
108
import java.io.IOException;
119
import java.net.URISyntaxException;
1210
import java.nio.file.Path;
1311
import java.nio.file.Paths;
1412
import java.util.LinkedList;
1513
import java.util.List;
14+
import org.junit.jupiter.api.Assertions;
15+
import org.junit.jupiter.api.Test;
1616

17+
/**
18+
* Test cases for Delta Sharing connector.
19+
*
20+
*/
1721
public class DeltaSharingTestCase {
1822

1923
@Test
2024
public void testGetters() throws IOException {
2125
DeltaSharingProfileProvider profileProvider = new DeltaSharingJsonProvider(Mocks.providerJson);
2226
Path checkpointPath = Paths.get("target/testing/");
2327
DeltaSharing sharing = DeltaSharingFactory.create(profileProvider, checkpointPath);
24-
Assertions.assertAll(
25-
"assert sharing client",
26-
() ->
27-
Assertions.assertNotNull(sharing.getHttpClient()),
28-
() ->
29-
Assertions.assertNotNull(sharing.getProfileProvider())
30-
);
28+
Assertions.assertAll("assert sharing client",
29+
() -> Assertions.assertNotNull(sharing.getHttpClient()),
30+
() -> Assertions.assertNotNull(sharing.getProfileProvider()));
3131
}
3232

3333
@Test

‎src/test/java/io/delta/sharing/java/adaptor/DeltaSharingJSONProviderTestCase.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
import org.junit.jupiter.api.Test;
99

1010

11+
/**
12+
* Test cases for Delta Sharing Json Provider.
13+
*
14+
* @throws JsonProcessingException for all problems encountered when processing Json
15+
*/
16+
1117
public class DeltaSharingJsonProviderTestCase {
1218

1319
@SuppressWarnings("ResultOfMethodCallIgnored")
Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,87 @@
11
package io.delta.sharing.java.format.parquet;
22

3-
import org.apache.parquet.io.SeekableInputStream;
4-
import org.junit.jupiter.api.Assertions;
5-
import org.junit.jupiter.api.Test;
6-
73
import java.io.IOException;
84
import java.nio.ByteBuffer;
95
import java.nio.file.Path;
106
import java.nio.file.Paths;
7+
import org.apache.parquet.io.SeekableInputStream;
8+
import org.junit.jupiter.api.Assertions;
9+
import org.junit.jupiter.api.Test;
1110

11+
/**
12+
* Test cases for local Input File.
13+
*
14+
* @throws IOException for all IO problems
15+
*/
1216
public class LocalInputFileTestCase {
1317

1418
@Test
1519
public void testRead() throws IOException {
16-
Path filePath = Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath();
20+
Path filePath =
21+
Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath();
1722
LocalInputFile localInputFile = new LocalInputFile(filePath);
1823

1924
byte[] b = new byte[1024];
2025
SeekableInputStream stream = localInputFile.newStream();
2126

22-
Assertions.assertDoesNotThrow(
23-
() -> stream.read(b),
24-
"assert no exception for read with buffer"
25-
);
26-
27-
Assertions.assertDoesNotThrow(
28-
() -> stream.read(),
29-
"assert no exception for read without buffer"
30-
);
31-
32-
Assertions.assertDoesNotThrow(
33-
() -> stream.read(b, 100, 100),
34-
"assert no exception for read with offset using a buffer"
35-
);
36-
37-
Assertions.assertDoesNotThrow(
38-
() -> stream.readFully(b, 100, 100),
39-
"assert no exception for read with offset using a buffer"
40-
);
27+
Assertions.assertDoesNotThrow(() -> stream.read(b), "assert no exception for read with buffer");
28+
29+
Assertions.assertDoesNotThrow(() -> stream.read(),
30+
"assert no exception for read without buffer");
31+
32+
Assertions.assertDoesNotThrow(() -> stream.read(b, 100, 100),
33+
"assert no exception for read with offset using a buffer");
34+
35+
Assertions.assertDoesNotThrow(() -> stream.readFully(b, 100, 100),
36+
"assert no exception for read with offset using a buffer");
4137
}
4238

4339
@Test
4440
public void testSkip() throws IOException {
45-
Path filePath = Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath();
41+
Path filePath =
42+
Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath();
4643
LocalInputFile localInputFile = new LocalInputFile(filePath);
4744

4845
byte[] b = new byte[1024];
4946
SeekableInputStream stream = localInputFile.newStream();
5047

51-
Assertions.assertDoesNotThrow(
52-
() -> stream.skip(100) + stream.read(b),
53-
"assert no exception for read after a skip"
54-
);
48+
Assertions.assertDoesNotThrow(() -> stream.skip(100) + stream.read(b),
49+
"assert no exception for read after a skip");
5550
}
5651

5752
@Test
5853
public void testReadByteBuffers() throws IOException {
59-
Path filePath = Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath();
54+
Path filePath =
55+
Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath();
6056
LocalInputFile localInputFile = new LocalInputFile(filePath);
6157

62-
//8192 is page size constant inside the LocalInputFile
58+
// 8192 is page size constant inside the LocalInputFile
6359
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(8192 * 4);
6460
SeekableInputStream stream = localInputFile.newStream();
6561

66-
Assertions.assertDoesNotThrow(
67-
() -> stream.read(byteBuffer),
68-
"assert no exception for read with byte buffer"
69-
);
62+
Assertions.assertDoesNotThrow(() -> stream.read(byteBuffer),
63+
"assert no exception for read with byte buffer");
7064

71-
Assertions.assertDoesNotThrow(
72-
() -> stream.readFully(byteBuffer),
73-
"assert no exception for readFully with byte buffer"
74-
);
65+
Assertions.assertDoesNotThrow(() -> stream.readFully(byteBuffer),
66+
"assert no exception for readFully with byte buffer");
7567
}
7668

7769
@Test
7870
public void testPointers() throws IOException {
79-
Path filePath = Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath();
71+
Path filePath =
72+
Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath();
8073
LocalInputFile localInputFile = new LocalInputFile(filePath);
8174

82-
//8192 is page size constant inside the LocalInputFile
75+
// 8192 is page size constant inside the LocalInputFile
8376
SeekableInputStream stream = localInputFile.newStream();
8477

8578
Assertions.assertTrue(stream.markSupported());
8679
Assertions.assertEquals(stream.available(), 0);
8780

88-
Assertions.assertDoesNotThrow(
89-
() -> stream.mark(0),
90-
"assert mark operation doesnt throw an exception"
91-
);
81+
Assertions.assertDoesNotThrow(() -> stream.mark(0),
82+
"assert mark operation doesnt throw an exception");
9283

93-
Assertions.assertDoesNotThrow(
94-
() -> stream.mark(0),
95-
"assert mark operation doesnt throw an exception"
96-
);
84+
Assertions.assertDoesNotThrow(() -> stream.mark(0),
85+
"assert mark operation doesnt throw an exception");
9786
}
9887
}
Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,51 @@
11
package io.delta.sharing.java.format.parquet;
22

3-
import org.apache.avro.Schema;
4-
import org.apache.avro.generic.GenericRecord;
5-
import org.junit.jupiter.api.Assertions;
6-
import org.junit.jupiter.api.Test;
7-
83
import java.io.IOException;
94
import java.nio.file.Path;
105
import java.nio.file.Paths;
116
import java.util.LinkedList;
127
import java.util.List;
8+
import org.apache.avro.Schema;
9+
import org.apache.avro.generic.GenericRecord;
10+
import org.junit.jupiter.api.Assertions;
11+
import org.junit.jupiter.api.Test;
1312

13+
/**
14+
* Test cases for Table Reader.
15+
*
16+
* @throws IOException for all IO problems
17+
*/
1418
public class TableReaderTestCase {
1519

1620
@Test
1721
public void testRead() throws IOException {
1822
List<Path> paths = new LinkedList<>();
1923
paths.add(
20-
Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath()
21-
);
24+
Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath());
2225

2326
TableReader<GenericRecord> tableReader = new TableReader<>(paths);
2427

2528
GenericRecord record = tableReader.read();
2629
Schema schema = record.getSchema();
2730
Schema.Field field = schema.getFields().get(0);
28-
Assertions.assertAll(
29-
"assert table reader",
30-
() ->
31-
Assertions.assertEquals(record.get("date").toString(), "2020-10-10"),
32-
() ->
33-
Assertions.assertEquals(record.get(field.name()).toString(), "2020-10-10")
34-
);
31+
Assertions.assertAll("assert table reader",
32+
() -> Assertions.assertEquals(record.get("date").toString(), "2020-10-10"),
33+
() -> Assertions.assertEquals(record.get(field.name()).toString(), "2020-10-10"));
3534
}
3635

3736
@Test
3837
public void testReadN() throws IOException {
3938
List<Path> paths = new LinkedList<>();
4039
paths.add(
41-
Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath()
42-
);
40+
Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath());
4341

4442
TableReader<GenericRecord> tableReader = new TableReader<>(paths);
4543

4644
List<GenericRecord> records = tableReader.readN(2);
4745
Schema schema = records.get(0).getSchema();
4846
Schema.Field field = schema.getFields().get(0);
49-
Assertions.assertAll(
50-
"assert table reader",
51-
() ->
52-
Assertions.assertEquals(records.get(0).get("date").toString(), "2020-10-10"),
53-
() ->
54-
Assertions.assertEquals(records.get(0).get(field.name()).toString(), "2020-10-10")
55-
);
47+
Assertions.assertAll("assert table reader",
48+
() -> Assertions.assertEquals(records.get(0).get("date").toString(), "2020-10-10"),
49+
() -> Assertions.assertEquals(records.get(0).get(field.name()).toString(), "2020-10-10"));
5650
}
5751
}
Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
package io.delta.sharing.java.mocks;
22

3+
/**
4+
* Mock for provider json.
5+
*/
36
public class Mocks {
4-
public static String providerJson = "{\n" +
5-
" \"shareCredentialsVersion\": 1,\n" +
6-
" \"endpoint\": \"https://sharing.delta.io/delta-sharing/\",\n" +
7-
" \"bearerToken\": \"faaie590d541265bcab1f2de9813274bf233\"\n" +
8-
"}";
7+
public static String providerJson = "{\n" + " \"shareCredentialsVersion\": 1,\n"
8+
+ " \"endpoint\": \"https://sharing.delta.io/delta-sharing/\",\n"
9+
+ " \"bearerToken\": \"faaie590d541265bcab1f2de9813274bf233\"\n" + "}";
910

10-
public static String ProviderJsonUnsupportedCredentials = "{\n" +
11-
" \"shareCredentialsVersion\": 12,\n" +
12-
" \"endpoint\": \"https://sharing.delta.io/delta-sharing/\",\n" +
13-
" \"bearerToken\": \"faaie590d541265bcab1f2de9813274bf233\"\n" +
14-
"}";
11+
public static String ProviderJsonUnsupportedCredentials =
12+
"{\n" + " \"shareCredentialsVersion\": 12,\n"
13+
+ " \"endpoint\": \"https://sharing.delta.io/delta-sharing/\",\n"
14+
+ " \"bearerToken\": \"faaie590d541265bcab1f2de9813274bf233\"\n" + "}";
1515

16-
public static String ProviderJsonNoEndpoint = "{\n" +
17-
" \"shareCredentialsVersion\": 12,\n" +
18-
" \"bearerToken\": \"faaie590d541265bcab1f2de9813274bf233\"\n" +
19-
"}";
16+
public static String ProviderJsonNoEndpoint = "{\n" + " \"shareCredentialsVersion\": 12,\n"
17+
+ " \"bearerToken\": \"faaie590d541265bcab1f2de9813274bf233\"\n" + "}";
2018

21-
public static String ProviderJsonNoToken = "{\n" +
22-
" \"shareCredentialsVersion\": 1,\n" +
23-
" \"endpoint\": \"https://sharing.delta.io/delta-sharing/\",\n" +
24-
"}";
19+
public static String ProviderJsonNoToken = "{\n" + " \"shareCredentialsVersion\": 1,\n"
20+
+ " \"endpoint\": \"https://sharing.delta.io/delta-sharing/\",\n" + "}";
2521
}

0 commit comments

Comments
 (0)