2 * Copyright (c) 2017 Brocade Communications 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.controller.cluster.datastore.persisted;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
13 import org.apache.commons.lang.SerializationUtils;
14 import org.junit.Test;
15 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
19 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
22 * Unit tests for ShardSnapshotState.
24 * @author Thomas Pantelis
26 public class ShardSnapshotStateTest {
29 public void testSerialization() {
30 NormalizedNode expectedNode = ImmutableContainerNodeBuilder.create()
31 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
32 .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();
34 ShardSnapshotState expected = new ShardSnapshotState(new MetadataShardDataTreeSnapshot(expectedNode));
35 ShardSnapshotState cloned = (ShardSnapshotState) SerializationUtils.clone(expected);
37 assertNotNull("getSnapshot is null", cloned.getSnapshot());
38 assertEquals("getSnapshot type", MetadataShardDataTreeSnapshot.class, cloned.getSnapshot().getClass());
39 assertEquals("getRootNode", expectedNode,
40 ((MetadataShardDataTreeSnapshot)cloned.getSnapshot()).getRootNode().get());