-
Notifications
You must be signed in to change notification settings - Fork 3
/
ChainOfResponsibilitiesTest.kt
37 lines (31 loc) · 1.29 KB
/
ChainOfResponsibilitiesTest.kt
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
import main.kotlin.AuthenticationHeader
import main.kotlin.BodyPayloadHeader
import main.kotlin.ContentTypeHeader
import org.junit.Test
class ChainOfResponsibilitiesTest {
@Test
fun testChainOfResponsibility() {
val authenticationHeader = AuthenticationHeader("token")
val contentTypeHeader = ContentTypeHeader("application/json")
val bodyPayloadHeader = BodyPayloadHeader("Body: {\"username\" = \"joseph\"}")
authenticationHeader.next = contentTypeHeader
contentTypeHeader.next = bodyPayloadHeader
val messageWithAuthentication = authenticationHeader.addHeader("Headers with authentication")
val messageWithoutAuthentication = contentTypeHeader.addHeader("Headers without authentication")
assert(
messageWithAuthentication == """
Headers with authentication
Authorization: token
ContentType: application/json
Body: {"username" = "joseph"}
""".trimIndent()
)
assert(
messageWithoutAuthentication == """
Headers without authentication
ContentType: application/json
Body: {"username" = "joseph"}
""".trimIndent()
)
}
}