Commit b23d2404 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Add local test run class.

parent 354a93db
Pipeline #21015 passed with stage
in 2 minutes and 3 seconds
...@@ -171,7 +171,7 @@ abstract class RecordResource(institutionId: String) : IResource { ...@@ -171,7 +171,7 @@ abstract class RecordResource(institutionId: String) : IResource {
blank.addProperty(RICO.regulates, resource) blank.addProperty(RICO.regulates, resource)
resource.addProperty(RICO.regulatedBy, blank) resource.addProperty(RICO.regulatedBy, blank)
} else { } else {
log.error("Add no rule for type $type, because there were no content properties mapped.") log.error("Added no rule for type $type, because there were no content properties mapped.")
} }
} }
......
/*
* Mapper Service Configuration
* Copyright (C) 2020 Memoriav
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.memobase.test
import ch.memobase.builder.ResourceBuilder
import ch.memobase.mapping.MappingConfigurationParser
import ch.memobase.settings.HeaderMetadata
import com.beust.klaxon.Klaxon
import java.io.File
import java.io.FileOutputStream
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Disabled
class LocalTestRun {
private val headerMetadata = HeaderMetadata(
"snp-001",
"1",
"snp",
false,
"record",
"identifierMain",
0, 0, 0, 0
)
@Test
@Disabled
fun `test local folder`() {
val folder = "/home/jonas/memobase/data/snp-001"
val inputFolder = "/home/jonas/memobase/data/test/step-2"
val outputFolder = "/home/jonas/memobase/data/test/step-3"
val mappingFile = "/config/mapping.yml"
val klaxon = Klaxon()
val configurationParser = MappingConfigurationParser(File(folder + mappingFile).readBytes())
val configuration = configurationParser.get()
File(inputFolder)
.walk(FileWalkDirection.TOP_DOWN)
.maxDepth(1)
.filter { it.isFile }
.map { Pair(it.name, it) }
.map {
Pair(it.first, klaxon.parse<Map<String, Any>>(it.second).orEmpty())
}
.map {
val builder = ResourceBuilder(
it.second,
configuration,
headerMetadata.institutionId,
headerMetadata.recordSetId,
headerMetadata.isPublished
)
builder.extractRecordId()
builder.extractRecordTypeValue()
.generateRecord()
.generatePhysicalObject()
.generateDigitalObject()
.addDerivedConnection()
.writeRecord()
}
.forEach { result ->
FileOutputStream(File(outputFolder + "/" + result.first.substringAfterLast("/"))).use {
it.bufferedWriter().use { writer ->
writer.write(result.second)
}
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment