aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/utils/JsonMatcherTest.kt
blob: 9179176f910fa78a2094bc23e19a0efb5670aa63 (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package org.onap.ccsdk.cds.blueprintsprocessor.uat.utils

import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test

class JsonMatcherTest {
    @Test
    fun `matches easy case`() {
        val expected = """
         {
            "a": "b"
         }   
        """.trimIndent()
        val actual = """
         {
            "a": "b"
         }   
        """.trimIndent()
        assertTrue(JsonMatcher(expected).matches(actual))
    }

    @Test
    fun `matches fails easy case`() {
        val expected = """
         {
            "a": "b"
         }   
        """.trimIndent()
        val actual = """
         {
            "a": "c"
         }   
        """.trimIndent()
        assertFalse(JsonMatcher(expected).matches(actual))
    }

    @Test
    fun `matches easy case (actual is lenient aka Extensible)`() {
        val expected = """
         {
            "a": "b"
         }   
        """.trimIndent()
        val actual = """
         {
            "a": "b",
            "c": "d"
         }   
        """.trimIndent()
        assertTrue(JsonMatcher(expected).matches(actual))

        assertFalse(JsonMatcher(actual).matches(expected))
    }

    @Test
    fun `matches null`() {
        assertTrue(JsonMatcher(null).matches(null))
    }

    @Test
    fun `matches null and "null"`() {
        val expected: String? = null
        val actual: String? = null
        assertTrue(JsonMatcher("null").matches(null))
    }

    @Test
    fun `matches ""`() {
        val expected: String? = null
        val actual: String? = null
        assertTrue(JsonMatcher("").matches(""))
    }
}