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.databroker;
10 import static org.junit.Assert.assertNotNull;
11 import static org.mockito.Mockito.doReturn;
12 import static org.mockito.Mockito.verify;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.junit.runner.RunWith;
17 import org.mockito.Mock;
18 import org.mockito.junit.MockitoJUnitRunner;
19 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
20 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
22 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
24 @RunWith(MockitoJUnitRunner.StrictStubs.class)
25 public class ClientBackedWriteTransactionTest extends ClientBackedTransactionTest<ClientBackedWriteTransaction> {
26 private ClientBackedWriteTransaction object;
29 private ClientTransaction delegate;
31 private NormalizedNode data;
33 private YangInstanceIdentifier path;
35 private DOMStoreThreePhaseCommitCohort readyCohort;
39 doReturn(TRANSACTION_ID).when(delegate).getIdentifier();
40 doReturn(readyCohort).when(delegate).ready();
42 object = new ClientBackedWriteTransaction(delegate, null);
46 ClientBackedWriteTransaction object() {
51 public void testWrite() {
52 object().write(path, data);
53 verify(delegate).write(path, data);
57 public void testMerge() {
58 object().merge(path, data);
59 verify(delegate).merge(path, data);
63 public void testDelete() {
64 object().delete(path);
65 verify(delegate).delete(path);
69 public void testReady() {
70 final DOMStoreThreePhaseCommitCohort result = object().ready();
71 assertNotNull(result);
72 verify(delegate).ready();