2020-06-17 09:10:38 +02:00
|
|
|
package eu.dnetlib.dhp.export
|
|
|
|
|
|
|
|
import java.time.LocalDateTime
|
|
|
|
import java.time.format.DateTimeFormatter
|
|
|
|
|
|
|
|
import eu.dnetlib.dhp.schema.oaf.Relation
|
2020-08-06 10:28:24 +02:00
|
|
|
import eu.dnetlib.dhp.schema.scholexplorer.{DLIDataset, DLIPublication}
|
2020-10-13 08:47:58 +02:00
|
|
|
|
2020-06-17 09:10:38 +02:00
|
|
|
import org.codehaus.jackson.map.{ObjectMapper, SerializationConfig}
|
|
|
|
import org.junit.jupiter.api.Test
|
|
|
|
|
|
|
|
import scala.io.Source
|
|
|
|
|
|
|
|
class ExportDLITOOAFTest {
|
|
|
|
|
|
|
|
val mapper = new ObjectMapper()
|
|
|
|
|
|
|
|
@Test
|
|
|
|
def testDate():Unit = {
|
|
|
|
println(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-10-13 08:47:58 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
def testMappingRele():Unit = {
|
|
|
|
|
|
|
|
val r:Relation = new Relation
|
|
|
|
r.setSource("60|fbff1d424e045eecf24151a5fe3aa738")
|
|
|
|
r.setTarget("50|dedup_wf_001::ec409f09e63347d4e834087fe1483877")
|
|
|
|
|
|
|
|
val r1 =DLIToOAF.convertDLIRelation(r)
|
|
|
|
println(r1.getSource, r1.getTarget)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-06-17 09:10:38 +02:00
|
|
|
@Test
|
|
|
|
def testPublicationMapping():Unit = {
|
|
|
|
|
|
|
|
mapper.getSerializationConfig.enable(SerializationConfig.Feature.INDENT_OUTPUT)
|
|
|
|
val json = Source.fromInputStream(getClass.getResourceAsStream("publication.json")).mkString
|
|
|
|
|
|
|
|
|
|
|
|
val oaf =DLIToOAF.convertDLIPublicationToOAF(mapper.readValue(json, classOf[DLIPublication]))
|
|
|
|
|
|
|
|
println(mapper.writeValueAsString(oaf))
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
def testExternalReferenceMapping():Unit = {
|
|
|
|
|
|
|
|
mapper.getSerializationConfig.enable(SerializationConfig.Feature.INDENT_OUTPUT)
|
|
|
|
val json = Source.fromInputStream(getClass.getResourceAsStream("dataset.json")).mkString
|
|
|
|
|
|
|
|
|
|
|
|
val oaf =DLIToOAF.convertDLIDatasetToExternalReference(mapper.readValue(json, classOf[DLIDataset]))
|
|
|
|
|
|
|
|
println(oaf)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
def testRelationMapping():Unit = {
|
|
|
|
|
|
|
|
mapper.getSerializationConfig.enable(SerializationConfig.Feature.INDENT_OUTPUT)
|
|
|
|
val json = Source.fromInputStream(getClass.getResourceAsStream("relation.json")).mkString
|
|
|
|
|
|
|
|
|
2020-08-06 10:28:24 +02:00
|
|
|
val oaf =mapper.readValue(json, classOf[Relation])
|
2020-06-17 09:10:38 +02:00
|
|
|
|
|
|
|
println(mapper.writeValueAsString(oaf))
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|