Skip to content

Commit

Permalink
fix for awslab#432 (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanofornari authored Apr 11, 2024
1 parent 074099f commit 43cba86
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import software.amazon.awssdk.services.s3.S3AsyncClient;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class S3WritableByteChannelTest {
Expand All @@ -39,7 +40,7 @@ class S3WritableByteChannelTest {
@DisplayName("when file exists and constructor is invoked with option `CREATE_NEW` should throw FileAlreadyExistsException")
void whenFileExistsAndCreateNewShouldThrowFileAlreadyExistsException() throws InterruptedException, TimeoutException {
S3FileSystemProvider provider = mock();
when(provider.exists(any(), any())).thenReturn(true);
when(provider.exists(any(S3AsyncClient.class), any())).thenReturn(true);

S3FileSystem fs = mock();
when(fs.provider()).thenReturn(provider);
Expand All @@ -53,7 +54,7 @@ void whenFileExistsAndCreateNewShouldThrowFileAlreadyExistsException() throws In
@DisplayName("when file does not exist and constructor is invoked without option `CREATE_NEW` nor `CREATE` should throw NoSuchFileException")
void whenFileDoesNotExistsAndNoCreateNewShouldThrowNoSuchFileException() throws InterruptedException, TimeoutException {
S3FileSystemProvider provider = mock();
when(provider.exists(any(), any())).thenReturn(false);
when(provider.exists(any(S3AsyncClient.class), any())).thenReturn(false);

S3FileSystem fs = mock();
when(fs.provider()).thenReturn(provider);
Expand All @@ -68,7 +69,7 @@ void whenFileDoesNotExistsAndNoCreateNewShouldThrowNoSuchFileException() throws
@DisplayName("S3WritableByteChannel")
void shouldNotThrowWhen(boolean fileExists, Set<StandardOpenOption> openOptions) throws InterruptedException, TimeoutException, IOException {
S3FileSystemProvider provider = mock();
when(provider.exists(any(), any())).thenReturn(fileExists);
when(provider.exists(any(S3AsyncClient.class), any())).thenReturn(fileExists);

S3FileSystem fs = mock();
when(fs.provider()).thenReturn(provider);
Expand All @@ -81,7 +82,7 @@ void shouldNotThrowWhen(boolean fileExists, Set<StandardOpenOption> openOptions)
@DisplayName("open() should be true before close()")
void shouldBeOpenBeforeClose() throws InterruptedException, TimeoutException, IOException {
S3FileSystemProvider provider = mock();
when(provider.exists(any(), any())).thenReturn(false);
when(provider.exists(any(S3AsyncClient.class), any())).thenReturn(false);

S3FileSystem fs = mock();
when(fs.provider()).thenReturn(provider);
Expand All @@ -96,7 +97,7 @@ void shouldBeOpenBeforeClose() throws InterruptedException, TimeoutException, IO
@DisplayName("open() should be false after close()")
void shouldBeNotOpenAfterClose() throws InterruptedException, TimeoutException, IOException {
S3FileSystemProvider provider = mock();
when(provider.exists(any(), any())).thenReturn(false);
when(provider.exists(any(S3AsyncClient.class), any())).thenReturn(false);

S3FileSystem fs = mock();
when(fs.provider()).thenReturn(provider);
Expand All @@ -111,7 +112,7 @@ void shouldBeNotOpenAfterClose() throws InterruptedException, TimeoutException,
@DisplayName("close() should clean up the temporary file")
void tmpFileIsCleanedUpAfterClose(@TempDir Path tempDir) throws InterruptedException, TimeoutException, IOException {
S3FileSystemProvider provider = mock();
when(provider.exists(any(), any())).thenReturn(false);
when(provider.exists(any(S3AsyncClient.class), any())).thenReturn(false);
S3FileSystem fs = mock();
when(fs.provider()).thenReturn(provider);
var file = S3Path.getPath(fs, "somefile");
Expand Down

0 comments on commit 43cba86

Please sign in to comment.