2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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.hwvtepsouthbound;
11 import org.junit.Test;
12 import org.junit.runner.RunWith;
13 import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
14 import org.opendaylight.ovsdb.hwvtepsouthbound.transact.HwvtepOperationalState;
15 import org.opendaylight.ovsdb.lib.notation.UUID;
16 import org.opendaylight.ovsdb.lib.operations.Operations;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitchesKey;
21 import org.opendaylight.yangtools.yang.binding.DataObject;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 import org.powermock.core.classloader.annotations.PowerMockIgnore;
24 import org.powermock.core.classloader.annotations.PrepareForTest;
25 import org.powermock.modules.junit4.PowerMockRunner;
27 import static org.junit.Assert.assertEquals;
28 import static org.junit.Assert.assertFalse;
29 import static org.junit.Assert.assertNull;
30 import static org.junit.Assert.assertTrue;
31 import static org.junit.Assert.assertNotNull;
32 import static org.mockito.Mockito.when;
33 import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
35 @RunWith(PowerMockRunner.class)
36 @PrepareForTest({HwvtepConnectionInstance.class, HwvtepConnectionManager.class, Operations.class})
37 public class HwvtepOperationalStateTest extends DataChangeListenerTestBase {
39 UUID uuid = new UUID("ls0");
42 public void testUpdateCurrentTxData() throws Exception {
43 InstanceIdentifier<LogicalSwitches> lsIid = nodeIid.augmentation(HwvtepGlobalAugmentation.class).
44 child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName("ls0")));
46 HwvtepOperationalState opState = new HwvtepOperationalState(connectionInstance);
48 UUID resultUuid = opState.getUUIDFromCurrentTx(LogicalSwitches.class, lsIid);
49 assertNull(resultUuid);
51 opState.updateCurrentTxData(LogicalSwitches.class, lsIid, uuid);
52 resultUuid = opState.getUUIDFromCurrentTx(LogicalSwitches.class, lsIid);
53 assertEquals(uuid, resultUuid);
55 boolean result = opState.getDeviceInfo().isKeyInTransit(LogicalSwitches.class, lsIid);
58 opState.getDeviceInfo().markKeyAsInTransit(LogicalSwitches.class, lsIid);
59 result = opState.getDeviceInfo().isKeyInTransit(LogicalSwitches.class, lsIid);
62 opState.getDeviceInfo().updateDeviceOpData(LogicalSwitches.class, lsIid, uuid, lsIid);
63 result = opState.getDeviceInfo().isKeyInTransit(LogicalSwitches.class, lsIid);
66 result = opState.getDeviceInfo().isConfigDataAvailable(LogicalSwitches.class, lsIid);
69 opState.getDeviceInfo().updateConfigData(LogicalSwitches.class, lsIid, null);
70 result = opState.getDeviceInfo().isConfigDataAvailable(LogicalSwitches.class, lsIid);