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.google.common.collect.ImmutableList;
11 import com.typesafe.config.Config;
12 import com.typesafe.config.ConfigFactory;
13 import java.util.List;
14 import org.junit.Test;
16 public class ConfigurationImplHybridTest extends ConfigurationImplBaseTest {
19 public ConfigurationImpl createConfiguration() {
20 Config moduleShardsConf = generateModuleShards(ImmutableList.of(
21 generateShard("default", "default", ImmutableList.of("member-1", "member-2", "member-3")),
22 generateShard("people", "people-1", ImmutableList.of("member-1")),
23 generateShard("cars", "cars-1", ImmutableList.of("member-1")),
24 generateShard("test", "test-1", ImmutableList.of("member-1"))
26 return new ConfigurationImpl(new HybridModuleShardConfigProvider(moduleShardsConf, "modules.conf"));
29 @Test(expected = NullPointerException.class)
30 public void testNullModuleShardsConf() {
31 new HybridModuleShardConfigProvider(null, "modules.conf");
34 private static Config generateModuleShards(final List<String> shards) {
35 String moduleShardsContent = String.format("module-shards = [%n%s]", String.join(",\n", shards));
36 return ConfigFactory.parseString(moduleShardsContent);
39 private static String generateShard(final String name, final String shardsName, final List<String> replicas) {
41 + " name = \"" + name + "\"\n"
44 + " name=\"" + shardsName + "\"\n"
45 + " replicas = " + replicas