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 java.util.Optional;
14 import org.apache.commons.lang3.SerializationUtils;
15 import org.junit.Test;
16 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
19 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
20 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
23 * Unit tests for ShardSnapshotState.
25 * @author Thomas Pantelis
27 public class ShardSnapshotStateTest {
29 public void testSerialization() {
30 ContainerNode expectedNode = Builders.containerBuilder()
31 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
32 .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo"))
35 ShardSnapshotState expected = new ShardSnapshotState(new MetadataShardDataTreeSnapshot(expectedNode));
36 ShardSnapshotState cloned = SerializationUtils.clone(expected);
38 assertNotNull("getSnapshot is null", cloned.getSnapshot());
39 assertEquals("getSnapshot type", MetadataShardDataTreeSnapshot.class, cloned.getSnapshot().getClass());
40 assertEquals("getRootNode", Optional.of(expectedNode),
41 ((MetadataShardDataTreeSnapshot)cloned.getSnapshot()).getRootNode());