summaryrefslogtreecommitdiffstats
path: root/so-nssmf-adapter-application/src/test/java/org/onap/so/adapters/nssmf/entity/RestResponseTest.java
blob: d80359de56355bf535867cb47f2a401eddb5de8e (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*-
 * ============LICENSE_START=======================================================
 * ONAP - SO
 * ================================================================================
 # Copyright (c) 2020, CMCC Technologies Co., Ltd.
 #
 # Licensed under the Apache License, Version 2.0 (the "License")
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 #
 #       http://www.apache.org/licenses/LICENSE-2.0
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 * ============LICENSE_END=========================================================
 */
package org.onap.so.adapters.nssmf.entity;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*;

@RunWith(SpringRunner.class)
public class RestResponseTest {

    @Test
    public void testRestResponse() {
        RestResponse restResponse = new RestResponse();
        Map<String, String> header = new HashMap<>();
        header.put("X-RequestID", "05a63ae2-249a-49b9-bc52-0c70a3bca487");
        header.put("X-InvocationID", "bb7f7fc5-52ba-4937-a7af-55036694fe19");
        header.put("testlong", "55036694");
        header.put("testint", "55");
        restResponse.setRespHeaderMap(header);

        String headerStr = restResponse.getRespHeaderStr("X-RequestID");
        assertEquals(headerStr, "05a63ae2-249a-49b9-bc52-0c70a3bca487");

        long headerLong = restResponse.getRespHeaderLong("testlong");
        long headerLongNull = restResponse.getRespHeaderLong("testlong1");
        assertNotNull(headerLong);
        assertEquals(headerLongNull, -1L);

        int headerInt = restResponse.getRespHeaderInt("testint");
        int headerIntNull = restResponse.getRespHeaderInt("testint1");
        assertNotNull(headerInt);
        assertEquals(headerIntNull, -1);

        Map headerMap = restResponse.getRespHeaderMap();
        assertNotNull(headerMap);
    }

}