Remove use of {String,UUID}Identifier
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / identifiers / TransactionChainIdentifierTest.java
1 /*
2  * Copyright (c) 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.hamcrest.CoreMatchers.startsWith;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertThat;
14 import org.junit.Test;
15 import org.opendaylight.controller.cluster.access.concepts.MemberName;
16
17 public class TransactionChainIdentifierTest {
18     private static final MemberName MEMBER_1 = MemberName.forName("member-1");
19
20     @Test
21     public void testToString(){
22         TransactionChainIdentifier transactionChainIdentifier = new TransactionChainIdentifier(MEMBER_1, 99);
23
24         String id = transactionChainIdentifier.toString();
25
26         assertEquals("member-1-chn-99", id);
27     }
28
29     @Test
30     public void testNewTransactionIdentifier(){
31         TransactionChainIdentifier transactionChainIdentifier = new TransactionChainIdentifier(MEMBER_1, 99);
32
33         TransactionIdentifier txId1 = transactionChainIdentifier.newTransactionIdentifier();
34
35         assertThat(txId1.toString(), startsWith("member-1-chn-99-txn-1-"));
36
37         TransactionIdentifier txId2 = transactionChainIdentifier.newTransactionIdentifier();
38
39         assertThat(txId2.toString(), startsWith("member-1-chn-99-txn-2-"));
40     }
41
42 }