diff --git a/Makefile b/Makefile
index 4b48afa0e88..9ab5c04eb6a 100644
--- a/Makefile
+++ b/Makefile
@@ -40,6 +40,8 @@ openapi-generate-schema:
.PHONY: openapi-generate-java-classes
openapi-generate-java-classes:
+ # Test dependency needed for model de/serialization validation
+ mvn $(MAVEN_ARGS) clean install -pl . -pl zjsonpatch
cd kubernetes-model-generator && mvn $(MAVEN_ARGS) -Pgenerate clean install
# TODO: run generate from extensions module root once all extensions are migrated
cd extensions && mvn $(MAVEN_ARGS) -N clean install
diff --git a/java-generator/it/src/main/java/io/fabric8/java/generator/testing/KubernetesResourceDiff.java b/java-generator/it/src/main/java/io/fabric8/java/generator/testing/KubernetesResourceDiff.java
index 05bbadd7bc3..6ff04ad18a5 100644
--- a/java-generator/it/src/main/java/io/fabric8/java/generator/testing/KubernetesResourceDiff.java
+++ b/java-generator/it/src/main/java/io/fabric8/java/generator/testing/KubernetesResourceDiff.java
@@ -40,7 +40,7 @@ public class KubernetesResourceDiff {
private final String source1;
private final String source2;
- private ObjectMapper yamlMapper = new ObjectMapper(
+ private final ObjectMapper yamlMapper = new ObjectMapper(
new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
public KubernetesResourceDiff(String source1, String source2) {
diff --git a/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1/ConversionReviewTest.java b/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1/ConversionReviewTest.java
index 6f2887987f5..9ecdda68471 100644
--- a/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1/ConversionReviewTest.java
+++ b/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1/ConversionReviewTest.java
@@ -17,28 +17,24 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.Test;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
class ConversionReviewTest {
- private final ObjectMapper objectMapper = new ObjectMapper();
+ private final ObjectMapper mapper = new ObjectMapper();
@Test
void testDeserializationAndSerialization() throws Exception {
// Given
final String originalJson = Helper.loadJson("/valid-conversionreview.json");
-
- // when
- final ConversionReview conversionReview = objectMapper.readValue(originalJson, ConversionReview.class);
- final String serializedJson = objectMapper.writeValueAsString(conversionReview);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ final ConversionReview conversionReview = mapper.readValue(originalJson, ConversionReview.class);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson),
+ mapper.readTree(mapper.writeValueAsString(conversionReview)));
+ // Then
+ assertThat(diff).isEmpty();
}
-};
+}
diff --git a/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1/CustomResourceDefinitionTest.java b/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1/CustomResourceDefinitionTest.java
index 4a948c924a5..21e916854d2 100644
--- a/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1/CustomResourceDefinitionTest.java
+++ b/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1/CustomResourceDefinitionTest.java
@@ -18,22 +18,18 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.Test;
import java.util.Map;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
import static org.assertj.core.api.Assertions.as;
-import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
class CustomResourceDefinitionTest {
- private final ObjectMapper objectMapper = new ObjectMapper();
+ private final ObjectMapper mapper = new ObjectMapper();
@Test
void testBuilder() {
@@ -69,65 +65,51 @@ void testBuilder() {
void testLoadFromJsonSchemaPropsOrBool() throws JsonProcessingException {
// Given
final String originalJson = Helper.loadJson("/valid-v1-crd.json");
-
- // when
- final CustomResourceDefinition customResourceDefinition = objectMapper.readValue(originalJson,
+ final CustomResourceDefinition customResourceDefinition = mapper.readValue(originalJson,
CustomResourceDefinition.class);
- final String serializedJson = objectMapper.writeValueAsString(customResourceDefinition);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson),
+ mapper.readTree(mapper.writeValueAsString(customResourceDefinition)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
void testLoadFromJsonSchemaPropsOrArray() throws JsonProcessingException {
// Given
- String jsonString = Helper.loadJson("/valid-crd-jsonschemapropsorarray.json");
-
+ final String originalJson = Helper.loadJson("/valid-crd-jsonschemapropsorarray.json");
+ final CustomResourceDefinition result = mapper.readValue(originalJson, CustomResourceDefinition.class);
// When
- CustomResourceDefinition result = objectMapper.readValue(jsonString, CustomResourceDefinition.class);
- final String serializedJson = objectMapper.writeValueAsString(result);
-
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(result)));
// Then
- assertNotNull(result);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(jsonString);
+ assertThat(diff).isEmpty();
}
@Test
void testLoadFromJsonSchemaPropsOrStringArray() throws JsonProcessingException {
// Given
- String jsonString = Helper.loadJson("/valid-crd-jsonschemapropsorstringarray.json");
-
+ final String originalJson = Helper.loadJson("/valid-crd-jsonschemapropsorstringarray.json");
+ final CustomResourceDefinition result = mapper.readValue(originalJson, CustomResourceDefinition.class);
// When
- CustomResourceDefinition result = objectMapper.readValue(jsonString, CustomResourceDefinition.class);
- final String serializedJson = objectMapper.writeValueAsString(result);
-
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(result)));
// Then
- assertNotNull(result);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(jsonString);
+ assertThat(diff).isEmpty();
}
@Test
void testLoadFromCrdWithValidationExpressionLanguage() throws JsonProcessingException {
// Given
- String jsonString = Helper.loadJson("/valid-v1-crd-validation-expression.json");
-
+ final String originalJson = Helper.loadJson("/valid-v1-crd-validation-expression.json");
+ final CustomResourceDefinition result = mapper.readValue(originalJson, CustomResourceDefinition.class);
// When
- CustomResourceDefinition result = objectMapper.readValue(jsonString, CustomResourceDefinition.class);
-
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(result)));
// Then
+ assertThat(diff).isEmpty();
assertThat(result)
.extracting(CustomResourceDefinition::getSpec)
.extracting(CustomResourceDefinitionSpec::getVersions)
- .asList()
- .singleElement(InstanceOfAssertFactories.type(CustomResourceDefinitionVersion.class))
+ .asInstanceOf(InstanceOfAssertFactories.list(CustomResourceDefinitionVersion.class))
+ .singleElement()
.extracting(CustomResourceDefinitionVersion::getSchema)
.extracting(CustomResourceValidation::getOpenAPIV3Schema)
.extracting(JSONSchemaProps::getProperties, as(InstanceOfAssertFactories.type(Map.class)))
diff --git a/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1beta1/CustomResourceDefinitionTest.java b/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1beta1/CustomResourceDefinitionTest.java
index b60547a17ff..8cd6c4111b5 100644
--- a/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1beta1/CustomResourceDefinitionTest.java
+++ b/kubernetes-model-generator/kubernetes-model-apiextensions/src/test/java/io/fabric8/kubernetes/api/model/apiextensions/v1beta1/CustomResourceDefinitionTest.java
@@ -18,19 +18,16 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
+import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
class CustomResourceDefinitionTest {
- private final ObjectMapper objectMapper = new ObjectMapper();
+ private final ObjectMapper mapper = new ObjectMapper();
@Test
public void testBuilder() {
@@ -68,48 +65,34 @@ public void testBuilder() {
void testLoadFromJsonSchemaPropsOrBool() throws JsonProcessingException {
// Given
final String originalJson = Helper.loadJson("/valid-crd.json");
-
- // when
- final CustomResourceDefinition customResourceDefinition = objectMapper.readValue(originalJson,
+ final CustomResourceDefinition customResourceDefinition = mapper.readValue(originalJson,
CustomResourceDefinition.class);
- final String serializedJson = objectMapper.writeValueAsString(customResourceDefinition);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson),
+ mapper.readTree(mapper.writeValueAsString(customResourceDefinition)));
+ // Then
+ Assertions.assertThat(diff).isEmpty();
}
@Test
void testLoadFromJsonSchemaPropsOrArray() throws JsonProcessingException {
// Given
- String jsonString = Helper.loadJson("/valid-crd-jsonschemapropsorarray.json");
-
+ final String originalJson = Helper.loadJson("/valid-crd-jsonschemapropsorarray.json");
+ final CustomResourceDefinition result = mapper.readValue(originalJson, CustomResourceDefinition.class);
// When
- CustomResourceDefinition result = objectMapper.readValue(jsonString, CustomResourceDefinition.class);
- final String serializedJson = objectMapper.writeValueAsString(result);
-
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(result)));
// Then
- assertNotNull(result);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(jsonString);
+ Assertions.assertThat(diff).isEmpty();
}
@Test
void testLoadFromJsonSchemaPropsOrStringArray() throws JsonProcessingException {
// Given
- String jsonString = Helper.loadJson("/valid-crd-jsonschemapropsorstringarray.json");
-
+ String originalJson = Helper.loadJson("/valid-crd-jsonschemapropsorstringarray.json");
+ CustomResourceDefinition result = mapper.readValue(originalJson, CustomResourceDefinition.class);
// When
- CustomResourceDefinition result = objectMapper.readValue(jsonString, CustomResourceDefinition.class);
- final String serializedJson = objectMapper.writeValueAsString(result);
-
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(result)));
// Then
- assertNotNull(result);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(jsonString);
+ Assertions.assertThat(diff).isEmpty();
}
}
diff --git a/kubernetes-model-generator/kubernetes-model-apps/src/test/java/io/fabric8/kubernetes/api/model/apps/DeploymentTest.java b/kubernetes-model-generator/kubernetes-model-apps/src/test/java/io/fabric8/kubernetes/api/model/apps/DeploymentTest.java
index 72f10a10b26..ff20aac0d00 100644
--- a/kubernetes-model-generator/kubernetes-model-apps/src/test/java/io/fabric8/kubernetes/api/model/apps/DeploymentTest.java
+++ b/kubernetes-model-generator/kubernetes-model-apps/src/test/java/io/fabric8/kubernetes/api/model/apps/DeploymentTest.java
@@ -22,15 +22,13 @@
import io.fabric8.kubernetes.api.model.Quantity;
import io.fabric8.kubernetes.api.model.VolumeMount;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -42,16 +40,13 @@ class DeploymentTest {
@Test
void kubernetesDeploymentTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-deployment.json");
-
- // when
final Deployment deployment = mapper.readValue(originalJson, Deployment.class);
- final String serializedJson = mapper.writeValueAsString(deployment);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(deployment)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
diff --git a/kubernetes-model-generator/kubernetes-model-core/pom.xml b/kubernetes-model-generator/kubernetes-model-core/pom.xml
index ce754f23bfa..3ca977ada90 100644
--- a/kubernetes-model-generator/kubernetes-model-core/pom.xml
+++ b/kubernetes-model-generator/kubernetes-model-core/pom.xml
@@ -123,11 +123,6 @@
mockito-core
test
-
- org.assertj
- assertj-core
- test
-
diff --git a/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/ConfigMapTest.java b/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/ConfigMapTest.java
index 6e46be1f9dc..3c4945e6340 100644
--- a/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/ConfigMapTest.java
+++ b/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/ConfigMapTest.java
@@ -17,15 +17,13 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -40,16 +38,13 @@ void setUp() {
@Test
void configMapTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-configMap.json");
-
- // when
final ConfigMap configMap = mapper.readValue(originalJson, ConfigMap.class);
- final String serializedJson = mapper.writeValueAsString(configMap);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(configMap)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
diff --git a/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/EventTest.java b/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/EventTest.java
index b2b48643544..12107d8cde3 100644
--- a/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/EventTest.java
+++ b/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/EventTest.java
@@ -18,13 +18,11 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
class EventTest {
@@ -37,15 +35,12 @@ void setUp() {
@Test
void testEventSerializationDeserialization() throws JsonProcessingException {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-event.json");
-
- // when
final Event event = mapper.readValue(originalJson, Event.class);
- final String serializedJson = mapper.writeValueAsString(event);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(event)));
+ // Then
+ assertThat(diff).isEmpty();
}
}
diff --git a/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/KubernetesListTest.java b/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/KubernetesListTest.java
index fd48ed17089..97e3774f9c5 100644
--- a/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/KubernetesListTest.java
+++ b/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/KubernetesListTest.java
@@ -15,10 +15,9 @@
*/
package io.fabric8.kubernetes.api.model;
-import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -60,8 +59,8 @@ void testDefaultValues() {
assertNotNull(kubernetesList.getApiVersion());
assertEquals("v1", kubernetesList.getApiVersion());
assertEquals("List", kubernetesList.getKind());
- assertThat(kubernetesList.getItems(), CoreMatchers.hasItem(service));
- assertThat(kubernetesList.getItems(), CoreMatchers.hasItem(replicationController));
+ assertThat(kubernetesList.getItems())
+ .contains(service, replicationController);
}
@Test
diff --git a/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/SecretTest.java b/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/SecretTest.java
index ad3e3a492e5..1241a44d213 100644
--- a/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/SecretTest.java
+++ b/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/SecretTest.java
@@ -17,15 +17,13 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -40,16 +38,13 @@ void setUp() {
@Test
void secretTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-secret.json");
-
- // when
final Secret secret = mapper.readValue(originalJson, Secret.class);
- final String serializedJson = mapper.writeValueAsString(secret);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(secret)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
diff --git a/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/ServiceTest.java b/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/ServiceTest.java
index f0fe0b818cd..b507619cc45 100644
--- a/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/ServiceTest.java
+++ b/kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/ServiceTest.java
@@ -17,13 +17,11 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -38,16 +36,13 @@ void setUp() {
@Test
void serviceTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-service.json");
-
- // when
final Service service = mapper.readValue(originalJson, Service.class);
- final String serializedJson = mapper.writeValueAsString(service);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(service)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
diff --git a/kubernetes-model-generator/kubernetes-model-discovery/src/test/java/io/fabric8/kubernetes/api/model/discovery/v1beta1/EndpointSliceTest.java b/kubernetes-model-generator/kubernetes-model-discovery/src/test/java/io/fabric8/kubernetes/api/model/discovery/v1beta1/EndpointSliceTest.java
index 2a2644ef9c4..e6808e09103 100644
--- a/kubernetes-model-generator/kubernetes-model-discovery/src/test/java/io/fabric8/kubernetes/api/model/discovery/v1beta1/EndpointSliceTest.java
+++ b/kubernetes-model-generator/kubernetes-model-discovery/src/test/java/io/fabric8/kubernetes/api/model/discovery/v1beta1/EndpointSliceTest.java
@@ -17,12 +17,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.Test;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
class EndpointSliceTest {
@@ -30,21 +28,18 @@ class EndpointSliceTest {
@Test
void loadTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-endpointslice.json");
-
- // when
final EndpointSlice endpointSlice = mapper.readValue(originalJson, EndpointSlice.class);
- final String serializedJson = mapper.writeValueAsString(endpointSlice);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(endpointSlice)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
void testBuilder() {
- // Given + When
+ // Given + When
EndpointSlice endpointSlice = new EndpointSliceBuilder()
.withNewMetadata()
.withName("example-abc")
diff --git a/kubernetes-model-generator/kubernetes-model-rbac/src/test/java/io/fabric8/kubernetes/api/model/rbac/RoleBindingTest.java b/kubernetes-model-generator/kubernetes-model-rbac/src/test/java/io/fabric8/kubernetes/api/model/rbac/RoleBindingTest.java
index 325bc1292a8..e7fc5ad4ebb 100644
--- a/kubernetes-model-generator/kubernetes-model-rbac/src/test/java/io/fabric8/kubernetes/api/model/rbac/RoleBindingTest.java
+++ b/kubernetes-model-generator/kubernetes-model-rbac/src/test/java/io/fabric8/kubernetes/api/model/rbac/RoleBindingTest.java
@@ -17,12 +17,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.Test;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
public class RoleBindingTest {
@@ -30,26 +28,21 @@ public class RoleBindingTest {
@Test
public void kubernetesRoleBindingTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-roleBinding.json");
-
- // when
final RoleBinding kubernetesRoleBinding = mapper.readValue(originalJson, RoleBinding.class);
- final String serializedJson = mapper.writeValueAsString(kubernetesRoleBinding);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson),
+ mapper.readTree(mapper.writeValueAsString(kubernetesRoleBinding)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
public void kubernetesRoleBuilderTest() throws Exception {
-
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-roleBinding.json");
-
- // when
- RoleBinding kubernetesRoleBinding = new RoleBindingBuilder()
+ final RoleBinding kubernetesRoleBinding = new RoleBindingBuilder()
.withNewMetadata()
.withName("read-jobs")
.withNamespace("default")
@@ -66,12 +59,11 @@ public void kubernetesRoleBuilderTest() throws Exception {
.withName("job-reader")
.build())
.build();
-
- final String serializedJson = mapper.writeValueAsString(kubernetesRoleBinding);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson),
+ mapper.readTree(mapper.writeValueAsString(kubernetesRoleBinding)));
+ // Then
+ assertThat(diff).isEmpty();
}
}
diff --git a/kubernetes-model-generator/kubernetes-model-rbac/src/test/java/io/fabric8/kubernetes/api/model/rbac/RoleTest.java b/kubernetes-model-generator/kubernetes-model-rbac/src/test/java/io/fabric8/kubernetes/api/model/rbac/RoleTest.java
index 6e0891d427d..afd79d74205 100644
--- a/kubernetes-model-generator/kubernetes-model-rbac/src/test/java/io/fabric8/kubernetes/api/model/rbac/RoleTest.java
+++ b/kubernetes-model-generator/kubernetes-model-rbac/src/test/java/io/fabric8/kubernetes/api/model/rbac/RoleTest.java
@@ -17,12 +17,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.Test;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
public class RoleTest {
@@ -30,26 +28,20 @@ public class RoleTest {
@Test
public void kubernetesRoleTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-role.json");
-
- // when
final Role kubernetesRole = mapper.readValue(originalJson, Role.class);
- final String serializedJson = mapper.writeValueAsString(kubernetesRole);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(kubernetesRole)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
public void kubernetesRoleBuilderTest() throws Exception {
-
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-role.json");
-
- // when
- Role kubernetesRole = new RoleBuilder()
+ final Role kubernetesRole = new RoleBuilder()
.withNewMetadata()
.withName("job-reader")
.withNamespace("default")
@@ -64,12 +56,9 @@ public void kubernetesRoleBuilderTest() throws Exception {
.addToVerbs(2, "list")
.build())
.build();
-
- final String serializedJson = mapper.writeValueAsString(kubernetesRole);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
-
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(kubernetesRole)));
+ // Then
+ assertThat(diff).isEmpty();
}
}
diff --git a/kubernetes-model-generator/openshift-model-operator/src/test/java/io/fabric8/openshift/api/model/operator/network/v1/EgressRouterTest.java b/kubernetes-model-generator/openshift-model-operator/src/test/java/io/fabric8/openshift/api/model/operator/network/v1/EgressRouterTest.java
index 61f35e23b13..eb1071c769c 100644
--- a/kubernetes-model-generator/openshift-model-operator/src/test/java/io/fabric8/openshift/api/model/operator/network/v1/EgressRouterTest.java
+++ b/kubernetes-model-generator/openshift-model-operator/src/test/java/io/fabric8/openshift/api/model/operator/network/v1/EgressRouterTest.java
@@ -17,14 +17,12 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.model.util.Helper;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.Test;
import java.io.IOException;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -35,14 +33,11 @@ class EgressRouterTest {
void deserializationAndSerializationShouldWorkAsExpected() throws IOException {
// Given
final String originalJson = Helper.loadJson("/valid-egressrouter.json");
-
- // When
final EgressRouter egressRouter = mapper.readValue(originalJson, EgressRouter.class);
- final String serializedJson = mapper.writeValueAsString(egressRouter);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(egressRouter)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
diff --git a/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/BuildConfigTest.java b/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/BuildConfigTest.java
index 44dd3c063b4..a13806e159d 100644
--- a/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/BuildConfigTest.java
+++ b/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/BuildConfigTest.java
@@ -31,14 +31,12 @@
import io.fabric8.openshift.api.model.SourceBuildStrategyBuilder;
import io.fabric8.openshift.api.model.SourceControlUserBuilder;
import io.fabric8.openshift.api.model.WebHookTriggerBuilder;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -49,16 +47,13 @@ public class BuildConfigTest {
@Test
public void buildConfigTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-buildConfig.json");
-
- // when
final BuildConfig buildConfig = mapper.readValue(originalJson, BuildConfig.class);
- final String serializedJson = mapper.writeValueAsString(buildConfig);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(buildConfig)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
diff --git a/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/ImageStreamImportTest.java b/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/ImageStreamImportTest.java
index abbba0ffa0a..499a05bd7cd 100644
--- a/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/ImageStreamImportTest.java
+++ b/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/ImageStreamImportTest.java
@@ -19,39 +19,32 @@
import io.fabric8.openshift.api.model.ImageImportSpecBuilder;
import io.fabric8.openshift.api.model.ImageStreamImport;
import io.fabric8.openshift.api.model.ImageStreamImportBuilder;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
public class ImageStreamImportTest {
private final ObjectMapper mapper = new ObjectMapper();
@Test
public void imageStreamImportTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-imagestreamimport.json");
-
- // when
final ImageStreamImport imageStreamImport = mapper.readValue(originalJson, ImageStreamImport.class);
- final String serializedJson = mapper.writeValueAsString(imageStreamImport);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson),
+ mapper.readTree(mapper.writeValueAsString(imageStreamImport)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
public void imageStreamImportBuilderTest() throws Exception {
-
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-imagestreamimport.json");
-
- // when
ImageStreamImport imageStreamImport = new ImageStreamImportBuilder()
.withNewMetadata()
.withName("test-isi")
@@ -93,12 +86,10 @@ public void imageStreamImportBuilderTest() throws Exception {
.endRepository()
.endSpec()
.build();
-
- final String serializedJson = mapper.writeValueAsString(imageStreamImport);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
-
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson),
+ mapper.readTree(mapper.writeValueAsString(imageStreamImport)));
+ // Then
+ assertThat(diff).isEmpty();
}
}
diff --git a/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/ImageStreamTagTest.java b/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/ImageStreamTagTest.java
index 46a44ed0125..9480a5d957f 100644
--- a/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/ImageStreamTagTest.java
+++ b/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/ImageStreamTagTest.java
@@ -22,12 +22,10 @@
import io.fabric8.openshift.api.model.ImageLookupPolicyBuilder;
import io.fabric8.openshift.api.model.ImageStreamTagBuilder;
import io.fabric8.openshift.api.model.TagReferenceBuilder;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.Test;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -38,16 +36,13 @@ public class ImageStreamTagTest {
@Test
public void imageStreamTagTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-ist.json");
-
- // when
final ImageStreamTag ist = mapper.readValue(originalJson, ImageStreamTag.class);
- final String serializedJson = mapper.writeValueAsString(ist);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(ist)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
@@ -123,7 +118,6 @@ public void imageStreamTagBuilderTest() {
assertEquals("jenkins-slave", ist.getTag().getAnnotations().get("role"));
assertEquals("jenkins-slave", ist.getTag().getAnnotations().get("slave-label"));
assertEquals("Source", ist.getTag().getReferencePolicy().getType());
-
}
}
diff --git a/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/RouteTest.java b/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/RouteTest.java
index 64beec5136b..b1bdc49f5c5 100644
--- a/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/RouteTest.java
+++ b/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/kubernetes/api/model/RouteTest.java
@@ -19,12 +19,10 @@
import io.fabric8.openshift.api.model.Route;
import io.fabric8.openshift.api.model.RouteBuilder;
import io.fabric8.openshift.api.model.RouteTargetReferenceBuilder;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.Test;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -34,16 +32,13 @@ public class RouteTest {
@Test
public void routeTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-route.json");
-
- // when
final Route route = mapper.readValue(originalJson, Route.class);
- final String serializedJson = mapper.writeValueAsString(route);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT, IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson), mapper.readTree(mapper.writeValueAsString(route)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
diff --git a/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/openshift/api/model/DeploymentConfigRollbackTest.java b/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/openshift/api/model/DeploymentConfigRollbackTest.java
index 1bd6fca2d20..4489b6a239d 100644
--- a/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/openshift/api/model/DeploymentConfigRollbackTest.java
+++ b/kubernetes-model-generator/openshift-model/src/test/java/io/fabric8/openshift/api/model/DeploymentConfigRollbackTest.java
@@ -18,15 +18,13 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fabric8.kubernetes.api.model.Helper;
import io.fabric8.kubernetes.api.model.ObjectReferenceBuilder;
+import io.fabric8.zjsonpatch.JsonDiff;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
-import static net.javacrumbs.jsonunit.core.Option.IGNORING_EXTRA_FIELDS;
-import static net.javacrumbs.jsonunit.core.Option.TREATING_NULL_AS_ABSENT;
-import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
+import static org.assertj.core.api.Assertions.assertThat;
class DeploymentConfigRollbackTest {
@@ -34,18 +32,15 @@ class DeploymentConfigRollbackTest {
@Test
void deploymentConfigRollbackTest() throws Exception {
- // given
+ // Given
final String originalJson = Helper.loadJson("/valid-deploymentConfigRollback.json");
-
- // when
final DeploymentConfigRollback deploymentConfigRollback = mapper.readValue(originalJson,
DeploymentConfigRollback.class);
- final String serializedJson = mapper.writeValueAsString(deploymentConfigRollback);
-
- // then
- assertThatJson(serializedJson).when(IGNORING_ARRAY_ORDER, TREATING_NULL_AS_ABSENT,
- IGNORING_EXTRA_FIELDS)
- .isEqualTo(originalJson);
+ // When
+ final var diff = JsonDiff.asJson(mapper.readTree(originalJson),
+ mapper.readTree(mapper.writeValueAsString(deploymentConfigRollback)));
+ // Then
+ assertThat(diff).isEmpty();
}
@Test
diff --git a/kubernetes-model-generator/openshift-model/src/test/resources/valid-ist.json b/kubernetes-model-generator/openshift-model/src/test/resources/valid-ist.json
index a0e2ad6038a..c59dc9c760b 100644
--- a/kubernetes-model-generator/openshift-model/src/test/resources/valid-ist.json
+++ b/kubernetes-model-generator/openshift-model/src/test/resources/valid-ist.json
@@ -2,6 +2,8 @@
"apiVersion": "v1",
"generation": 2,
"image": {
+ "apiVersion": "v1",
+ "kind": "Image",
"dockerImageLayers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
@@ -50,4 +52,4 @@
"type": "Source"
}
}
-}
\ No newline at end of file
+}
diff --git a/kubernetes-model-generator/pom.xml b/kubernetes-model-generator/pom.xml
index fee50943204..96c5774657d 100644
--- a/kubernetes-model-generator/pom.xml
+++ b/kubernetes-model-generator/pom.xml
@@ -116,6 +116,7 @@
org.projectlombok
lombok
+ provided
io.sundr
@@ -125,10 +126,12 @@
io.sundr
transform-annotations
+ provided
io.sundr
sundr-codegen-velocity-nodeps
+ provided
@@ -142,9 +145,13 @@
test
- net.javacrumbs.json-unit
- json-unit-fluent
- 2.38.0
+ org.assertj
+ assertj-core
+ test
+
+
+ io.fabric8
+ zjsonpatch
test
diff --git a/pom.xml b/pom.xml
index fe5e6cd0e98..e16a6dda78e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -207,8 +207,8 @@
io.fabric8.kubernetes.api.model
- kubernetes-model-generator
zjsonpatch
+ kubernetes-model-generator
kubernetes-client-api
httpclient-jdk
httpclient-jetty