Update gvnfm-driver .gitreview file
[vfc/nfvo/driver/vnfm/gvnfm.git] / juju / juju-vnfmadapter / Juju-vnfmadapterService / service / src / test / java / org / onap / vfc / nfvo / vnfm / gvnfm / jujuvnfmadapter / common / EntityUtilsTest.java
1 /*
2  * Copyright 2016 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common;
17
18 import static org.junit.Assert.*;
19
20 import java.lang.reflect.Constructor;
21 import java.lang.reflect.Modifier;
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
25 import org.junit.Test;
26 import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.EntityUtils;
27 import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.EntityUtils.ExeRes;
28
29 import net.sf.json.JSONObject;
30
31 public class EntityUtilsTest {
32
33     @Test
34     public void formatCommandTest(){
35         List<String> command = new ArrayList<>();
36         command.add("test");
37         String result =  EntityUtils.formatCommand(command);
38         assertTrue(result.contains("test"));
39     }
40     @Test
41     public void formatCommandTestNull(){
42         List<String> command = null;
43         String result =  EntityUtils.formatCommand(command);
44         assertTrue(result.equals(""));
45     }
46     @Test
47     public void executeTest(){
48         ExeRes res = EntityUtils.execute("test", "test","test2");
49         assertNotNull(res);
50     }
51     @Test(expected = Exception.class)
52     public void toEntity() throws Exception{
53         JSONObject jsonObject = new JSONObject();
54         HashMap map = EntityUtils.toEntity(jsonObject, HashMap.class);
55     }
56     @Test
57     public void testPrivateConstructor() throws Exception {
58         Constructor constructor = EntityUtils.class.getDeclaredConstructor();
59         assertTrue("Constructor private", Modifier.isPrivate(constructor.getModifiers()));
60
61         constructor.setAccessible(true);
62         constructor.newInstance();
63     }
64 }