checkStyleViolationSeverity=error implemented for mdsal-dom-broker
[mdsal.git] / dom / mdsal-dom-broker / src / test / java / org / opendaylight / mdsal / dom / broker / BlockingTransactionChainListener.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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.mdsal.dom.broker;
9
10 import com.google.common.util.concurrent.SettableFuture;
11 import org.opendaylight.mdsal.common.api.AsyncTransaction;
12 import org.opendaylight.mdsal.common.api.TransactionChain;
13 import org.opendaylight.mdsal.common.api.TransactionChainListener;
14
15 /**
16  * Simple implementation of {@link TransactionChainListener} for testing.
17  *
18  *<p>
19  * This transaction chain listener does not contain any logic, only update
20  * futures ({@link #getFailFuture()} and {@link #getSuccessFuture()} when
21  * transaction chain event is retrieved.
22  *
23  */
24 class BlockingTransactionChainListener implements TransactionChainListener {
25
26     private final SettableFuture<Throwable> failFuture = SettableFuture.create();
27     private final SettableFuture<Void> successFuture = SettableFuture.create();
28
29     @Override
30     public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction,
31             final Throwable cause) {
32         failFuture.set(cause);
33     }
34
35     @Override
36     public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
37         successFuture.set(null);
38     }
39
40     public SettableFuture<Throwable> getFailFuture() {
41         return failFuture;
42     }
43
44     public SettableFuture<Void> getSuccessFuture() {
45         return successFuture;
46     }
47
48 }