Add AbstractIdentifiablePayload unit tests 52/54252/3
authorAndrej Mak <andrej.mak@pantheon.tech>
Mon, 3 Apr 2017 09:01:04 +0000 (11:01 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Thu, 6 Apr 2017 16:34:12 +0000 (16:34 +0000)
Change-Id: I884f3c35d1767ed02accabc3b9a775ef9c667716
Signed-off-by: Andrej Mak <andrej.mak@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayloadTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayloadTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CloseLocalHistoryPayloadTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CreateLocalHistoryPayloadTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeLocalHistoryPayloadTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeTransactionPayloadTest.java [new file with mode: 0644]

index 43b2c9eaa99725d932178d52c84e84b914fbbde2..6b4ee9c8de50818e0bec87285b8a63b74bcf4d0b 100644 (file)
@@ -7,17 +7,10 @@
  */
 package org.opendaylight.controller.cluster.datastore.persisted;
 
-import static org.junit.Assert.assertEquals;
+public class AbortTransactionPayloadTest extends AbstractIdentifiablePayloadTest<AbortTransactionPayload> {
 
-import org.apache.commons.lang3.SerializationUtils;
-import org.junit.Test;
-import org.opendaylight.controller.cluster.datastore.AbstractTest;
-
-public class AbortTransactionPayloadTest extends AbstractTest {
-    @Test
-    public void testPayloadSerDes() {
-        final AbortTransactionPayload template = AbortTransactionPayload.create(nextTransactionId());
-        final AbortTransactionPayload cloned = SerializationUtils.clone(template);
-        assertEquals(template.getIdentifier(), cloned.getIdentifier());
+    @Override
+    AbortTransactionPayload object() {
+        return AbortTransactionPayload.create(nextTransactionId());
     }
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayloadTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayloadTest.java
new file mode 100644 (file)
index 0000000..2ff9a91
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.datastore.persisted;
+
+import org.apache.commons.lang3.SerializationUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.controller.cluster.datastore.AbstractTest;
+
+abstract class AbstractIdentifiablePayloadTest<T extends AbstractIdentifiablePayload> extends AbstractTest {
+
+    abstract T object();
+
+    @Test
+    public void testSerialization() {
+        final T object = object();
+        final T cloned = SerializationUtils.clone(object);
+        Assert.assertEquals(object.getIdentifier(), cloned.getIdentifier());
+    }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CloseLocalHistoryPayloadTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CloseLocalHistoryPayloadTest.java
new file mode 100644 (file)
index 0000000..c6785c0
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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.datastore.persisted;
+
+public class CloseLocalHistoryPayloadTest extends AbstractIdentifiablePayloadTest<CloseLocalHistoryPayload> {
+
+    @Override
+    CloseLocalHistoryPayload object() {
+        return CloseLocalHistoryPayload.create(nextHistoryId());
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CreateLocalHistoryPayloadTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CreateLocalHistoryPayloadTest.java
new file mode 100644 (file)
index 0000000..a7d7e93
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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.datastore.persisted;
+
+public class CreateLocalHistoryPayloadTest extends AbstractIdentifiablePayloadTest<CreateLocalHistoryPayload> {
+
+    @Override
+    CreateLocalHistoryPayload object() {
+        return CreateLocalHistoryPayload.create(nextHistoryId());
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeLocalHistoryPayloadTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeLocalHistoryPayloadTest.java
new file mode 100644 (file)
index 0000000..8e5423a
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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.datastore.persisted;
+
+public class PurgeLocalHistoryPayloadTest extends AbstractIdentifiablePayloadTest<PurgeLocalHistoryPayload> {
+
+    @Override
+    PurgeLocalHistoryPayload object() {
+        return PurgeLocalHistoryPayload.create(nextHistoryId());
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeTransactionPayloadTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeTransactionPayloadTest.java
new file mode 100644 (file)
index 0000000..ff1d30f
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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.datastore.persisted;
+
+public class PurgeTransactionPayloadTest extends AbstractIdentifiablePayloadTest<PurgeTransactionPayload> {
+
+    @Override
+    PurgeTransactionPayload object() {
+        return PurgeTransactionPayload.create(nextTransactionId());
+    }
+}
\ No newline at end of file