Unit tests for Request derived classes 96/52896/15
authorIvan Hrasko <ivan.hrasko@pantheon.tech>
Mon, 6 Mar 2017 15:09:20 +0000 (16:09 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 8 Mar 2017 15:25:43 +0000 (15:25 +0000)
Change-Id: I56d98cb89bf0cc474e69a797553aace1d8c2c040
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
14 files changed:
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbortLocalTransactionRequestTest.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractLocalTransactionRequestTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequestTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractTransactionRequestTest.java
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/ConnectClientRequestTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionRequestTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionRequestTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortRequestTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionDoCommitRequestTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitRequestTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeRequestTest.java [new file with mode: 0644]
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestTest.java [new file with mode: 0644]

index ec960c6..5d801c6 100644 (file)
@@ -7,9 +7,6 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
-import akka.actor.ActorRef;
-import akka.actor.ActorSystem;
-import akka.testkit.TestProbe;
 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
@@ -17,21 +14,18 @@ import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 
-public class AbortLocalTransactionRequestTest extends AbstractTransactionRequestTest<AbortLocalTransactionRequest> {
-
+public class AbortLocalTransactionRequestTest
+        extends AbstractLocalTransactionRequestTest<AbortLocalTransactionRequest> {
     private static final FrontendIdentifier FRONTEND = FrontendIdentifier.create(
             MemberName.forName("test"), FrontendType.forName("one"));
     private static final ClientIdentifier CLIENT = ClientIdentifier.create(FRONTEND, 0);
     private static final LocalHistoryIdentifier HISTORY = new LocalHistoryIdentifier(CLIENT, 0);
     private static final TransactionIdentifier TRANSACTION = new TransactionIdentifier(HISTORY, 0);
 
-    private static final ActorSystem SYSTEM = ActorSystem.create("test");
-    private static final ActorRef ACTOR_REF = TestProbe.apply(SYSTEM).ref();
-
     private static final AbortLocalTransactionRequest OBJECT = new AbortLocalTransactionRequest(TRANSACTION, ACTOR_REF);
 
     @Override
-    AbortLocalTransactionRequest object() {
+    protected AbortLocalTransactionRequest object() {
         return OBJECT;
     }
 }
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractLocalTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractLocalTransactionRequestTest.java
new file mode 100644 (file)
index 0000000..33cba17
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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 abstract class AbstractLocalTransactionRequestTest<T extends AbstractLocalTransactionRequest>
+        extends AbstractTransactionRequestTest {
+    @Override
+    protected abstract T object();
+
+    @Test(expected = UnsupportedOperationException.class)
+    public void testExternalizableProxy() {
+        object().externalizableProxy(ABIVersion.BORON);
+    }
+
+    @Test
+    public void cloneAsVersionTest() {
+        Assert.assertEquals(object(), object().cloneAsVersion(ABIVersion.BORON));
+    }
+}
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequestTest.java
new file mode 100644 (file)
index 0000000..376e13f
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.yangtools.yang.data.api.YangInstanceIdentifier;
+
+public abstract class AbstractReadTransactionRequestTest<T extends AbstractReadTransactionRequest>
+        extends AbstractTransactionRequestTest {
+    protected static final YangInstanceIdentifier PATH = YangInstanceIdentifier.EMPTY;
+    protected static final boolean SNAPSHOT_ONLY = true;
+
+    @Override
+    protected abstract T object();
+
+    @Test
+    public void getPathTest() {
+        Assert.assertEquals(PATH, object().getPath());
+    }
+
+    @Test
+    public void isSnapshotOnlyTest() {
+        Assert.assertEquals(SNAPSHOT_ONLY, object().isSnapshotOnly());
+    }
+
+    @Test
+    public void addToStringAttributesTest() {
+        final MoreObjects.ToStringHelper result = object().addToStringAttributes(MoreObjects.toStringHelper(object()));
+        Assert.assertTrue(result.toString().contains("path=" + PATH));
+    }
+}
index 73ee6d6..87a0af1 100644 (file)
@@ -9,18 +9,34 @@ package org.opendaylight.controller.cluster.access.commands;
 
 import org.junit.Assert;
 import org.junit.Test;
-import org.opendaylight.controller.cluster.access.ABIVersion;
+import org.opendaylight.controller.cluster.access.concepts.AbstractRequestTest;
+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.RequestException;
+import org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException;
+import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 
-public abstract class AbstractTransactionRequestTest<T extends AbstractLocalTransactionRequest> {
-    abstract T object();
+public abstract class AbstractTransactionRequestTest<T extends TransactionRequest>
+        extends AbstractRequestTest {
+    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);
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testExternalizableProxy() {
-        object().externalizableProxy(ABIVersion.BORON);
-    }
+    @Override
+    protected abstract T object();
 
     @Test
-    public void cloneAsVersionTest() {
-        Assert.assertEquals(object(), object().cloneAsVersion(ABIVersion.BORON));
+    public void toRequestFailureTest() {
+        final Throwable cause = new Throwable();
+        final RequestException exception = new RuntimeRequestException("fail", cause);
+        final TransactionFailure failure = object().toRequestFailure(exception);
+        Assert.assertNotNull(failure);
     }
 }
index 4675c59..209766a 100644 (file)
@@ -7,9 +7,6 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
-import akka.actor.ActorRef;
-import akka.actor.ActorSystem;
-import akka.testkit.TestProbe;
 import com.google.common.base.MoreObjects;
 import org.junit.Assert;
 import org.junit.Test;
@@ -22,17 +19,14 @@ import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 
-public class CommitLocalTransactionRequestTest extends AbstractTransactionRequestTest<CommitLocalTransactionRequest> {
-
+public class CommitLocalTransactionRequestTest
+        extends AbstractLocalTransactionRequestTest<CommitLocalTransactionRequest> {
     private static final FrontendIdentifier FRONTEND = FrontendIdentifier.create(
             MemberName.forName("test"), FrontendType.forName("one"));
     private static final ClientIdentifier CLIENT = ClientIdentifier.create(FRONTEND, 0);
     private static final LocalHistoryIdentifier HISTORY = new LocalHistoryIdentifier(CLIENT, 0);
     private static final TransactionIdentifier TRANSACTION = new TransactionIdentifier(HISTORY, 0);
 
-    private static final ActorSystem SYSTEM = ActorSystem.create("test");
-    private static final ActorRef ACTOR_REF = TestProbe.apply(SYSTEM).ref();
-
     private static final DataTreeModification MODIFICATION = Mockito.mock(DataTreeModification.class);
     private static final boolean COORDINATED = Boolean.TRUE;
 
@@ -40,7 +34,7 @@ public class CommitLocalTransactionRequestTest extends AbstractTransactionReques
             TRANSACTION, 0, ACTOR_REF, MODIFICATION, COORDINATED);
 
     @Override
-    CommitLocalTransactionRequest object() {
+    protected CommitLocalTransactionRequest object() {
         return OBJECT;
     }
 
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ConnectClientRequestTest.java
new file mode 100644 (file)
index 0000000..43f9450
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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;
+import org.opendaylight.controller.cluster.access.concepts.AbstractRequestProxy;
+import org.opendaylight.controller.cluster.access.concepts.AbstractRequestTest;
+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.MemberName;
+import org.opendaylight.controller.cluster.access.concepts.RequestException;
+
+public class ConnectClientRequestTest extends AbstractRequestTest<ConnectClientRequest> {
+    private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
+            MemberName.forName("member"), FrontendType.forName("frontend"));
+    private static final ClientIdentifier CLIENT_IDENTIFIER = ClientIdentifier.create(FRONTEND_IDENTIFIER, 0);
+
+    private static final ABIVersion MIN_VERSION = ABIVersion.TEST_PAST_VERSION;
+    private static final ABIVersion MAX_VERSION = ABIVersion.TEST_FUTURE_VERSION;
+
+    private static final ConnectClientRequest OBJECT = new ConnectClientRequest(
+            CLIENT_IDENTIFIER, 0, ACTOR_REF, MIN_VERSION, MAX_VERSION);
+
+    @Override
+    protected ConnectClientRequest object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void getMinVersion() throws Exception {
+        Assert.assertEquals(MIN_VERSION, OBJECT.getMinVersion());
+    }
+
+    @Test
+    public void getMaxVersion() throws Exception {
+        Assert.assertEquals(MAX_VERSION, OBJECT.getMaxVersion());
+    }
+
+    @Test
+    public void toRequestFailure() throws Exception {
+        final RequestException exception = new DeadTransactionException(0);
+        final ConnectClientFailure failure = OBJECT.toRequestFailure(exception);
+        Assert.assertNotNull(failure);
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final AbstractRequestProxy<ClientIdentifier, ConnectClientRequest> proxy = OBJECT.externalizableProxy(
+                ABIVersion.current());
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final ConnectClientRequest clone = OBJECT.cloneAsVersion(ABIVersion.BORON);
+        Assert.assertNotNull(clone);
+        Assert.assertEquals(ABIVersion.BORON, clone.getVersion());
+    }
+
+    @Test
+    public void addToStringAttributes() throws Exception {
+        final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
+        Assert.assertTrue(result.toString().contains("minVersion=" + MIN_VERSION));
+        Assert.assertTrue(result.toString().contains("maxVersion=" + MAX_VERSION));
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ExistsTransactionRequestTest.java
new file mode 100644 (file)
index 0000000..d80525b
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 ExistsTransactionRequestTest extends AbstractReadTransactionRequestTest<ExistsTransactionRequest> {
+    private static final ExistsTransactionRequest OBJECT = new ExistsTransactionRequest(
+            TRANSACTION_IDENTIFIER, 0, ACTOR_REF, PATH, SNAPSHOT_ONLY);
+
+    @Override
+    protected ExistsTransactionRequest object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final ABIVersion cloneVersion = ABIVersion.TEST_FUTURE_VERSION;
+        final ExistsTransactionRequest clone = OBJECT.cloneAsVersion(cloneVersion);
+        Assert.assertEquals(cloneVersion, clone.getVersion());
+        Assert.assertEquals(OBJECT.getPath(), clone.getPath());
+        Assert.assertEquals(OBJECT.isSnapshotOnly(), clone.isSnapshotOnly());
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final ABIVersion proxyVersion = ABIVersion.TEST_FUTURE_VERSION;
+        final ExistsTransactionRequestProxyV1 proxy = OBJECT.externalizableProxy(proxyVersion);
+        Assert.assertNotNull(proxy);
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestTest.java
new file mode 100644 (file)
index 0000000..6fe32bb
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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 com.google.common.collect.Lists;
+import java.util.List;
+import java.util.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 ModifyTransactionRequestTest extends AbstractTransactionRequestTest<ModifyTransactionRequest> {
+    private static final NormalizedNode<?, ?> NODE = Builders.containerBuilder().withNodeIdentifier(
+            YangInstanceIdentifier.NodeIdentifier.create(QName.create("namespace", "localName"))).build();
+
+    private static final List<TransactionModification> MODIFICATIONS = Lists.newArrayList(
+            new TransactionWrite(YangInstanceIdentifier.EMPTY, NODE),
+            new TransactionMerge(YangInstanceIdentifier.EMPTY, NODE));
+
+    private static final PersistenceProtocol PROTOCOL = PersistenceProtocol.ABORT;
+
+    private static final ModifyTransactionRequest OBJECT = new ModifyTransactionRequest(
+            TRANSACTION_IDENTIFIER, 0, ACTOR_REF, MODIFICATIONS, PROTOCOL);
+
+    @Override
+    protected ModifyTransactionRequest object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void getPersistenceProtocol() throws Exception {
+        final Optional<PersistenceProtocol> result = OBJECT.getPersistenceProtocol();
+        Assert.assertTrue(result.isPresent());
+        Assert.assertEquals(PROTOCOL, result.get());
+    }
+
+    @Test
+    public void getModificationsTest() throws Exception {
+        final List<TransactionModification> result = OBJECT.getModifications();
+        Assert.assertNotNull(result);
+        Assert.assertEquals(MODIFICATIONS, result);
+    }
+
+    @Test
+    public void addToStringAttributesTest() {
+        final MoreObjects.ToStringHelper result = OBJECT.addToStringAttributes(MoreObjects.toStringHelper(OBJECT));
+        Assert.assertTrue(result.toString().contains("operations=" + MODIFICATIONS));
+        Assert.assertTrue(result.toString().contains("protocol=" + PROTOCOL));
+    }
+
+    @Test
+    public void externalizableProxyTest() throws Exception {
+        final ModifyTransactionRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersionTest() throws Exception {
+        final ModifyTransactionRequest 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/ReadTransactionRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionRequestTest.java
new file mode 100644 (file)
index 0000000..c815887
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 ReadTransactionRequestTest extends AbstractReadTransactionRequestTest<ReadTransactionRequest> {
+    private static final ReadTransactionRequest OBJECT = new ReadTransactionRequest(
+            TRANSACTION_IDENTIFIER, 0, ACTOR_REF, PATH, SNAPSHOT_ONLY);
+
+    @Override
+    protected ReadTransactionRequest object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final ABIVersion cloneVersion = ABIVersion.TEST_FUTURE_VERSION;
+        final ReadTransactionRequest clone = OBJECT.cloneAsVersion(cloneVersion);
+        Assert.assertEquals(cloneVersion, clone.getVersion());
+        Assert.assertEquals(OBJECT.getPath(), clone.getPath());
+        Assert.assertEquals(OBJECT.isSnapshotOnly(), clone.isSnapshotOnly());
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final ABIVersion proxyVersion = ABIVersion.TEST_FUTURE_VERSION;
+        final ReadTransactionRequestProxyV1 proxy = OBJECT.externalizableProxy(proxyVersion);
+        Assert.assertNotNull(proxy);
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionAbortRequestTest.java
new file mode 100644 (file)
index 0000000..79a2634
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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 TransactionAbortRequestTest extends AbstractTransactionRequestTest<TransactionAbortRequest> {
+    private static final TransactionAbortRequest OBJECT = new TransactionAbortRequest(
+            TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
+
+    @Override
+    protected TransactionAbortRequest object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final TransactionAbortRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final TransactionAbortRequest 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/TransactionDoCommitRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionDoCommitRequestTest.java
new file mode 100644 (file)
index 0000000..a0b6664
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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 TransactionDoCommitRequestTest extends AbstractTransactionRequestTest<TransactionDoCommitRequest> {
+    private static final TransactionDoCommitRequest OBJECT = new TransactionDoCommitRequest(
+            TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
+
+    @Override
+    protected TransactionDoCommitRequest object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final TransactionDoCommitRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final TransactionDoCommitRequest 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/TransactionPreCommitRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPreCommitRequestTest.java
new file mode 100644 (file)
index 0000000..5b40e9e
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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 TransactionPreCommitRequestTest extends AbstractTransactionRequestTest<TransactionPreCommitRequest> {
+    private static final TransactionPreCommitRequest OBJECT = new TransactionPreCommitRequest(
+            TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
+
+    @Override
+    protected TransactionPreCommitRequest object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final TransactionPreCommitRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final TransactionPreCommitRequest 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/TransactionPurgeRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/commands/TransactionPurgeRequestTest.java
new file mode 100644 (file)
index 0000000..a0581d4
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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 TransactionPurgeRequestTest extends AbstractTransactionRequestTest<TransactionPurgeRequest> {
+    private static final TransactionPurgeRequest OBJECT = new TransactionPurgeRequest(
+            TRANSACTION_IDENTIFIER, 0, ACTOR_REF);
+
+    @Override
+    protected TransactionPurgeRequest object() {
+        return OBJECT;
+    }
+
+    @Test
+    public void externalizableProxy() throws Exception {
+        final TransactionPurgeRequestProxyV1 proxy = OBJECT.externalizableProxy(ABIVersion.BORON);
+        Assert.assertNotNull(proxy);
+    }
+
+    @Test
+    public void cloneAsVersion() throws Exception {
+        final TransactionPurgeRequest 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/concepts/AbstractRequestTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractRequestTest.java
new file mode 100644 (file)
index 0000000..6bf0088
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.concepts;
+
+import akka.actor.ActorRef;
+import akka.actor.ActorSystem;
+import akka.testkit.TestProbe;
+import com.google.common.base.MoreObjects;
+import org.junit.Assert;
+import org.junit.Test;
+
+public abstract class AbstractRequestTest<T extends Request> {
+    private static final ActorSystem SYSTEM = ActorSystem.create("test");
+    protected static final ActorRef ACTOR_REF = TestProbe.apply(SYSTEM).ref();
+
+    protected abstract T object();
+
+    @Test
+    public void getReplyToTest() {}
+
+    @Test
+    public void addToStringAttributesCommonTest() {
+        final MoreObjects.ToStringHelper result = object().addToStringAttributes(MoreObjects.toStringHelper(object()));
+        Assert.assertTrue(result.toString().contains("replyTo=" + ACTOR_REF));
+    }
+}

©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.