1 package vid.automation.test.services;
3 import com.fasterxml.jackson.databind.ObjectMapper;
4 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
5 import vid.automation.test.model.Service;
6 import vid.automation.test.model.ServicesObject;
9 import java.io.IOException;
10 import java.util.HashMap;
13 * Created by itzikliderman on 08/09/2017.
15 public class ServicesService {
16 private HashMap<String, Service> services;
18 public ServicesService() throws IOException {
19 services = getServicesFromJson();
23 HashMap<String, Service> getServicesFromJson() throws IOException {
24 String fileName = "services";
25 ObjectMapper mapper = new ObjectMapper();
26 ServicesObject servicesObject;
28 File servicesFile = FileHandling.getConfigFile(fileName);
29 if(!servicesFile.exists()) {
30 String basePath = System.getProperty("BASE_PATH");
31 servicesFile = new File( basePath + File.separator + "conf" + File.separator + fileName);
33 servicesObject = mapper.readValue(servicesFile, ServicesObject.class);
34 return servicesObject.services;
35 } catch (IOException e) {
38 } catch (Exception e) {
44 public Service getService(String serviceId) {
45 return services.get(serviceId);