Commit 077ce4cc authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Add large file test

fix report status source
parent e423f271
Pipeline #30305 failed with stages
in 1 minute and 47 seconds
......@@ -28,6 +28,7 @@ import org.apache.logging.log4j.LogManager
import org.apache.poi.ss.usermodel.WorkbookFactory
import org.xml.sax.SAXException
import ch.memobase.reporting.Report
import ch.memobase.reporting.ReportStatus
class FileValidation {
private val log = LogManager.getLogger("TextFileValidationService")
......@@ -61,7 +62,7 @@ class FileValidation {
Message(Formats.error, file.path),
Report(
id = file.name,
status = ReportStatus.failure,
status = ReportStatus.fatal,
message = ReportMessages.formatError(file.path, format, ex.localizedMessage),
step = Service.step
)
......@@ -87,7 +88,7 @@ class FileValidation {
Message(Formats.error, file.path),
Report(
id = file.name,
status = ReportStatus.failure,
status = ReportStatus.fatal,
message = ReportMessages.formatError(file.path, format, ex.localizedMessage),
step = Service.step
)
......@@ -123,7 +124,7 @@ class FileValidation {
Message(Formats.error, file.path),
Report(
id = file.name,
status = ReportStatus.failure,
status = ReportStatus.fatal,
message = ReportMessages.formatError(file.path, format, ex.localizedMessage),
step = Service.step
)
......@@ -133,7 +134,7 @@ class FileValidation {
Message(Formats.error, file.path),
Report(
id = file.name,
status = ReportStatus.failure,
status = ReportStatus.fatal,
message = ReportMessages.formatError(file.path, format, ex.localizedMessage),
step = Service.step
)
......@@ -145,7 +146,7 @@ class FileValidation {
Message(Formats.error, file.path),
Report(
id = file.name,
status = ReportStatus.failure,
status = ReportStatus.fatal,
message = ReportMessages.invalidFileExtension(file.name),
step = Service.step
)
......
......@@ -38,11 +38,6 @@ object Extensions {
const val xml = "xml"
}
object ReportStatus {
const val success = "SUCCESS"
const val failure = "FAILURE"
}
object ReportMessages {
fun processFailure(failures: Int, total: Int): String {
return "Failed to validate $failures of $total files."
......
/*
* 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 ch.memobase.reporting.ReportStatus
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.memobase.FileValidation
import org.memobase.Formats
import java.io.File
import java.io.FileInputStream
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestFileValidation {
private val path = "src/test/resources/data"
@Test
fun testLargeFileValidation() {
val validation = FileValidation()
val result = validation.validate(
FileInputStream(File("$path/test_large_file.xlsx")),
Formats.xlsx,
File("$path/test_large_file.xlsx")
)
assertThat(result.second.status)
.isEqualTo(ReportStatus.success)
}
}
\ No newline at end of file
Supports Markdown
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