blob: 8948ee22c39011a62c918c2c14b134c5a58d7d28 (
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
|
package org.onap.vid.client
import org.onap.vid.testUtils.TestUtils
import org.testng.Assert.assertEquals
import org.testng.annotations.Test
class UnirestPatchKtTest {
@Test
fun givenHttpResponseIsNull_whenExtractRawAsString_emptyStringIsReturn() {
val result = extractRawAsString(null)
assertEquals(result, "")
}
@Test
fun givenHttpResponseBodyIsNull_whenExtractRawAsString_emptyStringIsReturn() {
val result = extractRawAsString(TestUtils.createTestHttpResponse(200, null))
assertEquals(result, "")
}
@Test
fun givenHttpResponseBodyIsString_whenExtractRawAsString_sameStringIsReturn() {
val body = "someBody"
val result = extractRawAsString(TestUtils.createTestHttpResponse(200, body))
assertEquals(result, body)
}
@Test
fun givenHttpResponseBodyIsString_whenReadBodyAndExtractRawAsString_sameStringIsReturn() {
val body = "someBody"
val httpResponse = TestUtils.createTestHttpResponse(200, body);
assertEquals(httpResponse.body, body) //read body once
val result = extractRawAsString(httpResponse)
assertEquals(result, body)
}
}
|