55f665a87e278c11f809584ccb90b9265298adee
[controller.git] / opendaylight / md-sal / cds-access-api / src / test / java / org / opendaylight / controller / cluster / access / commands / ReadTransactionSuccessTest.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.controller.cluster.access.commands;
9
10 import com.google.common.base.Optional;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.controller.cluster.access.ABIVersion;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
18
19 public class ReadTransactionSuccessTest extends AbstractTransactionSuccessTest<ReadTransactionSuccess> {
20     private static final NormalizedNode<?, ?> NODE = Builders.containerBuilder().withNodeIdentifier(
21             YangInstanceIdentifier.NodeIdentifier.create(QName.create("namespace", "localName"))).build();
22
23     private static final ReadTransactionSuccess OBJECT = new ReadTransactionSuccess(
24             TRANSACTION_IDENTIFIER, 0, Optional.of(NODE));
25
26     @Test
27     public void getData() throws Exception {
28         final Optional<NormalizedNode<?, ?>> result = OBJECT.getData();
29         Assert.assertTrue(result.isPresent());
30         Assert.assertEquals(NODE.getValue(), result.get().getValue());
31     }
32
33     @Test
34     public void externalizableProxy() throws Exception {
35         final AbstractTransactionSuccessProxy<ReadTransactionSuccess> proxy = OBJECT.externalizableProxy(
36                 ABIVersion.BORON);
37         Assert.assertNotNull(proxy);
38     }
39
40     @Test
41     public void cloneAsVersion() throws Exception {
42         final ReadTransactionSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
43         Assert.assertEquals(OBJECT, clone);
44     }
45 }