Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.