From 869d95ba60bc5c6b10d546ac87ffcb3c712b5444 Mon Sep 17 00:00:00 2001
From: Marc Nuri <marc@marcnuri.com>
Date: Tue, 7 May 2024 14:18:47 +0200
Subject: [PATCH] test(crd-generator): approval tests use lombok for proper
 serialization

Signed-off-by: Marc Nuri <marc@marcnuri.com>
---
 .../approvaltests/inherited/BaseSpec.java          | 11 +++--------
 .../approvaltests/inherited/BaseStatus.java        |  3 +++
 .../approvaltests/inherited/ChildSpec.java         |  3 +++
 .../approvaltests/json/ContainingJsonSpec.java     | 14 ++------------
 .../crd/generator/approvaltests/json/Foo.java      |  1 +
 .../k8svalidation/K8sValidationSpec.java           | 12 +++++++++---
 .../k8svalidation/K8sValidationStatus.java         |  3 +++
 .../approvaltests/map/ContainingMaps.java          |  2 ++
 .../approvaltests/map/ContainingMapsSpec.java      | 13 ++++---------
 .../multipleversions/v1/MultipleSpec.java          |  7 +++----
 .../multipleversions/v2/MultipleSpec.java          |  7 +++----
 .../approvaltests/nocyclic/NoCyclicSpec.java       |  3 +++
 .../approvaltests/nocyclic/NoCyclicStatus.java     |  3 +++
 .../crd/generator/approvaltests/nocyclic/Ref.java  |  5 ++++-
 14 files changed, 46 insertions(+), 41 deletions(-)

diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/BaseSpec.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/BaseSpec.java
index 28d906d9939..d0bc7ca35da 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/BaseSpec.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/BaseSpec.java
@@ -15,14 +15,9 @@
  */
 package io.fabric8.crd.generator.approvaltests.inherited;
 
+import lombok.Data;
+
+@Data
 public class BaseSpec {
   private int baseInt;
-
-  public int getBaseInt() {
-    return baseInt;
-  }
-
-  public void setBaseInt(int baseInt) {
-    this.baseInt = baseInt;
-  }
 }
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/BaseStatus.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/BaseStatus.java
index fadf5a3182d..30cff751f32 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/BaseStatus.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/BaseStatus.java
@@ -15,9 +15,12 @@
  */
 package io.fabric8.crd.generator.approvaltests.inherited;
 
+import lombok.Data;
+
 /**
  * @author <a href="claprun@redhat.com">Christophe Laprun</a>
  */
+@Data
 public class BaseStatus {
 
 }
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/ChildSpec.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/ChildSpec.java
index 352ab4e4d7a..63ae65d9e2b 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/ChildSpec.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/inherited/ChildSpec.java
@@ -15,8 +15,11 @@
  */
 package io.fabric8.crd.generator.approvaltests.inherited;
 
+import lombok.Data;
+
 import java.util.Map;
 
+@Data
 public class ChildSpec extends BaseSpec {
   private Map<String, Object> unsupported;
   private Map<String, String> supported;
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/json/ContainingJsonSpec.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/json/ContainingJsonSpec.java
index 7f1be1d0f5e..84183a495dd 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/json/ContainingJsonSpec.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/json/ContainingJsonSpec.java
@@ -16,25 +16,15 @@
 package io.fabric8.crd.generator.approvaltests.json;
 
 import com.fasterxml.jackson.databind.JsonNode;
+import lombok.Data;
 
+@Data
 public class ContainingJsonSpec {
 
   private int field;
 
-  public int getField() {
-    return field;
-  }
-
   private JsonNode free;
 
-  public JsonNode getFree() {
-    return free;
-  }
-
   private Foo foo;
 
-  public Foo getFoo() {
-    return foo;
-  }
-
 }
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/json/Foo.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/json/Foo.java
index 3e27b063f26..555b1693a36 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/json/Foo.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/json/Foo.java
@@ -17,6 +17,7 @@
 
 import com.fasterxml.jackson.annotation.JsonAnyGetter;
 import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 
 import java.util.HashMap;
 import java.util.Map;
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/k8svalidation/K8sValidationSpec.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/k8svalidation/K8sValidationSpec.java
index 43250e81d92..e0d9efe7cd2 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/k8svalidation/K8sValidationSpec.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/k8svalidation/K8sValidationSpec.java
@@ -17,8 +17,10 @@
 
 import io.fabric8.generator.annotation.Required;
 import io.fabric8.generator.annotation.ValidationRule;
+import lombok.Data;
 
 @ValidationRule(value = "self.minReplicas <= self.replicas && self.replicas <= self.maxReplicas", fieldPath = ".replicas")
+@Data
 public class K8sValidationSpec {
   @Required
   String namePrefix;
@@ -82,7 +84,8 @@ enum Priority {
     high
   }
 
-  static class DeepLevel1 {
+  @Data
+  static final class DeepLevel1 {
     @Required
     private String valueL1;
 
@@ -90,7 +93,8 @@ static class DeepLevel1 {
     private DeepLevel2 deepLevel2;
   }
 
-  static class DeepLevel2 {
+  @Data
+  static final class DeepLevel2 {
     @Required
     private String valueL2;
 
@@ -100,7 +104,8 @@ static class DeepLevel2 {
   }
 
   @ValidationRule("self.dummy.startsWith('on-class-')")
-  static class OnClass {
+  @Data
+  static final class OnClass {
     @Required
     private String dummy;
   }
@@ -110,6 +115,7 @@ static class ClassWithValidationsFromAbstractClass extends AbstractBase {
   }
 
   @ValidationRule("self.dummy.startsWith('abstract-')")
+  @Data
   static abstract class AbstractBase {
     @Required
     private String dummy;
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/k8svalidation/K8sValidationStatus.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/k8svalidation/K8sValidationStatus.java
index 73c9f4f2487..1b1833c51c7 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/k8svalidation/K8sValidationStatus.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/k8svalidation/K8sValidationStatus.java
@@ -15,6 +15,9 @@
  */
 package io.fabric8.crd.generator.approvaltests.k8svalidation;
 
+import lombok.Data;
+
+@Data
 public class K8sValidationStatus {
   Integer availableReplicas;
 }
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/map/ContainingMaps.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/map/ContainingMaps.java
index 28e666a7232..c6626abd1c4 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/map/ContainingMaps.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/map/ContainingMaps.java
@@ -18,11 +18,13 @@
 import io.fabric8.kubernetes.client.CustomResource;
 import io.fabric8.kubernetes.model.annotation.Group;
 import io.fabric8.kubernetes.model.annotation.Version;
+import lombok.Data;
 
 import java.util.EnumMap;
 
 @Group("sample.fabric8.io")
 @Version("v1alpha1")
+@Data
 public class ContainingMaps extends CustomResource<ContainingMapsSpec, Void> {
 
   public enum Foo {
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/map/ContainingMapsSpec.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/map/ContainingMapsSpec.java
index e59b1848bd4..b9e24602c33 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/map/ContainingMapsSpec.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/map/ContainingMapsSpec.java
@@ -15,24 +15,19 @@
  */
 package io.fabric8.crd.generator.approvaltests.map;
 
+import lombok.Data;
+
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+@Data
 public class ContainingMapsSpec {
 
   private Map<String, List<String>> test = null;
 
-  public Map<String, List<String>> getTest() {
-    return test;
-  }
-
   private Map<String, Map<String, List<Boolean>>> test2 = null;
 
-  public Map<String, Map<String, List<Boolean>>> getTest2() {
-    return test2;
-  }
-
   private MultiHashMap<String, Integer> stringToIntMultiMap1;
   private MultiMap<String, Integer> stringToIntMultiMap2;
   private SwappedParametersMap<List<Integer>, String> stringToIntMultiMap3;
@@ -56,7 +51,7 @@ interface RedundantParametersMap<A, B, K, V> extends Map<K, V> {
   interface RedundantParametersStringToIntMultiMap<K, V> extends Map<String, List<Integer>> {
   }
 
-  static class StringKeyedMultiHashMap<V> extends MultiHashMap<String, V> {
+  static final class StringKeyedMultiHashMap<V> extends MultiHashMap<String, V> {
   }
 
   interface IntValuedMultiMap<K> extends MultiMap<K, Integer> {
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/multipleversions/v1/MultipleSpec.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/multipleversions/v1/MultipleSpec.java
index 46bb4660c9e..318a4540c62 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/multipleversions/v1/MultipleSpec.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/multipleversions/v1/MultipleSpec.java
@@ -15,10 +15,9 @@
  */
 package io.fabric8.crd.generator.approvaltests.multipleversions.v1;
 
+import lombok.Data;
+
+@Data
 public class MultipleSpec {
   private String v1;
-
-  public String getV1() {
-    return v1;
-  }
 }
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/multipleversions/v2/MultipleSpec.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/multipleversions/v2/MultipleSpec.java
index 098fb2e0851..23fd2373510 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/multipleversions/v2/MultipleSpec.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/multipleversions/v2/MultipleSpec.java
@@ -15,10 +15,9 @@
  */
 package io.fabric8.crd.generator.approvaltests.multipleversions.v2;
 
+import lombok.Data;
+
+@Data
 public class MultipleSpec {
   private String v2;
-
-  public String getV2() {
-    return v2;
-  }
 }
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/NoCyclicSpec.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/NoCyclicSpec.java
index 448ed9e4a22..a79353afb87 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/NoCyclicSpec.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/NoCyclicSpec.java
@@ -15,6 +15,9 @@
  */
 package io.fabric8.crd.generator.approvaltests.nocyclic;
 
+import lombok.Data;
+
+@Data
 public class NoCyclicSpec {
   private Ref ref1;
   private Ref ref2;
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/NoCyclicStatus.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/NoCyclicStatus.java
index 99cf43202bb..40b3029ccb8 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/NoCyclicStatus.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/NoCyclicStatus.java
@@ -15,6 +15,9 @@
  */
 package io.fabric8.crd.generator.approvaltests.nocyclic;
 
+import lombok.Data;
+
+@Data
 public class NoCyclicStatus {
   private String message;
   private Ref ref1;
diff --git a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/Ref.java b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/Ref.java
index 35c6b2fed0e..60546ecc514 100644
--- a/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/Ref.java
+++ b/crd-generator/test/src/test/java/io/fabric8/crd/generator/approvaltests/nocyclic/Ref.java
@@ -15,13 +15,16 @@
  */
 package io.fabric8.crd.generator.approvaltests.nocyclic;
 
+import lombok.Data;
+
+@Data
 public class Ref {
 
   private int ref;
 
   protected Inner inner;
 
-  public static class Inner {
+  public static final class Inner {
   }
 
 }