2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * * Copyright (C) 2017 AT&T Intellectual Property.
6 * ================================================================================
7 * Copyright (C) 2018 Samsung Electronics. All rights
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package jtest.org.onap.ccsdk.sli.plugins.sshapicall;
26 import java.io.BufferedReader;
27 import java.io.IOException;
28 import java.io.InputStreamReader;
29 import java.util.ArrayList;
30 import java.util.Collections;
31 import java.util.List;
34 import org.junit.Test;
35 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
36 import org.onap.ccsdk.sli.plugins.sshapicall.model.JsonParser;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
40 public class TestJsonParser {
42 private static final Logger log = LoggerFactory.getLogger(TestJsonParser.class);
45 public void test() throws SvcLogicException, IOException {
46 BufferedReader in = new BufferedReader(
47 new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json"))
49 StringBuilder b = new StringBuilder();
51 while ((line = in.readLine()) != null)
52 b.append(line).append('\n');
54 Map<String, String> mm = JsonParser.convertToProperties(b.toString());
61 @Test(expected = NullPointerException.class)
62 public void testNullString() throws SvcLogicException {
63 JsonParser.convertToProperties(null);
66 private void logProperties(Map<String, String> mm) {
67 List<String> ll = new ArrayList<>();
68 for (Object o : mm.keySet())
71 log.info("Properties:");
72 for (String name : ll)
73 log.info("--- {}: {}", name, mm.get(name));