|
| 1 | +/**************************************************************************** |
| 2 | + * Copyright 2017, Optimizely, Inc. and contributors * |
| 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.optimizely.ab.android.sdk; |
| 18 | + |
| 19 | +import org.junit.Test; |
| 20 | +import org.junit.runner.RunWith; |
| 21 | +import org.mockito.runners.MockitoJUnitRunner; |
| 22 | + |
| 23 | +import java.util.concurrent.TimeUnit; |
| 24 | + |
| 25 | +import static junit.framework.Assert.assertEquals; |
| 26 | + |
| 27 | +@RunWith(MockitoJUnitRunner.class) |
| 28 | +public class OptimizelyManagerBuilderTest { |
| 29 | + |
| 30 | + /** |
| 31 | + * Verify that building the {@link OptimizelyManager} with a polling interval less than 60 |
| 32 | + * seconds defaults to 60 seconds. |
| 33 | + */ |
| 34 | + @Test |
| 35 | + public void testBuildWithInvalidPollingInterval() { |
| 36 | + OptimizelyManager manager = OptimizelyManager.builder("1") |
| 37 | + .withDataFileDownloadInterval(5, TimeUnit.SECONDS) |
| 38 | + .build(); |
| 39 | + |
| 40 | + assertEquals(60L, manager.getDataFileDownloadInterval().longValue()); |
| 41 | + assertEquals(TimeUnit.SECONDS, manager.getDataFileDownloadIntervalTimeUnit()); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Verify that building the {@link OptimizelyManager} with a polling interval greater than 60 |
| 46 | + * seconds is properly registered. |
| 47 | + */ |
| 48 | + @Test |
| 49 | + public void testBuildWithValidPollingInterval() { |
| 50 | + OptimizelyManager manager = OptimizelyManager.builder("1") |
| 51 | + .withDataFileDownloadInterval(61, TimeUnit.SECONDS) |
| 52 | + .build(); |
| 53 | + |
| 54 | + assertEquals(61L, manager.getDataFileDownloadInterval().longValue()); |
| 55 | + assertEquals(TimeUnit.SECONDS, manager.getDataFileDownloadIntervalTimeUnit()); |
| 56 | + } |
| 57 | +} |
0 commit comments