Commit 45020c09 authored by Jonas Waeber's avatar Jonas Waeber

Add local test run class. This class can be used to run the streaming pipeline...

Add local test run class. This class can be used to run the streaming pipeline locally without Kafka, but with files instead.
parent 9874f437
Pipeline #21279 passed with stages
in 4 minutes and 7 seconds
/*
* Text File Validation
* 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 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
import org.memobase.FileValidation
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Disabled
class LocalTestRun {
@Test
@Disabled
fun `test local folder`() {
val folder = "/home/jonas/memobase/data/snp-001"
val outputFolder = "/home/jonas/memobase/data/test/step-1"
val validator = FileValidation()
File(folder)
.walk(FileWalkDirection.TOP_DOWN)
.maxDepth(1)
.filter { it.isFile }
.map { Pair(it.name, it) }
.map {
Triple(it.first, it.second, validator.validateExtension(it.second))
}
.map {
validator.validate(it.second.inputStream(), it.third, it.second)
}
.forEach { result ->
FileOutputStream(File(outputFolder + "/" + result.second.id)).use {
it.bufferedWriter().use { writer ->
writer.write(result.first.toJson())
}
}
}
}
}
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