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.PrepareForTest;
24 import org.powermock.modules.junit4.PowerMockRunner;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertFalse;
28 import static org.junit.Assert.assertNull;
29 import static org.junit.Assert.assertTrue;
30 import static org.junit.Assert.assertNotNull;
31 import static org.mockito.Mockito.when;
32 import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
34 @RunWith(PowerMockRunner.class)
35 @PrepareForTest({HwvtepConnectionInstance.class, HwvtepConnectionManager.class, Operations.class})
36 public class HwvtepOperationalStateTest extends DataChangeListenerTestBase {
38 UUID uuid = new UUID("ls0");
41 public void testUpdateCurrentTxData() throws Exception {
42 InstanceIdentifier<LogicalSwitches> lsIid = nodeIid.augmentation(HwvtepGlobalAugmentation.class).
43 child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName("ls0")));
45 HwvtepOperationalState opState = new HwvtepOperationalState(connectionInstance);
47 UUID resultUuid = opState.getUUIDFromCurrentTx(LogicalSwitches.class, lsIid);
48 assertNull(resultUuid);
50 opState.updateCurrentTxData(LogicalSwitches.class, lsIid, uuid);
51 resultUuid = opState.getUUIDFromCurrentTx(LogicalSwitches.class, lsIid);
52 assertEquals(uuid, resultUuid);
54 boolean result = opState.getDeviceInfo().isKeyInTransit(LogicalSwitches.class, lsIid);
57 opState.getDeviceInfo().updateDeviceOpData(LogicalSwitches.class, lsIid, uuid, lsIid);
58 result = opState.getDeviceInfo().isKeyInTransit(LogicalSwitches.class, lsIid);
61 result = opState.getDeviceInfo().isConfigDataAvailable(LogicalSwitches.class, lsIid);
64 opState.getDeviceInfo().updateConfigData(LogicalSwitches.class, lsIid, null);
65 result = opState.getDeviceInfo().isConfigDataAvailable(LogicalSwitches.class, lsIid);