Add changed-leaf-nodes-only subscription extension
[netconf.git] / apps / netconf-topology-singleton / src / test / java / org / opendaylight / netconf / topology / singleton / impl / actors / ReadWriteTransactionActorTest.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.netconf.topology.singleton.impl.actors;
9
10 import akka.actor.ActorSystem;
11 import akka.testkit.TestActorRef;
12 import akka.testkit.javadsl.TestKit;
13 import java.time.Duration;
14 import org.junit.AfterClass;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.junit.runner.RunWith;
18 import org.mockito.Mock;
19 import org.mockito.junit.MockitoJUnitRunner;
20 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
21
22 @RunWith(MockitoJUnitRunner.StrictStubs.class)
23 public class ReadWriteTransactionActorTest {
24     private static ActorSystem system = ActorSystem.apply();
25
26     @Mock
27     private DOMDataTreeReadWriteTransaction mockReadWriteTx;
28
29     private final ReadTransactionActorTestAdapter readTestAdapter = new ReadTransactionActorTestAdapter() {};
30     private final WriteTransactionActorTestAdapter writeTestAdapter = new WriteTransactionActorTestAdapter() {};
31
32     @Before
33     public void setUp() {
34         TestActorRef<?> actorRef = TestActorRef.create(system, ReadWriteTransactionActor.props(mockReadWriteTx,
35                 Duration.ofSeconds(2)));
36         readTestAdapter.init(mockReadWriteTx, system, actorRef);
37         writeTestAdapter.init(mockReadWriteTx, system, actorRef);
38     }
39
40     @AfterClass
41     public static void staticTearDown() {
42         TestKit.shutdownActorSystem(system, true);
43     }
44
45     @Test
46     public void testRead() {
47         readTestAdapter.testRead();
48     }
49
50     @Test
51     public void testReadEmpty() {
52         readTestAdapter.testReadEmpty();
53     }
54
55     @Test
56     public void testReadFailure() {
57         readTestAdapter.testReadFailure();
58     }
59
60     @Test
61     public void testExists() {
62         readTestAdapter.testExists();
63     }
64
65     @Test
66     public void testExistsFailure() {
67         readTestAdapter.testExistsFailure();
68     }
69
70     @Test
71     public void testPut() {
72         writeTestAdapter.testPut();
73     }
74
75     @Test
76     public void testMerge() {
77         writeTestAdapter.testMerge();
78     }
79
80     @Test
81     public void testDelete() {
82         writeTestAdapter.testDelete();
83     }
84
85     @Test
86     public void testCancel() throws Exception {
87         writeTestAdapter.testCancel();
88     }
89
90     @Test
91     public void testSubmit() throws Exception {
92         writeTestAdapter.testSubmit();
93     }
94
95     @Test
96     public void testSubmitFail() throws Exception {
97         writeTestAdapter.testSubmitFail();
98     }
99
100     @Test
101     public void testIdleTimeout() throws Exception {
102         writeTestAdapter.testIdleTimeout();
103     }
104 }