From f30c662e357d7cd96c6b39e06df60fc5334936c6 Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Tue, 22 Dec 2020 17:49:15 +0100 Subject: [PATCH] Serialization tests --- .../geoportal/common/model/legacy/Record.java | 5 +++-- .../model/legacy/report/ValidationReport.java | 8 ++++++++ .../geoportal/common/model/SerializationTest.java | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/Record.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/Record.java index 780bab0..4efecac 100644 --- a/src/main/java/org/gcube/application/geoportal/common/model/legacy/Record.java +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/Record.java @@ -51,8 +51,9 @@ public abstract class Record { validator.checkMandatory(getRecordType(), "Record Type"); validator.checkMandatory(getNome(), "Nome"); - - return validator; + setReport(validator); + + return getReport(); } public void setDefaults() { diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/ValidationReport.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/ValidationReport.java index 252c649..ed91409 100644 --- a/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/ValidationReport.java +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/ValidationReport.java @@ -5,11 +5,19 @@ import java.util.ArrayList; import java.util.List; import lombok.Data; +import lombok.NoArgsConstructor; @Data +@NoArgsConstructor public class ValidationReport implements Serializable{ + /** + * + */ + private static final long serialVersionUID = -3629142756787381094L; + + public static enum ValidationStatus{ PASSED, ERROR, WARNING } diff --git a/src/test/java/org/gcube/application/geoportal/common/model/SerializationTest.java b/src/test/java/org/gcube/application/geoportal/common/model/SerializationTest.java index d1cc3fb..5006417 100644 --- a/src/test/java/org/gcube/application/geoportal/common/model/SerializationTest.java +++ b/src/test/java/org/gcube/application/geoportal/common/model/SerializationTest.java @@ -48,4 +48,18 @@ public class SerializationTest { System.out.println("Concessione is "+concessione.toString()); } + + @Test + public void generic() throws JsonProcessingException, IOException { + Concessione conc=TestModel.prepareConcessione(); + conc.validate(); + full(conc); + } + + + public void full(Object obj) throws JsonProcessingException, IOException { + String asString=mapper.writeValueAsString(obj); + Object other=mapper.readerFor(obj.getClass()).readValue(asString); + + } }