2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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
8 package org.opendaylight.controller.cluster.access.commands;
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;
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);
30 private static final DataTreeModification MODIFICATION = Mockito.mock(DataTreeModification.class);
31 private static final boolean COORDINATED = true;
33 private static final CommitLocalTransactionRequest OBJECT = new CommitLocalTransactionRequest(
34 TRANSACTION, 0, ACTOR_REF, MODIFICATION, null, COORDINATED);
37 protected CommitLocalTransactionRequest object() {
42 public void getModificationTest() {
43 Assert.assertEquals(MODIFICATION, OBJECT.getModification());
47 public void isCoordinatedTest() {
48 Assert.assertEquals(COORDINATED, OBJECT.isCoordinated());
52 public void addToStringAttributesTest() {
53 final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
54 Assert.assertTrue(result.toString().contains("coordinated=" + COORDINATED));
58 protected void doAdditionalAssertions(final Object deserialize) {
59 Assert.assertTrue(deserialize instanceof CommitLocalTransactionRequest);
60 Assert.assertEquals(OBJECT.getReplyTo(), ((CommitLocalTransactionRequest) deserialize).getReplyTo());
61 Assert.assertEquals(OBJECT.getModification(), ((CommitLocalTransactionRequest) deserialize).getModification());