File tree Expand file tree Collapse file tree
main/java/com/retailsvc/http/spec/schema
test/java/com/retailsvc/http/spec/schema Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .retailsvc .http .spec .schema ;
2+
3+ import java .util .List ;
4+ import java .util .Set ;
5+
6+ public record AllOfSchema (List <Schema > parts ) implements Schema {
7+ @ Override
8+ public Set <TypeName > types () {
9+ return Set .of ();
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ package com .retailsvc .http .spec .schema ;
2+
3+ import java .util .List ;
4+ import java .util .Set ;
5+
6+ public record AnyOfSchema (List <Schema > options ) implements Schema {
7+ @ Override
8+ public Set <TypeName > types () {
9+ return Set .of ();
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ package com .retailsvc .http .spec .schema ;
2+
3+ import java .util .Set ;
4+
5+ public record ConstSchema (Object value ) implements Schema {
6+ @ Override
7+ public Set <TypeName > types () {
8+ return Set .of ();
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ package com .retailsvc .http .spec .schema ;
2+
3+ import java .util .List ;
4+ import java .util .Set ;
5+
6+ public record EnumSchema (List <Object > values ) implements Schema {
7+ @ Override
8+ public Set <TypeName > types () {
9+ return Set .of ();
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ package com .retailsvc .http .spec .schema ;
2+
3+ import java .util .Set ;
4+
5+ public record NotSchema (Schema schema ) implements Schema {
6+ @ Override
7+ public Set <TypeName > types () {
8+ return Set .of ();
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ package com .retailsvc .http .spec .schema ;
2+
3+ import java .util .List ;
4+ import java .util .Set ;
5+
6+ public record OneOfSchema (List <Schema > options ) implements Schema {
7+ @ Override
8+ public Set <TypeName > types () {
9+ return Set .of ();
10+ }
11+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,12 @@ public sealed interface Schema
1010 ObjectSchema ,
1111 ArraySchema ,
1212 NullSchema ,
13- RefSchema {
13+ RefSchema ,
14+ OneOfSchema ,
15+ AnyOfSchema ,
16+ AllOfSchema ,
17+ NotSchema ,
18+ ConstSchema ,
19+ EnumSchema {
1420 Set <TypeName > types ();
1521}
Original file line number Diff line number Diff line change 1+ package com .retailsvc .http .spec .schema ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import java .util .List ;
6+ import java .util .Set ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ class CombinatorScaffoldTest {
10+ private final Schema s = new BooleanSchema (Set .of (TypeName .BOOLEAN ));
11+
12+ @ Test
13+ void oneOfHoldsOptions () {
14+ assertThat (new OneOfSchema (List .of (s )).options ()).hasSize (1 );
15+ }
16+
17+ @ Test
18+ void anyOfHoldsOptions () {
19+ assertThat (new AnyOfSchema (List .of (s )).options ()).hasSize (1 );
20+ }
21+
22+ @ Test
23+ void allOfHoldsParts () {
24+ assertThat (new AllOfSchema (List .of (s )).parts ()).hasSize (1 );
25+ }
26+
27+ @ Test
28+ void notHoldsSchema () {
29+ assertThat (new NotSchema (s ).schema ()).isSameAs (s );
30+ }
31+
32+ @ Test
33+ void constHoldsValue () {
34+ assertThat (new ConstSchema ("x" ).value ()).isEqualTo ("x" );
35+ }
36+
37+ @ Test
38+ void enumHoldsValues () {
39+ assertThat (new EnumSchema (List .of (1 , 2 )).values ()).hasSize (2 );
40+ }
41+
42+ @ Test
43+ void allCombinatorsTypesEmpty () {
44+ assertThat (new OneOfSchema (List .of (s )).types ()).isEmpty ();
45+ assertThat (new ConstSchema ("x" ).types ()).isEmpty ();
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments