Skip to content

Instantly share code, notes, and snippets.

@holyjak
Created September 9, 2012 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holyjak/3684150 to your computer and use it in GitHub Desktop.
Save holyjak/3684150 to your computer and use it in GitHub Desktop.
S3FilesResourceTest - refactored
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