2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.sal.restconf.impl.test;
10 import java.util.concurrent.ExecutionException;
11 import java.util.concurrent.Future;
12 import java.util.concurrent.TimeUnit;
13 import java.util.concurrent.TimeoutException;
15 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
16 import org.opendaylight.yangtools.yang.common.RpcResult;
18 public class DummyFuture implements Future<RpcResult<TransactionStatus>> {
20 private final boolean cancel;
21 private final boolean isCancelled;
22 private final boolean isDone;
23 private final RpcResult<TransactionStatus> result;
25 public DummyFuture() {
32 private DummyFuture(final Builder builder) {
33 cancel = builder.cancel;
34 isCancelled = builder.isCancelled;
35 isDone = builder.isDone;
36 result = builder.result;
39 public static Builder builder() {
40 return new DummyFuture.Builder();
44 public boolean cancel(final boolean mayInterruptIfRunning) {
49 public boolean isCancelled() {
54 public boolean isDone() {
59 public RpcResult<TransactionStatus> get() throws InterruptedException, ExecutionException {
64 public RpcResult<TransactionStatus> get(final long timeout, final TimeUnit unit) throws InterruptedException,
65 ExecutionException, TimeoutException {
69 public static class Builder {
71 private boolean cancel;
72 private boolean isCancelled;
73 private boolean isDone;
74 private RpcResult<TransactionStatus> result;
76 public Builder cancel(final boolean cancel) {
81 public Builder isCancelled(final boolean isCancelled) {
82 this.isCancelled = isCancelled;
86 public Builder isDone(final boolean isDone) {
91 public Builder rpcResult(final RpcResult<TransactionStatus> result) {
96 public Future<RpcResult<TransactionStatus>> build() {
97 return new DummyFuture(this);