Update .gitreview to stable/neon
[ovsdb.git] / southbound / southbound-impl / src / test / java / org / opendaylight / ovsdb / southbound / ovsdb / transact / ControllerRemovedCommandTest.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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntry;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 import org.powermock.api.mockito.PowerMockito;
29 import org.powermock.core.classloader.annotations.PrepareForTest;
30 import org.powermock.modules.junit4.PowerMockRunner;
31
32 @PrepareForTest({ControllerRemovedCommand.class, TransactUtils.class})
33 @RunWith(PowerMockRunner.class)
34 public class ControllerRemovedCommandTest {
35
36     private ControllerRemovedCommand contRemoveCmd = new ControllerRemovedCommand();
37     @Mock private DataChangeEvent changes;
38     @Mock private DataChangeEvent returnChanges;
39     private final Set<InstanceIdentifier<ControllerEntry>> removed = new HashSet<>();
40     private final Map<InstanceIdentifier<ControllerEntry>, ControllerEntry> operationalControllerEntries =
41             new HashMap<>();
42     private final Map<InstanceIdentifier<OvsdbBridgeAugmentation>, OvsdbBridgeAugmentation> created = new HashMap<>();
43     private final Map<InstanceIdentifier<OvsdbBridgeAugmentation>, OvsdbBridgeAugmentation> updated = new HashMap<>();
44
45     @Before
46     public void setUp() throws Exception {
47         contRemoveCmd = mock(ControllerRemovedCommand.class, Mockito.CALLS_REAL_METHODS);
48     }
49
50     @Test
51     public void testExecute() throws Exception {
52         PowerMockito.mockStatic(TransactUtils.class);
53         when(TransactUtils.extractRemoved(changes, ControllerEntry.class)).thenReturn(removed);
54         when(TransactUtils.extractOriginal(changes, ControllerEntry.class)).thenReturn(operationalControllerEntries);
55         when(TransactUtils.extractCreated(changes, OvsdbBridgeAugmentation.class)).thenReturn(created);
56         when(TransactUtils.extractUpdated(changes, OvsdbBridgeAugmentation.class)).thenReturn(updated);
57
58         TransactionBuilder transaction = mock(TransactionBuilder.class, Mockito.RETURNS_MOCKS);
59         contRemoveCmd.execute(transaction, null, changes, mock(InstanceIdentifierCodec.class));
60
61         // TODO Actually verify something
62     }
63
64 }