Add sender actor to the ForwardingDataTreeChangeListener
[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 java.util.Arrays;
12 import java.util.Collection;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.mockito.Mockito;
16 import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
17 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
18 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
19
20 public class ForwardingDataTreeChangeListenerTest extends AbstractActorTest {
21
22     @Test
23     public void testOnDataChanged() {
24         final ActorRef actorRef = getSystem().actorOf(MessageCollectorActor.props());
25
26         ForwardingDataTreeChangeListener forwardingListener = new ForwardingDataTreeChangeListener(
27                 getSystem().actorSelection(actorRef.path()), ActorRef.noSender());
28
29         Collection<DataTreeCandidate> expected = Arrays.asList(Mockito.mock(DataTreeCandidate.class));
30         forwardingListener.onDataTreeChanged(expected);
31
32         DataTreeChanged actual = MessageCollectorActor.expectFirstMatching(actorRef, DataTreeChanged.class, 5000);
33         Assert.assertSame(expected, actual.getChanges());
34     }
35 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.