serialization tests

This commit is contained in:
Fabio Sinibaldi 2020-11-17 18:16:19 +01:00
parent 711317c81f
commit 2662a25f30
5 changed files with 244 additions and 30 deletions

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -1,3 +0,0 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding/<project>=UTF-8

19
pom.xml
View File

@ -57,6 +57,8 @@
<version>1.1</version>
</dependency>
<!-- TEST -->
<dependency>
@ -71,8 +73,25 @@
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<!-- read JSON -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<scope>test</scope>
</dependency>
<!-- jackson java time -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.8.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>

View File

@ -2,19 +2,37 @@ package org.gcube.application.geoportal.common.model;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.json.Json;
import javax.json.JsonObject;
import org.gcube.application.geoportal.common.faults.JsonParseException;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.profile.Profile;
import org.gcube.application.geoportal.common.utils.Files;
import org.junit.Assert;
import org.junit.Test;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
public class SerializationTest {
private static ObjectMapper mapper = new ObjectMapper();
static {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
mapper.setSerializationInclusion(Include.NON_NULL);
// mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}
@Test
public void readProfile() throws FileNotFoundException, JsonParseException {
JsonObject object=Json.createReader(new FileInputStream(Files.getFileFromResources("ProfileConcessioni.json"))).readObject();
@ -28,4 +46,11 @@ public class SerializationTest {
}
@Test
public void readConcessione() throws JsonProcessingException, IOException {
Concessione concessione=mapper.readerFor(Concessione.class).readValue(
Files.getFileFromResources("Concessione.json"));
System.out.println("Concessione is "+concessione.toString());
}
}

View File

@ -0,0 +1,200 @@
{
"id": 1,
"recordType": "CONCESSIONE",
"version": "1.0.0",
"licenzaID": "CC-BY",
"policy": "OPEN",
"nome": "Italia, forse",
"folderId": "2f1bcd4b-fc3d-48c5-aa3b-064c68ba94c9",
"lastUpdateTime": [
2020,
11,
17,
12,
19,
58,
418000000
],
"lastUpdateUser": "NO NAME",
"creationTime": [
2020,
11,
17,
12,
19,
58,
418000000
],
"creationUser": "NO NAME",
"introduzione": "This is my project",
"descrizioneContenuto": "It contains this and that",
"authors": [
"Some one",
"Some, oneelse"
],
"contributore": "Contrib 1",
"titolari": [
"Some one",
"Some, oneelse"
],
"responsabile": "Someone",
"editore": "Editore",
"fontiFinanziamento": [
"Big pharma",
"Pentagon"
],
"soggetto": [
"Research Excavation",
"Archeology"
],
"risorseCorrelate": [],
"dataInizioProgetto": [
2020,
11,
17,
12,
19,
40,
741000000
],
"dataFineProgetto": [
2020,
11,
17,
12,
19,
40,
752000000
],
"titolareLicenza": "Qualcun altro",
"titolareCopyright": "Chiedilo in giro",
"paroleChiaveLibere": [
"Robba",
"Stuff"
],
"paroleChiaveICCD": [
"vattelapesca",
"somthing something"
],
"centroidLat": 43.0,
"centroidLong": 9.0,
"relazioneScavo": {
"id": 11,
"policy": "OPEN",
"licenseID": "CC-BY",
"titolo": "Italia, forse relazione di scavo",
"creationTime": [
2020,
11,
17,
12,
19,
58,
418000000
],
"record": null,
"actualContent": [
{
"id": 16,
"associated": null,
"mimetype": "application/pdf",
"storageID": "78ec815e-cc0e-4a61-8248-8eebe8c7c6be",
"link": "https://data.dev.d4science.org/shub/E_K0lSY05ja0s2N2hkVkxzWTVRSGN0MWZ4UFFOQnFTZHgraytOK05lcHZ2d002aGQ1Z2grZkE5d1ZmTUc5V3diLw=="
}
],
"abstractSection": "simple abstract section",
"responsabili": [
"Some one",
"Some, oneelse"
],
"soggetto": [
"Research Excavation",
"Archeology"
]
},
"immaginiRappresentative": [],
"posizionamentoScavo": {
"id": 10,
"policy": "OPEN",
"licenseID": "CC-BY",
"titolo": "Italia, forse posizionamento scavo",
"creationTime": [
2020,
11,
17,
12,
19,
58,
418000000
],
"record": null,
"actualContent": [
{
"id": 11,
"associated": null,
"mimetype": "application/x-dbf",
"storageID": "6c6ab4c4-5691-4652-9010-485ec8f1fc3d",
"link": "https://data.dev.d4science.org/shub/E_OThaZC9lRkk5cVprcjBwZlBFS1NyZEtvcjNTekFJYjVoZUdXalQweGI2emJzZ3cxNTFoUUJNbUs1YXRKLzA0bg=="
},
{
"id": 12,
"associated": null,
"mimetype": "text/plain",
"storageID": "10b8fbce-89a1-4a76-9e91-17c08c45c8ca",
"link": "https://data.dev.d4science.org/shub/E_eEo2NEV5WHl6RDhVSUMvWm1NTndwOW5FTjZaSkdPVjR0MFBiclNWWTBCbUJXUjA1ZmNVbU00N3FXeU5JQVdnLw=="
},
{
"id": 13,
"associated": null,
"mimetype": "text/plain",
"storageID": "435380a5-812d-4bef-b0f1-f0e89cd93730",
"link": "https://data.dev.d4science.org/shub/E_YTMyTDU5cVBxSWRkZEFuYi9hTVQ2ZUxtbnNyYU9KcUNydFl6dk5jbkhYWHk2ODAwUDZuemE5M2xVT2RPZDA5MA=="
},
{
"id": 14,
"associated": null,
"mimetype": "application/x-shapefile",
"storageID": "04a284fe-c6f2-4dd6-8c9c-06cc1ebbefb8",
"link": "https://data.dev.d4science.org/shub/E_UXRlN0F0OUdWazdCNElORExJUlppL0JEMjdkcHIvNWNDNGdtejNBQkxQTFlySERlWnQySUVDSkVTWHJHblRtdg=="
},
{
"id": 15,
"associated": null,
"mimetype": "application/x-shapefile",
"storageID": "285882cd-7922-4755-b7f2-95fe72960425",
"link": "https://data.dev.d4science.org/shub/E_aFlKbkhhREE3VlQ3TzZRMzlNK2YrODYxamFsclRmOWZKL1FYS1BzbjIvYWNBMjNnK2pyQzZTZUVKODUrRjBlTQ=="
}
],
"layerUUID": null,
"layerID": null,
"layerName": null,
"wmsLink": null,
"abstractSection": "Posizionamento topografico georeferenziato dellarea interessata dalle indagini",
"topicCategory": "Society",
"subTopic": "Archeology",
"bbox": {
"maxLat": 90.0,
"maxLong": 180.0,
"minLat": -90.0,
"minLong": -180.0
},
"paroleChiaveLibere": [
"Robba",
"Stuff"
],
"paroleChiaveICCD": [
"vattelapesca",
"somthing something"
],
"valutazioneQualita": "Secondo me si",
"metodoRaccoltaDati": "Fattobbene",
"scalaAcquisizione": "1:10000",
"authors": [
"Some one",
"Some, oneelse"
],
"responsabile": "Someone"
},
"pianteFineScavo": [],
"genericContent": []
}