2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.datastore.config;
10 import com.typesafe.config.Config;
11 import com.typesafe.config.ConfigFactory;
12 import java.util.List;
13 import org.junit.Test;
15 public class ConfigurationImplHybridTest extends ConfigurationImplBaseTest {
18 public ConfigurationImpl createConfiguration() {
19 Config moduleShardsConf = generateModuleShards(List.of(
20 generateShard("default", "default", List.of("member-1", "member-2", "member-3")),
21 generateShard("people", "people-1", List.of("member-1")),
22 generateShard("cars", "cars-1", List.of("member-1")),
23 generateShard("test", "test-1", List.of("member-1"))
25 return new ConfigurationImpl(new HybridModuleShardConfigProvider(moduleShardsConf, "modules.conf"));
28 @Test(expected = NullPointerException.class)
29 public void testNullModuleShardsConf() {
30 new HybridModuleShardConfigProvider(null, "modules.conf");
33 private static Config generateModuleShards(final List<String> shards) {
34 String moduleShardsContent = String.format("module-shards = [%n%s]", String.join(",\n", shards));
35 return ConfigFactory.parseString(moduleShardsContent);
38 private static String generateShard(final String name, final String shardsName, final List<String> replicas) {
40 + " name = \"" + name + "\"\n"
43 + " name=\"" + shardsName + "\"\n"
44 + " replicas = " + replicas