16
16
package io .fabric8 .crd .generator .types ;
17
17
18
18
import io .fabric8 .kubernetes .api .model .apiextensions .v1 .CustomResourceDefinition ;
19
+ import io .fabric8 .kubernetes .api .model .apiextensions .v1 .JSONSchemaProps ;
19
20
import io .fabric8 .kubernetes .client .utils .Serialization ;
20
21
import org .junit .jupiter .api .BeforeEach ;
21
22
import org .junit .jupiter .params .ParameterizedTest ;
22
23
import org .junit .jupiter .params .provider .Arguments ;
23
24
import org .junit .jupiter .params .provider .MethodSource ;
24
25
26
+ import java .util .Map ;
25
27
import java .util .stream .Stream ;
26
28
27
29
import static org .assertj .core .api .Assertions .assertThat ;
@@ -40,27 +42,29 @@ void setUp() {
40
42
@ ParameterizedTest (name = "{0} type maps to {1}" )
41
43
@ MethodSource ("targetTypeCases" )
42
44
void targetType (String propertyName , String expectedType ) {
43
- assertThat (crd .getSpec ().getVersions ().iterator ().next ().getSchema ().getOpenAPIV3Schema ().getProperties ())
44
- .extracting (schema -> schema .get ("spec" ).getProperties ())
45
+ Map <String , JSONSchemaProps > properties = crd .getSpec ().getVersions ().iterator ().next ().getSchema ().getOpenAPIV3Schema ()
46
+ .getProperties ().get ("spec" ).getProperties ();
47
+ assertThat (properties )
48
+ .withFailMessage ("Expected %s to be %s, but was %s" , propertyName , expectedType , properties .get (propertyName ).getType ())
45
49
.returns (expectedType , specProps -> specProps .get (propertyName ).getType ());
46
50
}
47
51
48
52
private static Stream <Arguments > targetTypeCases () {
49
53
return Stream .of (
50
54
Arguments .of ("date" , "string" ),
51
- Arguments .of ("localDate" , "object " ), // to review
52
- Arguments .of ("localDateTime" , "object " ), // to review
53
- Arguments .of ("zonedDateTime" , "object " ), // to review
54
- Arguments .of ("offsetDateTime" , "object " ), // to review
55
- Arguments .of ("offsetTime" , "object " ), // to review
56
- Arguments .of ("yearMonth" , "object " ), // to review
57
- Arguments .of ("monthDay" , "object " ), // to review
58
- Arguments .of ("instant" , "object " ), // to review
59
- Arguments .of ("duration" , "object " ), // to review
60
- Arguments .of ("period" , "object " ), // to review
61
- Arguments .of ("timestamp" , "object " ), // to review
55
+ Arguments .of ("localDate" , "array " ), // to review
56
+ Arguments .of ("localDateTime" , "array " ), // to review
57
+ Arguments .of ("zonedDateTime" , "number " ), // to review
58
+ Arguments .of ("offsetDateTime" , "number " ), // to review
59
+ Arguments .of ("offsetTime" , "array " ), // to review
60
+ Arguments .of ("yearMonth" , "array " ), // to review
61
+ Arguments .of ("monthDay" , "array " ), // to review
62
+ Arguments .of ("instant" , "number " ), // to review
63
+ Arguments .of ("duration" , "integer " ), // to review
64
+ Arguments .of ("period" , "string " ),
65
+ Arguments .of ("timestamp" , "integer " ), // to review
62
66
// Arguments.of("aShort", "integer"), // TODO: Not even present in the CRD
63
- Arguments .of ("aShortObj" , "object " ), // to review
67
+ Arguments .of ("aShortObj" , "integer " ),
64
68
Arguments .of ("aInt" , "integer" ),
65
69
Arguments .of ("aIntegerObj" , "integer" ),
66
70
Arguments .of ("aLong" , "integer" ),
@@ -69,21 +73,21 @@ private static Stream<Arguments> targetTypeCases() {
69
73
Arguments .of ("aDoubleObj" , "number" ),
70
74
Arguments .of ("aFloat" , "number" ),
71
75
Arguments .of ("aFloatObj" , "number" ),
72
- Arguments .of ("aNumber" , "object " ), // to review
73
- Arguments .of ("aBigInteger" , "object " ), // to review
74
- Arguments .of ("aBigDecimal" , "object " ), // to review
76
+ Arguments .of ("aNumber" , "number " ),
77
+ Arguments .of ("aBigInteger" , "integer " ),
78
+ Arguments .of ("aBigDecimal" , "number " ),
75
79
Arguments .of ("aBoolean" , "boolean" ),
76
80
Arguments .of ("aBooleanObj" , "boolean" ),
77
81
// Arguments.of("aChar", "string"), // TODO: Not even present in the CRD
78
- Arguments .of ("aCharacterObj" , "object " ), // to review
82
+ Arguments .of ("aCharacterObj" , "string " ),
79
83
Arguments .of ("aCharArray" , "array" ),
80
- Arguments .of ("aCharSequence" , "object " ), // to review
84
+ Arguments .of ("aCharSequence" , "string " ),
81
85
Arguments .of ("aString" , "string" ),
82
86
Arguments .of ("aStringArray" , "array" ),
83
87
// Arguments.of("aByte", "?"), // TODO: Not even present in the CRD
84
- Arguments .of ("aByteObj" , "object " ), // to review
88
+ Arguments .of ("aByteObj" , "integer " ),
85
89
Arguments .of ("aByteArray" , "array" ), // to review, should be string (base64)
86
- Arguments .of ("uuid" , "object " )); // to review, should be string
90
+ Arguments .of ("uuid" , "string " ));
87
91
}
88
92
89
93
}
0 commit comments