test for checking structural equality in new and old records in elasticsearch

This commit is contained in:
Alessia Bardi 2020-07-08 16:34:48 +02:00
parent 7b644e04da
commit eb805ebf9b
3 changed files with 244 additions and 0 deletions

View File

@ -1,4 +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;
}
}
}

View File

@ -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": ""
}

View File

@ -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": ""
}
]
}
}