Created
September 9, 2012 12:53
-
-
Save holyjak/3684150 to your computer and use it in GitHub Desktop.
S3FilesResourceTest - refactored
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
public class S3FilesResourceTest { | |
private static class FakeS3Facade implements S3Facade { | |
List<S3File> fileList; | |
public List<S3File> listObjects(String bucketName) { | |
return fileList; | |
} | |
} | |
private S3FilesResource resource; | |
private FakeS3Facade fakeS3; | |
@Before | |
public void setUp() throws Exception { | |
fakeS3 = new FakeS3Facade(); | |
resource = new S3FilesResource(); | |
resource.amazonS3Client = fakeS3; | |
} | |
@Test | |
public void excludeDirectories() throws Exception { | |
S3File s3File = new S3File("file", "/file.xx"); | |
fakeS3.fileList = asList(new S3File("dir", "/my/dir/"), s3File); | |
assertThat(resource.fetchS3Files()) | |
.hasSize(1) | |
.contains(s3File); | |
} | |
/** Simplest possible test of listS3Files */ | |
@Test | |
public void renderToHtml() throws Exception { | |
fakeS3.fileList = asList(new S3File("file", "/file.xx")); | |
assertThat(resource.listS3Files()) | |
.contains("/file.xx"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment