2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.model.tosca.converters;
23 import com.google.gson.JsonPrimitive;
24 import static org.junit.jupiter.api.Assertions.assertFalse;
25 import static org.junit.jupiter.api.Assertions.assertTrue;
26 import org.junit.jupiter.api.Test;
29 import java.util.HashMap;
30 import java.util.LinkedList;
33 public class ToscaValueBaseConverterTest {
35 private ToscaValueBaseConverter converter = new ToscaValueBaseConverter();
38 public void testJson2JavaPrimitive() throws Exception {
39 JsonPrimitive prim1 = new JsonPrimitive(Boolean.FALSE);
40 Object res1 = converter.json2JavaPrimitive(prim1);
41 assertFalse((Boolean)res1);
43 JsonPrimitive prim2 = new JsonPrimitive("Test");
44 Object res2 = converter.json2JavaPrimitive(prim2);
45 assertTrue(res2.equals("Test"));
47 JsonPrimitive prim3 = new JsonPrimitive(3);
48 Object res3 = converter.json2JavaPrimitive(prim3);
49 assertTrue((Integer)res3 == 3);
51 JsonPrimitive prim4 = new JsonPrimitive(3.6);
52 Object res4 = converter.json2JavaPrimitive(prim4);
53 assertTrue((Double)res4 == 3.6);
57 public void testIsEmptyObjectValue() throws Exception {
58 boolean res1 = ToscaValueBaseConverter.isEmptyObjectValue(null);
61 boolean res2 = ToscaValueBaseConverter.isEmptyObjectValue("");
64 boolean res3 = ToscaValueBaseConverter.isEmptyObjectValue(new HashMap<>());
67 boolean res4 = ToscaValueBaseConverter.isEmptyObjectValue(new LinkedList<>());
70 boolean res5 = ToscaValueBaseConverter.isEmptyObjectValue("test");