BGPCEP-580: Implement PCEP stats DS rendering
[bgpcep.git] / bmp / bmp-impl / src / test / java / org / opendaylight / protocol / bmp / impl / BmpMonitorConfigFileProcessorTest.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.protocol.bmp.impl;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.mockito.Matchers.any;
14 import static org.mockito.Mockito.doNothing;
15 import static org.mockito.Mockito.never;
16 import static org.mockito.Mockito.verify;
17
18 import com.google.common.collect.Lists;
19 import java.util.List;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.mockito.Mock;
23 import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
24 import org.opendaylight.protocol.bgp.config.loader.impl.AbstractConfigLoader;
25 import org.opendaylight.protocol.bmp.impl.api.BmpDeployer;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev170517.OdlBmpMonitors;
27 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
28 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
29
30 public class BmpMonitorConfigFileProcessorTest extends AbstractConfigLoader {
31     @Mock
32     private BmpDeployer bmpDeployer;
33
34     @Override
35     @Before
36     public void setUp() throws Exception {
37         super.setUp();
38     }
39
40     @Override
41     protected void registerModules(final ModuleInfoBackedContext moduleInfoBackedContext) throws Exception {
42         moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(OdlBmpMonitors.class));
43
44     }
45
46     @Override
47     protected List<String> getYangModelsPaths() {
48         final List<String> paths = Lists.newArrayList(
49                 "/META-INF/yang/odl-bmp-monitor-config.yang",
50                 "/META-INF/yang/ietf-inet-types@2013-07-15.yang",
51                 "/META-INF/yang/ietf-yang-types@2013-07-15.yang",
52                 "/META-INF/yang/bgp-rib.yang",
53                 "/META-INF/yang/bgp-multiprotocol.yang",
54                 "/META-INF/yang/bgp-types.yang",
55                 "/META-INF/yang/network-concepts.yang",
56                 "/META-INF/yang/ieee754.yang",
57                 "/META-INF/yang/bgp-message.yang",
58                 "/META-INF/yang/yang-ext.yang",
59                 "/META-INF/yang/bmp-monitor.yang",
60                 "/META-INF/yang/bmp-message.yang",
61                 "/META-INF/yang/rfc2385.yang"
62         );
63         return paths;
64     }
65
66     @Test
67     public void configFileTest() throws Exception {
68         assertNotNull(ClassLoader.getSystemClassLoader().getResource("initial/odl-bmp-monitors-config.xml"));
69         verify(this.bmpDeployer, never()).writeBmpMonitor(any());
70         doNothing().when(this.bmpDeployer).writeBmpMonitor(any());
71         final BmpMonitorConfigFileProcessor processor =
72                 new BmpMonitorConfigFileProcessor(this.configLoader, this.bmpDeployer);
73         processor.register();
74         assertEquals(SchemaPath.create(true, OdlBmpMonitors.QNAME), processor.getSchemaPath());
75
76         verify(this.bmpDeployer).writeBmpMonitor(any());
77         processor.close();
78     }
79 }