Remove prefix shard leftovers
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / shardstrategy / ShardStrategyFactoryTest.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.datastore.shardstrategy;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertThrows;
13 import static org.junit.Assert.assertTrue;
14
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
18 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
19 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
21
22 public class ShardStrategyFactoryTest {
23     private ShardStrategyFactory factory;
24
25     @Before
26     public void setUp() {
27         factory = new ShardStrategyFactory(new ConfigurationImpl("module-shards.conf", "modules.conf"));
28     }
29
30     @Test
31     public void testGetStrategy() {
32         ShardStrategy strategy = factory.getStrategy(TestModel.TEST_PATH);
33         assertNotNull(strategy);
34     }
35
36     @Test
37     public void testGetStrategyForKnownModuleName() {
38         ShardStrategy strategy = factory.getStrategy(YangInstanceIdentifier.of(CarsModel.BASE_QNAME));
39         assertTrue(strategy instanceof ModuleShardStrategy);
40     }
41
42     @Test
43     public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
44         final NullPointerException ex = assertThrows(NullPointerException.class, () -> factory.getStrategy(null));
45         assertEquals("path should not be null", ex.getMessage());
46     }
47 }