-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split PartFilenameTest into classic and reactive
- Loading branch information
1 parent
9e55e3c
commit c5b53b1
Showing
3 changed files
with
112 additions
and
1 deletion.
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
101 changes: 101 additions & 0 deletions
101
...e/src/test/java/io/quarkiverse/openapi/generator/it/PartFilenameRestEasyReactiveTest.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,101 @@ | ||
package io.quarkiverse.openapi.generator.it; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
import jakarta.ws.rs.FormParam; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import org.acme.openapi.api.DoNotGeneratePartFilenameApi; | ||
import org.acme.openapi.api.GeneratePartFilenameApi; | ||
import org.acme.openapi.api.GlobalGeneratePartFilenameApi; | ||
import org.acme.openapi.api.PartFilenameValueApi; | ||
import org.acme.openapi.api.PartFilenameValueSuffixApi; | ||
import org.jboss.resteasy.reactive.PartFilename; | ||
import org.jboss.resteasy.reactive.PartType; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
@Tag("resteasy-reactive") | ||
class PartFilenameRestEasyReactiveTest { | ||
|
||
private static final String PROFILE_IMAGE = "profileImage"; | ||
|
||
private Field getProfileImageField(Class<?> clazz) throws NoSuchFieldException { | ||
return clazz.getField(PROFILE_IMAGE); | ||
} | ||
|
||
private void testOtherAnnotations(Field field) { | ||
var formParam = field.getAnnotation(FormParam.class); | ||
assertNotNull(formParam); | ||
assertEquals(PROFILE_IMAGE, formParam.value()); | ||
|
||
var partType = field.getAnnotation(PartType.class); | ||
assertNotNull(partType); | ||
assertEquals(MediaType.APPLICATION_OCTET_STREAM, partType.value()); | ||
} | ||
|
||
@Test | ||
void testGlobalGeneratePartFilename() throws NoSuchFieldException { | ||
var field = getProfileImageField( | ||
GlobalGeneratePartFilenameApi.PostUserProfileDataMultipartForm.class); | ||
|
||
this.testOtherAnnotations(field); | ||
|
||
var partFilename = field.getAnnotation(PartFilename.class); | ||
assertNull(partFilename); | ||
} | ||
|
||
@Test | ||
void testGeneratePartFilename() throws NoSuchFieldException { | ||
var field = getProfileImageField( | ||
GeneratePartFilenameApi.PostUserProfileDataMultipartForm.class); | ||
|
||
this.testOtherAnnotations(field); | ||
|
||
var partFilename = field.getAnnotation(PartFilename.class); | ||
assertNotNull(partFilename); | ||
assertEquals(PROFILE_IMAGE + "File", partFilename.value()); | ||
} | ||
|
||
@Test | ||
void testDoNotGeneratePartFilename() throws NoSuchFieldException { | ||
var field = getProfileImageField( | ||
DoNotGeneratePartFilenameApi.PostUserProfileDataMultipartForm.class); | ||
|
||
this.testOtherAnnotations(field); | ||
|
||
var partFilename = field.getAnnotation(PartFilename.class); | ||
assertNull(partFilename); | ||
} | ||
|
||
@Test | ||
void testPartFilenameValue() throws NoSuchFieldException { | ||
var field = getProfileImageField( | ||
PartFilenameValueApi.PostUserProfileDataMultipartForm.class); | ||
|
||
this.testOtherAnnotations(field); | ||
|
||
var partFilename = field.getAnnotation(PartFilename.class); | ||
assertNotNull(partFilename); | ||
assertEquals("test.pdf", partFilename.value()); | ||
} | ||
|
||
@Test | ||
void testPartFilenameValueSuffix() throws NoSuchFieldException { | ||
var field = getProfileImageField( | ||
PartFilenameValueSuffixApi.PostUserProfileDataMultipartForm.class); | ||
|
||
this.testOtherAnnotations(field); | ||
|
||
var partFilename = field.getAnnotation(PartFilename.class); | ||
assertNotNull(partFilename); | ||
assertEquals(PROFILE_IMAGE + ".pdf", partFilename.value()); | ||
} | ||
} |