Unit test for RequestSuccess.java and derived classes
[controller.git] / opendaylight / md-sal / cds-access-api / src / test / java / org / opendaylight / controller / cluster / access / commands / ExistsTransactionSuccessTest.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.MoreObjects;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.controller.cluster.access.ABIVersion;
14
15 public class ExistsTransactionSuccessTest extends AbstractTransactionSuccessTest<ExistsTransactionSuccess> {
16     private static final boolean EXISTS = true;
17
18     private static final ExistsTransactionSuccess OBJECT = new ExistsTransactionSuccess(
19             TRANSACTION_IDENTIFIER, 0, EXISTS);
20
21     @Override
22     protected ExistsTransactionSuccess object() {
23         return OBJECT;
24     }
25
26     @Test
27     public void getExistsTest() throws Exception {
28         final boolean result = OBJECT.getExists();
29         Assert.assertEquals(EXISTS, result);
30     }
31
32     @Test
33     public void cloneAsVersionTest() throws Exception {
34         final ExistsTransactionSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
35         Assert.assertEquals(OBJECT, clone);
36     }
37
38     @Test
39     public void addToStringAttributesTest() throws Exception {
40         final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
41         Assert.assertTrue(result.toString().contains("exists=" + EXISTS));
42     }
43
44     @Override
45     protected void doAdditionalAssertions(final Object deserialize) {
46         Assert.assertTrue(deserialize instanceof ExistsTransactionSuccess);
47         Assert.assertEquals(OBJECT.getExists(), ((ExistsTransactionSuccess) deserialize).getExists());
48     }
49 }