Search in sources :

Example 1 with DirectoryEntry

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"));
}
Also used : FolderDirectoryEntry(com.thoughtworks.go.domain.FolderDirectoryEntry) FolderDirectoryEntry(com.thoughtworks.go.domain.FolderDirectoryEntry) DirectoryEntry(com.thoughtworks.go.domain.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 2 with DirectoryEntry

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));
}
Also used : FolderDirectoryEntry(com.thoughtworks.go.domain.FolderDirectoryEntry) DirectoryEntry(com.thoughtworks.go.domain.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 3 with DirectoryEntry

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"));
}
Also used : FolderDirectoryEntry(com.thoughtworks.go.domain.FolderDirectoryEntry) FolderDirectoryEntry(com.thoughtworks.go.domain.FolderDirectoryEntry) DirectoryEntry(com.thoughtworks.go.domain.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 4 with DirectoryEntry

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"));
}
Also used : FolderDirectoryEntry(com.thoughtworks.go.domain.FolderDirectoryEntry) FolderDirectoryEntry(com.thoughtworks.go.domain.FolderDirectoryEntry) DirectoryEntry(com.thoughtworks.go.domain.DirectoryEntry) Test(org.junit.Test)

Example 5 with DirectoryEntry

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));
}
Also used : FolderDirectoryEntry(com.thoughtworks.go.domain.FolderDirectoryEntry) DirectoryEntry(com.thoughtworks.go.domain.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Aggregations

DirectoryEntry (com.thoughtworks.go.domain.DirectoryEntry)5 FolderDirectoryEntry (com.thoughtworks.go.domain.FolderDirectoryEntry)5 Test (org.junit.Test)5 File (java.io.File)4