Unit tests for TransactionSuccess derived classes 32/52932/13
authorIvan Hrasko <ivan.hrasko@pantheon.tech>
Tue, 7 Mar 2017 09:42:22 +0000 (10:42 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 8 Mar 2017 15:25:44 +0000 (15:25 +0000)
Change-Id: I4f5a27d86875f53d1dee28350c16af79fd97eef0
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractTransactionSuccessTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/CommitLocalTransactionRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionSuccessTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionSuccessTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccessTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortSuccessTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionCanCommitSuccessTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionCommitSuccessTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitSuccessTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeResponseTest.java [new file with mode: 0644]

diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractTransactionSuccessTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractTransactionSuccessTest.java
new file mode 100644 (file)
index 0000000..e762912
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
+import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
+import org.opendaylight.controller.cluster.access.concepts.FrontendType;
+import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
+import org.opendaylight.controller.cluster.access.concepts.MemberName;
+import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
+
+public abstract class AbstractTransactionSuccessTest<T extends TransactionSuccess> {
+    private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
+            MemberName.forName("test"), FrontendType.forName("one"));
+    private static final ClientIdentifier CLIENT_IDENTIFIER = ClientIdentifier.create(FRONTEND_IDENTIFIER, 0);
+    private static final LocalHistoryIdentifier HISTORY_IDENTIFIER = new LocalHistoryIdentifier(
+            CLIENT_IDENTIFIER, 0);
+
+    protected static final TransactionIdentifier TRANSACTION_IDENTIFIER = new TransactionIdentifier(
+            HISTORY_IDENTIFIER, 0);
+}
index 209766a..646a7c5 100644 (file)
@@ -28,7 +28,7 @@ public class CommitLocalTransactionRequestTest
     private static final TransactionIdentifier TRANSACTION = new TransactionIdentifier(HISTORY, 0);
 
     private static final DataTreeModification MODIFICATION = Mockito.mock(DataTreeModification.class);
-    private static final boolean COORDINATED = Boolean.TRUE;
+    private static final boolean COORDINATED = true;
 
     private static final CommitLocalTransactionRequest OBJECT = new CommitLocalTransactionRequest(
             TRANSACTION, 0, ACTOR_REF, MODIFICATION, COORDINATED);
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionSuccessTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionSuccessTest.java
new file mode 100644 (file)
index 0000000..027613f
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import com.google.common.base.MoreObjects;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+
+public class ExistsTransactionSuccessTest extends AbstractTransactionSuccessTest<ExistsTransactionSuccess> {
+    private static final boolean EXISTS = true;
+
+    private static final ExistsTransactionSuccess OBJECT = new ExistsTransactionSuccess(
+            TRANSACTION_IDENTIFIER, 0, EXISTS);
+
+    @Test
+    public void getExists() throws Exception {
+        final boolean result = OBJECT.getExists();
+        Assert.assertEquals(EXISTS, result);
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final ExistsTransactionSuccessProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final ExistsTransactionSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
+        Assert.assertEquals(OBJECT, clone);
+    }
+
+    @Test
+    public void addToStringAttributes() throws Exception {
+        final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
+        Assert.assertTrue(result.toString().contains("exists=" + EXISTS));
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionSuccessTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionSuccessTest.java
new file mode 100644 (file)
index 0000000..0961493
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+
+public class ModifyTransactionSuccessTest extends AbstractTransactionSuccessTest<ModifyTransactionSuccess> {
+    private static final ModifyTransactionSuccess OBJECT = new ModifyTransactionSuccess(
+            TRANSACTION_IDENTIFIER, 0);
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final AbstractTransactionSuccessProxy<ModifyTransactionSuccess> proxy = OBJECT.externalizableProxy(
+                ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final ModifyTransactionSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
+        Assert.assertEquals(OBJECT.getVersion(), clone.getVersion());
+        Assert.assertEquals(OBJECT.getSequence(), clone.getSequence());
+        Assert.assertEquals(OBJECT.getTarget(), clone.getTarget());
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccessTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccessTest.java
new file mode 100644 (file)
index 0000000..55f665a
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import com.google.common.base.Optional;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+
+public class ReadTransactionSuccessTest extends AbstractTransactionSuccessTest<ReadTransactionSuccess> {
+    private static final NormalizedNode<?, ?> NODE = Builders.containerBuilder().withNodeIdentifier(
+            YangInstanceIdentifier.NodeIdentifier.create(QName.create("namespace", "localName"))).build();
+
+    private static final ReadTransactionSuccess OBJECT = new ReadTransactionSuccess(
+            TRANSACTION_IDENTIFIER, 0, Optional.of(NODE));
+
+    @Test
+    public void getData() throws Exception {
+        final Optional<NormalizedNode<?, ?>> result = OBJECT.getData();
+        Assert.assertTrue(result.isPresent());
+        Assert.assertEquals(NODE.getValue(), result.get().getValue());
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final AbstractTransactionSuccessProxy<ReadTransactionSuccess> proxy = OBJECT.externalizableProxy(
+                ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final ReadTransactionSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
+        Assert.assertEquals(OBJECT, clone);
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortSuccessTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortSuccessTest.java
new file mode 100644 (file)
index 0000000..b86e42c
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+
+public class TransactionAbortSuccessTest extends AbstractTransactionSuccessTest<TransactionAbortSuccess> {
+    private static final TransactionAbortSuccess OBJECT = new TransactionAbortSuccess(
+            TRANSACTION_IDENTIFIER, 0);
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final AbstractTransactionSuccessProxy<TransactionAbortSuccess> proxy = OBJECT.externalizableProxy(
+                ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final TransactionAbortSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
+        Assert.assertEquals(OBJECT, clone);
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionCanCommitSuccessTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionCanCommitSuccessTest.java
new file mode 100644 (file)
index 0000000..bf2677d
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+
+public class TransactionCanCommitSuccessTest extends AbstractTransactionSuccessTest<TransactionCanCommitSuccess> {
+    private static final TransactionCanCommitSuccess OBJECT = new TransactionCanCommitSuccess(
+            TRANSACTION_IDENTIFIER, 0);
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final AbstractTransactionSuccessProxy<TransactionCanCommitSuccess> proxy = OBJECT.externalizableProxy(
+                ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final TransactionCanCommitSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
+        Assert.assertEquals(OBJECT, clone);
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionCommitSuccessTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionCommitSuccessTest.java
new file mode 100644 (file)
index 0000000..363707f
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+
+public class TransactionCommitSuccessTest extends AbstractTransactionSuccessTest<TransactionCommitSuccess> {
+    private static final TransactionCommitSuccess OBJECT = new TransactionCommitSuccess(
+            TRANSACTION_IDENTIFIER, 0);
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final AbstractTransactionSuccessProxy<TransactionCommitSuccess> proxy = OBJECT.externalizableProxy(
+                ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final TransactionCommitSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
+        Assert.assertEquals(OBJECT, clone);
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitSuccessTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitSuccessTest.java
new file mode 100644 (file)
index 0000000..fc426fc
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+
+public class TransactionPreCommitSuccessTest extends AbstractTransactionSuccessTest<TransactionPreCommitSuccess> {
+    private static final TransactionPreCommitSuccess OBJECT = new TransactionPreCommitSuccess(
+            TRANSACTION_IDENTIFIER, 0);
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final AbstractTransactionSuccessProxy<TransactionPreCommitSuccess> proxy = OBJECT.externalizableProxy(
+                ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final TransactionPreCommitSuccess clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
+        Assert.assertEquals(OBJECT, clone);
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeResponseTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeResponseTest.java
new file mode 100644 (file)
index 0000000..c190e61
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.access.commands;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.access.ABIVersion;
+
+public class TransactionPurgeResponseTest extends AbstractTransactionSuccessTest<TransactionPurgeResponse> {
+    private static final TransactionPurgeResponse OBJECT = new TransactionPurgeResponse(
+            TRANSACTION_IDENTIFIER, 0);
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final AbstractTransactionSuccessProxy<TransactionPurgeResponse> proxy = OBJECT.externalizableProxy(
+                ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final TransactionPurgeResponse clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
+        Assert.assertEquals(OBJECT, clone);
+    }
+}
\ No newline at end of file

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.