]> git.basschouten.com Git - openhab-addons.git/blob
c9b28768324aa4afd42e1b34094cfb856ea83587
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.persistence.influxdb.internal;
14
15 import static org.openhab.persistence.influxdb.internal.InfluxDBConfiguration.DATABASE_PARAM;
16 import static org.openhab.persistence.influxdb.internal.InfluxDBConfiguration.RETENTION_POLICY_PARAM;
17 import static org.openhab.persistence.influxdb.internal.InfluxDBConfiguration.TOKEN_PARAM;
18 import static org.openhab.persistence.influxdb.internal.InfluxDBConfiguration.URL_PARAM;
19 import static org.openhab.persistence.influxdb.internal.InfluxDBConfiguration.VERSION_PARAM;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 import org.eclipse.jdt.annotation.NonNullByDefault;
25 import org.eclipse.jdt.annotation.Nullable;
26
27 /**
28  * @author Joan Pujol Espinar - Initial contribution
29  */
30 @NonNullByDefault
31 public class ConfigurationTestHelper {
32
33     public static Map<String, @Nullable Object> createValidConfigurationParameters() {
34         Map<String, @Nullable Object> config = new HashMap<>();
35         config.put(URL_PARAM, "http://localhost:9999");
36         config.put(VERSION_PARAM, InfluxDBVersion.V2.name());
37         config.put(TOKEN_PARAM, "sampletoken");
38         config.put(DATABASE_PARAM, "openhab");
39         config.put(RETENTION_POLICY_PARAM, "default");
40         return config;
41     }
42
43     public static InfluxDBConfiguration createValidConfiguration() {
44         return new InfluxDBConfiguration(createValidConfigurationParameters());
45     }
46
47     public static Map<String, @Nullable Object> createInvalidConfigurationParameters() {
48         Map<String, @Nullable Object> config = createValidConfigurationParameters();
49         config.remove(TOKEN_PARAM);
50         return config;
51     }
52 }