X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Ftest%2FDummyFuture.java;h=8ae8d0bdac927415b7ebd514cf8c356a45a6b52e;hp=a32a3479bada1b7a5b63d5c8f39e7c86731dc12f;hb=17d82f582a6bc13c78be3b19954ff8c021180e93;hpb=c88736a564601862c255247f2cfd99f5ef7e9ef2 diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java index a32a3479ba..8ae8d0bdac 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java @@ -1,35 +1,94 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.sal.restconf.impl.test; -import java.util.concurrent.*; - -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.opendaylight.yangtools.yang.common.RpcResult; -public class DummyFuture implements Future> { +public class DummyFuture implements Future> { + + private final boolean cancel; + private final boolean isCancelled; + private final boolean isDone; + private final RpcResult result; + + public DummyFuture() { + cancel = false; + isCancelled = false; + isDone = false; + result = null; + } + + private DummyFuture(final Builder builder) { + cancel = builder.cancel; + isCancelled = builder.isCancelled; + isDone = builder.isDone; + result = builder.result; + } @Override - public boolean cancel(boolean mayInterruptIfRunning) { - return false; + public boolean cancel(final boolean mayInterruptIfRunning) { + return cancel; } @Override public boolean isCancelled() { - return false; + return isCancelled; } @Override public boolean isDone() { - return false; + return isDone; } @Override - public RpcResult get() throws InterruptedException, ExecutionException { - return null; + public RpcResult get() throws InterruptedException, ExecutionException { + return result; } @Override - public RpcResult get(long timeout, TimeUnit unit) throws InterruptedException, - ExecutionException, TimeoutException { - return null; + public RpcResult get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, + TimeoutException { + return result; + } + + public static class Builder { + + private boolean cancel; + private boolean isCancelled; + private boolean isDone; + private RpcResult result; + + public Builder cancel(final boolean cancel) { + this.cancel = cancel; + return this; + } + + public Builder isCancelled(final boolean isCancelled) { + this.isCancelled = isCancelled; + return this; + } + + public Builder isDone(final boolean isDone) { + this.isDone = isDone; + return this; + } + + public Builder rpcResult(final RpcResult result) { + this.result = result; + return this; + } + + public Future> build() { + return new DummyFuture(this); + } } -} \ No newline at end of file +}