Epic-231:versioning, and backup the configuration
[sdnc/oam.git] / configbackuprestore / vnfconfigbackupservice / src / test / java / com / onap / sdnc / vnfbackupservice / scheduler / VnfRestClientTest.java
1 /*
2 * ============LICENSE_START=======================================================
3 * ONAP : SDNC-FEATURES
4 * ================================================================================
5 * Copyright 2018 TechMahindra
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
10 *
11 *     http://www.apache.org/licenses/LICENSE-2.0
12 *
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=========================================================
19 */
20 package com.onap.sdnc.vnfbackupservice.scheduler;
21
22 import static org.mockito.Mockito.mock;
23 import static org.mockito.Mockito.when;
24
25 import org.junit.Test;
26 import org.springframework.http.HttpEntity;
27 import org.springframework.http.HttpMethod;
28 import org.springframework.http.HttpStatus;
29 import org.springframework.http.ResponseEntity;
30 import org.springframework.web.client.RestClientException;
31 import org.springframework.web.client.RestTemplate;
32
33 import mockit.Mock;
34 import mockit.MockUp;
35
36
37 public class VnfRestClientTest {
38         
39         String url = "/restconf/config/VNF-API:vnfs";
40         String userName = "abc";
41         String password = "abc";
42         
43         @Test
44         public void restClientTest() {
45
46                 new MockUp<RestTemplate>() {
47                         @SuppressWarnings("unchecked")
48                         @Mock
49                         public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
50                                         Class<T> responseType, Object... uriVariables) throws RestClientException {
51                                 ResponseEntity<String> str = new ResponseEntity<String>(HttpStatus.ACCEPTED);
52                                 return (ResponseEntity<T>) str;
53                         }
54                 };
55                 VnfRestClient vnfRestClientmock = mock(VnfRestClient.class);
56                 when(vnfRestClientmock.vnfRestClient(url, userName, password)).thenReturn("successfully mocked");
57          
58                 VnfRestClient vnfRestClient =new VnfRestClient();
59                 vnfRestClient.vnfRestClient(url, userName, password);
60                 
61         }
62 }