a0a798697f2eed804ad648fffe96413468df6e82
[controller.git] / opendaylight / md-sal / cds-access-api / src / test / java / org / opendaylight / controller / cluster / access / commands / AbstractRequestFailureTest.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.junit.Assert;
11 import org.junit.Test;
12 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
13 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
14 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
15 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
16 import org.opendaylight.controller.cluster.access.concepts.MemberName;
17 import org.opendaylight.controller.cluster.access.concepts.RequestException;
18 import org.opendaylight.controller.cluster.access.concepts.RequestFailure;
19 import org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException;
20 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
21
22 public abstract class AbstractRequestFailureTest<T extends RequestFailure> {
23     private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
24             MemberName.forName("member"), FrontendType.forName("frontend"));
25
26     protected static final ClientIdentifier CLIENT_IDENTIFIER = ClientIdentifier.create(FRONTEND_IDENTIFIER, 0);
27     protected static final LocalHistoryIdentifier HISTORY_IDENTIFIER = new LocalHistoryIdentifier(CLIENT_IDENTIFIER, 0);
28     protected static final TransactionIdentifier TRANSACTION_IDENTIFIER = new TransactionIdentifier(
29             HISTORY_IDENTIFIER, 0);
30     protected static final RequestException CAUSE = new RuntimeRequestException("fail", new Throwable());
31
32     abstract T object();
33
34     @Test
35     public void getCauseTest() throws Exception {
36         Assert.assertEquals(CAUSE, object().getCause());
37     }
38
39     @Test
40     public void isHardFailureTest() throws Exception {
41         Assert.assertTrue(object().isHardFailure());
42     }
43 }