From 8320ad2248e398aef165acd020f3fd3566a741c1 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Tue, 29 Jun 2021 17:49:11 +0200 Subject: [PATCH] added tests for the normalization of the dois --- .../crossref/CrossrefMappingTest.scala | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/dhp-workflows/dhp-doiboost/src/test/java/eu/dnetlib/doiboost/crossref/CrossrefMappingTest.scala b/dhp-workflows/dhp-doiboost/src/test/java/eu/dnetlib/doiboost/crossref/CrossrefMappingTest.scala index 4568e23a5..21ce8a417 100644 --- a/dhp-workflows/dhp-doiboost/src/test/java/eu/dnetlib/doiboost/crossref/CrossrefMappingTest.scala +++ b/dhp-workflows/dhp-doiboost/src/test/java/eu/dnetlib/doiboost/crossref/CrossrefMappingTest.scala @@ -367,6 +367,7 @@ class CrossrefMappingTest { val relevantDates = result.getRelevantdate.asScala + assert(relevantDates.exists(d => d.getQualifier.getClassid.equalsIgnoreCase("created")), "Missing relevant date of type created") val rels = resultList.filter(p => p.isInstanceOf[Relation]).asInstanceOf[List[Relation]] @@ -384,4 +385,36 @@ class CrossrefMappingTest { } + @Test + def testNormalizeDOI(): Unit = { + val template = Source.fromInputStream(getClass.getResourceAsStream("article_funder_template.json")).mkString + val line :String = "\"funder\": [{\"name\": \"Wellcome Trust Masters Fellowship\",\"award\": [\"090633\"]}]," + val json = template.replace("%s", line) + val resultList: List[Oaf] = Crossref2Oaf.convert(json) + assertTrue(resultList.nonEmpty) + val items = resultList.filter(p => p.isInstanceOf[Publication]) + val result: Result = items.head.asInstanceOf[Publication] + + result.getPid.asScala.foreach(pid => assertTrue(pid.getQualifier.getClassid.equals("doi"))) + assertTrue(result.getPid.size() == 1) + result.getPid.asScala.foreach(pid => assertTrue(pid.getValue.equals("10.26850/1678-4618EQJ.v35.1.2010.p41-46".toLowerCase()))) + + } + + @Test + def testNormalizeDOI2(): Unit = { + val template = Source.fromInputStream(getClass.getResourceAsStream("article.json")).mkString + + val resultList: List[Oaf] = Crossref2Oaf.convert(template) + assertTrue(resultList.nonEmpty) + val items = resultList.filter(p => p.isInstanceOf[Publication]) + val result: Result = items.head.asInstanceOf[Publication] + + result.getPid.asScala.foreach(pid => assertTrue(pid.getQualifier.getClassid.equals("doi"))) + assertTrue(result.getPid.size() == 1) + result.getPid.asScala.foreach(pid => assertTrue(pid.getValue.equals("10.26850/1678-4618EQJ.v35.1.2010.p41-46".toLowerCase()))) + + } + + }