e5b4be33bd1237f916db330ff2cc6434b08866cb
[ovsdb.git] / southbound / southbound-impl / src / test / java / org / opendaylight / ovsdb / southbound / ovsdb / transact / BridgeRemovedCommandTest.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.Mockito.mock;
12 import static org.mockito.Mockito.when;
13
14 import java.util.HashMap;
15 import java.util.HashSet;
16 import java.util.Map;
17 import java.util.Set;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.junit.runner.RunWith;
21 import org.mockito.Mock;
22 import org.mockito.Mockito;
23 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
24 import org.opendaylight.ovsdb.southbound.InstanceIdentifierCodec;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 import org.powermock.api.mockito.PowerMockito;
28 import org.powermock.core.classloader.annotations.PrepareForTest;
29 import org.powermock.modules.junit4.PowerMockRunner;
30
31 @PrepareForTest({BridgeRemovedCommand.class, TransactUtils.class})
32 @RunWith(PowerMockRunner.class)
33 public class BridgeRemovedCommandTest {
34
35     private BridgeRemovedCommand briRemovedCmd = new BridgeRemovedCommand();
36     @Mock private DataChangeEvent changes;
37     @Mock private DataChangeEvent returnChanges;
38     private final Set<InstanceIdentifier<OvsdbBridgeAugmentation>> removed = new HashSet<>();
39     private final Map<InstanceIdentifier<OvsdbBridgeAugmentation>, OvsdbBridgeAugmentation> originals = new HashMap<>();
40
41     @Before
42     public void setUp() throws Exception {
43         briRemovedCmd = mock(BridgeRemovedCommand.class, Mockito.CALLS_REAL_METHODS);
44     }
45
46     @Test
47     public void testExecute() throws Exception {
48         PowerMockito.mockStatic(TransactUtils.class);
49         when(TransactUtils.extractRemoved(changes, OvsdbBridgeAugmentation.class)).thenReturn(removed);
50         when(TransactUtils.extractOriginal(changes, OvsdbBridgeAugmentation.class)).thenReturn(originals);
51
52         TransactionBuilder transaction = mock(TransactionBuilder.class, Mockito.RETURNS_MOCKS);
53         briRemovedCmd.execute(transaction, mock(BridgeOperationalState.class), changes,
54                 mock(InstanceIdentifierCodec.class));
55
56         // TODO Actually verify something
57     }
58
59 }