Bump upstreams
[bgpcep.git] / config-loader / config-loader-impl / src / test / java / org / opendaylight / bgpcep / config / loader / impl / AbstractConfigLoaderTest.java
1 /*
2  * Copyright (c) 2016 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 package org.opendaylight.bgpcep.config.loader.impl;
9
10 import static org.mockito.ArgumentMatchers.any;
11 import static org.mockito.Mockito.doNothing;
12
13 import java.io.File;
14 import org.junit.Before;
15 import org.mockito.Mock;
16 import org.mockito.MockitoAnnotations;
17 import org.opendaylight.bgpcep.config.loader.spi.ConfigFileProcessor;
18 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
19 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTestCustomizer;
20 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
21
22 public abstract class AbstractConfigLoaderTest extends AbstractConcurrentDataBrokerTest {
23     protected final class TestConfigLoader extends AbstractConfigLoader {
24         @Override
25         File directory() {
26             return new File(getResourceFolder());
27         }
28
29         public void triggerEvent(final String filename) {
30             handleEvent(filename);
31         }
32     }
33
34     protected final TestConfigLoader configLoader = new TestConfigLoader();
35
36     @Mock
37     ConfigFileProcessor processor;
38     protected DOMSchemaService schemaService;
39
40     public AbstractConfigLoaderTest() {
41         super(true);
42     }
43
44     @Before
45     public void setUp() throws Exception {
46         MockitoAnnotations.initMocks(this);
47         doNothing().when(processor).loadConfiguration(any());
48         configLoader.updateModelContext(modelContext());
49     }
50
51     @Override
52     protected AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
53         final var customizer = super.createDataBrokerTestCustomizer();
54         schemaService = customizer.getSchemaService();
55         return customizer;
56     }
57
58     protected String getResourceFolder() {
59         return ClassLoader.getSystemClassLoader().getResource("initial").getPath();
60     }
61 }