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 org.junit.Assert;
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.mockito.Mock;
14 import org.mockito.Mockito;
15 import org.mockito.MockitoAnnotations;
16 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
17 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21 public class ClientBackedWriteTransactionTest extends ClientBackedTransactionTest<ClientBackedWriteTransaction> {
22 private ClientBackedWriteTransaction object;
25 private ClientTransaction delegate;
27 private NormalizedNode data;
29 private YangInstanceIdentifier path;
31 private DOMStoreThreePhaseCommitCohort readyCohort;
34 public void setUp() throws Exception {
35 MockitoAnnotations.initMocks(this);
37 Mockito.doReturn(TRANSACTION_ID).when(delegate).getIdentifier();
38 Mockito.doReturn(readyCohort).when(delegate).ready();
40 object = new ClientBackedWriteTransaction(delegate);
44 ClientBackedWriteTransaction object() throws Exception {
49 public void testWrite() throws Exception {
50 object().write(path, data);
51 Mockito.verify(delegate).write(path, data);
55 public void testMerge() throws Exception {
56 object().merge(path, data);
57 Mockito.verify(delegate).merge(path, data);
61 public void testDelete() throws Exception {
62 object().delete(path);
63 Mockito.verify(delegate).delete(path);
67 public void testReady() throws Exception {
68 final org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort result = object().ready();
69 Assert.assertNotNull(result);
70 Mockito.verify(delegate).ready();