// Path: provider/src/main/java/com/cloudera/director/aws/ec2/EC2Retryer.java
// @VisibleForTesting
// static Duration getTimeout(DateTime timeout) {
//   DateTime now = DateTime.now();
// 
//   if (timeout.isBefore(now)) {
//     return Duration.ZERO;
//   }
// 
//   return new Interval(now, timeout).toDuration();
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/ec2/EC2Retryer.java
// public static <T> T retryUntil(Callable<T> func)
//     throws InterruptedException, RetryException, ExecutionException {
//   return retryUntil(func, DEFAULT_TIMEOUT);
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/ec2/common/EC2Exceptions.java
// public static final String INVALID_INSTANCE_ID_NOT_FOUND = "InvalidInstanceID.NotFound";


import org.junit.Test;
import static com.cloudera.director.aws.ec2.EC2Retryer.getTimeout;
import static com.cloudera.director.aws.ec2.EC2Retryer.retryUntil;
import static com.cloudera.director.aws.ec2.common.EC2Exceptions.INVALID_INSTANCE_ID_NOT_FOUND;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.cloudera.director.aws.shaded.com.amazonaws.AmazonServiceException;
import com.cloudera.director.aws.shaded.org.joda.time.DateTime;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
// (c) Copyright 2017 Cloudera, Inc.
//
// 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.cloudera.director.aws.ec2;





@SuppressWarnings("unchecked")
public class EC2RetryerTest {

  @Test
  public void testRetrySucceeds() throws Exception {
// Path: provider/src/main/java/com/cloudera/director/aws/ec2/EC2Retryer.java
// @VisibleForTesting
// static Duration getTimeout(DateTime timeout) {
//   DateTime now = DateTime.now();
// 
//   if (timeout.isBefore(now)) {
//     return Duration.ZERO;
//   }
// 
//   return new Interval(now, timeout).toDuration();
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/ec2/EC2Retryer.java
// public static <T> T retryUntil(Callable<T> func)
//     throws InterruptedException, RetryException, ExecutionException {
//   return retryUntil(func, DEFAULT_TIMEOUT);
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/ec2/common/EC2Exceptions.java
// public static final String INVALID_INSTANCE_ID_NOT_FOUND = "InvalidInstanceID.NotFound";


// Path: tests/src/test/java/com/cloudera/director/aws/ec2/EC2RetryerTest.java
import org.junit.Test;
import static com.cloudera.director.aws.ec2.EC2Retryer.getTimeout;
import static com.cloudera.director.aws.ec2.EC2Retryer.retryUntil;
import static com.cloudera.director.aws.ec2.common.EC2Exceptions.INVALID_INSTANCE_ID_NOT_FOUND;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.cloudera.director.aws.shaded.com.amazonaws.AmazonServiceException;
import com.cloudera.director.aws.shaded.org.joda.time.DateTime;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;

// (c) Copyright 2017 Cloudera, Inc.
//
// 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.cloudera.director.aws.ec2;





@SuppressWarnings("unchecked")
public class EC2RetryerTest {

  @Test
  public void testRetrySucceeds() throws Exception {
    AmazonServiceException exception = new AmazonServiceException(INVALID_INSTANCE_ID_NOT_FOUND);