2 * Copyright 2019 Huawei Technologies Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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;
30 import java.util.ArrayList;
31 import java.util.List;
33 import static org.junit.Assert.*;
34 import static org.mockito.Mockito.*;
35 //@RunWith(MockitoJUnitRunner.class)
36 public class VTPScenarioResourceTest {
38 VTPScenarioResource vtpScenarioResource;
41 public void setUp() throws Exception {
43 MockitoAnnotations.initMocks(this);
44 vtpScenarioResource=new VTPScenarioResource();
45 //vtpScenarioResource2= Mockito.spy(new VTPScenarioResource());
48 @Test(expected = Exception.class)
49 public void testListTestScenariosHandler() throws Exception{
50 vtpScenarioResource.listTestScenariosHandler();
52 @Test(expected = Exception.class)
53 public void testListTestSutiesHandler() throws Exception{
54 VTPScenarioResource vtpScenarioResource2=mock(VTPScenarioResource.class);
55 List<String> args = new ArrayList<>();
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");
63 // doReturn(actualObj).when((VTPResource)vtpScenarioResource2).makeRpcAndGetJson(args);
64 // vtpScenarioResource2.makeRpc(args);
65 //verify(vtpScenarioResource2).makeRpcAndGetJson(args);
68 @Test(expected = Exception.class)
69 public void testListTestcasesHandler() throws Exception
71 vtpScenarioResource.listTestcasesHandler("testsuite","open-cli");
73 @Test(expected = Exception.class)
74 public void testListTestcases() throws Exception
76 vtpScenarioResource.listTestcases("open-cli","testsuite");
78 @Test(expected = Exception.class)
79 public void testGetTestcase() throws Exception
81 vtpScenarioResource.getTestcase("open-cli","testsuit","testcase");
83 @Test(expected = Exception.class)
84 public void testGetTestcaseHandler() throws Exception
86 vtpScenarioResource.getTestcaseHandler("open-cli","testsuit","testcase");