2 * ============LICENSE_START=======================================================
 
   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
 
  11 *     http://www.apache.org/licenses/LICENSE-2.0
 
  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=========================================================
 
  20 package org.onap.universalvesadapter.service;
 
  22 import static org.junit.Assert.assertEquals;
 
  24 import org.junit.Before;
 
  25 import org.junit.Test;
 
  26 import org.junit.runner.RunWith;
 
  27 import org.mockito.InjectMocks;
 
  28 import org.mockito.Mock;
 
  29 import org.mockito.Mockito;
 
  30 import org.mockito.MockitoAnnotations;
 
  31 import org.onap.universalvesadapter.Application;
 
  32 import org.onap.universalvesadapter.exception.ConfigFileReadException;
 
  33 import org.onap.universalvesadapter.service.DiskRepoConfigFileService;
 
  34 import org.slf4j.Logger;
 
  35 import org.slf4j.LoggerFactory;
 
  36 import org.springframework.beans.factory.annotation.Autowired;
 
  37 import org.springframework.boot.test.context.SpringBootTest;
 
  38 import org.springframework.http.HttpStatus;
 
  39 import org.springframework.http.ResponseEntity;
 
  40 import org.springframework.test.context.junit4.SpringRunner;
 
  41 import org.springframework.web.client.RestTemplate;
 
  43 @RunWith(SpringRunner.class)
 
  44 @SpringBootTest(classes = Application.class)
 
  45 public class DiskRepoConfigFileServiceTest {
 
  48     RestTemplate restTemplate;
 
  52     DiskRepoConfigFileService diskRepoConfigFileService;
 
  54     private final Logger eLOGGER = LoggerFactory.getLogger(this.getClass());
 
  58         MockitoAnnotations.initMocks(this);
 
  63     public void testReadConfigFile() {
 
  65         String result = "test file";
 
  67         ResponseEntity<String> fileDataEntity = new ResponseEntity<String>(result, HttpStatus.OK);
 
  69         Mockito.when(restTemplate.getForEntity(Mockito.any(URI.class), Mockito.any(Class.class))).thenReturn(fileDataEntity);
 
  72             String readConfigFile = diskRepoConfigFileService.readConfigFile("testCase.xml");
 
  73             assertEquals(result, readConfigFile);
 
  74         } catch (ConfigFileReadException exception) {
 
  75             eLOGGER.error("Error occurred : ", exception);