Search in sources :

Example 1 with JSONSchemaPropsOrBoolBuilder

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsOrBoolBuilder in project kubernetes-client by fabric8io.

the class JSONSchemaPropsOrBoolTest method itSerializesAdditionalPropertiesTyped.

@Test
void itSerializesAdditionalPropertiesTyped() throws JsonProcessingException {
    String expectedJson = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/additionalproperties_typed.json"), StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
    String outputJson = new ObjectMapper().writeValueAsString(new JSONSchemaPropsBuilder().withType("object").withAdditionalProperties(new JSONSchemaPropsOrBoolBuilder().withNewSchema().withType("string").endSchema().build()).build());
    Assertions.assertEquals(expectedJson, outputJson);
}
Also used : JSONSchemaPropsBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsBuilder) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) JSONSchemaPropsOrBoolBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsOrBoolBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 2 with JSONSchemaPropsOrBoolBuilder

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsOrBoolBuilder in project kubernetes-client by fabric8io.

the class JSONSchemaPropsOrBoolTest method itDeserializesAdditionalPropertiesTyped.

@Test
void itDeserializesAdditionalPropertiesTyped() throws IOException {
    InputStream resourceAsStream = getClass().getResourceAsStream("/additionalproperties_typed.json");
    JSONSchemaProps props = new ObjectMapper().readValue(resourceAsStream, JSONSchemaProps.class);
    Assertions.assertEquals(props, new JSONSchemaPropsBuilder().withType("object").withAdditionalProperties(new JSONSchemaPropsOrBoolBuilder().withAllows(true).withNewSchema().withType("string").endSchema().build()).build());
}
Also used : JSONSchemaPropsBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsBuilder) InputStream(java.io.InputStream) JSONSchemaProps(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaProps) JSONSchemaPropsOrBoolBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsOrBoolBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 3 with JSONSchemaPropsOrBoolBuilder

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsOrBoolBuilder in project kubernetes-client by fabric8io.

the class JSONSchemaPropsOrBoolTest method itSerializesAdditionalPropertiesTrue.

@Test
void itSerializesAdditionalPropertiesTrue() throws JsonProcessingException {
    String expectedJson = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/additionalproperties_true.json"), StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
    String outputJson = new ObjectMapper().writeValueAsString(new JSONSchemaPropsBuilder().withType("object").withAdditionalProperties(new JSONSchemaPropsOrBoolBuilder().withAllows(true).build()).build());
    Assertions.assertEquals(expectedJson, outputJson);
}
Also used : JSONSchemaPropsBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsBuilder) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) JSONSchemaPropsOrBoolBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsOrBoolBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 4 with JSONSchemaPropsOrBoolBuilder

use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsOrBoolBuilder in project kubernetes-client by fabric8io.

the class JSONSchemaPropsOrBoolTest method itDeserializesAdditionalPropertiesTrue.

@Test
void itDeserializesAdditionalPropertiesTrue() throws IOException {
    InputStream resourceAsStream = getClass().getResourceAsStream("/additionalproperties_true.json");
    JSONSchemaProps props = new ObjectMapper().readValue(resourceAsStream, JSONSchemaProps.class);
    Assertions.assertEquals(props, new JSONSchemaPropsBuilder().withType("object").withAdditionalProperties(new JSONSchemaPropsOrBoolBuilder().withAllows(true).build()).build());
}
Also used : JSONSchemaPropsBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsBuilder) InputStream(java.io.InputStream) JSONSchemaProps(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaProps) JSONSchemaPropsOrBoolBuilder(io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsOrBoolBuilder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 JSONSchemaPropsBuilder (io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsBuilder)4 JSONSchemaPropsOrBoolBuilder (io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaPropsOrBoolBuilder)4 Test (org.junit.jupiter.api.Test)4 JSONSchemaProps (io.fabric8.kubernetes.api.model.apiextensions.v1beta1.JSONSchemaProps)2 BufferedReader (java.io.BufferedReader)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2