2 * Copyright (c) 2015 Inocybe Technologies. 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.ovsdb.southbound.ovsdb.transact;
11 import static org.mockito.Mockito.mock;
12 import static org.mockito.Mockito.when;
14 import java.util.HashMap;
15 import java.util.HashSet;
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;
31 @PrepareForTest({BridgeRemovedCommand.class, TransactUtils.class})
32 @RunWith(PowerMockRunner.class)
33 public class BridgeRemovedCommandTest {
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<>();
42 public void setUp() throws Exception {
43 briRemovedCmd = mock(BridgeRemovedCommand.class, Mockito.CALLS_REAL_METHODS);
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);
52 TransactionBuilder transaction = mock(TransactionBuilder.class, Mockito.RETURNS_MOCKS);
53 briRemovedCmd.execute(transaction, mock(BridgeOperationalState.class), changes,
54 mock(InstanceIdentifierCodec.class));
56 // TODO Actually verify something