Merge dev/fluorine work across to master
[unimgr.git] / template-driver / src / test / java / org / opendaylight / unimgr / mef / nrp / template / tapi / TopologyDataHandlerTest.java
1 /*
2  * Copyright (c) 2017 Cisco Systems Inc 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.unimgr.mef.nrp.template.tapi;
10
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
17 import org.opendaylight.unimgr.mef.nrp.api.TapiConstants;
18 import org.opendaylight.unimgr.mef.nrp.common.NrpDao;
19 import org.opendaylight.unimgr.mef.nrp.impl.AbstractTestWithTopo;
20 import org.opendaylight.unimgr.mef.nrp.template.TemplateConstants;
21 import org.opendaylight.yang.gen.v1.urn.odl.unimgr.yang.unimgr.ext.rev170531.NodeAdiAugmentation;
22 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev180307.topology.context.Topology;
23
24 /**
25  * A simple integration test to look at the handler
26  * @author bartosz.michalik@amartus.com
27  */
28 public class TopologyDataHandlerTest extends AbstractTestWithTopo {
29
30     private TopologyDataHandler topologyDataHandler;
31
32     @Before
33     public void testSetup() {
34         topologyDataHandler = new TopologyDataHandler(dataBroker, topologyManager);
35     }
36
37     @Test
38     public void init() throws Exception {
39         //having
40         topologyDataHandler.init();
41
42         //then
43         ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction();
44         Topology t = new NrpDao(tx).getTopology(TapiConstants.PRESTO_SYSTEM_TOPO);
45         assertNotNull(t.getNode());
46         assertTrue(t.getNode().stream().allMatch(n -> n.augmentation(NodeAdiAugmentation.class).getActivationDriverId().equals(TemplateConstants.DRIVER_ID)));
47
48     }
49
50 }