Commit 8bbb8927 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Refactor org.memobase to ch.memobase

parent 11497cb3
Pipeline #26593 passed with stages
in 4 minutes and 31 seconds
......@@ -15,10 +15,11 @@
* 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.model
package ch.memobase.model
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonInclude
import ch.memobase.model.Schema
@JsonInclude(JsonInclude.Include.NON_EMPTY)
......
......@@ -15,7 +15,7 @@
* 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.model
package ch.memobase.model
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.databind.ObjectMapper
......
......@@ -15,7 +15,7 @@
* 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.model
package ch.memobase.model
import com.fasterxml.jackson.annotation.JsonInclude
......
......@@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.memobase.model
package ch.memobase.model
import com.fasterxml.jackson.annotation.JsonInclude
......
......@@ -15,7 +15,7 @@
* 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.model
package ch.memobase.model
import com.fasterxml.jackson.annotation.JsonInclude
......
......@@ -15,7 +15,7 @@
* 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.model
package ch.memobase.model
data class UpdateQuery(
val term: String,
......
......@@ -15,8 +15,12 @@
* 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
package ch.memobase
import ch.memobase.helpers.ElasticSearchWrapper
import ch.memobase.model.FacetContainer
import ch.memobase.model.LanguageContainer
import ch.memobase.params.TestParam
import io.mockk.every
import io.mockk.mockk
import java.io.File
......@@ -32,11 +36,6 @@ import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.assertAll
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.memobase.helpers.ElasticSearchWrapper
import org.memobase.model.FacetContainer
import org.memobase.model.FacetContainer.Companion
import org.memobase.model.LanguageContainer
import org.memobase.params.TestParam
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class IntegrationTest {
......
package org.memobase
/*
* search-doc-service
* 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 ch.memobase
import ch.memobase.helpers.Filter
import com.beust.klaxon.json
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.memobase.helpers.Filter
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestCheckLocator {
......
package org.memobase
/*
* search-doc-service
* 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 ch.memobase
import ch.memobase.helpers.ElasticSearchWrapper
import ch.memobase.helpers.JsonUtility
import ch.memobase.model.DocumentsSearchDoc
import ch.memobase.model.LanguageContainer
import io.mockk.every
import io.mockk.mockk
import java.io.File
......@@ -7,10 +28,6 @@ import java.nio.charset.Charset
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.memobase.helpers.ElasticSearchWrapper
import org.memobase.helpers.JsonUtility
import org.memobase.model.DocumentsSearchDoc
import org.memobase.model.LanguageContainer
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestDocumentsSearchDoc {
......
package org.memobase
/*
* search-doc-service
* 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 ch.memobase
import java.net.ConnectException
import java.net.SocketTimeoutException
......@@ -16,9 +33,9 @@ import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.assertAll
import org.memobase.helpers.ElasticSearchWrapper
import org.memobase.model.FacetContainer
import org.memobase.model.LanguageContainer
import ch.memobase.helpers.ElasticSearchWrapper
import ch.memobase.model.FacetContainer
import ch.memobase.model.LanguageContainer
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Disabled("Does not work in CI environment.")
......
......@@ -15,9 +15,13 @@
* 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 ch.memobase
package org.memobase
import ch.memobase.builders.PersonFacetBuilder
import ch.memobase.helpers.Constants
import ch.memobase.helpers.DateFacetBuildHelpers
import ch.memobase.params.PersonFacetBuilderParams
import ch.memobase.params.TestDate
import ch.memobase.rdf.NS
import com.beust.klaxon.json
import java.util.stream.Stream
......@@ -27,11 +31,6 @@ import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.assertAll
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.memobase.builders.PersonFacetBuilder
import org.memobase.helpers.DateFacetBuildHelpers
import org.memobase.helpers.Constants
import org.memobase.params.PersonFacetBuilderParams
import org.memobase.params.TestDate
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestFacetBuilders {
......@@ -44,73 +43,73 @@ class TestFacetBuilders {
val log = builder.append("key", params.source)
val result = builder.build()
assertAll("",
{ assertThat(log).isEqualTo(params.log) },
{ assertThat(params.result).containsAll(result.facet) }
{ assertThat(log).isEqualTo(params.log) },
{ assertThat(params.result).containsAll(result.facet) }
)
} else {
assertThat(params.source)
.hasEntrySatisfying("@type") { value -> value.let { if (it is String) NS.rico + "Person" == it else false } }
.hasEntrySatisfying("@type") { value -> value.let { if (it is String) NS.rico + "Person" == it else false } }
}
}
private fun testPersons() = Stream.of(
PersonFacetBuilderParams(
json { obj(Pair("@type", NS.rico + "Record")) },
mapOf(),
"",
"",
emptyList()
),
PersonFacetBuilderParams(
json {
obj(
Pair(Constants.atType, NS.rico + "Person"),
Pair(Constants.name, "Einstein, Albert"),
Pair(Constants.agentIsTargetOfCreationRelation, "identifier")
)
},
mapOf(Pair("identifier", json { obj(Pair(Constants.ricoType, Constants.creator)) })),
Constants.creator,
"",
listOf(
"0~E~",
"1~E~Einstein, Albert~"
)
),
PersonFacetBuilderParams(
json {
obj(
Pair("@type", NS.rico + "Person"),
Pair(Constants.name, "Einstein"),
Pair(Constants.lastName, "Einstein"),
Pair(Constants.agentIsTargetOfCreationRelation, "identifier")
)
},
mapOf(Pair("identifier", json { obj(Pair(Constants.ricoType, Constants.contributor)) })),
Constants.contributor,
"",
listOf(
"0~E~",
"1~E~Einstein~"
)
),
PersonFacetBuilderParams(
json {
obj(
Pair("@type", NS.rico + "Person"),
Pair(Constants.name, "Albert"),
Pair(Constants.firstName, "Albert"),
Pair(Constants.agentIsTargetOfCreationRelation, "identifier")
)
},
mapOf(Pair("identifier", json { obj(Pair(Constants.ricoType, Constants.contributor)) })),
Constants.contributor,
"",
listOf(
"0~A~",
"1~A~Albert~"
)
PersonFacetBuilderParams(
json { obj(Pair("@type", NS.rico + "Record")) },
mapOf(),
"",
"",
emptyList()
),
PersonFacetBuilderParams(
json {
obj(
Pair(Constants.atType, NS.rico + "Person"),
Pair(Constants.name, "Einstein, Albert"),
Pair(Constants.agentIsTargetOfCreationRelation, "identifier")
)
},
mapOf(Pair("identifier", json { obj(Pair(Constants.ricoType, Constants.creator)) })),
Constants.creator,
"",
listOf(
"0~E~",
"1~E~Einstein, Albert~"
)
),
PersonFacetBuilderParams(
json {
obj(
Pair("@type", NS.rico + "Person"),
Pair(Constants.name, "Einstein"),
Pair(Constants.lastName, "Einstein"),
Pair(Constants.agentIsTargetOfCreationRelation, "identifier")
)
},
mapOf(Pair("identifier", json { obj(Pair(Constants.ricoType, Constants.contributor)) })),
Constants.contributor,
"",
listOf(
"0~E~",
"1~E~Einstein~"
)
),
PersonFacetBuilderParams(
json {
obj(
Pair("@type", NS.rico + "Person"),
Pair(Constants.name, "Albert"),
Pair(Constants.firstName, "Albert"),
Pair(Constants.agentIsTargetOfCreationRelation, "identifier")
)
},
mapOf(Pair("identifier", json { obj(Pair(Constants.ricoType, Constants.contributor)) })),
Constants.contributor,
"",
listOf(
"0~A~",
"1~A~Albert~"
)
)
)
@Test
......@@ -119,27 +118,27 @@ class TestFacetBuilders {
builder.append("key", json {
obj(
Pair(Constants.atType, NS.rico + "Person"),
Pair(Constants.name, "Einstein, Albert"),
Pair(Constants.agentIsTargetOfCreationRelation, "identifier")
Pair(Constants.atType, NS.rico + "Person"),
Pair(Constants.name, "Einstein, Albert"),
Pair(Constants.agentIsTargetOfCreationRelation, "identifier")
)
})
builder.append("key", json {
obj(
Pair(Constants.atType, NS.rico + "Person"),
Pair(Constants.name, "Albert, Einstein"),
Pair(Constants.agentIsTargetOfCreationRelation, "identifier")
Pair(Constants.atType, NS.rico + "Person"),
Pair(Constants.name, "Albert, Einstein"),
Pair(Constants.agentIsTargetOfCreationRelation, "identifier")
)
})
val result = builder.build()
assertThat(result.facet)
.isSortedAccordingTo { s, s2 -> s.substring(2).compareTo(s2.substring(2)) }
.containsAll(
listOf(
"0~A~", "1~A~Albert, Einstein~", "0~E~", "1~E~Einstein, Albert~"
)
.isSortedAccordingTo { s, s2 -> s.substring(2).compareTo(s2.substring(2)) }
.containsAll(
listOf(
"0~A~", "1~A~Albert, Einstein~", "0~E~", "1~E~Einstein, Albert~"
)
)
}
@ParameterizedTest
......@@ -155,119 +154,119 @@ class TestFacetBuilders {
}
assertThat(result)
.isEqualTo(date.result)
.isEqualTo(date.result)
}
private fun testDates() = Stream.of(
TestDate(
"1920-09-14",
"single",
listOf(
"0~20.Jahrhundert~", "1~20.Jahrhundert~1911-1920~"
)
),
TestDate(
"1921-09-14",
"single",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1921",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1921/1922",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1921-05-01/02",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1921-05-01/06-02",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1920/1930",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1911-1920~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1921/1931",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~", "1~20.Jahrhundert~1931-1940~")
),
TestDate(
"1921-04-01/1931-05-02",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~", "1~20.Jahrhundert~1931-1940~")
),
TestDate(
"1921/1951",
"range",
listOf(
"0~20.Jahrhundert~",
"1~20.Jahrhundert~1921-1930~",
"1~20.Jahrhundert~1931-1940~",
"1~20.Jahrhundert~1941-1950~",
"1~20.Jahrhundert~1951-1960~"
)
),
TestDate(
"1721/1951",
"range",
listOf(
"0~18.Jahrhundert~",
"0~19.Jahrhundert~",
"0~20.Jahrhundert~",
"1~18.Jahrhundert~1721-1730~",
"1~18.Jahrhundert~1731-1740~",
"1~18.Jahrhundert~1741-1750~",
"1~18.Jahrhundert~1751-1760~",
"1~18.Jahrhundert~1761-1770~",
"1~18.Jahrhundert~1771-1780~",
"1~18.Jahrhundert~1781-1790~",
"1~18.Jahrhundert~1791-1800~",
"1~19.Jahrhundert~1801-1810~",
"1~19.Jahrhundert~1811-1820~",
"1~19.Jahrhundert~1821-1830~",
"1~19.Jahrhundert~1831-1840~",
"1~19.Jahrhundert~1841-1850~",
"1~19.Jahrhundert~1851-1860~",
"1~19.Jahrhundert~1861-1870~",
"1~19.Jahrhundert~1871-1880~",
"1~19.Jahrhundert~1881-1890~",
"1~19.Jahrhundert~1891-1900~",
"1~20.Jahrhundert~1901-1910~",
"1~20.Jahrhundert~1911-1920~",
"1~20.Jahrhundert~1921-1930~",
"1~20.Jahrhundert~1931-1940~",
"1~20.Jahrhundert~1941-1950~",
"1~20.Jahrhundert~1951-1960~"
)
),
TestDate(
"1721/1822",
"range",
listOf(
"0~18.Jahrhundert~",
"0~19.Jahrhundert~",
"1~18.Jahrhundert~1721-1730~",
"1~18.Jahrhundert~1731-1740~",
"1~18.Jahrhundert~1741-1750~",
"1~18.Jahrhundert~1751-1760~",
"1~18.Jahrhundert~1761-1770~",
"1~18.Jahrhundert~1771-1780~",
"1~18.Jahrhundert~1781-1790~",
"1~18.Jahrhundert~1791-1800~",
"1~19.Jahrhundert~1801-1810~",
"1~19.Jahrhundert~1811-1820~",
"1~19.Jahrhundert~1821-1830~"
)
TestDate(
"1920-09-14",
"single",
listOf(
"0~20.Jahrhundert~", "1~20.Jahrhundert~1911-1920~"
)
),
TestDate(
"1921-09-14",
"single",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1921",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1921/1922",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1921-05-01/02",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1921-05-01/06-02",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1920/1930",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1911-1920~", "1~20.Jahrhundert~1921-1930~")
),
TestDate(
"1921/1931",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~", "1~20.Jahrhundert~1931-1940~")
),
TestDate(
"1921-04-01/1931-05-02",
"range",
listOf("0~20.Jahrhundert~", "1~20.Jahrhundert~1921-1930~", "1~20.Jahrhundert~1931-1940~")
),
TestDate(
"1921/1951",
"range",
listOf(
"0~20.Jahrhundert~",
"1~20.Jahrhundert~1921-1930~",
"1~20.Jahrhundert~1931-1940~",
"1~20.Jahrhundert~1941-1950~",
"1~20.Jahrhundert~1951-1960~"
)
),
TestDate(
"1721/1951",
"range",
listOf(
"0~18.Jahrhundert~",
"0~19.Jahrhundert~",
"0~20.Jahrhundert~",
"1~18.Jahrhundert~1721-1730~",
"1~18.Jahrhundert~1731-1740~",
"1~18.Jahrhundert~1741-1750~",
"1~18.Jahrhundert~1751-1760~",
"1~18.Jahrhundert~1761-1770~",
"1~18.Jahrhundert~1771-1780~",
"1~18.Jahrhundert~1781-1790~",
"1~18.Jahrhundert~1791-1800~",
"1~19.Jahrhundert~1801-1810~",
"1~19.Jahrhundert~1811-1820~",
"1~19.Jahrhundert~1821-1830~",
"1~19.Jahrhundert~1831-1840~",
"1~19.Jahrhundert~1841-1850~",
"1~19.Jahrhundert~1851-1860~",
"1~19.Jahrhundert~1861-1870~",
"1~19.Jahrhundert~1871-1880~",
"1~19.Jahrhundert~1881-1890~",
"1~19.Jahrhundert~1891-1900~",
"1~20.Jahrhundert~1901-1910~",
"1~20.Jahrhundert~1911-1920~",
"1~20.Jahrhundert~1921-1930~",
"1~20.Jahrhundert~1931-1940~",
"1~20.Jahrhundert~1941-1950~",
"1~20.Jahrhundert~1951-1960~"
)
),
TestDate(
"1721/1822",
"range",
listOf(
"0~18.Jahrhundert~",
"0~19.Jahrhundert~",