a24539fea511b3dce15beba048c299af55bbe2c5
[controller.git] / opendaylight / md-sal / cds-access-api / src / test / java / org / opendaylight / controller / cluster / access / commands / ReadTransactionSuccessNoDataTest.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 java.util.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.data.api.schema.NormalizedNode;
15
16 public class ReadTransactionSuccessNoDataTest extends AbstractTransactionSuccessTest<ReadTransactionSuccess> {
17     private static final ReadTransactionSuccess OBJECT = new ReadTransactionSuccess(
18             TRANSACTION_IDENTIFIER, 0, Optional.empty());
19
20     @Override
21     protected ReadTransactionSuccess object() {
22         return OBJECT;
23     }
24
25     @Test
26     public void getDataTest() throws Exception {
27         final Optional<NormalizedNode<?, ?>> result = OBJECT.getData();
28         Assert.assertFalse(result.isPresent());
29     }
30
31     @Test
32     public void cloneAsVersionTest() throws Exception {
33         final ReadTransactionSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
34         Assert.assertEquals(OBJECT, clone);
35     }
36
37     @Override
38     protected void doAdditionalAssertions(Object deserialize) {
39         Assert.assertTrue(deserialize instanceof ReadTransactionSuccess);
40         Assert.assertEquals(OBJECT.getData(), ((ReadTransactionSuccess) deserialize).getData());
41     }
42 }