2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.aai.sparky.util;
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertNull;
26 import static org.junit.Assert.assertTrue;
28 import java.io.IOException;
29 import java.util.ArrayList;
31 import org.junit.Before;
32 import org.junit.Test;
34 import com.fasterxml.jackson.core.JsonProcessingException;
35 import com.fasterxml.jackson.databind.JsonNode;
36 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
38 public class NodeUtilsTest {
41 private NodeUtils nodeUtils;
42 private JsonNode jsonNode, jsonNode2;
43 private ArrayList<String> lst;
47 public void init() throws Exception {
48 nodeUtils = new NodeUtils();
49 jsonNode = JsonNodeFactory.instance.objectNode();
51 lst = new ArrayList<String>();
55 @SuppressWarnings("static-access")
57 public void updateValues() throws IOException {
60 assertNotNull(nodeUtils.buildDepthPadding(2));
61 assertNotNull(nodeUtils.isNumeric("234"));
62 assertNull(nodeUtils.calculateEditAttributeUri(null));
63 assertNotNull(nodeUtils.generateUniqueShaDigest("unique-101"));
64 assertNull(nodeUtils.getNodeFieldAsText(jsonNode,""));
65 assertNotNull(nodeUtils.getDurationBreakdown(2));
66 assertTrue(nodeUtils.isEqual(jsonNode,jsonNode2));
67 assertNotNull(nodeUtils.concatArray(lst));
68 assertNotNull(nodeUtils.concatArray(lst," "));
69 assertNotNull(nodeUtils.getDurationBreakdown(2));
70 assertNotNull(nodeUtils.buildEntityResourceKey("vserver","1232342"));
71 assertNull(nodeUtils.extractResourceIdFromLink(null));
72 assertNotNull(nodeUtils.getXmlStreamConstantAsStr(2));
73 assertNotNull(nodeUtils.convertObjectToJson(obj,false));
74 assertNull(nodeUtils.convertJsonStrToJsonNode(null));
75 assertNull(nodeUtils.extractObjectValueByKey(null,null));
76 assertNull(nodeUtils.extractFieldValueFromObject(null,null));