-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
645 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,87 @@ | ||
package org.embulk.input.sftp; | ||
|
||
/** | ||
* Created by satoshi on 2016/03/17. | ||
*/ | ||
public class TestFileList { | ||
import org.embulk.EmbulkTestRuntime; | ||
import org.embulk.config.ConfigSource; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class TestFileList | ||
{ | ||
@Rule | ||
public EmbulkTestRuntime runtime = new EmbulkTestRuntime(); | ||
|
||
private ConfigSource config; | ||
|
||
@Before | ||
public void createConfigSource() | ||
{ | ||
config = runtime.getExec().newConfigSource(); | ||
} | ||
|
||
@Test | ||
public void checkMinTaskSize() | ||
throws Exception | ||
{ | ||
{ // not specify min_task_size | ||
FileList fileList = newFileList(config.deepCopy(), | ||
"sample_00", 100L, | ||
"sample_01", 150L, | ||
"sample_02", 350L); | ||
|
||
assertEquals(3, fileList.getTaskCount()); | ||
assertEquals("sample_00", fileList.get(0).get(0)); | ||
assertEquals("sample_01", fileList.get(1).get(0)); | ||
assertEquals("sample_02", fileList.get(2).get(0)); | ||
} | ||
|
||
{ | ||
FileList fileList = newFileList(config.deepCopy().set("min_task_size", 100), | ||
"sample_00", 100L, | ||
"sample_01", 150L, | ||
"sample_02", 350L); | ||
|
||
assertEquals(3, fileList.getTaskCount()); | ||
assertEquals("sample_00", fileList.get(0).get(0)); | ||
assertEquals("sample_01", fileList.get(1).get(0)); | ||
assertEquals("sample_02", fileList.get(2).get(0)); | ||
} | ||
|
||
{ | ||
FileList fileList = newFileList(config.deepCopy().set("min_task_size", 200), | ||
"sample_00", 100L, | ||
"sample_01", 150L, | ||
"sample_02", 350L); | ||
|
||
assertEquals(2, fileList.getTaskCount()); | ||
assertEquals("sample_00", fileList.get(0).get(0)); | ||
assertEquals("sample_01", fileList.get(0).get(1)); | ||
assertEquals("sample_02", fileList.get(1).get(0)); | ||
} | ||
|
||
{ | ||
FileList fileList = newFileList(config.deepCopy().set("min_task_size", 700), | ||
"sample_00", 100L, | ||
"sample_01", 150L, | ||
"sample_02", 350L); | ||
|
||
assertEquals(1, fileList.getTaskCount()); | ||
assertEquals("sample_00", fileList.get(0).get(0)); | ||
assertEquals("sample_01", fileList.get(0).get(1)); | ||
assertEquals("sample_02", fileList.get(0).get(2)); | ||
} | ||
} | ||
|
||
private static FileList newFileList(ConfigSource config, Object... nameAndSize) | ||
{ | ||
FileList.Builder builder = new FileList.Builder(config); | ||
|
||
for (int i = 0; i < nameAndSize.length; i += 2) { | ||
builder.add((String) nameAndSize[i], (long) nameAndSize[i + 1]); | ||
} | ||
|
||
return builder.build(); | ||
} | ||
} |
Oops, something went wrong.