BUG-1472: deprecated CompositeNode and friends
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / CompositeNodeTOImplTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.data.impl;
9
10 import static junit.framework.Assert.assertEquals;
11 import static junit.framework.Assert.assertNotNull;
12 import static junit.framework.Assert.assertTrue;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 import org.apache.commons.lang.SerializationUtils;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.data.api.ModifyAction;
21 import org.opendaylight.yangtools.yang.data.api.Node;
22
23 @Deprecated
24 public class CompositeNodeTOImplTest {
25     @Test
26     public void testSerialization() throws Exception{
27         CompositeNodeTOImpl child1 = new CompositeNodeTOImpl(QName.create("ns", "2013-12-09", "child1"), null, new ArrayList<Node<?>>(), ModifyAction.REPLACE);
28         CompositeNodeTOImpl child2 = new CompositeNodeTOImpl(QName.create("ns", "2013-12-09", "child2"), null, new ArrayList<Node<?>>(), ModifyAction.REPLACE);
29         SimpleNodeTOImpl child3 = new SimpleNodeTOImpl(QName.create("ns", "2013-12-09", "child2"), null, "foo");
30
31         List<Node<?>> children = new ArrayList<Node<?>>();
32         children.add(child1);
33         children.add(child2);
34         children.add(child3);
35
36         CompositeNodeTOImpl parent = new CompositeNodeTOImpl(QName.create("ns", "2013-12-09", "parent"), null, new ArrayList<Node<?>>(), ModifyAction.REPLACE);
37
38         CompositeNodeTOImpl object = new CompositeNodeTOImpl(QName.create("ns", "2013-12-09", "root"), parent, children , ModifyAction.MERGE);
39
40         CompositeNodeTOImpl clone = (CompositeNodeTOImpl) SerializationUtils.clone(object);
41
42         assertNotNull(clone.getNodeType());
43         assertEquals(ModifyAction.MERGE, clone.getModificationAction());
44         assertNotNull(clone.getParent());
45         assertNotNull(clone.getParent().getNodeType());
46         assertNotNull(clone.getValue());
47         assertEquals(3, clone.getValue().size());
48         assertNotNull(clone.getValue().get(0).getNodeType());
49         assertNotNull(clone.getValue().get(1).getNodeType());
50
51         SimpleNodeTOImpl child3Clone = (SimpleNodeTOImpl) clone.getValue().get(2);
52
53         assertNotNull(child3Clone.getNodeType());
54         assertTrue(child3Clone instanceof SimpleNodeTOImpl);
55         assertEquals("foo", child3Clone.getValue());
56
57     }
58 }