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;
14 import org.opendaylight.yangtools.yang.common.RpcResult;
16 public class DummyFuture<T> implements Future<RpcResult<T>> {
18 private final boolean cancel;
19 private final boolean isCancelled;
20 private final boolean isDone;
21 private final RpcResult<T> result;
23 public DummyFuture() {
30 private DummyFuture(final Builder<T> builder) {
31 cancel = builder.cancel;
32 isCancelled = builder.isCancelled;
33 isDone = builder.isDone;
34 result = builder.result;
39 public boolean cancel(final boolean mayInterruptIfRunning) {
44 public boolean isCancelled() {
49 public boolean isDone() {
54 public RpcResult<T> get() throws InterruptedException, ExecutionException {
59 public RpcResult<T> get(final long timeout, final TimeUnit unit) throws InterruptedException,
60 ExecutionException, TimeoutException {
64 public static class Builder<T> {
66 private boolean cancel;
67 private boolean isCancelled;
68 private boolean isDone;
69 private RpcResult<T> result;
71 public Builder<T> cancel(final boolean cancel) {
76 public Builder<T> isCancelled(final boolean isCancelled) {
77 this.isCancelled = isCancelled;
81 public Builder<T> isDone(final boolean isDone) {
86 public Builder<T> rpcResult(final RpcResult<T> result) {
91 public Future<RpcResult<T>> build() {
92 return new DummyFuture<T>(this);