1616package io .fabric8 .crd .generator .types ;
1717
1818import io .fabric8 .kubernetes .api .model .apiextensions .v1 .CustomResourceDefinition ;
19+ import io .fabric8 .kubernetes .api .model .apiextensions .v1 .JSONSchemaProps ;
1920import io .fabric8 .kubernetes .client .utils .Serialization ;
2021import org .junit .jupiter .api .BeforeEach ;
2122import org .junit .jupiter .params .ParameterizedTest ;
2223import org .junit .jupiter .params .provider .Arguments ;
2324import org .junit .jupiter .params .provider .MethodSource ;
2425
26+ import java .util .Map ;
2527import java .util .stream .Stream ;
2628
2729import static org .assertj .core .api .Assertions .assertThat ;
@@ -40,27 +42,29 @@ void setUp() {
4042 @ ParameterizedTest (name = "{0} type maps to {1}" )
4143 @ MethodSource ("targetTypeCases" )
4244 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 ())
4549 .returns (expectedType , specProps -> specProps .get (propertyName ).getType ());
4650 }
4751
4852 private static Stream <Arguments > targetTypeCases () {
4953 return Stream .of (
5054 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
6266 // Arguments.of("aShort", "integer"), // TODO: Not even present in the CRD
63- Arguments .of ("aShortObj" , "object " ), // to review
67+ Arguments .of ("aShortObj" , "integer " ),
6468 Arguments .of ("aInt" , "integer" ),
6569 Arguments .of ("aIntegerObj" , "integer" ),
6670 Arguments .of ("aLong" , "integer" ),
@@ -69,21 +73,21 @@ private static Stream<Arguments> targetTypeCases() {
6973 Arguments .of ("aDoubleObj" , "number" ),
7074 Arguments .of ("aFloat" , "number" ),
7175 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 " ),
7579 Arguments .of ("aBoolean" , "boolean" ),
7680 Arguments .of ("aBooleanObj" , "boolean" ),
7781 // Arguments.of("aChar", "string"), // TODO: Not even present in the CRD
78- Arguments .of ("aCharacterObj" , "object " ), // to review
82+ Arguments .of ("aCharacterObj" , "string " ),
7983 Arguments .of ("aCharArray" , "array" ),
80- Arguments .of ("aCharSequence" , "object " ), // to review
84+ Arguments .of ("aCharSequence" , "string " ),
8185 Arguments .of ("aString" , "string" ),
8286 Arguments .of ("aStringArray" , "array" ),
8387 // Arguments.of("aByte", "?"), // TODO: Not even present in the CRD
84- Arguments .of ("aByteObj" , "object " ), // to review
88+ Arguments .of ("aByteObj" , "integer " ),
8589 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 " ));
8791 }
8892
8993}
0 commit comments