8fc108c651c62de6083d59323296dc619b76783e
[vfc/nfvo/driver/vnfm/gvnfm.git] / juju / juju-vnfmadapter / Juju-vnfmadapterService / service / src / test / java / org / openo / nfvo / jujuvnfmadapter / service / adapter / impl / JujuClientManagerTest.java
1 /*
2  * Copyright 2016-2017 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.openo.nfvo.jujuvnfmadapter.service.adapter.impl;
17
18 import static org.junit.Assert.assertTrue;
19
20 import java.io.IOException;
21
22 import org.junit.Ignore;
23 import org.junit.Test;
24
25 import mockit.Mock;
26 import mockit.MockUp;
27 import net.sf.json.JSONObject;
28
29 public class JujuClientManagerTest {
30
31     @Test
32     public void testdeploy() {
33         JujuClientManager jujuClientManager = new JujuClientManager();
34         JSONObject json = jujuClientManager.deploy("charmPath", "appName");
35         assertTrue(json != null);
36     }
37
38     @Test
39     public void testdeploy3() {
40         new MockUp<ProcessBuilder>() {
41             @Mock
42             public Process start() throws IOException {
43                 Process process = new ProcessMockImpl();
44                 return process;
45             }
46         };
47         JujuClientManager jujuClientManager = new JujuClientManager();
48         JSONObject json = jujuClientManager.deploy("charmPath","appName");
49         assertTrue(json != null);
50     }
51
52     @Test
53     public void testdeploy1() {
54
55         JujuClientManager jujuClientManager = new JujuClientManager();
56         JSONObject json = jujuClientManager.deploy("charmPath", null);
57         assertTrue(json != null);
58     }
59
60     @Test
61     public void testdeploy2() {
62
63         JujuClientManager jujuClientManager = new JujuClientManager();
64         JSONObject json = jujuClientManager.deploy(null, null);
65         assertTrue(json != null);
66     }
67
68     @Test
69 @Ignore
70     public void testdestroy() {
71
72         JujuClientManager jujuClientManager = new JujuClientManager();
73         JSONObject json = jujuClientManager.destroy("appName");
74         assertTrue(json != null);
75     }
76
77     @Test
78     public void testdestroy1() {
79         new MockUp<ProcessBuilder>() {
80             @Mock
81             public Process start() throws IOException {
82                 Process process = new ProcessMockImpl();
83                 return process;
84             }
85         };
86         JujuClientManager jujuClientManager = new JujuClientManager();
87         JSONObject json = jujuClientManager.destroy("appName");
88         assertTrue(json != null);
89     }
90
91     @Test
92     public void testgetStatus() {
93
94         JujuClientManager jujuClientManager = new JujuClientManager();
95         JSONObject json = jujuClientManager.getStatus("appName");
96         assertTrue(json != null);
97     }
98
99     @Test
100     public void testgetStatus1() {
101
102         JujuClientManager jujuClientManager = new JujuClientManager();
103         JSONObject json = jujuClientManager.getStatus("");
104         assertTrue(json != null);
105     }
106
107     @Test
108     public void testgetStatus2() {
109         new MockUp<ProcessBuilder>() {
110             @Mock
111             public Process start() throws IOException {
112                 Process process = new ProcessMockImpl();
113                 return process;
114             }
115         };
116
117         JujuClientManager jujuClientManager = new JujuClientManager();
118         JSONObject json = jujuClientManager.getStatus("");
119         assertTrue(json != null);
120     }
121     @Test
122     public void testParseYaml(){
123         JujuClientManager jujuClientManager = new JujuClientManager();
124         jujuClientManager.parseYaml("abc/efg", "mediawiki.yaml", "addResource");
125     }
126 }