Fix warnings in tests
[controller.git] / opendaylight / md-sal / cds-access-api / src / test / java / org / opendaylight / controller / cluster / access / commands / AbstractRequestSuccessTest.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 org.apache.commons.lang.SerializationUtils;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
14 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
15 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
16 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
17 import org.opendaylight.controller.cluster.access.concepts.MemberName;
18 import org.opendaylight.controller.cluster.access.concepts.RequestSuccess;
19
20 public abstract class AbstractRequestSuccessTest<T extends RequestSuccess<?, ?>> {
21
22     private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
23             MemberName.forName("test"), FrontendType.forName("one"));
24     protected static final ClientIdentifier CLIENT_IDENTIFIER = ClientIdentifier.create(FRONTEND_IDENTIFIER, 0);
25     protected static final LocalHistoryIdentifier HISTORY_IDENTIFIER = new LocalHistoryIdentifier(
26             CLIENT_IDENTIFIER, 0);
27
28     protected abstract T object();
29
30     @SuppressWarnings("unchecked")
31     @Test
32     public void serializationTest() {
33         final Object deserialize = SerializationUtils.clone(object());
34
35         Assert.assertEquals(object().getTarget(), ((T) deserialize).getTarget());
36         Assert.assertEquals(object().getVersion(), ((T) deserialize).getVersion());
37         Assert.assertEquals(object().getSequence(), ((T) deserialize).getSequence());
38         doAdditionalAssertions(deserialize);
39     }
40
41     protected abstract void doAdditionalAssertions(final Object deserialize);
42 }