Unit tests for TransactionSuccess derived classes
[controller.git] / opendaylight / md-sal / cds-access-api / src / test / java / org / opendaylight / controller / cluster / access / commands / CommitLocalTransactionRequestTest.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.access.commands;
9
10 import com.google.common.base.MoreObjects;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.mockito.Mockito;
14 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
15 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
16 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
17 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
18 import org.opendaylight.controller.cluster.access.concepts.MemberName;
19 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
21
22 public class CommitLocalTransactionRequestTest
23         extends AbstractLocalTransactionRequestTest<CommitLocalTransactionRequest> {
24     private static final FrontendIdentifier FRONTEND = FrontendIdentifier.create(
25             MemberName.forName("test"), FrontendType.forName("one"));
26     private static final ClientIdentifier CLIENT = ClientIdentifier.create(FRONTEND, 0);
27     private static final LocalHistoryIdentifier HISTORY = new LocalHistoryIdentifier(CLIENT, 0);
28     private static final TransactionIdentifier TRANSACTION = new TransactionIdentifier(HISTORY, 0);
29
30     private static final DataTreeModification MODIFICATION = Mockito.mock(DataTreeModification.class);
31     private static final boolean COORDINATED = true;
32
33     private static final CommitLocalTransactionRequest OBJECT = new CommitLocalTransactionRequest(
34             TRANSACTION, 0, ACTOR_REF, MODIFICATION, COORDINATED);
35
36     @Override
37     protected CommitLocalTransactionRequest object() {
38         return OBJECT;
39     }
40
41     @Test
42     public void getModificationTest() {
43         Assert.assertEquals(MODIFICATION, OBJECT.getModification());
44     }
45
46     @Test
47     public void isCoordinatedTest() {
48         Assert.assertEquals(COORDINATED, OBJECT.isCoordinated());
49     }
50
51     @Test
52     public void addToStringAttributesTest() {
53         final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
54         Assert.assertTrue(result.toString().contains("coordinated=" + COORDINATED));
55     }
56 }