2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.dom.adapter.test.util;
10 import com.google.common.collect.ClassToInstanceMap;
11 import com.google.common.collect.ImmutableClassToInstanceMap;
12 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
13 import org.opendaylight.mdsal.dom.api.DOMSchemaServiceExtension;
14 import org.opendaylight.yangtools.concepts.ListenerRegistration;
15 import org.opendaylight.yangtools.util.ListenerRegistry;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
17 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
18 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextProvider;
20 public final class MockSchemaService implements DOMSchemaService, EffectiveModelContextProvider {
22 private EffectiveModelContext schemaContext;
24 final ListenerRegistry<EffectiveModelContextListener> listeners = ListenerRegistry.create();
27 public synchronized EffectiveModelContext getGlobalContext() {
32 public ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
33 final EffectiveModelContextListener listener) {
34 return listeners.register(listener);
38 public synchronized EffectiveModelContext getEffectiveModelContext() {
43 public ClassToInstanceMap<DOMSchemaServiceExtension> getExtensions() {
44 return ImmutableClassToInstanceMap.of();
47 public synchronized void changeSchema(final EffectiveModelContext newContext) {
48 schemaContext = newContext;
49 listeners.streamListeners().forEach(listener -> listener.onModelContextUpdated(schemaContext));