Refrepo sonar fixes
[vnfsdk/refrepo.git] / vnfmarket-be / vnf-sdk-marketplace / src / test / java / org / onap / vtp / VTPScenarioResourceTest.java
1 /**
2  * Copyright 2019 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.vtp;
17
18 import com.fasterxml.jackson.databind.JsonNode;
19 import com.fasterxml.jackson.databind.ObjectMapper;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23 import org.mockito.InjectMocks;
24 import org.mockito.Mock;
25 import org.mockito.Mockito;
26 import org.mockito.MockitoAnnotations;
27 import org.mockito.runners.MockitoJUnitRunner;
28 import org.onap.vtp.scenario.VTPScenarioResource;
29
30 import java.util.ArrayList;
31 import java.util.List;
32
33 import static org.junit.Assert.*;
34 import static org.mockito.Mockito.*;
35 //@RunWith(MockitoJUnitRunner.class)
36 public class VTPScenarioResourceTest {
37
38     VTPScenarioResource vtpScenarioResource;
39
40     @Before
41     public void setUp() throws Exception {
42
43         MockitoAnnotations.initMocks(this);
44         vtpScenarioResource=new VTPScenarioResource();
45         //vtpScenarioResource2= Mockito.spy(new VTPScenarioResource());
46
47     }
48     @Test(expected = Exception.class)
49     public void testListTestScenariosHandler() throws Exception{
50         vtpScenarioResource.listTestScenariosHandler();
51     }
52     @Test(expected = Exception.class)
53     public void testListTestSutiesHandler() throws Exception{
54         VTPScenarioResource vtpScenarioResource2=mock(VTPScenarioResource.class);
55         List<String> args = new ArrayList<>();
56         args.add("abc");
57         ObjectMapper mapper = new ObjectMapper();
58         JsonNode actualObj = mapper.readTree("{\"k1\":\"v1\"}");
59         vtpScenarioResource.listTestSutiesHandler("abc");
60       // when(vtpScenarioResource2.makeRpcAndGetJson(args)).thenReturn(actualObj);
61         //vtpScenarioResource.listTestSutiesHandler("VTP Scenario 1");
62
63        // doReturn(actualObj).when((VTPResource)vtpScenarioResource2).makeRpcAndGetJson(args);
64       //  vtpScenarioResource2.makeRpc(args);
65        //verify(vtpScenarioResource2).makeRpcAndGetJson(args);
66
67     }
68     @Test(expected = Exception.class)
69     public void testListTestcasesHandler() throws Exception
70     {
71         vtpScenarioResource.listTestcasesHandler("testsuite","open-cli");
72     }
73     @Test(expected = Exception.class)
74     public void testListTestcases() throws Exception
75     {
76         vtpScenarioResource.listTestcases("open-cli","testsuite");
77     }
78     @Test(expected = Exception.class)
79     public void testGetTestcase() throws Exception
80     {
81         vtpScenarioResource.getTestcase("open-cli","testsuit","testcase");
82     }
83     @Test(expected = Exception.class)
84     public void testGetTestcaseHandler() throws Exception
85     {
86         vtpScenarioResource.getTestcaseHandler("open-cli","testsuit","testcase");
87     }
88 }