|
1 | 1 | package org.embulk.input.box; |
2 | 2 |
|
3 | | -public class TestBoxFileInputPlugin {} |
| 3 | +import static org.junit.Assert.assertEquals; |
| 4 | +import static org.junit.Assert.assertFalse; |
| 5 | +import static org.junit.Assert.assertTrue; |
| 6 | + |
| 7 | +import org.embulk.config.ConfigSource; |
| 8 | +import org.embulk.util.config.ConfigMapper; |
| 9 | +import org.embulk.util.config.ConfigMapperFactory; |
| 10 | +import org.junit.Test; |
| 11 | + |
| 12 | +public class TestBoxFileInputPlugin { |
| 13 | + private static final ConfigMapperFactory CONFIG_MAPPER_FACTORY = |
| 14 | + ConfigMapperFactory.builder().addDefaultModules().build(); |
| 15 | + private static final ConfigMapper CONFIG_MAPPER = CONFIG_MAPPER_FACTORY.createConfigMapper(); |
| 16 | + |
| 17 | + private ConfigSource baseJwtConfig() { |
| 18 | + return CONFIG_MAPPER_FACTORY |
| 19 | + .newConfigSource() |
| 20 | + .set("auth_method", "jwt") |
| 21 | + .set("json_config", "{}") |
| 22 | + .set("folder_id", "1234"); |
| 23 | + } |
| 24 | + |
| 25 | + @Test |
| 26 | + public void maximum_retries_defaults_to_3() { |
| 27 | + PluginTask task = CONFIG_MAPPER.map(baseJwtConfig(), PluginTask.class); |
| 28 | + assertEquals(3, task.getMaximumRetries()); |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + public void maximum_retries_accepts_explicit_value() { |
| 33 | + PluginTask task = |
| 34 | + CONFIG_MAPPER.map(baseJwtConfig().set("maximum_retries", 10), PluginTask.class); |
| 35 | + assertEquals(10, task.getMaximumRetries()); |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + public void maximum_retries_accepts_zero() { |
| 40 | + PluginTask task = |
| 41 | + CONFIG_MAPPER.map(baseJwtConfig().set("maximum_retries", 0), PluginTask.class); |
| 42 | + assertEquals(0, task.getMaximumRetries()); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void stop_when_file_not_found_defaults_to_false() { |
| 47 | + PluginTask task = CONFIG_MAPPER.map(baseJwtConfig(), PluginTask.class); |
| 48 | + assertFalse(task.getStopWhenFileNotFound()); |
| 49 | + } |
| 50 | + |
| 51 | + @Test |
| 52 | + public void stop_when_file_not_found_can_be_true() { |
| 53 | + PluginTask task = |
| 54 | + CONFIG_MAPPER.map(baseJwtConfig().set("stop_when_file_not_found", true), PluginTask.class); |
| 55 | + assertTrue(task.getStopWhenFileNotFound()); |
| 56 | + } |
| 57 | +} |
0 commit comments