/*-
 * -\-\-
 * async-google-pubsub-client
 * --
 * Copyright (C) 2016 - 2017 Spotify AB
 * --
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * -/-/-
 */

package com.spotify.google.cloud.pubsub.client;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.hamcrest.Matchers;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class PubsubFutureTest {

  @Rule public ExpectedException exception = ExpectedException.none();

  @Mock RequestInfo requestInfo;

  @Test
  public void testToCompletableFutureErrorPropagation() throws Exception {
    final PubsubFuture<Void> f1 = new PubsubFuture<>(requestInfo);
    final PubsubFuture<Void> f2 = f1.toCompletableFuture();

    final Exception cause = new Exception();

    f1.fail(cause);

    assertThat(f2.isDone(), is(true));
    assertThat(f2.isCompletedExceptionally(), is(true));

    exception.expectCause(is(cause));

    f2.get();
  }
}
@@ -1819,10 +1819,325 @@
 t();%0A  %7D
+%0A%0A  @Test%0A  public void testToCompletableFutureResultPropagation() throws Exception %7B%0A    final PubsubFuture%3CString%3E f1 = new PubsubFuture%3C%3E(requestInfo);%0A    final PubsubFuture%3CString%3E f2 = f1.toCompletableFuture();%0A%0A    final String value = %22foo%22;%0A%0A    f1.succeed(value);%0A%0A    assertThat(f2.get(), is(value));%0A  %7D
 %0A%7D

test result propagation