6089a7b81572a590206e36521300b922cf236f98
[ovsdb.git] / southbound / southbound-impl / src / test / java / org / opendaylight / ovsdb / southbound / ovsdb / transact / TransactCommandAggregatorTest.java
1 /*
2  * Copyright (c) 2015 Inocybe Technologies 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
9 package org.opendaylight.ovsdb.southbound.ovsdb.transact;
10
11 import static org.mockito.Matchers.any;
12 import static org.mockito.Mockito.doNothing;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.verify;
15
16 import java.util.ArrayList;
17 import java.util.List;
18 import org.junit.Before;
19 import org.junit.Ignore;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22 import org.mockito.Mock;
23 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
24 import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec;
25 import org.powermock.core.classloader.annotations.PrepareForTest;
26 import org.powermock.modules.junit4.PowerMockRunner;
27
28 @PrepareForTest({})
29 @RunWith(PowerMockRunner.class)
30 public class TransactCommandAggregatorTest {
31
32     private final List<TransactCommand> commands = new ArrayList<>();
33     private TransactCommandAggregator transactCommandAggregator;
34     @Mock private DataChangeEvent changes;
35     @Mock private BridgeOperationalState operationalState;
36
37     @Before
38     public void setUp() throws Exception {
39         transactCommandAggregator = new TransactCommandAggregator();
40
41         //mock commands field
42         commands.add(mock(BridgeUpdateCommand.class));
43         commands.add(mock(OpenVSwitchBridgeAddCommand.class));
44         commands.add(mock(ControllerUpdateCommand.class));
45         commands.add(mock(ControllerRemovedCommand.class));
46         commands.add(mock(ProtocolUpdateCommand.class));
47         commands.add(mock(ProtocolRemovedCommand.class));
48         commands.add(mock(BridgeRemovedCommand.class));
49         commands.add(mock(TerminationPointCreateCommand.class));
50         commands.add(mock(TerminationPointDeleteCommand.class));
51         commands.add(mock(OvsdbNodeUpdateCommand.class));
52         commands.add(mock(AutoAttachUpdateCommand.class));
53         commands.add(mock(AutoAttachRemovedCommand.class));
54         commands.add(mock(QosUpdateCommand.class));
55         commands.add(mock(QosRemovedCommand.class));
56         commands.add(mock(QueueUpdateCommand.class));
57         commands.add(mock(QueueRemovedCommand.class));
58         commands.add(mock(TerminationPointUpdateCommand.class));
59     }
60
61     @Test
62     @Ignore("This needs to be rewritten")
63     public void testExecute() {
64         TransactionBuilder transaction = mock(TransactionBuilder.class);
65         for (TransactCommand command: commands) {
66             doNothing().when(command).execute(any(TransactionBuilder.class), any(BridgeOperationalState.class),
67                     any(DataChangeEvent.class), any(InstanceIdentifierCodec.class));
68         }
69         transactCommandAggregator.execute(transaction, mock(BridgeOperationalState.class),
70                 mock(DataChangeEvent.class), mock(InstanceIdentifierCodec.class));
71         for (TransactCommand command: commands) {
72             verify(command).execute(any(TransactionBuilder.class), any(BridgeOperationalState.class),
73                     any(DataChangeEvent.class), any(InstanceIdentifierCodec.class));
74         }
75     }
76 }