TestCheckLocator.kt 899 Bytes
Newer Older
Jonas Waeber's avatar
Jonas Waeber committed
1 2 3 4 5 6 7 8 9 10 11 12
package org.memobase

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 {
    @Test
    fun `test check locator no digital object`() {
Jonas Waeber's avatar
Jonas Waeber committed
13
        val result = Filter.checkLocator(null)
Jonas Waeber's avatar
Jonas Waeber committed
14 15 16 17 18 19 20 21
        assertThat(result).isFalse()
    }

    @Test
    fun `test check locator digital object no locator`() {
        val result = Filter.checkLocator(json {
            obj(
            )
Jonas Waeber's avatar
Jonas Waeber committed
22
        })
Jonas Waeber's avatar
Jonas Waeber committed
23 24 25 26
        assertThat(result).isFalse()
    }

    @Test
Jonas Waeber's avatar
Jonas Waeber committed
27
    fun `test check locator digital object has locator`() {
Jonas Waeber's avatar
Jonas Waeber committed
28 29 30 31
        val result = Filter.checkLocator(json {
            obj(
                Pair("locator", "https://example.org")
            )
Jonas Waeber's avatar
Jonas Waeber committed
32
        })
Jonas Waeber's avatar
Jonas Waeber committed
33 34 35
        assertThat(result).isTrue()
    }
}