-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing manual FilePart openapi mapping - using default generator. File upload test added
- Loading branch information
Showing
7 changed files
with
80 additions
and
15 deletions.
There are no files selected for viewing
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
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
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
49 changes: 49 additions & 0 deletions
49
...-api/src/test/java/com/provectus/kafka/ui/controller/ApplicationConfigControllerTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.provectus.kafka.ui.controller; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.provectus.kafka.ui.AbstractIntegrationTest; | ||
import com.provectus.kafka.ui.model.UploadedFileInfoDTO; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.client.MultipartBodyBuilder; | ||
import org.springframework.test.web.reactive.server.WebTestClient; | ||
import org.springframework.util.MultiValueMap; | ||
|
||
class ApplicationConfigControllerTest extends AbstractIntegrationTest { | ||
|
||
@Autowired | ||
private WebTestClient webTestClient; | ||
|
||
@Test | ||
public void testUpload() throws IOException { | ||
var fileToUpload = new ClassPathResource("/fileForUploadTest.txt", this.getClass()); | ||
|
||
UploadedFileInfoDTO result = webTestClient | ||
.post() | ||
.uri("/api/config/relatedfiles") | ||
.bodyValue(generateBody(fileToUpload)) | ||
.exchange() | ||
.expectStatus() | ||
.isOk() | ||
.expectBody(UploadedFileInfoDTO.class) | ||
.returnResult() | ||
.getResponseBody(); | ||
|
||
assertThat(result).isNotNull(); | ||
assertThat(result.getLocation()).isNotNull(); | ||
assertThat(Path.of(result.getLocation())) | ||
.hasSameBinaryContentAs(fileToUpload.getFile().toPath()); | ||
} | ||
|
||
private MultiValueMap<String, HttpEntity<?>> generateBody(ClassPathResource resource) { | ||
MultipartBodyBuilder builder = new MultipartBodyBuilder(); | ||
builder.part("file", resource); | ||
return builder.build(); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
some content goes here |
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
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