Tweak test script no issue #
[arvados.git] / src / main / java / org / arvados / client / config / FileConfigProvider.java
1 /*
2  * Copyright (C) The Arvados Authors. All rights reserved.
3  *
4  * SPDX-License-Identifier: AGPL-3.0 OR Apache-2.0
5  *
6  */
7
8 package org.arvados.client.config;
9
10 import com.typesafe.config.Config;
11 import com.typesafe.config.ConfigFactory;
12
13 import java.io.File;
14
15 public class FileConfigProvider implements ConfigProvider {
16
17     private static final String DEFAULT_PATH = "arvados";
18     private final Config config;
19
20     public FileConfigProvider() {
21         config = ConfigFactory.load().getConfig(DEFAULT_PATH);
22     }
23
24     public FileConfigProvider(final String configFile) {
25         config = (configFile != null) ?
26                 ConfigFactory.load(configFile).getConfig(DEFAULT_PATH) : ConfigFactory.load().getConfig(DEFAULT_PATH);
27     }
28
29     public Config getConfig() {
30         return config;
31     }
32
33     private File getFile(String path) {
34         return new File(config.getString(path));
35     }
36
37     private int getInt(String path) {
38         return config.getInt(path);
39     }
40
41     private boolean getBoolean(String path) {
42         return config.getBoolean(path);
43     }
44
45     private String getString(String path) {
46         return config.getString(path);
47     }
48
49     @Override
50     public boolean isApiHostInsecure() {
51         return this.getBoolean("api.host-insecure");
52     }
53
54     @Override
55     public String getKeepWebHost() {
56         return this.getString("api.keepweb-host");
57     }
58
59     @Override
60     public int getKeepWebPort() {
61         return this.getInt("api.keepweb-port");
62     }
63
64     @Override
65     public String getApiHost() {
66         return this.getString("api.host");
67     }
68
69     @Override
70     public int getApiPort() {
71         return this.getInt("api.port");
72     }
73
74     @Override
75     public String getApiToken() {
76         return this.getString("api.token");
77     }
78
79     @Override
80     public String getApiProtocol() {
81         return this.getString("api.protocol");
82     }
83
84     @Override
85     public int getFileSplitSize() {
86         return this.getInt("split-size");
87     }
88
89     @Override
90     public File getFileSplitDirectory() {
91         return this.getFile("temp-dir");
92     }
93
94     @Override
95     public int getNumberOfCopies() {
96         return this.getInt("copies");
97     }
98
99     @Override
100     public int getNumberOfRetries() {
101         return this.getInt("retries");
102     }
103
104     public String getIntegrationTestProjectUuid() {
105         return this.getString("integration-tests.project-uuid");
106     }
107 }