1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.adservices.service.common; 18 19 import static com.google.common.truth.Truth.assertThat; 20 21 import com.android.adservices.common.AdServicesUnitTestCase; 22 import com.android.adservices.concurrency.AdServicesExecutors; 23 24 import org.junit.Test; 25 26 import java.util.concurrent.ExecutorService; 27 28 public final class RetryStrategyFactoryTest extends AdServicesUnitTestCase { 29 private static final int MAX_RETRY_ATTEMPTS = 1; 30 private static final ExecutorService EXECUTOR_SERVICE = 31 AdServicesExecutors.getLightWeightExecutor(); 32 33 @Test test_disabled()34 public void test_disabled() { 35 RetryStrategyFactory retryStrategyFactory = 36 RetryStrategyFactory.createInstance(false, EXECUTOR_SERVICE); 37 38 RetryStrategy retryStrategy = retryStrategyFactory.createRetryStrategy(MAX_RETRY_ATTEMPTS); 39 assertThat(retryStrategy).isInstanceOf(NoOpRetryStrategyImpl.class); 40 } 41 42 @Test test_enabled()43 public void test_enabled() { 44 RetryStrategyFactory retryStrategyFactory = 45 RetryStrategyFactory.createInstance(true, EXECUTOR_SERVICE); 46 47 RetryStrategy retryStrategy = retryStrategyFactory.createRetryStrategy(MAX_RETRY_ATTEMPTS); 48 assertThat(retryStrategy).isInstanceOf(RetryStrategyImpl.class); 49 } 50 } 51