bug 6579 added dependency queue
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / test / java / org / opendaylight / ovsdb / hwvtepsouthbound / HwvtepOperationalStateTest.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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.hwvtepsouthbound;
10
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;
26
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;
34
35 @RunWith(PowerMockRunner.class)
36 @PrepareForTest({HwvtepConnectionInstance.class, HwvtepConnectionManager.class, Operations.class})
37 public class HwvtepOperationalStateTest extends DataChangeListenerTestBase {
38
39     UUID uuid = new UUID("ls0");
40
41     @Test
42     public void testUpdateCurrentTxData() throws Exception {
43         InstanceIdentifier<LogicalSwitches> lsIid = nodeIid.augmentation(HwvtepGlobalAugmentation.class).
44                 child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName("ls0")));
45
46         HwvtepOperationalState opState = new HwvtepOperationalState(connectionInstance);
47
48         UUID resultUuid = opState.getUUIDFromCurrentTx(LogicalSwitches.class, lsIid);
49         assertNull(resultUuid);
50
51         opState.updateCurrentTxData(LogicalSwitches.class, lsIid, uuid);
52         resultUuid = opState.getUUIDFromCurrentTx(LogicalSwitches.class, lsIid);
53         assertEquals(uuid, resultUuid);
54
55         boolean result = opState.getDeviceInfo().isKeyInTransit(LogicalSwitches.class, lsIid);
56         assertFalse(result);
57
58         opState.getDeviceInfo().markKeyAsInTransit(LogicalSwitches.class, lsIid);
59         result = opState.getDeviceInfo().isKeyInTransit(LogicalSwitches.class, lsIid);
60         assertTrue(result);
61
62         opState.getDeviceInfo().updateDeviceOpData(LogicalSwitches.class, lsIid, uuid, lsIid);
63         result = opState.getDeviceInfo().isKeyInTransit(LogicalSwitches.class, lsIid);
64         assertFalse(result);
65
66         result = opState.getDeviceInfo().isConfigDataAvailable(LogicalSwitches.class, lsIid);
67         assertFalse(result);
68
69         opState.getDeviceInfo().updateConfigData(LogicalSwitches.class, lsIid, null);
70         result = opState.getDeviceInfo().isConfigDataAvailable(LogicalSwitches.class, lsIid);
71         assertTrue(result);
72     }
73 }