-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from muehmar/v2.6.1-tests
Add tests for #238
- Loading branch information
Showing
5 changed files
with
129 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
openapi: "3.0.0" | ||
info: { } | ||
|
||
paths: { } | ||
|
||
components: | ||
schemas: | ||
User: | ||
required: | ||
- username | ||
properties: | ||
username: | ||
type: string | ||
|
||
Admin: | ||
required: | ||
- adminname | ||
properties: | ||
adminname: | ||
type: string | ||
|
||
|
||
UserOrAdminOptionalProps: | ||
anyOf: | ||
- $ref: '#/components/schemas/User' | ||
- $ref: '#/components/schemas/Admin' | ||
properties: | ||
level: | ||
type: integer | ||
|
||
|
||
UserOrAdminRequiredProps: | ||
anyOf: | ||
- $ref: '#/components/schemas/User' | ||
- $ref: '#/components/schemas/Admin' | ||
required: | ||
- level | ||
properties: | ||
level: | ||
type: integer | ||
|
||
|
||
UserOrAdminRequiredAdditionalProps: | ||
anyOf: | ||
- $ref: '#/components/schemas/User' | ||
- $ref: '#/components/schemas/Admin' | ||
required: | ||
- level |
77 changes: 77 additions & 0 deletions
77
example/src/test/java/com/github/muehmar/gradle/openapi/issue238/Issue238Test.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,77 @@ | ||
package com.github.muehmar.gradle.openapi.issue238; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.Optional; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class Issue238Test { | ||
@Test | ||
void fullBuilder_when_usedWithOptionalPropsAnyOf_then_canSetLevel() { | ||
final UserOrAdminOptionalPropsDto dto = | ||
UserOrAdminOptionalPropsDto.fullBuilder() | ||
.setAdminDto(AdminDto.builder().setAdminname("adminname").build()) | ||
.setLevel(5) | ||
.build(); | ||
|
||
assertEquals(Optional.of(5), dto.getLevelOpt()); | ||
} | ||
|
||
@Test | ||
void builder_when_usedWithOptionalPropsAnyOf_then_canSetLevel() { | ||
final UserOrAdminOptionalPropsDto dto = | ||
UserOrAdminOptionalPropsDto.builder() | ||
.setAdminDto(AdminDto.builder().setAdminname("adminname").build()) | ||
.andAllOptionals() | ||
.setLevel(5) | ||
.build(); | ||
|
||
assertEquals(Optional.of(5), dto.getLevelOpt()); | ||
} | ||
|
||
@Test | ||
void fullBuilder_when_usedWithRequiredPropsAnyOf_then_canSetLevel() { | ||
final UserOrAdminRequiredPropsDto dto = | ||
UserOrAdminRequiredPropsDto.fullBuilder() | ||
.setAdminDto(AdminDto.builder().setAdminname("adminname").build()) | ||
.setLevel(5) | ||
.build(); | ||
|
||
assertEquals(5, dto.getLevel()); | ||
} | ||
|
||
@Test | ||
void builder_when_usedWithRequiredPropsAnyOf_then_canSetLevel() { | ||
final UserOrAdminRequiredPropsDto dto = | ||
UserOrAdminRequiredPropsDto.builder() | ||
.setAdminDto(AdminDto.builder().setAdminname("adminname").build()) | ||
.setLevel(5) | ||
.andAllOptionals() | ||
.build(); | ||
|
||
assertEquals(5, dto.getLevel()); | ||
} | ||
|
||
@Test | ||
void fullBuilder_when_usedWithRequiredAdditionalPropsAnyOf_then_canSetLevel() { | ||
final UserOrAdminRequiredAdditionalPropsDto dto = | ||
UserOrAdminRequiredAdditionalPropsDto.fullBuilder() | ||
.setAdminDto(AdminDto.builder().setAdminname("adminname").build()) | ||
.setLevel(5) | ||
.build(); | ||
|
||
assertEquals(5, dto.getLevel()); | ||
} | ||
|
||
@Test | ||
void builder_when_usedWithRequiredAdditionalPropsAnyOf_then_canSetLevel() { | ||
final UserOrAdminRequiredAdditionalPropsDto dto = | ||
UserOrAdminRequiredAdditionalPropsDto.builder() | ||
.setAdminDto(AdminDto.builder().setAdminname("adminname").build()) | ||
.setLevel(5) | ||
.andAllOptionals() | ||
.build(); | ||
|
||
assertEquals(5, dto.getLevel()); | ||
} | ||
} |
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