forked from fabric8io/kubernetes-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix primitive types encoding of default values
- Loading branch information
Showing
7 changed files
with
336 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
java-generator/it/src/it/default-values-instantiation/invoker.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# Copyright (C) 2015 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
invoker.goals=test |
106 changes: 106 additions & 0 deletions
106
java-generator/it/src/it/default-values-instantiation/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2015 Red Hat, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>default-values-instantiation</artifactId> | ||
<groupId>io.fabric8.it</groupId> | ||
<version>0.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<maven.compiler.source>@maven.compiler.source@</maven.compiler.source> | ||
<maven.compiler.target>@maven.compiler.target@</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.sundr</groupId> | ||
<artifactId>sundr-adapter-reflect</artifactId> | ||
<version>@sundrio.version@</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.sundr</groupId> | ||
<artifactId>builder-annotations</artifactId> | ||
<version>@sundrio.version@</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>@lombok.version@</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>java-generator-integration-tests</artifactId> | ||
<version>@project.version@</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>generator-annotations</artifactId> | ||
<version>@project.version@</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>@junit.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>@junit.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>java-generator-maven-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>generate</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<source>src/test/resources/example.yaml</source> | ||
<generatedAnnotations>false</generatedAnnotations> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>3.0.0-M7</version> | ||
<configuration> | ||
<useFile>false</useFile> | ||
<trimStackTrace>false</trimStackTrace> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
63 changes: 63 additions & 0 deletions
63
...fault-values-instantiation/src/test/java/io/fabric8/it/certmanager/TestDefaultValues.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* Copyright (C) 2015 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.fabric8.it.certmanager; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.cert_manager.v1.CertificateRequest; | ||
import io.cert_manager.v1.certificaterequestspec.Ten; | ||
import io.fabric8.kubernetes.client.utils.Serialization; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class TestDefaultValues { | ||
|
||
@Test | ||
void testDefaultValues() throws Exception { | ||
// Arrange | ||
CertificateRequest cr = | ||
Serialization.unmarshal(getClass().getResourceAsStream("/empty.yaml"), CertificateRequest.class); | ||
|
||
// Act | ||
String one = cr.getSpec().getOne(); | ||
Boolean two = cr.getSpec().getTwo(); | ||
Integer three = cr.getSpec().getThree(); | ||
Long four = cr.getSpec().getFour(); | ||
Long five = cr.getSpec().getFive(); | ||
Float six = cr.getSpec().getSix(); | ||
Double seven = cr.getSpec().getSeven(); | ||
Double eight = cr.getSpec().getEight(); | ||
List<String> nine = cr.getSpec().getNine(); | ||
Ten ten = cr.getSpec().getTen(); | ||
|
||
// Assert | ||
assertEquals("one", one); | ||
assertEquals(true, two); | ||
assertEquals(3, three); | ||
assertEquals(4L, four); | ||
assertEquals(5L, five); | ||
assertEquals(6,1f, six); | ||
assertEquals(7.2d, seven); | ||
assertEquals(8.2d, eight); | ||
assertEquals(2, nine.size()); | ||
assertEquals("nine1", nine.get(0)); | ||
assertEquals("nine2", nine.get(1)); | ||
assertEquals("tenone", ten.getTenOne()); | ||
assertEquals("tentwo", ten.getTenTwo()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
java-generator/it/src/it/default-values-instantiation/src/test/resources/empty.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# Copyright (C) 2015 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
apiVersion: cert-manager.io/v1 | ||
kind: CertificateRequest | ||
metadata: | ||
name: my-ca-cr | ||
spec: {} |
Oops, something went wrong.