2021-03-31 15:45:58 +02:00
|
|
|
package eu.dnetlib.dhp.actionmanager.datacite
|
|
|
|
|
2021-04-20 09:44:44 +02:00
|
|
|
|
2021-06-04 10:14:22 +02:00
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper
|
|
|
|
import com.fasterxml.jackson.databind.SerializationFeature
|
|
|
|
|
2021-03-31 15:45:58 +02:00
|
|
|
import eu.dnetlib.dhp.aggregation.AbstractVocabularyTest
|
|
|
|
import eu.dnetlib.dhp.schema.oaf.Oaf
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith
|
|
|
|
import org.junit.jupiter.api.{BeforeEach, Test}
|
|
|
|
import org.mockito.junit.jupiter.MockitoExtension
|
2021-06-04 10:14:22 +02:00
|
|
|
|
2021-03-31 15:45:58 +02:00
|
|
|
import scala.io.Source
|
|
|
|
|
|
|
|
@ExtendWith(Array(classOf[MockitoExtension]))
|
|
|
|
class DataciteToOAFTest extends AbstractVocabularyTest{
|
|
|
|
|
|
|
|
|
|
|
|
@BeforeEach
|
|
|
|
def setUp() :Unit = {
|
2021-04-20 09:44:44 +02:00
|
|
|
|
2021-03-31 15:45:58 +02:00
|
|
|
super.setUpVocabulary()
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
def testMapping() :Unit = {
|
|
|
|
val record =Source.fromInputStream(getClass.getResourceAsStream("record.json")).mkString
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-04 10:14:22 +02:00
|
|
|
val mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT)
|
|
|
|
val res:List[Oaf] =DataciteToOAFTransformation.generateOAF(record, 0L,0L, vocabularies, true )
|
|
|
|
|
|
|
|
res.foreach(r => {
|
|
|
|
println (mapper.writeValueAsString(r))
|
|
|
|
println("----------------------------")
|
|
|
|
|
|
|
|
})
|
|
|
|
|
2021-03-31 15:45:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|