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.yangtools.yang.data.json.schema.cnsn.serializer;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
13 import java.net.URISyntaxException;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
19 import org.opendaylight.yangtools.yang.data.api.Node;
20 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
21 import org.opendaylight.yangtools.yang.data.json.schema.TestUtils;
22 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
24 import org.opendaylight.yangtools.yang.model.api.Module;
26 public class SerializeNormalizedStructToCnSnStructTest {
28 private static DataSchemaNode resolvedDataSchemaNode;
31 public static void loadData() throws URISyntaxException {
32 Set<Module> modules = TestUtils.loadModulesFrom("/cnsn-to-normalized-node/yang");
33 Module resolvedModule = TestUtils.resolveModule("simple-container-yang", modules);
34 resolvedDataSchemaNode = TestUtils.resolveDataSchemaNode("cont", resolvedModule);
38 public void testCnSnToNormalizedNode() throws URISyntaxException {
39 ContainerNode containerNode = TestUtils.prepareNormalizedNodeStruct();
41 Iterable<Node<?>> serialized = CnSnFromNormalizedNodeSerializerFactory.getInstance()
42 .getContainerNodeSerializer().serialize((ContainerSchemaNode) resolvedDataSchemaNode, containerNode);
44 assertNotNull(serialized);
45 assertNotNull(serialized.iterator());
46 assertNotNull(serialized.iterator().hasNext());
48 CompositeNode compNode = TestUtils.prepareCompositeNodeStruct();
49 assertEquals(serialized.iterator().next(), compNode);