2 * Copyright (c) 2014 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.cluster.datastore.utils;
11 import java.util.Arrays;
12 import java.util.Collections;
13 import java.util.HashMap;
14 import java.util.List;
16 import java.util.stream.Collectors;
17 import javax.annotation.Nonnull;
18 import org.opendaylight.controller.cluster.access.concepts.MemberName;
19 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
20 import org.opendaylight.controller.cluster.datastore.config.ModuleConfig;
21 import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
22 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
24 public class MockConfiguration extends ConfigurationImpl {
25 public MockConfiguration() {
26 this(Collections.singletonMap("default", Arrays.asList("member-1", "member-2")));
29 public MockConfiguration(final Map<String, List<String>> shardMembers) {
30 super(configuration -> {
31 Map<String, ModuleConfig.Builder> retMap = new HashMap<>();
32 for (Map.Entry<String, List<String>> e : shardMembers.entrySet()) {
33 String shardName = e.getKey();
35 ModuleConfig.builder(shardName).shardConfig(
36 shardName, e.getValue().stream().map(MemberName::forName).collect(Collectors.toList())));
44 public ShardStrategy getStrategyForPrefix(@Nonnull final DOMDataTreeIdentifier prefix) {