blob: 9b502d3f67aa28e61e7db033f624a117a76be748 (
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
|
/*
* Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
*/
package ai.vespa.metricsproxy.metric.model.json;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author gjoranv
*/
public class JsonRenderingExceptionTest {
@Test
public void error_message_is_wrapped_in_json_object() {
var exception = new JsonRenderingException("bad");
assertEquals("{\"error\":\"bad\"}", exception.getMessageAsJson());
}
@Test
public void quotes_are_escaped() {
var exception = new JsonRenderingException("Message \" with \" embedded quotes.");
assertEquals("{\"error\":\"Message \\\" with \\\" embedded quotes.\"}", exception.getMessageAsJson());
}
}
|