This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 586b7150f2 refactor: Remove unused methods from the GsonSerializer 
(#2937)
586b7150f2 is described below

commit 586b7150f29ab9bfc943c56acde7c7bbb7b3db3e
Author: Philipp Zehnder <[email protected]>
AuthorDate: Mon Jun 17 23:38:58 2024 +0200

    refactor: Remove unused methods from the GsonSerializer (#2937)
---
 .../storage/couchdb/serializer/GsonSerializer.java | 37 -----------------
 .../couchdb/serializer/TestGsonSerializer.java     | 48 ++++++++++++++++------
 2 files changed, 36 insertions(+), 49 deletions(-)

diff --git 
a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/serializer/GsonSerializer.java
 
b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/serializer/GsonSerializer.java
index f141497ad5..37a2293ff4 100644
--- 
a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/serializer/GsonSerializer.java
+++ 
b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/serializer/GsonSerializer.java
@@ -46,8 +46,6 @@ import org.apache.streampipes.model.schema.ValueSpecification;
 import org.apache.streampipes.model.staticproperty.MappingProperty;
 import org.apache.streampipes.model.staticproperty.StaticProperty;
 
-import com.google.gson.ExclusionStrategy;
-import com.google.gson.FieldAttributes;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
@@ -60,7 +58,6 @@ public class GsonSerializer {
     builder.registerTypeHierarchyAdapter(AdapterDescription.class, new 
AdapterSerializer());
     builder.registerTypeAdapter(TransformationRuleDescription.class,
         new CouchDbJsonSerializer<TransformationRuleDescription>());
-//    
builder.registerTypeHierarchyAdapter(TransformationRuleDescription.class, new 
AdapterSerializer());
 
     return builder;
   }
@@ -72,10 +69,6 @@ public class GsonSerializer {
     return builder;
   }
 
-  public static Gson getAdapterGson() {
-    return getAdapterGsonBuilder().create();
-  }
-
   public static Gson getGson() {
     return getGsonBuilder().create();
   }
@@ -124,34 +117,4 @@ public class GsonSerializer {
     return builder;
   }
 
-  public static Gson getGson(boolean keepIds) {
-    return keepIds ? getGsonWithIds() : getGsonWithoutIds();
-  }
-
-  public static Gson getGsonWithIds() {
-    return getGsonBuilder().create();
-  }
-
-  public static Gson getGsonWithoutIds() {
-    GsonBuilder builder = getGsonBuilder();
-
-    builder.addSerializationExclusionStrategy(new ExclusionStrategy() {
-
-      @Override
-      public boolean shouldSkipField(FieldAttributes f) {
-        if (f.getName().equals("elementName")) {
-          return true;
-        }
-        return f.getName()
-                .equals("elementId");
-      }
-
-      @Override
-      public boolean shouldSkipClass(Class<?> clazz) {
-        // TODO Auto-generated method stub
-        return false;
-      }
-    });
-    return builder.create();
-  }
 }
diff --git 
a/streampipes-storage-couchdb/src/test/java/org/apache/streampipes/storage/couchdb/serializer/TestGsonSerializer.java
 
b/streampipes-storage-couchdb/src/test/java/org/apache/streampipes/storage/couchdb/serializer/TestGsonSerializer.java
index a25973a21d..ffca48f131 100644
--- 
a/streampipes-storage-couchdb/src/test/java/org/apache/streampipes/storage/couchdb/serializer/TestGsonSerializer.java
+++ 
b/streampipes-storage-couchdb/src/test/java/org/apache/streampipes/storage/couchdb/serializer/TestGsonSerializer.java
@@ -27,24 +27,48 @@ public class TestGsonSerializer {
   public static void assertions(PipelineElementTemplate template) {
     Assertions.assertEquals("name", template.getTemplateName());
     Assertions.assertEquals("description", template.getTemplateDescription());
-    Assertions.assertEquals(2,
-                            template.getTemplateConfigs().size());
-    Assertions.assertEquals("test-string",
-                            
template.getTemplateConfigs().get("test-key").getValue());
-    
Assertions.assertTrue(template.getTemplateConfigs().get("test-key").isEditable());
-    
Assertions.assertTrue(template.getTemplateConfigs().get("test-key").isDisplayed());
-    
Assertions.assertTrue(template.getTemplateConfigs().get("test-key-2").isEditable());
-    
Assertions.assertFalse(template.getTemplateConfigs().get("test-key-2").isDisplayed());
+    Assertions.assertEquals(
+        2,
+        template.getTemplateConfigs()
+                .size()
+    );
+    Assertions.assertEquals(
+        "test-string",
+        template.getTemplateConfigs()
+                .get("test-key")
+                .getValue()
+    );
+    Assertions.assertTrue(template.getTemplateConfigs()
+                                  .get("test-key")
+                                  .isEditable());
+    Assertions.assertTrue(template.getTemplateConfigs()
+                                  .get("test-key")
+                                  .isDisplayed());
+    Assertions.assertTrue(template.getTemplateConfigs()
+                                  .get("test-key-2")
+                                  .isEditable());
+    Assertions.assertFalse(template.getTemplateConfigs()
+                                   .get("test-key-2")
+                                   .isDisplayed());
   }
 
   @Test
   public void testPipelineElementTemplateSerialization() {
     PipelineElementTemplate template = 
PipelineElementTemplateHelpers.makePipelineElementTemplate();
 
-    String json = GsonSerializer.getGsonWithIds().toJson(template);
-    PipelineElementTemplate template2 = 
GsonSerializer.getGsonWithIds().fromJson(json, PipelineElementTemplate.class);
+    String json = GsonSerializer.getGsonBuilder()
+                                .create()
+                                .toJson(template);
+    PipelineElementTemplate template2 = GsonSerializer
+        .getGsonBuilder()
+        .create()
+        .fromJson(json, PipelineElementTemplate.class);
     assertions(template2);
-    Assertions.assertEquals(2.0,
-                            
template2.getTemplateConfigs().get("test-key-2").getValue());
+    Assertions.assertEquals(
+        2.0,
+        template2.getTemplateConfigs()
+                 .get("test-key-2")
+                 .getValue()
+    );
   }
 }

Reply via email to