-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
JsonSchemaTypeTest.kt
89 lines (86 loc) · 3.72 KB
/
JsonSchemaTypeTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Copyright (c) 2023 Airbyte, Inc., all rights reserved.
*/
package io.airbyte.cdk.integrations.destination.s3.avro
import io.airbyte.cdk.integrations.destination.s3.avro.JsonSchemaType.Companion.fromJsonSchemaType
import java.util.stream.Stream
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.extension.ExtensionContext
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.ArgumentsProvider
import org.junit.jupiter.params.provider.ArgumentsSource
class JsonSchemaTypeTest {
@ParameterizedTest
@ArgumentsSource(JsonSchemaTypeProvider::class)
fun testFromJsonSchemaType(
type: String,
airbyteType: String?,
expectedJsonSchemaType: JsonSchemaType?
) {
Assertions.assertEquals(expectedJsonSchemaType, fromJsonSchemaType(type, airbyteType))
}
class JsonSchemaTypeProvider : ArgumentsProvider {
override fun provideArguments(context: ExtensionContext): Stream<out Arguments> {
return Stream.of(
Arguments.of(
"WellKnownTypes.json#/definitions/Number",
null,
JsonSchemaType.NUMBER_V1
),
Arguments.of(
"WellKnownTypes.json#/definitions/String",
null,
JsonSchemaType.STRING_V1
),
Arguments.of(
"WellKnownTypes.json#/definitions/Integer",
null,
JsonSchemaType.INTEGER_V1
),
Arguments.of(
"WellKnownTypes.json#/definitions/Boolean",
null,
JsonSchemaType.BOOLEAN_V1
),
Arguments.of(
"WellKnownTypes.json#/definitions/BinaryData",
null,
JsonSchemaType.BINARY_DATA_V1
),
Arguments.of("WellKnownTypes.json#/definitions/Date", null, JsonSchemaType.DATE_V1),
Arguments.of(
"WellKnownTypes.json#/definitions/TimestampWithTimezone",
null,
JsonSchemaType.TIMESTAMP_WITH_TIMEZONE_V1
),
Arguments.of(
"WellKnownTypes.json#/definitions/TimestampWithoutTimezone",
null,
JsonSchemaType.TIMESTAMP_WITHOUT_TIMEZONE_V1
),
Arguments.of(
"WellKnownTypes.json#/definitions/TimeWithTimezone",
null,
JsonSchemaType.TIME_WITH_TIMEZONE_V1
),
Arguments.of(
"WellKnownTypes.json#/definitions/TimeWithoutTimezone",
null,
JsonSchemaType.TIME_WITHOUT_TIMEZONE_V1
),
Arguments.of("number", "integer", JsonSchemaType.NUMBER_INT_V0),
Arguments.of("string", "big_integer", JsonSchemaType.NUMBER_BIGINT_V0),
Arguments.of("number", "float", JsonSchemaType.NUMBER_FLOAT_V0),
Arguments.of("number", null, JsonSchemaType.NUMBER_V0),
Arguments.of("string", null, JsonSchemaType.STRING_V0),
Arguments.of("integer", null, JsonSchemaType.INTEGER_V0),
Arguments.of("boolean", null, JsonSchemaType.BOOLEAN_V0),
Arguments.of("null", null, JsonSchemaType.NULL),
Arguments.of("object", null, JsonSchemaType.OBJECT),
Arguments.of("array", null, JsonSchemaType.ARRAY),
Arguments.of("combined", null, JsonSchemaType.COMBINED)
)
}
}
}