Skip to content

Commit

Permalink
fix WRITE_TO_POSITION file exist test
Browse files Browse the repository at this point in the history
  • Loading branch information
L-Applin committed Jun 10, 2024
1 parent 417fe5b commit 0042b1d
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import software.amazon.awssdk.core.FileTransformerConfiguration.FileWriteOption;
import software.amazon.awssdk.core.FileTransformerConfiguration.FailureBehavior;
import software.amazon.awssdk.core.async.SdkPublisher;
import software.amazon.awssdk.core.util.FileUtils;

/**
* Tests for {@link FileAsyncResponseTransformer}.
Expand Down Expand Up @@ -270,12 +271,19 @@ void writeToPosition_fileExists_shouldAppendFromPosition() throws Exception {
@Test
void writeToPosition_fileDoesNotExists_shouldThrowException() throws Exception {
Path path = testFs.getPath("this/file/does/not/exists");
FileAsyncResponseTransformer<String> transformer = new FileAsyncResponseTransformer<>(path);
transformer.prepare();
FileAsyncResponseTransformer<String> transformer = new FileAsyncResponseTransformer<>(
path,
FileTransformerConfiguration.builder()
.position(0L)
.failureBehavior(DELETE)
.fileWriteOption(FileWriteOption.WRITE_TO_POSITION)
.build());
CompletableFuture<?> future = transformer.prepare();
transformer.onResponse("foobar");
assertThatThrownBy(() -> transformer.onStream(testPublisher("foo-bar-content")))
.hasRootCauseInstanceOf(NoSuchFileException.class);

assertThatThrownBy(() -> {
transformer.onStream(testPublisher("foo-bar-content"));
future.join();
}).hasRootCauseInstanceOf(NoSuchFileException.class);
}

@Test
Expand Down

0 comments on commit 0042b1d

Please sign in to comment.