2 * Copyright (c) 2014 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.cluster.datastore.utils;
11 import akka.actor.ActorRef;
12 import akka.actor.ActorSystem;
13 import akka.actor.Props;
14 import java.util.List;
15 import org.junit.Assert;
16 import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
17 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
19 public class TestUtils {
21 public static void assertFirstSentMessage(final ActorSystem actorSystem, final ActorRef actorRef, final Class<?> clazz){
22 ActorContext testContext = new ActorContext(actorSystem, actorSystem.actorOf(
23 Props.create(DoNothingActor.class)), new MockClusterWrapper(), new MockConfiguration());
24 Object messages = testContext
25 .executeOperation(actorRef, MessageCollectorActor.GET_ALL_MESSAGES);
27 Assert.assertNotNull(messages);
29 Assert.assertTrue(messages instanceof List);
31 List<?> listMessages = (List<?>) messages;
33 Assert.assertEquals(1, listMessages.size());
35 Assert.assertTrue(listMessages.get(0).getClass().equals(clazz));