TestElasticSearchWrapper.kt 1.62 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.memobase

import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.assertAll
import org.memobase.helpers.ElasticSearchWrapper
import java.util.Properties
import org.junit.jupiter.api.Disabled
import org.memobase.helpers.KEYS

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestElasticSearchWrapper {

    private val documentTypeLabelPath = "src/test/resources/configs/document-type-labels.csv"

    @Test
    // @Disabled
    fun `test connect`() {
        val props = Properties()
        props.setProperty("elastic.host", "localhost")
        props.setProperty("elastic.port", "8080")
        props.setProperty("elastic.index", "documents-v14")
        props.setProperty(KEYS.SettingsProps.documentTypeLabelsPath, documentTypeLabelPath)

        val wrapper = ElasticSearchWrapper(props)
        val client = wrapper.connect()
        assertAll("",
            { assertThat(client).isNotNull }
        )
    }

    @Test
    // @Disabled
    fun `test getDocumentTypesFromRecords`() {
        val props = Properties()
        props.setProperty("elastic.host", "localhost")
        props.setProperty("elastic.port", "8080")
        props.setProperty("elastic.index", "documents-v14")
        props.setProperty(KEYS.SettingsProps.documentTypeLabelsPath, documentTypeLabelPath)
        val wrapper = ElasticSearchWrapper(props)

        val results = wrapper.getDocumentTypesFromRecords("IASA-Collart", "recordSet.facet")
        assertAll("",
                { assertThat(results)
                        .hasSize(1)}
                )
    }
}