2 * Copyright (c) 2016, 2017 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
8 package org.opendaylight.openflowplugin.applications.bulk.o.matic;
10 import static org.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.doReturn;
12 import static org.mockito.Mockito.when;
14 import java.util.Optional;
15 import org.junit.Assert;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19 import org.mockito.Mock;
20 import org.mockito.junit.MockitoJUnitRunner;
21 import org.opendaylight.mdsal.binding.api.DataBroker;
22 import org.opendaylight.mdsal.binding.api.ReadTransaction;
23 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
25 import org.opendaylight.yangtools.util.concurrent.FluentFutures;
28 * Test for {@link FlowReader}.
30 @RunWith(MockitoJUnitRunner.class)
31 public class FlowReaderTest {
34 private DataBroker mockDataBroker;
36 private ReadTransaction readOnlyTransaction;
40 private FlowReader flowReader;
43 public void setUp() throws Exception {
44 doReturn(FluentFutures.immediateFluentFuture(Optional.of(node))).when(readOnlyTransaction)
45 .read(any(LogicalDatastoreType.class), any());
46 when(mockDataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction);
47 flowReader = FlowReader.getNewInstance(mockDataBroker, 2, 5, true, false, (short) 1, (short) 2);
51 public void testRun() throws Exception {
53 Assert.assertEquals(10, flowReader.getFlowCount());
54 Assert.assertEquals(FlowCounter.OperationStatus.SUCCESS.status(), flowReader.getReadOpStatus());