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

Update record set & institution index generation & tests.

parent 0e5460f2
Pipeline #21852 passed with stages
in 5 minutes and 17 seconds
...@@ -34,7 +34,7 @@ ext { ...@@ -34,7 +34,7 @@ ext {
dependencies { dependencies {
compile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-high-level-client', version: '7.6.1' compile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-high-level-client', version: '7.6.1'
implementation 'org.memobase:memobase-service-utilities:2.0.9' implementation 'org.memobase:memobase-service-utilities:2.0.13'
implementation 'org.apache.jena:apache-jena:3.14.0' implementation 'org.apache.jena:apache-jena:3.14.0'
// Logging Framework // Logging Framework
......
...@@ -7,6 +7,7 @@ data: ...@@ -7,6 +7,7 @@ data:
APPLICATION_ID: "{{ .Values.deploymentName }}-app" APPLICATION_ID: "{{ .Values.deploymentName }}-app"
DOCUMENTS_INDEX: "{{ .Values.documentsIndex }}" DOCUMENTS_INDEX: "{{ .Values.documentsIndex }}"
INSTITUTION_INDEX: "{{ .Values.institutionIndex }}" INSTITUTION_INDEX: "{{ .Values.institutionIndex }}"
RECORD_SET_INDEX: "{{ .Values.recordSetIndex }}"
MEDIA_SERVER_URL: "{{ .Values.mediaServerUrl }}" MEDIA_SERVER_URL: "{{ .Values.mediaServerUrl }}"
TOPIC_IN: "{{ .Values.inputTopic }}" TOPIC_IN: "{{ .Values.inputTopic }}"
TOPIC_OUT: "{{ .Values.outputTopic }}" TOPIC_OUT: "{{ .Values.outputTopic }}"
......
...@@ -9,6 +9,7 @@ elasticConfigs: prod-elastic-configs ...@@ -9,6 +9,7 @@ elasticConfigs: prod-elastic-configs
documentsIndex: documents-v17 documentsIndex: documents-v17
institutionIndex: institutions-v1 institutionIndex: institutions-v1
recordSetIndex: record-sets-v1
outputTopic: search-doc-output-documents outputTopic: search-doc-output-documents
inputTopic: search-doc-input-documents inputTopic: search-doc-input-documents
reportingTopic: postprocessing-reporting reportingTopic: postprocessing-reporting
......
...@@ -24,7 +24,7 @@ import org.memobase.helpers.KEYS.SettingsProps ...@@ -24,7 +24,7 @@ import org.memobase.helpers.KEYS.SettingsProps
class App { class App {
companion object { companion object {
private val log = LogManager.getLogger("App") private val log = LogManager.getLogger("SearchDocServiceApp")
fun createSettings(file: String): SettingsLoader { fun createSettings(file: String): SettingsLoader {
return SettingsLoader( return SettingsLoader(
listOf( listOf(
...@@ -36,7 +36,8 @@ class App { ...@@ -36,7 +36,8 @@ class App {
SettingsProps.elasticHost, SettingsProps.elasticHost,
SettingsProps.elasticPort, SettingsProps.elasticPort,
SettingsProps.documentsIndex, SettingsProps.documentsIndex,
SettingsProps.institutionIndex SettingsProps.institutionIndex,
SettingsProps.recordSetIndex
), ),
file, file,
useStreamsConfig = true useStreamsConfig = true
......
...@@ -19,9 +19,10 @@ ...@@ -19,9 +19,10 @@
package org.memobase package org.memobase
import ch.memobase.rdf.DC import ch.memobase.rdf.DC
import ch.memobase.rdf.NS
import ch.memobase.rdf.RDA import ch.memobase.rdf.RDA
import ch.memobase.rdf.RDF
import ch.memobase.rdf.RICO import ch.memobase.rdf.RICO
import ch.memobase.rdf.RICO.Types.RecordSet
import com.beust.klaxon.JsonObject import com.beust.klaxon.JsonObject
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import org.memobase.helpers.Date import org.memobase.helpers.Date
...@@ -42,8 +43,8 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW ...@@ -42,8 +43,8 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW
fun transform(key: String, input: Map<String, JsonObject>): Schema { fun transform(key: String, input: Map<String, JsonObject>): Schema {
val recordSet = val recordSet =
input[JSON.recordSetTag] ?: throw InvalidInputException("No record set entity found in message $key.") input[JSON.recordSetTag] ?: throw InvalidInputException("No record set entity found in message $key.")
val publicationIds = Extract.identifiers(recordSet[RICO.isSubjectOf.localName]) val relatedRecordSetIds =
val relatedRecordSetIds = Extract.identifiers(recordSet[RICO.isRecordResourceAssociatedWithRecordResource.localName]) Extract.identifiers(recordSet[RICO.isRecordResourceAssociatedWithRecordResource.localName])
val metadataLanguages = mutableListOf<JsonObject>() val metadataLanguages = mutableListOf<JsonObject>()
var originalTitles = LanguageContainer.EMPTY var originalTitles = LanguageContainer.EMPTY
var projectTitles = LanguageContainer.EMPTY var projectTitles = LanguageContainer.EMPTY
...@@ -63,19 +64,25 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW ...@@ -63,19 +64,25 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW
it[RICO.type.localName] == KEYS.CorporateBodyType.memoriavProject -> { it[RICO.type.localName] == KEYS.CorporateBodyType.memoriavProject -> {
projectTitles = projectTitles.add(it[RICO.title.localName]) projectTitles = projectTitles.add(it[RICO.title.localName])
} }
it[KEYS.atType] == RICO.RecordSet.uri && it[KEYS.atType] == RICO.RecordSet.uri && it[RICO.type.localName] == RecordSet.related -> {
relatedRecordSetIds.contains(it[KEYS.entityId]) -> {
relatedRecordSets = relatedRecordSets.add(it[RICO.title.localName]) relatedRecordSets = relatedRecordSets.add(it[RICO.title.localName])
} }
it[KEYS.atType] == RICO.Record.uri -> { it[KEYS.atType] == RICO.Record.uri -> {
if (publicationIds.contains(it[KEYS.entityId])) { if (it[RICO.type.localName] == RICO.Types.Record.publication) {
publicationTitles = publicationTitles.add(it[RICO.title.localName]) publicationTitles = publicationTitles.add(it[RICO.title.localName])
} else { } else if (it[RICO.type.localName] == RICO.Types.Record.related) {
relatedDocumentTitles = relatedDocumentTitles.add(it[RICO.title.localName]) relatedDocumentTitles = relatedDocumentTitles.add(it[RICO.title.localName])
} }
} }
} }
} }
// related record sets which are present in memobase.
relatedRecordSetIds.forEach { id ->
if (id.startsWith(NS.mbrs)) {
val languageContainer = elasticSearchWrapper.getRecordSetName(id.substringAfterLast("/"))
relatedRecordSets = relatedRecordSets.merge(languageContainer)
}
}
val name = extractLanguageContainer(recordSet[RICO.title.localName], "") val name = extractLanguageContainer(recordSet[RICO.title.localName], "")
val dates = Extract.identifiers(recordSet[RICO.isAssociatedWithDate.localName]).mapNotNull { val dates = Extract.identifiers(recordSet[RICO.isAssociatedWithDate.localName]).mapNotNull {
......
...@@ -40,8 +40,7 @@ class Service(settings: SettingsLoader) { ...@@ -40,8 +40,7 @@ class Service(settings: SettingsLoader) {
const val name = "search-doc-service" const val name = "search-doc-service"
} }
private val log = LogManager.getLogger("SearchDocService") private val log = LogManager.getLogger("SearchDocServiceService")
private val appSettings = settings.appSettings private val appSettings = settings.appSettings
private val documentMapperPath = appSettings.getProperty(SettingsProps.documentTypeLabelsPath) private val documentMapperPath = appSettings.getProperty(SettingsProps.documentTypeLabelsPath)
...@@ -55,6 +54,7 @@ class Service(settings: SettingsLoader) { ...@@ -55,6 +54,7 @@ class Service(settings: SettingsLoader) {
private val port = appSettings.getProperty(SettingsProps.elasticPort).toInt() private val port = appSettings.getProperty(SettingsProps.elasticPort).toInt()
private val documentsIndex = appSettings.getProperty(SettingsProps.documentsIndex) private val documentsIndex = appSettings.getProperty(SettingsProps.documentsIndex)
private val institutionIndex = appSettings.getProperty(SettingsProps.institutionIndex) private val institutionIndex = appSettings.getProperty(SettingsProps.institutionIndex)
private val recordSetIndex = appSettings.getProperty(SettingsProps.recordSetIndex)
private val client: RestHighLevelClient = connect() private val client: RestHighLevelClient = connect()
private fun connect(): RestHighLevelClient { private fun connect(): RestHighLevelClient {
...@@ -67,13 +67,20 @@ class Service(settings: SettingsLoader) { ...@@ -67,13 +67,20 @@ class Service(settings: SettingsLoader) {
val indexExists = c.indices().exists(GetIndexRequest(documentsIndex), RequestOptions.DEFAULT) val indexExists = c.indices().exists(GetIndexRequest(documentsIndex), RequestOptions.DEFAULT)
val aliasExists = c.indices().existsAlias(GetAliasesRequest(documentsIndex), RequestOptions.DEFAULT) val aliasExists = c.indices().existsAlias(GetAliasesRequest(documentsIndex), RequestOptions.DEFAULT)
val institutionIndexExists = c.indices().exists(GetIndexRequest(institutionIndex), RequestOptions.DEFAULT) val institutionIndexExists = c.indices().exists(GetIndexRequest(institutionIndex), RequestOptions.DEFAULT)
val institutionIndexAliasExists = c.indices().existsAlias(GetAliasesRequest(institutionIndex), RequestOptions.DEFAULT) val institutionIndexAliasExists =
c.indices().existsAlias(GetAliasesRequest(institutionIndex), RequestOptions.DEFAULT)
val recordSetIndexExists = c.indices().exists(GetIndexRequest(recordSetIndex), RequestOptions.DEFAULT)
val recordSetIndexAliasExists =
c.indices().existsAlias(GetAliasesRequest(recordSetIndex), RequestOptions.DEFAULT)
if (!indexExists && !aliasExists && !institutionIndexExists && !institutionIndexAliasExists) { if (!indexExists && !aliasExists && !institutionIndexExists && !institutionIndexAliasExists
log.error("Could not find the indices or aliases defined in the configuration: $documentsIndex, $institutionIndex.") && !recordSetIndexExists && !recordSetIndexAliasExists
) {
log.error("Could not find at least one index name or alias defined " +
"in the configuration: $documentsIndex, $institutionIndex, $recordSetIndex.")
exitProcess(1) exitProcess(1)
} else { } else {
log.info("Successfully connected to indices $documentsIndex and $institutionIndex. Ready to query.") log.info("Connected to $documentsIndex, $institutionIndex, $recordSetIndex. Ready to query.")
c c
} }
} catch (ex: ElasticsearchException) { } catch (ex: ElasticsearchException) {
...@@ -88,7 +95,8 @@ class Service(settings: SettingsLoader) { ...@@ -88,7 +95,8 @@ class Service(settings: SettingsLoader) {
} }
} }
private val elasticSearchWrapper = ElasticSearchWrapper(appSettings, client, translationMappers) private val elasticSearchWrapper =
ElasticSearchWrapper(client, translationMappers, documentsIndex, institutionIndex, recordSetIndex)
private val topology = KafkaTopology(settings, translationMappers, elasticSearchWrapper).build() private val topology = KafkaTopology(settings, translationMappers, elasticSearchWrapper).build()
private val stream = KafkaStreams(topology, settings.kafkaStreamsSettings) private val stream = KafkaStreams(topology, settings.kafkaStreamsSettings)
......
...@@ -19,7 +19,6 @@ package org.memobase.helpers ...@@ -19,7 +19,6 @@ package org.memobase.helpers
import com.beust.klaxon.Klaxon import com.beust.klaxon.Klaxon
import com.beust.klaxon.KlaxonException import com.beust.klaxon.KlaxonException
import java.util.Properties
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import org.elasticsearch.ElasticsearchException import org.elasticsearch.ElasticsearchException
import org.elasticsearch.action.get.GetRequest import org.elasticsearch.action.get.GetRequest
...@@ -35,7 +34,6 @@ import org.elasticsearch.search.Scroll ...@@ -35,7 +34,6 @@ import org.elasticsearch.search.Scroll
import org.elasticsearch.search.builder.SearchSourceBuilder import org.elasticsearch.search.builder.SearchSourceBuilder
import org.memobase.model.FacetContainer import org.memobase.model.FacetContainer
import org.memobase.model.LanguageContainer import org.memobase.model.LanguageContainer
import org.memobase.model.LanguageContainer.Companion
/** /**
...@@ -43,18 +41,15 @@ import org.memobase.model.LanguageContainer.Companion ...@@ -43,18 +41,15 @@ import org.memobase.model.LanguageContainer.Companion
* the necessary data. * the necessary data.
*/ */
class ElasticSearchWrapper( class ElasticSearchWrapper(
settings: Properties,
private val client: RestHighLevelClient, private val client: RestHighLevelClient,
private val translationMappers: TranslationMappers private val translationMappers: TranslationMappers,
private val documentsIndex: String,
private val institutionIndex: String,
private val recordSetIndex: String
) { ) {
private val log = LogManager.getLogger("ElasticSearchWrapper") private val log = LogManager.getLogger("ElasticSearchWrapper")
private val documentsIndex = settings.getProperty(KEYS.SettingsProps.documentsIndex)
private val institutionIndex = settings.getProperty(KEYS.SettingsProps.institutionIndex)
private val klaxon = Klaxon() private val klaxon = Klaxon()
/** /**
* Counts the number of documents attached to a specific record set. * Counts the number of documents attached to a specific record set.
* *
...@@ -181,4 +176,23 @@ class ElasticSearchWrapper( ...@@ -181,4 +176,23 @@ class ElasticSearchWrapper(
} }
fun getRecordSetName(identifier: String): LanguageContainer {
return try {
log.info("Attempting to retrieve record set document from $recordSetIndex.")
val request = GetRequest(recordSetIndex, identifier)
val response = client.get(request, RequestOptions.DEFAULT)
if (response.isExists) {
val map = response.sourceAsMap.getValue("name")
log.info("Successfully retrieved record set names: $map.")
LanguageContainer.fromMap(map)
} else {
log.error("Could not find record set $identifier in index $recordSetIndex.")
LanguageContainer.EMPTY
}
} catch (ex: ElasticsearchException) {
log.error(ex.detailedMessage)
LanguageContainer.EMPTY
}
}
} }
\ No newline at end of file
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
*/ */
package org.memobase.helpers package org.memobase.helpers
import ch.memobase.rdf.NS
import ch.memobase.rdf.RICO import ch.memobase.rdf.RICO
import ch.memobase.rdf.RICO.Types
import com.beust.klaxon.JsonArray import com.beust.klaxon.JsonArray
import com.beust.klaxon.JsonObject import com.beust.klaxon.JsonObject
import com.beust.klaxon.Klaxon import com.beust.klaxon.Klaxon
...@@ -52,9 +52,15 @@ object JSON { ...@@ -52,9 +52,15 @@ object JSON {
fun unpack(input: JsonObject): Map<String, JsonObject> { fun unpack(input: JsonObject): Map<String, JsonObject> {
val graph = input[graph] as JsonArray<JsonObject> val graph = input[graph] as JsonArray<JsonObject>
return graph.map { return graph.map {
if (it[KEYS.atType] == RICO.Record.uri) { if (it[KEYS.atType] == RICO.Record.uri && it[RICO.type.localName] !in listOf(
Types.Record.publication,
Types.Record.related
)
) {
Pair(recordTag, it) Pair(recordTag, it)
} else if (it[KEYS.atType] == RICO.RecordSet.uri) { } else if (it[KEYS.atType] == RICO.RecordSet.uri &&
it[RICO.type.localName] !in listOf(Types.RecordSet.original, Types.RecordSet.related)
) {
Pair(recordSetTag, it) Pair(recordSetTag, it)
} else if (it[KEYS.atType] == RICO.CorporateBody.uri && it[KEYS.ricoType] == KEYS.CorporateBodyType.memobaseInstitution) { } else if (it[KEYS.atType] == RICO.CorporateBody.uri && it[KEYS.ricoType] == KEYS.CorporateBodyType.memobaseInstitution) {
Pair(institutionTag, it) Pair(institutionTag, it)
......
...@@ -33,6 +33,7 @@ object KEYS { ...@@ -33,6 +33,7 @@ object KEYS {
const val elasticPort = "elastic.port" const val elasticPort = "elastic.port"
const val documentsIndex = "elastic.documentsIndex" const val documentsIndex = "elastic.documentsIndex"
const val institutionIndex = "elastic.institutionIndex" const val institutionIndex = "elastic.institutionIndex"
const val recordSetIndex = "elastic.recordSetIndex"
} }
......
...@@ -4,6 +4,7 @@ app: ...@@ -4,6 +4,7 @@ app:
port: ${ELASTIC_PORT:?system} port: ${ELASTIC_PORT:?system}
documentsIndex: ${DOCUMENTS_INDEX:?system} documentsIndex: ${DOCUMENTS_INDEX:?system}
institutionIndex: ${INSTITUTION_INDEX:?system} institutionIndex: ${INSTITUTION_INDEX:?system}
recordSetIndex: ${RECORD_SET_INDEX:?system}
media: media:
url: ${MEDIA_SERVER_URL:?system} url: ${MEDIA_SERVER_URL:?system}
institutionTypeLabelsPath: "/configs/institution_types/labels.csv" institutionTypeLabelsPath: "/configs/institution_types/labels.csv"
......
...@@ -2,7 +2,6 @@ package org.memobase ...@@ -2,7 +2,6 @@ package org.memobase
import java.net.ConnectException import java.net.ConnectException
import java.net.SocketTimeoutException import java.net.SocketTimeoutException
import java.util.Properties
import kotlin.system.exitProcess import kotlin.system.exitProcess
import org.apache.http.HttpHost import org.apache.http.HttpHost
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
...@@ -18,7 +17,6 @@ import org.junit.jupiter.api.Test ...@@ -18,7 +17,6 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.assertAll import org.junit.jupiter.api.assertAll
import org.memobase.helpers.ElasticSearchWrapper import org.memobase.helpers.ElasticSearchWrapper
import org.memobase.helpers.KEYS
import org.memobase.model.FacetContainer import org.memobase.model.FacetContainer
import org.memobase.model.LanguageContainer import org.memobase.model.LanguageContainer
...@@ -30,6 +28,7 @@ class TestElasticSearchWrapper { ...@@ -30,6 +28,7 @@ class TestElasticSearchWrapper {
private val port = 8080 private val port = 8080
private val documentsIndex = "documents-v17" private val documentsIndex = "documents-v17"
private val institutionIndex = "institutions-v1" private val institutionIndex = "institutions-v1"
private val recordSetIndex = "record-sets-v1"
private val client: RestHighLevelClient = connect() private val client: RestHighLevelClient = connect()
...@@ -66,12 +65,13 @@ class TestElasticSearchWrapper { ...@@ -66,12 +65,13 @@ class TestElasticSearchWrapper {
@Test @Test
@Disabled @Disabled
fun `test get institution name`() { fun `test get institution name`() {
val props = Properties() val wrapper = ElasticSearchWrapper(
props.setProperty(KEYS.SettingsProps.documentsIndex, documentsIndex) client,
props.setProperty(KEYS.SettingsProps.institutionIndex, institutionIndex) TestUtilities.translationMappers,
documentsIndex,
val wrapper = ElasticSearchWrapper(props, client, TestUtilities.translationMappers) institutionIndex,
recordSetIndex
)
val result = wrapper.getInstitutionName("aag") val result = wrapper.getInstitutionName("aag")
assertAll("", assertAll("",
{ {
...@@ -100,12 +100,13 @@ class TestElasticSearchWrapper { ...@@ -100,12 +100,13 @@ class TestElasticSearchWrapper {
@Test @Test
@Disabled @Disabled
fun `test getDocumentTypesFromRecords`() { fun `test getDocumentTypesFromRecords`() {
val props = Properties() val wrapper = ElasticSearchWrapper(
props.setProperty(KEYS.SettingsProps.documentsIndex, documentsIndex) client,
props.setProperty(KEYS.SettingsProps.institutionIndex, institutionIndex) TestUtilities.translationMappers,
documentsIndex,
val wrapper = ElasticSearchWrapper(props, client, TestUtilities.translationMappers) institutionIndex,
recordSetIndex
)
val results = wrapper.getDocumentTypesFromRecords("aag-001", "recordSet.facet") val results = wrapper.getDocumentTypesFromRecords("aag-001", "recordSet.facet")
assertAll("", assertAll("",
{ {
......
...@@ -18,6 +18,7 @@ import org.junit.jupiter.api.TestInstance ...@@ -18,6 +18,7 @@ import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.assertAll import org.junit.jupiter.api.assertAll
import org.memobase.helpers.ElasticSearchWrapper import org.memobase.helpers.ElasticSearchWrapper
import org.memobase.helpers.JSON import org.memobase.helpers.JSON
import org.memobase.helpers.KEYS.SettingsProps
import org.memobase.model.FacetContainer import org.memobase.model.FacetContainer
import org.memobase.model.InstitutionSearchDoc import org.memobase.model.InstitutionSearchDoc
import org.memobase.model.LanguageContainer import org.memobase.model.LanguageContainer
...@@ -25,7 +26,6 @@ import org.memobase.model.LanguageContainer ...@@ -25,7 +26,6 @@ import org.memobase.model.LanguageContainer
@TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestInstitutionSearchDoc { class TestInstitutionSearchDoc {
private val reader = ObjectMapper().registerKotlinModule().reader() private val reader = ObjectMapper().registerKotlinModule().reader()
private val dataPath = "src/test/resources/data/institution" private val dataPath = "src/test/resources/data/institution"
private fun readFile(fileName: String): String { private fun readFile(fileName: String): String {
return File("$dataPath/$fileName").readText(Charset.defaultCharset()) return File("$dataPath/$fileName").readText(Charset.defaultCharset())
...@@ -36,9 +36,11 @@ class TestInstitutionSearchDoc { ...@@ -36,9 +36,11 @@ class TestInstitutionSearchDoc {
fun `test institution search doc with production es client`() { fun `test institution search doc with production es client`() {
val props = App.createSettings("kafkaTest1.yml") val props = App.createSettings("kafkaTest1.yml")
val elastic = ElasticSearchWrapper( val elastic = ElasticSearchWrapper(
props.appSettings, TestUtilities.connectToElasticSearch("localhost", 8080, TestUtilities.currentDocumentsIndex),
TestUtilities.connectToElasticSearch("localhost", 8080, "documents-v17"), TestUtilities.translationMappers,
TestUtilities.translationMappers props.appSettings.getProperty(SettingsProps.documentsIndex),
props.appSettings.getProperty(SettingsProps.institutionIndex),
props.appSettings.getProperty(SettingsProps.recordSetIndex)
) )
val input = JSON.unpack(JSON.parse(readFile("completeExample.json"))) val input = JSON.unpack(JSON.parse(readFile("completeExample.json")))
...@@ -109,7 +111,7 @@ class TestInstitutionSearchDoc { ...@@ -109,7 +111,7 @@ class TestInstitutionSearchDoc {
val key = record.key() val key = record.key()
val value = record.value().replace(TestUtilities.dateRegex, "2020") val value = record.value().replace(TestUtilities.dateRegex, "2020")
val resultValue = readFile("completeExample.json").replace(TestUtilities.dateRegex, "2020") val resultValue = readFile("completeExampleOutput.json").replace(TestUtilities.dateRegex, "2020")
assertAll("", assertAll("",
{ {
......
...@@ -37,7 +37,7 @@ class TestRecordSetSearchDoc { ...@@ -37,7 +37,7 @@ class TestRecordSetSearchDoc {
fun `test create default record set `() { fun `test create default record set `() {
val searchDoc = RecordSetSearchDoc.DEFAULT val searchDoc = RecordSetSearchDoc.DEFAULT
assertThat(searchDoc.toJson()) assertThat(searchDoc.toJson())
.isEqualTo(readFile("default_record_set.json")) .isEqualTo(readFile("default_record_set.json"))
} }
...@@ -48,7 +48,13 @@ class TestRecordSetSearchDoc { ...@@ -48,7 +48,13 @@ class TestRecordSetSearchDoc {
val wrapper = mockk<ElasticSearchWrapper>() val wrapper = mockk<ElasticSearchWrapper>()
every { wrapper.countNumberOfDocuments("testComplete") } returns 102 every { wrapper.countNumberOfDocuments("testComplete") } returns 102
every { wrapper.getDocumentTypesFromRecords("testComplete", "recordSet.facet") } returns listOf(FacetContainer(LanguageContainer(listOf("Fotographie"), listOf("Photographie"), listOf("Fotografia"), emptyList()), null, emptyList())) every { wrapper.getDocumentTypesFromRecords("testComplete", "recordSet.facet") } returns listOf(
FacetContainer(
LanguageContainer(listOf("Fotographie"), listOf("Photographie"), listOf("Fotografia"), emptyList()),
null,
emptyList()
)
)
every { wrapper.getInstitutionName("completeInstitution") } returns FacetContainer( every { wrapper.getInstitutionName("completeInstitution") } returns FacetContainer(
LanguageContainer( LanguageContainer(
listOf("Test Complete"), listOf("Test Complete"),
...@@ -59,6 +65,13 @@ class TestRecordSetSearchDoc { ...@@ -59,6 +65,13 @@ class TestRecordSetSearchDoc {
"completeExampleTest", "completeExampleTest",
emptyList() emptyList()
) )
every {
wrapper.getRecordSetName("testComplete")
} returns LanguageContainer(
listOf("Complete Record Set (DE)"),
listOf("Complete Record Set (FR)"),
listOf("Complete Record Set (IT)")
)
val input = JSON.unpack(JSON.parse(data)) val input = JSON.unpack(JSON.parse(data))
val searchDocBuilder = RecordSetSearchDocBuilder(wrapper) val searchDocBuilder = RecordSetSearchDocBuilder(wrapper)
...@@ -69,14 +82,14 @@ class TestRecordSetSearchDoc { ...@@ -69,14 +82,14 @@ class TestRecordSetSearchDoc {
val targetString = readFile("completeExampleOutput.json").replace(TestUtilities.dateRegex, "2020") val targetString = readFile("completeExampleOutput.json").replace(TestUtilities.dateRegex, "2020")
assertAll("", assertAll("",
{ {
assertThat(result.id).isEqualTo("testComplete") assertThat(result.id).isEqualTo("testComplete")
}, },
{ {
assertThat(resultString).isEqualTo( assertThat(resultString).isEqualTo(
targetString targetString
) )
}