2 * Copyright (c) 2015 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.codec.test;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
14 import com.google.common.collect.ImmutableList;
15 import org.junit.Test;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChanged;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChangedBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelListKey;
20 import org.opendaylight.yangtools.yang.binding.Notification;
21 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
22 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
24 public class NotificationProcessingTest extends AbstractBindingCodecTest {
26 private static TwoLevelListChanged createTestData() {
27 final TwoLevelListChangedBuilder tb = new TwoLevelListChangedBuilder();
28 tb.setTopLevelList(ImmutableList.of(new TopLevelListBuilder().withKey(new TopLevelListKey("test")).build()));
33 public void testNotificationToNormalized() {
34 final TwoLevelListChanged bindingOriginal = createTestData();
35 final ContainerNode dom = registry.toNormalizedNodeNotification(bindingOriginal);
36 assertNotNull("Serialization must not return null obejct.",dom);
37 assertEquals(TwoLevelListChanged.QNAME,dom.getIdentifier().getNodeType());
39 final Notification bindingDeserialized = registry.fromNormalizedNodeNotification(SchemaPath.create(true,
40 TwoLevelListChanged.QNAME),dom);
41 assertNotNull(bindingDeserialized);
42 assertTrue(bindingDeserialized instanceof TwoLevelListChanged);
43 assertEquals(bindingOriginal,bindingDeserialized);