2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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 static com.google.common.base.Verify.verifyNotNull;
12 import org.opendaylight.mdsal.binding.dom.adapter.AdapterContext;
13 import org.opendaylight.mdsal.binding.dom.adapter.CurrentAdapterSerializer;
14 import org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext;
15 import org.opendaylight.mdsal.binding.generator.impl.DefaultBindingRuntimeGenerator;
16 import org.opendaylight.mdsal.binding.runtime.api.DefaultBindingRuntimeContext;
17 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
18 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContextListener;
20 public final class MockAdapterContext implements AdapterContext, EffectiveModelContextListener {
21 private volatile CurrentAdapterSerializer serializer = null;
24 public CurrentAdapterSerializer currentSerializer() {
25 return verifyNotNull(serializer);
29 public void onModelContextUpdated(final EffectiveModelContext newModelContext) {
30 serializer = new CurrentAdapterSerializer(new BindingCodecContext(new DefaultBindingRuntimeContext(
31 new DefaultBindingRuntimeGenerator().generateTypeMapping(newModelContext),
32 TestingModuleInfoSnapshot.INSTANCE)));