NETVIRT-1630 migrate to md-sal APIs
[netvirt.git] / elanmanager / impl / src / test / java / org / opendaylight / netvirt / elan / l2gw / nodehandlertest / TestUtil.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 package org.opendaylight.netvirt.elan.l2gw.nodehandlertest;
9
10 import static org.junit.Assert.assertEquals;
11
12 import java.util.Optional;
13 import org.opendaylight.mdsal.binding.api.DataBroker;
14 import org.opendaylight.mdsal.binding.api.ReadTransaction;
15 import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
16 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
17 import org.opendaylight.mdsal.common.api.ReadFailedException;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
19 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
21
22 /**
23  * Created by eaksahu on 8/12/2016.
24  */
25 final class TestUtil {
26
27     private TestUtil() {
28
29     }
30
31     static void verifyHAOpNode(Node d1GlobalOpNode, Node haGlobalOpNode, Node d1PsOpNode, Node haPsOpNode,
32             InstanceIdentifier<Node> haId, InstanceIdentifier<Node> d1PsId, InstanceIdentifier<Node> haPsId,
33             DataBroker dataBroker) throws ReadFailedException {
34         ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
35         TestComparators.compareLogicalSwitches(d1GlobalOpNode, haGlobalOpNode, haId);
36         //TestComparators.compareRemoteUcastMacs(d1GlobalOpNode, haGlobalOpNode, haId);
37         //TestComparators.compareRemoteMcastMacs(d1GlobalOpNode, haGlobalOpNode, haId);
38         TestComparators.compareLocalUcastMacs(d1GlobalOpNode, haGlobalOpNode, haId);
39         //TestComparators.compareLocalMcastMacs(d1GlobalOpNode, haGlobalOpNode, haId);
40         TestComparators.verifySwitches(haGlobalOpNode, haPsOpNode);
41         TestComparators.verifySwitches(d1GlobalOpNode, d1PsOpNode);
42         //TestComparators.comparePhysicalSwitches(d1PsOpNode, haPsOpNode, d1PsId, haPsId, transaction, "s3",
43         //        d1GlobalOpNode, haGlobalOpNode);
44     }
45
46     static Optional<Node> readNode(LogicalDatastoreType datastoreType, InstanceIdentifier<Node> id,
47         ReadTransaction tx) throws Exception {
48         return tx.read(datastoreType, id).get();
49     }
50
51
52     static void verifyHAconfigNode(Node haConfig, Node d1Node) {
53         String haid = haConfig.augmentation(HwvtepGlobalAugmentation.class).getManagers()
54                 .get(0).getManagerOtherConfigs().get(0).getOtherConfigValue();
55         String d1id = d1Node.getNodeId().getValue();
56         assertEquals("Other config should contain D1 as child manager", haid, d1id);
57     }
58 }