Serialization/Deserialization and a host of other fixes
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / md / cluster / datastore / model / SampleModelsTest.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
9 package org.opendaylight.controller.md.cluster.datastore.model;
10
11 import junit.framework.Assert;
12 import org.junit.Test;
13 import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
14 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17
18 public class SampleModelsTest {
19     @Test
20     public void testPeopleModel(){
21         NormalizedNode<?, ?> expected = PeopleModel.create();
22
23
24         NormalizedNodeMessages.Container node =
25             new NormalizedNodeToNodeCodec(SchemaContextHelper.full())
26                 .encode(YangInstanceIdentifier.of(PeopleModel.BASE_QNAME),
27                     expected);
28
29         NormalizedNodeMessages.Node normalizedNode =
30             node.getNormalizedNode();
31
32         NormalizedNode<?,?> actual = new NormalizedNodeToNodeCodec(SchemaContextHelper.full()).decode(YangInstanceIdentifier.of(PeopleModel.BASE_QNAME),
33             normalizedNode);
34
35
36         Assert.assertEquals(expected.toString(), actual.toString());
37
38     }
39
40
41     @Test
42     public void testCarsModel(){
43         NormalizedNode<?, ?> expected = CarsModel.create();
44
45
46         NormalizedNodeMessages.Container node =
47             new NormalizedNodeToNodeCodec(SchemaContextHelper.full())
48                 .encode(YangInstanceIdentifier.of(CarsModel.BASE_QNAME),
49                     expected);
50
51         NormalizedNodeMessages.Node normalizedNode =
52             node.getNormalizedNode();
53
54         NormalizedNode<?,?> actual = new NormalizedNodeToNodeCodec(SchemaContextHelper.full()).decode(
55             YangInstanceIdentifier.of(CarsModel.BASE_QNAME),
56             normalizedNode);
57
58
59         Assert.assertEquals(expected.toString(), actual.toString());
60
61     }
62 }