In order to mitigate against the brute force attacks against Gitlab accounts, we are moving to all edu-ID Logins. We would like to remind you to link your account with your edu-id. Login will be possible only by edu-ID after November 30, 2021. Here you can find the instructions for linking your account.

If you don't have a SWITCH edu-ID, you can create one with this guide here

kind regards

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

Add tests for singel date issue.

parent 0e17c239
Pipeline #23068 passed with stage
in 3 minutes and 2 seconds
......@@ -15,7 +15,12 @@
*/
package ch.memobase
import ch.memobase.configs.GlobalTransformsLoader
import ch.memobase.helpers.Date
import ch.memobase.rdf.MemobaseModel
import ch.memobase.rdf.RICO
import ch.memobase.rdf.RicoResource
import ch.memobase.transform.DateNormalizationTransform
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
......@@ -38,4 +43,28 @@ class TestDates {
assertThat(nullDate)
.isEqualTo(null)
}
@Test
fun `test year range normalization`() {
val value = "1911-1920"
val model = MemobaseModel()
val resource = RicoResource(
model.createResource(),
RICO.DateSet
)
resource.addLiteral(RICO.expressedDate, value)
val transforms = GlobalTransformsLoader(TestUtils.pathGlobalTransformSettings).get()
val dateNormalizer = transforms.first { it is DateNormalizationTransform }
dateNormalizer as DateNormalizationTransform
dateNormalizer.transform(resource, model)
assertThat(resource)
.satisfies {
assertThat(it.resource.hasLiteral(RICO.normalizedDateValue, "1911/1920"))
.isTrue()
}
}
}
package ch.memobase
object TestUtils {
const val pathGlobalTransformSettings = "src/test/resources/global/transforms.yml"
}
\ No newline at end of file
(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})T(?<time>\d{2}:\d{2}:\d{2})
(?<year>\d{4})[-]*(?<month>\d{2})[-]*(?<day>\d{2})
(?<day>\d{2})[.-]*(?<month>\d{2})[.-]*(?<year>\d{4})
\ No newline at end of file
(?<year>\d{4})-(?<month>[0-2][0-9])-(?<day>[1-3][0-9])
(?<year>\d{4})(?<month>[0-2][0-9])(?<day>[1-3][0-9])
(?<day>[1-3][0-9])\.(?<month>[0-2][0-9])\.(?<year>\d{4})
(?<day>[1-3][0-9])-(?<month>[0-2][0-9])-(?<year>\d{4})
\ No newline at end of file
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