Rename mdsal-netconf-connector to netconf-server-mdsal
[netconf.git] / plugins / netconf-server-mdsal / src / test / java / org / opendaylight / netconf / mdsal / connector / ops / SchemaServiceStub.java
1 /*
2  * Copyright (c) 2018 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.netconf.mdsal.connector.ops;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.collect.ClassToInstanceMap;
13 import com.google.common.collect.ImmutableClassToInstanceMap;
14 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
15 import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension;
16 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
17 import org.opendaylight.yangtools.concepts.ListenerRegistration;
18 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
19 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
20
21 final class SchemaServiceStub implements DOMSchemaService {
22     private final EffectiveModelContext schemaContext;
23
24     SchemaServiceStub(final EffectiveModelContext schemaContext) {
25         this.schemaContext = requireNonNull(schemaContext);
26     }
27
28     @Override
29     public EffectiveModelContext getGlobalContext() {
30         return schemaContext;
31     }
32
33     @Override
34     public ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
35         final EffectiveModelContextListener listener) {
36         listener.onModelContextUpdated(schemaContext);
37         return new AbstractListenerRegistration<>(listener) {
38             @Override
39             protected void removeRegistration() {
40                 // No-op
41             }
42         };
43     }
44
45     @Override
46     public ClassToInstanceMap<DOMSchemaServiceExtension> getExtensions() {
47         return ImmutableClassToInstanceMap.of();
48     }
49 }