BGPCEP-710: Create Network Topology Loader
[bgpcep.git] / config-loader / topology-config-loader / src / test / java / org / opendaylight / bgpcep / config / loader / topology / NetworkTopologyConfigFileProcessorTest.java
1 /*
2  * Copyright (c) 2017 AT&T Intellectual Property. 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.bgpcep.config.loader.topology;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.opendaylight.protocol.util.CheckUtil.checkNotPresentConfiguration;
14 import static org.opendaylight.protocol.util.CheckUtil.checkPresentConfiguration;
15
16 import org.junit.Test;
17 import org.opendaylight.bgpcep.config.loader.impl.AbstractConfigLoader;
18 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
19 import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
20 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
21 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
22 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
23 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
25 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
26 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
27 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
28
29 public class NetworkTopologyConfigFileProcessorTest extends AbstractConfigLoader {
30     @Override
31     protected void registerModules(final ModuleInfoBackedContext moduleInfoBackedContext) throws Exception {
32         moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(NetworkTopology.class));
33         moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(Topology.class));
34     }
35
36     @Test
37     public void configFileTest() throws ReadFailedException, InterruptedException {
38         final KeyedInstanceIdentifier<Topology, TopologyKey> topologyIIdKeyed =
39                 InstanceIdentifier.create(NetworkTopology.class).child(Topology.class,
40                         new TopologyKey(new TopologyId("topology-test")));
41         checkNotPresentConfiguration(getDataBroker(), topologyIIdKeyed);
42
43         assertNotNull(ClassLoader.getSystemClassLoader().getResource("initial/network-topology-config.xml"));
44         final NetworkTopologyConfigFileProcessor processor = new NetworkTopologyConfigFileProcessor(this.configLoader,
45                 getDataBroker());
46         processor.init();
47         checkPresentConfiguration(getDataBroker(), topologyIIdKeyed);
48
49         assertEquals(SchemaPath.create(true, NetworkTopology.QNAME), processor.getSchemaPath());
50         processor.close();
51     }
52 }