BUG-5626: Eliminate ShardIdentifier.Builder
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / identifiers / ShardIdentifierTest.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
9 package org.opendaylight.controller.cluster.datastore.identifiers;
10
11 import static org.junit.Assert.assertEquals;
12 import org.junit.Test;
13 import org.opendaylight.controller.cluster.access.concepts.MemberName;
14
15 public class ShardIdentifierTest {
16
17     @Test
18     public void testBasic(){
19         ShardIdentifier id = ShardIdentifier.create("inventory", MemberName.forName("member-1"), "config");
20
21         assertEquals("member-1-shard-inventory-config", id.toString());
22     }
23
24     @Test
25     public void testFromShardIdString(){
26         String shardIdStr = "member-1-shard-inventory-config";
27
28         ShardIdentifier id = ShardIdentifier.fromShardIdString(shardIdStr);
29
30         assertEquals("member-1", id.getMemberName().getName());
31         assertEquals("inventory", id.getShardName());
32         assertEquals("config", id.getType());
33     }
34 }