Skip to content

Commit c307b4a

Browse files
committed
test(model): Remove some minor code redundancy
Signed-off-by: Frank Viernau <[email protected]>
1 parent 06ea465 commit c307b4a

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

model/src/test/kotlin/JsonSchemaTest.kt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class JsonSchemaTest : StringSpec({
4646
"ORT's own repository configuration file validates successfully" {
4747
val repositoryConfiguration = File("../$ORT_REPO_CONFIG_FILENAME").readText()
4848

49-
val errors = schemaV7.getSchema(repositoryConfigurationSchema)
49+
val errors = getSchema(repositoryConfigurationSchema)
5050
.validate(repositoryConfiguration, InputFormat.YAML)
5151

5252
errors should beEmpty()
@@ -58,7 +58,7 @@ class JsonSchemaTest : StringSpec({
5858
examplesDir.walk().filterTo(mutableListOf()) { it.isFile && it.name.endsWith(ORT_REPO_CONFIG_FILENAME) }
5959

6060
repositoryConfiguration.forAll {
61-
val errors = schemaV7.getSchema(repositoryConfigurationSchema).validate(it.readText(), InputFormat.YAML)
61+
val errors = getSchema(repositoryConfigurationSchema).validate(it.readText(), InputFormat.YAML)
6262

6363
errors should beEmpty()
6464
}
@@ -69,7 +69,7 @@ class JsonSchemaTest : StringSpec({
6969
"/analyzer-repository-configuration.ort.yml"
7070
).analyzer
7171

72-
val errors = schemaV7.getSchema(repositoryConfigurationAnalyzerConfiguration)
72+
val errors = getSchema(repositoryConfigurationAnalyzerConfiguration)
7373
.validate(analyzerConfiguration.toYaml(), InputFormat.YAML)
7474

7575
errors should beEmpty()
@@ -80,7 +80,7 @@ class JsonSchemaTest : StringSpec({
8080
"/package-manager-repository-configuration.ort.yml"
8181
).analyzer?.packageManagers
8282

83-
val errors = schemaV7.getSchema(repositoryConfigurationPackageManagerConfiguration)
83+
val errors = getSchema(repositoryConfigurationPackageManagerConfiguration)
8484
.validate(packageManagerConfiguration.toYaml(), InputFormat.YAML)
8585

8686
errors should beEmpty()
@@ -90,7 +90,7 @@ class JsonSchemaTest : StringSpec({
9090
val curationsSchema = File("../integrations/schemas/curations-schema.json").toURI()
9191
val curationsExample = File("../examples/$ORT_PACKAGE_CURATIONS_FILENAME").readText()
9292

93-
val errors = schemaV7.getSchema(curationsSchema).validate(curationsExample, InputFormat.YAML)
93+
val errors = getSchema(curationsSchema).validate(curationsExample, InputFormat.YAML)
9494

9595
errors should beEmpty()
9696
}
@@ -99,7 +99,7 @@ class JsonSchemaTest : StringSpec({
9999
val packageConfigurationSchema = File("../integrations/schemas/package-configuration-schema.json").toURI()
100100
val packageConfiguration = File("../examples/$ORT_PACKAGE_CONFIGURATION_FILENAME").readText()
101101

102-
val errors = schemaV7.getSchema(packageConfigurationSchema).validate(packageConfiguration, InputFormat.YAML)
102+
val errors = getSchema(packageConfigurationSchema).validate(packageConfiguration, InputFormat.YAML)
103103

104104
errors should beEmpty()
105105
}
@@ -108,7 +108,7 @@ class JsonSchemaTest : StringSpec({
108108
val resolutionsSchema = File("../integrations/schemas/resolutions-schema.json").toURI()
109109
val resolutionsExample = File("../examples/$ORT_RESOLUTIONS_FILENAME").readText()
110110

111-
val errors = schemaV7.getSchema(resolutionsSchema).validate(resolutionsExample, InputFormat.YAML)
111+
val errors = getSchema(resolutionsSchema).validate(resolutionsExample, InputFormat.YAML)
112112

113113
errors should beEmpty()
114114
}
@@ -117,7 +117,7 @@ class JsonSchemaTest : StringSpec({
117117
val ortConfigurationSchema = File("../integrations/schemas/ort-configuration-schema.json").toURI()
118118
val referenceConfigFile = File("src/main/resources/$ORT_REFERENCE_CONFIG_FILENAME").readText()
119119

120-
val errors = schemaV7.getSchema(ortConfigurationSchema).validate(referenceConfigFile, InputFormat.YAML)
120+
val errors = getSchema(ortConfigurationSchema).validate(referenceConfigFile, InputFormat.YAML)
121121

122122
errors should beEmpty()
123123
}
@@ -126,7 +126,7 @@ class JsonSchemaTest : StringSpec({
126126
val licenseClassificationsSchema = File("../integrations/schemas/license-classifications-schema.json").toURI()
127127
val licenseClassificationsExample = File("../examples/$ORT_LICENSE_CLASSIFICATIONS_FILENAME").readText()
128128

129-
val errors = schemaV7.getSchema(licenseClassificationsSchema)
129+
val errors = getSchema(licenseClassificationsSchema)
130130
.validate(licenseClassificationsExample, InputFormat.YAML)
131131

132132
errors should beEmpty()
@@ -135,15 +135,15 @@ class JsonSchemaTest : StringSpec({
135135
"Snippet choices validate successfully" {
136136
val repositoryConfiguration = readResource("/snippet-choices-repository-configuration.ort.yml")
137137

138-
val errors = schemaV7.getSchema(repositoryConfigurationSchema)
138+
val errors = getSchema(repositoryConfigurationSchema)
139139
.validate(repositoryConfiguration, InputFormat.YAML)
140140

141141
errors should beEmpty()
142142
}
143143

144144
"Package configuration with no matchers validates successfully" {
145145
val packageConfigurationSchema = File("../integrations/schemas/package-configuration-schema.json").toURI()
146-
val schema = schemaV7.getSchema(packageConfigurationSchema)
146+
val schema = getSchema(packageConfigurationSchema)
147147

148148
val configWithNoMatchers = """
149149
id: "Pip::example-package:0.0.1"
@@ -156,7 +156,7 @@ class JsonSchemaTest : StringSpec({
156156

157157
"Package configuration with only vcs validates successfully" {
158158
val packageConfigurationSchema = File("../integrations/schemas/package-configuration-schema.json").toURI()
159-
val schema = schemaV7.getSchema(packageConfigurationSchema)
159+
val schema = getSchema(packageConfigurationSchema)
160160

161161
val configWithVcs = """
162162
id: "Pip::example-package:0.0.1"
@@ -172,7 +172,7 @@ class JsonSchemaTest : StringSpec({
172172

173173
"Package configuration with only source_artifact_url validates successfully" {
174174
val packageConfigurationSchema = File("../integrations/schemas/package-configuration-schema.json").toURI()
175-
val schema = schemaV7.getSchema(packageConfigurationSchema)
175+
val schema = getSchema(packageConfigurationSchema)
176176

177177
val configWithSourceArtifact = """
178178
id: "Pip::example-package:0.0.1"
@@ -186,7 +186,7 @@ class JsonSchemaTest : StringSpec({
186186

187187
"Package configuration with only source_code_origin validates successfully" {
188188
val packageConfigurationSchema = File("../integrations/schemas/package-configuration-schema.json").toURI()
189-
val schema = schemaV7.getSchema(packageConfigurationSchema)
189+
val schema = getSchema(packageConfigurationSchema)
190190

191191
val configWithSourceCodeOrigin = """
192192
id: "Pip::example-package:0.0.1"
@@ -200,7 +200,7 @@ class JsonSchemaTest : StringSpec({
200200

201201
"Package configuration with vcs and source_artifact_url fails validation" {
202202
val packageConfigurationSchema = File("../integrations/schemas/package-configuration-schema.json").toURI()
203-
val schema = schemaV7.getSchema(packageConfigurationSchema)
203+
val schema = getSchema(packageConfigurationSchema)
204204

205205
val configWithVcsAndSourceArtifact = """
206206
id: "Pip::example-package:0.0.1"
@@ -217,7 +217,7 @@ class JsonSchemaTest : StringSpec({
217217

218218
"Package configuration with vcs and source_code_origin fails validation" {
219219
val packageConfigurationSchema = File("../integrations/schemas/package-configuration-schema.json").toURI()
220-
val schema = schemaV7.getSchema(packageConfigurationSchema)
220+
val schema = getSchema(packageConfigurationSchema)
221221

222222
val configWithVcsAndSourceCodeOrigin = """
223223
id: "Pip::example-package:0.0.1"
@@ -234,7 +234,7 @@ class JsonSchemaTest : StringSpec({
234234

235235
"Package configuration with source_artifact_url and source_code_origin fails validation" {
236236
val packageConfigurationSchema = File("../integrations/schemas/package-configuration-schema.json").toURI()
237-
val schema = schemaV7.getSchema(packageConfigurationSchema)
237+
val schema = getSchema(packageConfigurationSchema)
238238

239239
val configWithSourceArtifactAndSourceCodeOrigin = """
240240
id: "Pip::example-package:0.0.1"
@@ -249,7 +249,7 @@ class JsonSchemaTest : StringSpec({
249249

250250
"Package configuration with all three matchers fails validation" {
251251
val packageConfigurationSchema = File("../integrations/schemas/package-configuration-schema.json").toURI()
252-
val schema = schemaV7.getSchema(packageConfigurationSchema)
252+
val schema = getSchema(packageConfigurationSchema)
253253

254254
val configWithAllMatchers = """
255255
id: "Pip::example-package:0.0.1"
@@ -281,4 +281,4 @@ private val repositoryConfigurationAnalyzerConfiguration =
281281
private val repositoryConfigurationPackageManagerConfiguration =
282282
File("../integrations/schemas/repository-configurations/package-manager-configuration-schema.json").toURI()
283283

284-
private fun SchemaRegistry.getSchema(uri: URI) = getSchema(uri.toURL().openStream())
284+
private fun getSchema(uri: URI) = schemaV7.getSchema(uri.toURL().openStream())

0 commit comments

Comments
 (0)