blob: 076851cbf5e24a9463636383a3f25c3da004a8ba (
plain) (
blame)
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.utils.communication.http;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class JsonHttpResultTest {
@Test
void testCopyConstructor() {
assertEquals("{}", new JsonHttpResult(new HttpResult()).getJson().toString());
}
@Test
void testOutput() {
assertEquals("""
HTTP 200/OK
JSON: {
"foo" : 3
}""",
new JsonHttpResult(new HttpResult().setContent("{ \"foo\" : 3 }")).toString(true));
assertEquals("""
HTTP 200/OK
{ "foo" : }""",
new JsonHttpResult(new HttpResult().setContent("{ \"foo\" : }")).toString(true));
}
@Test
void testNonJsonOutput() {
JsonHttpResult result = new JsonHttpResult();
result.setContent("Foo");
StringBuilder sb = new StringBuilder();
result.printContent(sb);
assertEquals("Foo", sb.toString());
}
}
|