diff --git a/dnet-ariadneplus-graphdb-publisher/pom.xml b/dnet-ariadneplus-graphdb-publisher/pom.xml index 62f32e4..6e0d310 100644 --- a/dnet-ariadneplus-graphdb-publisher/pom.xml +++ b/dnet-ariadneplus-graphdb-publisher/pom.xml @@ -127,6 +127,13 @@ elasticsearch-rest-client 7.4.2 + + org.skyscreamer + jsonassert + 1.5.0 + test + + diff --git a/dnet-ariadneplus-graphdb-publisher/test/java/eu/dnetlib/ariadneplus/elasticsearch/IndexedJsonTest.java b/dnet-ariadneplus-graphdb-publisher/test/java/eu/dnetlib/ariadneplus/elasticsearch/IndexedJsonTest.java new file mode 100644 index 0000000..f5151a0 --- /dev/null +++ b/dnet-ariadneplus-graphdb-publisher/test/java/eu/dnetlib/ariadneplus/elasticsearch/IndexedJsonTest.java @@ -0,0 +1,29 @@ +package eu.dnetlib.ariadneplus.elasticsearch; + +import org.apache.commons.io.IOUtils; +import org.json.JSONException; +import org.junit.Test; +import org.skyscreamer.jsonassert.JSONAssert; +import org.springframework.core.io.ClassPathResource; + +import java.io.IOException; + +public class IndexedJsonTest { + + @Test + public void testSimple() throws JSONException { + String old = getJSONResult("eu/dnetlib/ariadneplus/elasticsearch/old.json"); + String the_new = getJSONResult("eu/dnetlib/ariadneplus/elasticsearch/new.json"); + JSONAssert.assertEquals(old, the_new, false); // Pass + //JSONAssert.assertEquals(old, the_new, true); // Fail + } + + private String getJSONResult(String s) { + try { + final ClassPathResource resource = new ClassPathResource(s); + return IOUtils.toString(resource.getInputStream(), "UTF-8"); + }catch(IOException e){ + return null; + } + } +} diff --git a/dnet-ariadneplus-graphdb-publisher/test/resources/eu/dnetlib/ariadneplus/elasticsearch/new.json b/dnet-ariadneplus-graphdb-publisher/test/resources/eu/dnetlib/ariadneplus/elasticsearch/new.json new file mode 100644 index 0000000..9443beb --- /dev/null +++ b/dnet-ariadneplus-graphdb-publisher/test/resources/eu/dnetlib/ariadneplus/elasticsearch/new.json @@ -0,0 +1,162 @@ +{ + "aatSubjects": [ + { + "id": "", + "label": "", + "lang": "" + } + ], + "accessPolicy": "", + "accessRights": "", + "archaeologicalResourceType": { + "id": 0, + "name": "" + }, + "contributor": [ + { + "email": "", + "name": "", + "phone": "", + "type": "" + } + ], + "creator": [ + { + "email": "", + "name": "", + "phone": "", + "type": "" + } + ], + "derivedSubject": [ + { + "prefLabel": "", + "source": "" + } + ], + "description": "", + "distribution": [ + { + "accessURL": "", + "description": "", + "issued": "", + "modified": "", + "publisher": [ + { + "email": "", + "name": "", + "phone": "", + "type": "" + } + ], + "title": "" + } + ], + "publisher": [ + { + "email": "", + "name": "", + "phone": "", + "type": "" + } + ], + "title": "", + "hasItemMetadataStructure": [ + { + "characterSet": "" + } + ], + "hasMetadataRecord": [ + { + "conformsTo": [ + { + "characterSet": "", + "description": "" + } + ], + "xmlDoc": "" + } + ], + "identifier": "", + "isPartOf": [ + "" + ], + "issued": "", + "keyword": [ + "" + ], + "landingPage": "", + "language": "", + "legalResponsible": [ + { + "email": "", + "name": "", + "phone": "", + "type": "" + } + ], + "modified": "", + "nativeSubject": [ + { + "prefLabel": "", + "rdfAbout": "" + } + ], + "originalId": "580969", + "owner": [ + { + "email": "", + "name": "", + "phone": "", + "type": "" + } + ], + "resourceType": "", + "scientificResponsible": [ + { + "email": "", + "name": "", + "phone": "", + "type": "" + } + ], + "spatial": [ + { + "address": "", + "coordinateSystem": "", + "country": "", + "location": { + "lat": 0.0, + "lon": 0.0 + }, + "placeName": "", + "postcode": "" + } + ], + "technicalResponsible": [ + { + "email": "", + "name": "", + "phone": "", + "type": "" + } + ], + "temporal": [ + { + "from": "", + "periodName": "", + "until": "", + "uri": "" + } + ], + "accrualPeriodicity": "", + "audience": "", + "contactPoint": "", + "extent": "", + "providerId": "", + "packageId": "", + "placeName": "", + "postcode": "", + "rdfAbout": "", + "rights": "" + } \ No newline at end of file diff --git a/dnet-ariadneplus-graphdb-publisher/test/resources/eu/dnetlib/ariadneplus/elasticsearch/old.json b/dnet-ariadneplus-graphdb-publisher/test/resources/eu/dnetlib/ariadneplus/elasticsearch/old.json new file mode 100644 index 0000000..b986baf --- /dev/null +++ b/dnet-ariadneplus-graphdb-publisher/test/resources/eu/dnetlib/ariadneplus/elasticsearch/old.json @@ -0,0 +1,57 @@ +{ + "publisher": [ + { + "type": "", + "name": "" + } + ], + "identifier": "", + "description": "", + "language": "", + "title": "", + "archaeologicalResourceType": { + "id": 0, + "name": "" + }, + "issued": "", + "temporal": [ + { + "from": "", + "until": "" + } + ], + "isPartOf": [ + "" + ], + "originalId": "580969", + "modified": "", + "accessRights": "", + "accessPolicy": "", + "resourceType": "", + "providerId": "", + "packageId": "", + "spatial": [ + { + "placeName": "", + "country": "", + "location": { + "lat": 0.0, + "lon": 0.0 + }, + "coordinateSystem": "" + } + ], + "contributor": [ + { + "type": "", + "name": "" + } + ], + "landingPage": "", + "nativeSubject": [ + { + "prefLabel": "" + } + ] + } +} \ No newline at end of file