24
24
import com .apple .foundationdb .record .metadata .IndexTypes ;
25
25
import com .apple .foundationdb .record .metadata .Key ;
26
26
import com .apple .foundationdb .record .metadata .expressions .KeyExpression ;
27
- import com .apple .foundationdb .relational . api . exceptions . UncheckedRelationalException ;
27
+ import com .apple .foundationdb .record . util . pair . NonnullPair ;
28
28
import com .apple .foundationdb .relational .api .exceptions .RelationalException ;
29
+ import com .apple .foundationdb .relational .api .exceptions .UncheckedRelationalException ;
29
30
import com .apple .foundationdb .relational .api .metadata .DataType ;
30
-
31
31
import com .google .protobuf .DescriptorProtos ;
32
- import com .ibm .icu .impl .Pair ;
33
32
import org .junit .jupiter .api .Assertions ;
34
33
import org .junit .jupiter .api .Test ;
35
34
import org .junit .jupiter .params .ParameterizedTest ;
@@ -96,7 +95,7 @@ private static RecordLayerSchemaTemplate basicTestTemplate() {
96
95
.build ();
97
96
}
98
97
99
- private static RecordLayerSchemaTemplate getTestRecordLayerSchemaTemplate (@ Nonnull Map <String , List <Pair <Integer , DescriptorProtos .FieldOptions >>> template ) {
98
+ private static RecordLayerSchemaTemplate getTestRecordLayerSchemaTemplate (@ Nonnull Map <String , List <NonnullPair <Integer , DescriptorProtos .FieldOptions >>> template ) {
100
99
final var builder = RecordLayerSchemaTemplate .newBuilder ().setName ("TestSchemaTemplate" );
101
100
for (var entry : template .entrySet ()) {
102
101
final var tableBuilder = RecordLayerTable .newBuilder (false )
@@ -106,7 +105,7 @@ private static RecordLayerSchemaTemplate getTestRecordLayerSchemaTemplate(@Nonnu
106
105
.setDataType (DataType .Primitives .STRING .type ())
107
106
.build ());
108
107
for (var generation : entry .getValue ()) {
109
- tableBuilder .addGeneration (generation .first , generation .second );
108
+ tableBuilder .addGeneration (generation .getLeft () , generation .getRight () );
110
109
}
111
110
builder .addTable (tableBuilder .build ());
112
111
}
@@ -115,7 +114,7 @@ private static RecordLayerSchemaTemplate getTestRecordLayerSchemaTemplate(@Nonnu
115
114
116
115
@ Test
117
116
public void testGoodSchemaTemplate () {
118
- var testcase = new HashMap <String , List <Pair <Integer , DescriptorProtos .FieldOptions >>>();
117
+ var testcase = new HashMap <String , List <NonnullPair <Integer , DescriptorProtos .FieldOptions >>>();
119
118
testcase .put ("T1" , List .of ());
120
119
testcase .put ("T2" , List .of ());
121
120
@@ -183,9 +182,9 @@ public void testStoreRowVersions(boolean storeRowVersions) {
183
182
public void testGoodSchemaTemplateWithGenerations () {
184
183
final var fieldOptions1 = DescriptorProtos .FieldOptions .newBuilder ().setDeprecated (true ).build ();
185
184
final var fieldOptions2 = DescriptorProtos .FieldOptions .newBuilder ().setDeprecated (false ).build ();
186
- var testcase = new HashMap <String , List <Pair <Integer , DescriptorProtos .FieldOptions >>>();
187
- testcase .put ("T1" , List .of (Pair .of (1 , fieldOptions1 ), Pair .of (2 , fieldOptions2 )));
188
- testcase .put ("T2" , List .of (Pair .of (3 , fieldOptions2 ), Pair .of (4 , fieldOptions1 )));
185
+ var testcase = new HashMap <String , List <NonnullPair <Integer , DescriptorProtos .FieldOptions >>>();
186
+ testcase .put ("T1" , List .of (NonnullPair .of (1 , fieldOptions1 ), NonnullPair .of (2 , fieldOptions2 )));
187
+ testcase .put ("T2" , List .of (NonnullPair .of (3 , fieldOptions2 ), NonnullPair .of (4 , fieldOptions1 )));
189
188
190
189
var template = getTestRecordLayerSchemaTemplate (testcase );
191
190
var recordMetadataProto = template .toRecordMetadata ().toProto ();
@@ -205,7 +204,7 @@ public void testGoodSchemaTemplateWithGenerations() {
205
204
final var typeName = unionField .getTypeName ();
206
205
Assertions .assertTrue (testcase .containsKey (typeName ));
207
206
final var expectedGenerations = testcase .get (typeName );
208
- Assertions .assertTrue (expectedGenerations .contains (Pair .of (unionField .getNumber (), unionField .getOptions ())));
207
+ Assertions .assertTrue (expectedGenerations .contains (NonnullPair .of (unionField .getNumber (), unionField .getOptions ())));
209
208
}
210
209
}
211
210
@@ -232,18 +231,18 @@ public static Stream<Arguments> badSchemaTemplateGenerationsTestcaseProvider() {
232
231
final var fieldOptions2 = DescriptorProtos .FieldOptions .newBuilder ().setDeprecated (false ).build ();
233
232
234
233
// SchemaTemplate with field number 0
235
- var testcase1 = new TreeMap <String , List <Pair <Integer , DescriptorProtos .FieldOptions >>>();
236
- testcase1 .put ("T1" , List .of (Pair .of (0 , fieldOptions1 ), Pair .of (2 , fieldOptions2 )));
234
+ var testcase1 = new TreeMap <String , List <NonnullPair <Integer , DescriptorProtos .FieldOptions >>>();
235
+ testcase1 .put ("T1" , List .of (NonnullPair .of (0 , fieldOptions1 ), NonnullPair .of (2 , fieldOptions2 )));
237
236
// SchemaTemplate with duplicated field number
238
- var testcase2 = new TreeMap <String , List <Pair <Integer , DescriptorProtos .FieldOptions >>>();
239
- testcase2 .put ("T1" , List .of (Pair .of (1 , fieldOptions1 ), Pair .of (1 , fieldOptions2 )));
237
+ var testcase2 = new TreeMap <String , List <NonnullPair <Integer , DescriptorProtos .FieldOptions >>>();
238
+ testcase2 .put ("T1" , List .of (NonnullPair .of (1 , fieldOptions1 ), NonnullPair .of (1 , fieldOptions2 )));
240
239
// SchemaTemplate with duplicated fieldOptions
241
- var testcase3 = new TreeMap <String , List <Pair <Integer , DescriptorProtos .FieldOptions >>>();
242
- testcase3 .put ("T1" , List .of (Pair .of (1 , fieldOptions2 ), Pair .of (2 , fieldOptions2 )));
240
+ var testcase3 = new TreeMap <String , List <NonnullPair <Integer , DescriptorProtos .FieldOptions >>>();
241
+ testcase3 .put ("T1" , List .of (NonnullPair .of (1 , fieldOptions2 ), NonnullPair .of (2 , fieldOptions2 )));
243
242
// SchemaTemplate with duplicated field numbers across tables
244
- var testcase4 = new TreeMap <String , List <Pair <Integer , DescriptorProtos .FieldOptions >>>();
245
- testcase4 .put ("T1" , List .of (Pair .of (1 , fieldOptions2 ), Pair .of (2 , fieldOptions1 )));
246
- testcase4 .put ("T2" , List .of (Pair .of (2 , fieldOptions2 ), Pair .of (3 , fieldOptions1 )));
243
+ var testcase4 = new TreeMap <String , List <NonnullPair <Integer , DescriptorProtos .FieldOptions >>>();
244
+ testcase4 .put ("T1" , List .of (NonnullPair .of (1 , fieldOptions2 ), NonnullPair .of (2 , fieldOptions1 )));
245
+ testcase4 .put ("T2" , List .of (NonnullPair .of (2 , fieldOptions2 ), NonnullPair .of (3 , fieldOptions1 )));
247
246
248
247
return Stream .of (
249
248
Arguments .of (testcase1 , UncheckedRelationalException .class , "Field numbers must be positive integers" ),
@@ -255,7 +254,7 @@ public static Stream<Arguments> badSchemaTemplateGenerationsTestcaseProvider() {
255
254
256
255
@ ParameterizedTest
257
256
@ MethodSource ("badSchemaTemplateGenerationsTestcaseProvider" )
258
- public void testBadSchemaTemplateGenerations (Map <String , List <Pair <Integer , DescriptorProtos .FieldOptions >>> testcase ,
257
+ public void testBadSchemaTemplateGenerations (Map <String , List <NonnullPair <Integer , DescriptorProtos .FieldOptions >>> testcase ,
259
258
Class <? extends Exception > exceptionClass , String message ) {
260
259
final var thrown = Assertions .assertThrows (exceptionClass , () -> {
261
260
final var schemaTemplate = getTestRecordLayerSchemaTemplate (testcase );
@@ -265,7 +264,7 @@ public void testBadSchemaTemplateGenerations(Map<String, List<Pair<Integer, Desc
265
264
}
266
265
267
266
@ Test
268
- public void deserializationNestedTypesPreservesNamesCorrectly () throws Exception {
267
+ public void deserializationNestedTypesPreservesNamesCorrectly () {
269
268
final var sampleRecordSchemaTemplate = RecordLayerSchemaTemplate .newBuilder ()
270
269
.setName ("TestSchemaTemplate" )
271
270
.setVersion (42 )
@@ -292,7 +291,7 @@ public void deserializationNestedTypesPreservesNamesCorrectly() throws Exception
292
291
final var column = deserializedTableType .get ().getColumns ().stream ().findFirst ();
293
292
Assertions .assertTrue (column .isPresent ());
294
293
final var type = column .get ().getDatatype ();
295
- Assertions .assertTrue ( type instanceof DataType .StructType );
294
+ Assertions .assertInstanceOf ( DataType .StructType . class , type );
296
295
final var typeName = ((DataType .StructType ) type ).getName ();
297
296
Assertions .assertEquals ("Subtype" , typeName );
298
297
}
0 commit comments