From 7f2a3210bf5f02b578785a8934bc0c711796a0b3 Mon Sep 17 00:00:00 2001 From: Andrej Mak Date: Mon, 3 Apr 2017 11:01:04 +0200 Subject: [PATCH] Add AbstractIdentifiablePayload unit tests Change-Id: I884f3c35d1767ed02accabc3b9a775ef9c667716 Signed-off-by: Andrej Mak --- .../AbortTransactionPayloadTest.java | 15 +++-------- .../AbstractIdentifiablePayloadTest.java | 25 +++++++++++++++++++ .../CloseLocalHistoryPayloadTest.java | 16 ++++++++++++ .../CreateLocalHistoryPayloadTest.java | 16 ++++++++++++ .../PurgeLocalHistoryPayloadTest.java | 16 ++++++++++++ .../PurgeTransactionPayloadTest.java | 16 ++++++++++++ 6 files changed, 93 insertions(+), 11 deletions(-) create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayloadTest.java create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CloseLocalHistoryPayloadTest.java create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CreateLocalHistoryPayloadTest.java create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeLocalHistoryPayloadTest.java create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeTransactionPayloadTest.java diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayloadTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayloadTest.java index 43b2c9eaa9..6b4ee9c8de 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayloadTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayloadTest.java @@ -7,17 +7,10 @@ */ package org.opendaylight.controller.cluster.datastore.persisted; -import static org.junit.Assert.assertEquals; +public class AbortTransactionPayloadTest extends AbstractIdentifiablePayloadTest { -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 index 0000000000..2ff9a915ce --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayloadTest.java @@ -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 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 index 0000000000..c6785c0e47 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CloseLocalHistoryPayloadTest.java @@ -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 { + + @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 index 0000000000..a7d7e93ccf --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/CreateLocalHistoryPayloadTest.java @@ -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 { + + @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 index 0000000000..8e5423a146 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeLocalHistoryPayloadTest.java @@ -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 { + + @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 index 0000000000..ff1d30f7e4 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeTransactionPayloadTest.java @@ -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 { + + @Override + PurgeTransactionPayload object() { + return PurgeTransactionPayload.create(nextTransactionId()); + } +} \ No newline at end of file -- 2.36.6