2 * Copyright (c) 2018 Pantheon Technologies 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.codec.impl;
10 import static org.junit.Assert.assertEquals;
12 import java.util.Map.Entry;
13 import org.junit.AfterClass;
14 import org.junit.Before;
15 import org.junit.BeforeClass;
16 import org.opendaylight.yangtools.yang.binding.DataObject;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21 public abstract class AbstractBindingCodecTest extends AbstractBindingRuntimeTest {
22 protected BindingCodecContext codecContext;
25 public static void beforeClass() {
26 AbstractBindingRuntimeTest.beforeClass();
30 public static void afterClass() {
31 AbstractBindingRuntimeTest.afterClass();
35 public void before() {
36 this.codecContext = new BindingCodecContext(getRuntimeContext());
39 @SuppressWarnings("unchecked")
40 protected <T extends DataObject> T thereAndBackAgain(final InstanceIdentifier<T> path, final T data) {
41 final Entry<YangInstanceIdentifier, NormalizedNode> there = codecContext.toNormalizedNode(path, data);
42 final Entry<InstanceIdentifier<?>, DataObject> backAgain = codecContext.fromNormalizedNode(there.getKey(),
44 assertEquals(path, backAgain.getKey());
45 return (T) backAgain.getValue();