Skip to content

Commit 767a113

Browse files
committed
clean up deprecated
1 parent c639b39 commit 767a113

3 files changed

Lines changed: 29 additions & 30 deletions

File tree

json-schema-validator/src/main/java/io/openapiprocessor/jsonschema/schema/Bucket.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import java.util.function.BiConsumer;
1616
import java.util.function.Consumer;
1717

18-
import static io.openapiprocessor.jsonschema.schema.UriSupport.emptyUri;
1918
import static io.openapiprocessor.jsonschema.support.Nullness.nonNull;
2019

2120
/**
@@ -27,7 +26,7 @@ public class Bucket {
2726
private final Map<String, Object> properties;
2827

2928
public static Bucket empty() {
30-
return new Bucket (Collections.emptyMap ());
29+
return createBucket(Scope.empty(), Collections.emptyMap());
3130
}
3231

3332
public static @Nullable Bucket createBucket(Scope scope, @Nullable Object source) {
@@ -50,13 +49,6 @@ public static Bucket createBucket(Scope scope, Map<String, Object> source) {
5049
return new Bucket (scope, Types.asObject (source));
5150
}
5251

53-
@Deprecated // myself and tests
54-
public Bucket (Map<String, Object> properties) {
55-
this.scope = Scope.createScope(emptyUri());
56-
this.location = JsonPointer.EMPTY;
57-
this.properties = properties; // unmodifiable?
58-
}
59-
6052
/**
6153
* create a document "root" bucket with an empty location.
6254
*

openapi-parser/src/test/kotlin/io/openapiparser/PropertiesSpec.kt

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import io.openapiprocessor.jsonschema.schema.Bucket
1919
import io.openapiprocessor.jsonschema.schema.Bucket.createBucket
2020
import io.openapiprocessor.jsonschema.schema.SchemaVersion
2121
import io.openapiprocessor.jsonschema.schema.Scope
22-
import io.openapiprocessor.jsonschema.schema.Scope.empty
23-
import java.net.URI
22+
import io.openapiprocessor.jsonschema.schema.Scope.createScope
23+
import io.openapiprocessor.jsonschema.schema.UriSupport.createUri
2424

2525
class PropertiesSpec: StringSpec({
2626
@Suppress("UNUSED_PARAMETER")
@@ -34,7 +34,7 @@ class PropertiesSpec: StringSpec({
3434
}
3535

3636
"get raw value" {
37-
val bucket = createBucket(empty(), linkedMapOf<String, Any>("foo" to "bar"))
37+
val bucket = createBucket(Scope.empty(), linkedMapOf<String, Any>("foo" to "bar"))
3838
Properties(mockk(), bucket).getRawValue("foo").shouldBe("bar")
3939
}
4040

@@ -46,18 +46,18 @@ class PropertiesSpec: StringSpec({
4646
}
4747

4848
"gets object" {
49-
val bucket = createBucket(empty(), linkedMapOf<String, Any>("foo" to mapOf<String, Any>()))
49+
val bucket = createBucket(Scope.empty(), linkedMapOf<String, Any>("foo" to mapOf<String, Any>()))
5050

51-
val scope = Scope.createScope(URI.create("https://foo"), bucket.rawValues, anyVersion)
51+
val scope = createScope(createUri("https://foo"), bucket.rawValues, anyVersion)
5252
val props = Properties(Context(scope, mockk()), bucket)
5353

5454
props.getObjectOrNull("foo", DummyObject::class.java).shouldBeInstanceOf<DummyObject>()
5555
}
5656

5757
"gets object throws if value is not an object" {
58-
val bucket = createBucket(empty(), linkedMapOf<String, Any>("foo" to "no object"))!!
58+
val bucket = createBucket(Scope.empty(), linkedMapOf<String, Any>("foo" to "no object"))
5959

60-
val scope = Scope.createScope(URI.create("https://foo"), bucket.rawValues, anyVersion)
60+
val scope = createScope(createUri("https://foo"), bucket.rawValues, anyVersion)
6161
val props = Properties(Context(scope, mockk()), bucket)
6262

6363
shouldThrow<TypeMismatchException> {
@@ -82,7 +82,8 @@ class PropertiesSpec: StringSpec({
8282
}
8383

8484
"get objects array" {
85-
val bucket = Bucket(
85+
val bucket = createBucket(
86+
Scope.empty(),
8687
linkedMapOf<String, Any>(
8788
"property" to listOf(
8889
mapOf<String, Any>("foo" to "bar"),
@@ -91,14 +92,15 @@ class PropertiesSpec: StringSpec({
9192
)
9293
)
9394

94-
val scope = Scope.createScope(URI.create("https://foo"), bucket.rawValues, anyVersion)
95+
val scope = createScope(createUri("https://foo"), bucket.rawValues, anyVersion)
9596
val props = Properties(Context(scope, mockk()), bucket)
9697

9798
props.getObjectsOrEmpty("property", DummyObject::class.java).size shouldBe 2
9899
}
99100

100101
"get objects array throws if any value is not an object" {
101-
val bucket = Bucket(
102+
val bucket = createBucket(
103+
Scope.empty(),
102104
linkedMapOf<String, Any>(
103105
"property" to listOf(
104106
mapOf<String, Any>("foo" to "bar"),
@@ -107,7 +109,7 @@ class PropertiesSpec: StringSpec({
107109
)
108110
)
109111

110-
val scope = Scope.createScope(URI.create("https://foo"), bucket.rawValues, anyVersion)
112+
val scope = createScope(createUri("https://foo"), bucket.rawValues, anyVersion)
111113
val props = Properties(Context(scope, mockk()), bucket)
112114

113115
shouldThrow<TypeMismatchException> {
@@ -116,7 +118,8 @@ class PropertiesSpec: StringSpec({
116118
}
117119

118120
"get extension values" {
119-
val bucket = Bucket(
121+
val bucket = createBucket(
122+
Scope.empty(),
120123
linkedMapOf<String, Any>(
121124
"property" to "foo",
122125
"x-foo" to "foo extension",
@@ -131,7 +134,8 @@ class PropertiesSpec: StringSpec({
131134
}
132135

133136
"gets empty extension values if there are no extensions" {
134-
val bucket = Bucket(
137+
val bucket = createBucket(
138+
Scope.empty(),
135139
linkedMapOf<String, Any>(
136140
"property" to "foo",
137141
)

openapi-parser/src/test/kotlin/io/openapiparser/PropertiesStringSpec.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import io.mockk.mockk
1414
import io.openapiprocessor.jsonschema.converter.NoValueException
1515
import io.openapiprocessor.jsonschema.converter.TypeMismatchException
1616
import io.openapiprocessor.jsonschema.schema.Bucket
17+
import io.openapiprocessor.jsonschema.schema.Bucket.createBucket
18+
import io.openapiprocessor.jsonschema.schema.Scope
1719

1820
class PropertiesStringSpec: StringSpec({
1921

@@ -24,14 +26,13 @@ class PropertiesStringSpec: StringSpec({
2426
}
2527

2628
"gets string" {
27-
val bucket =
28-
Bucket(linkedMapOf<String, Any>("property" to "foo"))
29+
val bucket = createBucket(Scope.empty(), linkedMapOf<String, Any>("property" to "foo"))
2930
Properties(mockk(), bucket).getStringOrThrow("property") shouldBe "foo"
3031
}
3132

3233
"get string throws if value is not a string" {
33-
val bucket =
34-
Bucket(linkedMapOf<String, Any>("property" to 1))
34+
val bucket = createBucket(Scope.empty(), linkedMapOf<String, Any>("property" to 1))
35+
3536
shouldThrow<TypeMismatchException> {
3637
Properties(mockk(), bucket).getStringOrThrow("property")
3738
}
@@ -50,7 +51,8 @@ class PropertiesStringSpec: StringSpec({
5051
}
5152

5253
"gets nullable string array" {
53-
val bucket = Bucket(
54+
val bucket = createBucket(
55+
Scope.empty(),
5456
linkedMapOf<String, Any>(
5557
"property" to listOf(
5658
"foo",
@@ -67,7 +69,8 @@ class PropertiesStringSpec: StringSpec({
6769
}
6870

6971
"gets string array" {
70-
val bucket = Bucket(
72+
val bucket = createBucket(
73+
Scope.empty(),
7174
linkedMapOf<String, Any>(
7275
"property" to listOf(
7376
"foo",
@@ -81,7 +84,8 @@ class PropertiesStringSpec: StringSpec({
8184

8285
// todo
8386
"gets string array throws if values are not strings".config(enabled = false) {
84-
val bucket = Bucket(
87+
val bucket = createBucket(
88+
Scope.empty(),
8589
linkedMapOf<String, Any>(
8690
"property" to listOf(
8791
1,
@@ -94,5 +98,4 @@ class PropertiesStringSpec: StringSpec({
9498
Properties(mockk(), bucket).getStringsOrNull("property")
9599
}
96100
}
97-
98101
})

0 commit comments

Comments
 (0)