6263e287180307a845b5312d2f9b9f468942e8d2
[aai/sparky-be.git] / sparkybe-onap-service / src / test / java / org / onap / aai / sparky / util / NodeUtilsTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.aai.sparky.util;
23
24 import static org.junit.Assert.assertNotNull;
25 import static org.junit.Assert.assertNull;
26 import static org.junit.Assert.assertTrue;
27
28 import java.io.IOException;
29 import java.util.ArrayList;
30
31 import org.junit.Before;
32 import org.junit.Test;
33
34 import com.fasterxml.jackson.core.JsonProcessingException;
35 import com.fasterxml.jackson.databind.JsonNode;
36 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
37
38 public class NodeUtilsTest {
39
40
41   private NodeUtils nodeUtils;
42   private JsonNode jsonNode, jsonNode2;
43   private ArrayList<String> lst;
44   private Object obj;
45
46   @Before
47   public void init() throws Exception {
48     nodeUtils = new NodeUtils();
49     jsonNode = JsonNodeFactory.instance.objectNode();
50     jsonNode2 = jsonNode;
51     lst = new ArrayList<String>();
52     obj = new Object();
53   }
54
55   @SuppressWarnings("static-access")
56   @Test
57   public void updateValues() throws IOException {
58
59
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));
77
78
79   }
80 }