Merge "BUG-2288: deprecate old binding Notification API elements"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / ForwardingDataTreeChangeListenerTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.datastore;
9
10 import akka.actor.ActorRef;
11 import akka.actor.Props;
12 import java.util.Arrays;
13 import java.util.Collection;
14 import org.junit.Assert;
15 import org.junit.Test;
16 import org.mockito.Mockito;
17 import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
18 import org.opendaylight.controller.cluster.datastore.utils.MessageCollectorActor;
19 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
20
21 public class ForwardingDataTreeChangeListenerTest extends AbstractActorTest {
22
23     @Test
24     public void testOnDataChanged() throws Exception {
25         final Props props = Props.create(MessageCollectorActor.class);
26         final ActorRef actorRef = getSystem().actorOf(props);
27
28         ForwardingDataTreeChangeListener forwardingListener = new ForwardingDataTreeChangeListener(
29                 getSystem().actorSelection(actorRef.path()));
30
31         Collection<DataTreeCandidate> expected = Arrays.asList(Mockito.mock(DataTreeCandidate.class));
32         forwardingListener.onDataTreeChanged(expected);
33
34         DataTreeChanged actual = MessageCollectorActor.expectFirstMatching(actorRef, DataTreeChanged.class);
35         Assert.assertSame(expected, actual.getChanges());
36     }
37 }