use of com.thoughtworks.go.domain.DirectoryEntry in project gocd by gocd.
the class DirectoryReaderTest method shouldGetListOfFilesWithDirectoriesFirstAndFilesInAlphabeticOrder.
@Test
public void shouldGetListOfFilesWithDirectoriesFirstAndFilesInAlphabeticOrder() throws Exception {
TestFileUtil.createTestFile(testFolder, "build.html");
File subFolder = TestFileUtil.createTestFolder(testFolder, "testoutput");
TestFileUtil.createTestFile(subFolder, "baboon.html");
TestFileUtil.createTestFile(subFolder, "apple.html");
TestFileUtil.createTestFile(subFolder, "pear.html");
DirectoryReader reader = new DirectoryReader(jobIdentifier);
List<DirectoryEntry> entries = reader.listEntries(testFolder, folderRoot);
assertThat(entries.size(), is(2));
FolderDirectoryEntry folder = (FolderDirectoryEntry) entries.get(0);
assertThat(folder.getFileName(), is("testoutput"));
assertThat(entries.get(1).getFileName(), is("build.html"));
assertThat(folder.getSubDirectory().get(0).getFileName(), is("apple.html"));
assertThat(folder.getSubDirectory().get(1).getFileName(), is("baboon.html"));
assertThat(folder.getSubDirectory().get(2).getFileName(), is("pear.html"));
}
use of com.thoughtworks.go.domain.DirectoryEntry in project gocd by gocd.
the class DirectoryReaderTest method shouldKeepRootsInUrl.
@Test
public void shouldKeepRootsInUrl() throws Exception {
File b = TestFileUtil.createTestFolder(testFolder, "b");
TestFileUtil.createTestFile(b, "c.xml");
List<DirectoryEntry> entries = new DirectoryReader(jobIdentifier).listEntries(b, folderRoot + "/b");
assertThat(entries.size(), is(1));
String expectedUrl = "/files/pipelineName/LATEST/stageName/LATEST/buildName/" + testFolder.getName() + "/b/c.xml";
assertThat(entries.get(0).getUrl(), is(expectedUrl));
}
use of com.thoughtworks.go.domain.DirectoryEntry in project gocd by gocd.
the class DirectoryReaderTest method shouldGetListOfFilesAndFolders.
@Test
public void shouldGetListOfFilesAndFolders() throws Exception {
TestFileUtil.createTestFile(testFolder, "text.html");
File subFolder = TestFileUtil.createTestFolder(testFolder, "primate");
TestFileUtil.createTestFile(subFolder, "baboon.html");
DirectoryReader reader = new DirectoryReader(jobIdentifier);
List<DirectoryEntry> entries = reader.listEntries(testFolder, folderRoot);
assertThat(entries.size(), is(2));
FolderDirectoryEntry folder = (FolderDirectoryEntry) entries.get(0);
assertThat(folder.getFileName(), is("primate"));
assertThat(folder.getUrl(), is("/files/pipelineName/LATEST/stageName/LATEST/buildName" + folderRoot + "/primate"));
assertThat(entries.get(1).getFileName(), is("text.html"));
assertThat(folder.getSubDirectory().get(0).getFileName(), is("baboon.html"));
assertThat(folder.getSubDirectory().get(0).getUrl(), is("/files/pipelineName/LATEST/stageName/LATEST/buildName" + folderRoot + "/primate/baboon.html"));
}
use of com.thoughtworks.go.domain.DirectoryEntry in project gocd by gocd.
the class DirectoryReaderTest method shouldGetSubSubFolder.
@Test
public void shouldGetSubSubFolder() throws Exception {
TestFileUtil.createTestFile(TestFileUtil.createTestFolder(TestFileUtil.createTestFolder(testFolder, "primate"), "monkey"), "baboon.html");
DirectoryReader reader = new DirectoryReader(jobIdentifier);
List<DirectoryEntry> entries = reader.listEntries(testFolder, folderRoot);
FolderDirectoryEntry folder = (FolderDirectoryEntry) entries.get(0);
assertThat(folder.getFileName(), is("primate"));
FolderDirectoryEntry subFolder = (FolderDirectoryEntry) folder.getSubDirectory().get(0);
assertThat(subFolder.getFileName(), is("monkey"));
assertThat(subFolder.getSubDirectory().get(0).getFileName(), is("baboon.html"));
assertThat(subFolder.getSubDirectory().get(0).getUrl(), is("/files/pipelineName/LATEST/stageName/LATEST/buildName" + folderRoot + "/primate/monkey/baboon.html"));
}
use of com.thoughtworks.go.domain.DirectoryEntry in project gocd by gocd.
the class DirectoryReaderTest method shouldNotDieIfGivenBogusPath.
@Test
public void shouldNotDieIfGivenBogusPath() throws Exception {
DirectoryReader reader = new DirectoryReader(jobIdentifier);
List<DirectoryEntry> entries = reader.listEntries(new File("totally bogus path!!!"), "");
assertThat(entries.size(), is(0));
}
Aggregations