2 * Copyright (c) 2016 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
9 package org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.serializer;
11 import java.io.IOException;
12 import java.text.ParseException;
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
15 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
16 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetEntryNodeBuilder;
17 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
19 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
21 import org.w3c.dom.Element;
23 public class LeafSetDomSerializerTest {
24 private LeafSetEntryNodeDomSerializer temp;
25 private LeafListSchemaNode currentLeafList;
26 private LeafSetEntryNode<?> tempLeafList;
29 public void leafSetDomSerializerTest() throws IOException, YangSyntaxErrorException, ParseException, ReactorException {
30 leafSetEntryNodeDomSerializerTest();
31 leafSetNodeDomSerializerTest();
34 private void leafSetEntryNodeDomSerializerTest() throws ReactorException, IOException, YangSyntaxErrorException,
36 final ContainerSchemaNode currentContainer = (ContainerSchemaNode) DomSerializerTestUtils.getSchemaContext()
37 .findModuleByName("serializer-test", null)
38 .getDataChildByName(DomSerializerTestUtils.generateQname("root"));
39 currentLeafList = (LeafListSchemaNode) currentContainer.getDataChildByName(DomSerializerTestUtils
40 .generateQname("first-leaf-list"));
42 final NodeWithValue<?> barPath = new NodeWithValue<>(DomSerializerTestUtils.generateQname("first-leaf-list"), "bar");
43 tempLeafList = ImmutableLeafSetEntryNodeBuilder.create()
44 .withNodeIdentifier(barPath)
48 temp = new LeafSetEntryNodeDomSerializer(DomSerializerTestUtils.DOC, DomSerializerTestUtils.CODEC_PROVIDER);
49 final Element element = temp.serializeLeaf(currentLeafList, tempLeafList);
51 DomSerializerTestUtils.testResults("<first-leaf-list xmlns=\"dom-serializer-test\">bar</first-leaf-list>",
55 private void leafSetNodeDomSerializerTest() {
56 final LeafSetNodeDomSerializer nodeDomSerializer = new LeafSetNodeDomSerializer(temp);
57 final LeafSetEntryNodeDomSerializer leafSetEntryNodeSerializer = (LeafSetEntryNodeDomSerializer)
58 nodeDomSerializer.getLeafSetEntryNodeSerializer();
59 final Element element = temp.serializeLeaf(currentLeafList, tempLeafList);
61 leafSetEntryNodeSerializer.serializeLeaf(currentLeafList, tempLeafList);
62 DomSerializerTestUtils.testResults("<first-leaf-list xmlns=\"dom-serializer-test\">bar</first-leaf-list>",