aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo/container/handler/metrics/ErrorResponseTest.java
blob: 4743075a9a6dc668cd02868d29fb55994fdae161 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.handler.metrics;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @author gjoranv
 */
public class ErrorResponseTest {

    @Test
    void error_message_is_wrapped_in_json_object() {
        var json =  ErrorResponse.asErrorJson("bad");
        assertEquals("{\"error\":\"bad\"}", json);
    }

    @Test
    void quotes_are_escaped() {
        var json =  ErrorResponse.asErrorJson("Message \" with \" embedded quotes.");
        assertEquals("{\"error\":\"Message \\\" with \\\" embedded quotes.\"}", json);
    }

}