-
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.
- Loading branch information
Showing
8 changed files
with
246 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
openapi: "3.0.0" | ||
info: { } | ||
|
||
paths: { } | ||
|
||
components: | ||
schemas: | ||
Patient: | ||
allOf: | ||
- $ref: "#/components/schemas/Person" | ||
- $ref: "#/components/schemas/Employee" | ||
required: | ||
- patientId | ||
properties: | ||
patientId: | ||
type: string | ||
|
||
Person: | ||
required: | ||
- firstName | ||
- lastName | ||
- birthDate | ||
properties: | ||
firstName: | ||
type: string | ||
lastName: | ||
type: string | ||
birthDate: | ||
type: string | ||
format: date | ||
|
||
Employee: | ||
required: | ||
- employeeId | ||
- firstName | ||
- lastName | ||
properties: | ||
employeeId: | ||
type: string | ||
firstName: | ||
type: string | ||
lastName: | ||
type: string |
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,45 @@ | ||
openapi: "3.0.0" | ||
info: { } | ||
|
||
paths: { } | ||
|
||
components: | ||
schemas: | ||
Patient: | ||
allOf: | ||
- $ref: "#/components/schemas/Person" | ||
required: | ||
- patientId | ||
- birthDate | ||
properties: | ||
patientId: | ||
type: string | ||
birthDate: | ||
type: string | ||
format: date | ||
|
||
Person: | ||
allOf: | ||
- $ref: "#/components/schemas/Addressable" | ||
required: | ||
- firstName | ||
- lastName | ||
- birthDate | ||
properties: | ||
firstName: | ||
type: string | ||
lastName: | ||
type: string | ||
birthDate: | ||
type: string | ||
format: date | ||
|
||
Addressable: | ||
required: | ||
- street | ||
- city | ||
properties: | ||
street: | ||
type: string | ||
city: | ||
type: string |
19 changes: 14 additions & 5 deletions
19
example/src/test/java/com/github/muehmar/gradle/openapi/issue182/Issue182Test.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
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
84 changes: 84 additions & 0 deletions
84
example/src/test/java/com/github/muehmar/gradle/openapi/issue227/Issue227Test.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,84 @@ | ||
package com.github.muehmar.gradle.openapi.issue227; | ||
|
||
import static com.github.muehmar.gradle.openapi.issue227.PatientDto.fullPatientDtoBuilder; | ||
import static com.github.muehmar.gradle.openapi.issue227.PatientDto.patientDtoBuilder; | ||
import static com.github.muehmar.gradle.openapi.util.MethodList.listMethodNames; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import java.time.LocalDate; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class Issue227Test { | ||
|
||
private static final PersonDto PERSON_DTO = | ||
PersonDto.personDtoBuilder() | ||
.setFirstName("John") | ||
.setLastName("Doe") | ||
.setBirthDate(LocalDate.of(1990, 1, 1)) | ||
.andAllOptionals() | ||
.build(); | ||
|
||
@Test | ||
void fullPatientDtoBuilder_when_propertyStagesUsed_then_noPropertiesTwice() { | ||
final PatientDto patientDto = | ||
fullPatientDtoBuilder() | ||
.setFirstName("John") | ||
.setLastName("Doe") | ||
.setBirthDate(LocalDate.of(1990, 1, 1)) | ||
.setEmployeeId("employeeId") | ||
.setPatientId("patientId") | ||
.build(); | ||
assertNotNull(patientDto); | ||
} | ||
|
||
@Test | ||
void patientDtoBuilder_when_propertyStagesUsed_then_noPropertiesTwice() { | ||
final PatientDto patientDto = | ||
patientDtoBuilder() | ||
.setFirstName("John") | ||
.setLastName("Doe") | ||
.setBirthDate(LocalDate.of(1990, 1, 1)) | ||
.setEmployeeId("employeeId") | ||
.setPatientId("patientId") | ||
.andAllOptionals() | ||
.build(); | ||
assertNotNull(patientDto); | ||
} | ||
|
||
@Test | ||
void fullPatientDtoBuilder_when_propertyStagesUsed_then_noDtoSetterInReturnedStage() { | ||
final Object stage = | ||
fullPatientDtoBuilder() | ||
.setFirstName("John") | ||
.setLastName("Doe") | ||
.setBirthDate(LocalDate.of(1990, 1, 1)); | ||
|
||
assertEquals("setEmployeeId", listMethodNames(stage.getClass())); | ||
} | ||
|
||
@Test | ||
void patientDtoBuilder_when_propertyStagesUsed_then_noDtoSetterInReturnedStage() { | ||
final Object stage = | ||
patientDtoBuilder() | ||
.setFirstName("John") | ||
.setLastName("Doe") | ||
.setBirthDate(LocalDate.of(1990, 1, 1)); | ||
|
||
assertEquals("setEmployeeId", listMethodNames(stage.getClass())); | ||
} | ||
|
||
@Test | ||
void fullPatientDtoBuilder_when_dtoStagesUsed_then_noPropertySetterInReturnedStage() { | ||
final Object stage = fullPatientDtoBuilder().setPersonDto(PERSON_DTO); | ||
|
||
assertEquals("setEmployeeDto", listMethodNames(stage.getClass())); | ||
} | ||
|
||
@Test | ||
void patientDtoBuilder_when_dtoStagesUsed_then_noPropertySetterInReturnedStage() { | ||
final Object stage = patientDtoBuilder().setPersonDto(PERSON_DTO); | ||
|
||
assertEquals("setEmployeeDto", listMethodNames(stage.getClass())); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
example/src/test/java/com/github/muehmar/gradle/openapi/issue244/Issue244Test.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,41 @@ | ||
package com.github.muehmar.gradle.openapi.issue244; | ||
|
||
import static com.github.muehmar.gradle.openapi.issue244.PatientDto.fullPatientDtoBuilder; | ||
import static com.github.muehmar.gradle.openapi.issue244.PatientDto.patientDtoBuilder; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import java.time.LocalDate; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class Issue244Test { | ||
@Test | ||
void personDtoBuilder_when_used_then_allNestedAllOfPropertiesPresent() { | ||
final PatientDto patientDto = | ||
patientDtoBuilder() | ||
.setFirstName("John") | ||
.setLastName("Doe") | ||
.setBirthDate(LocalDate.of(1990, 1, 1)) | ||
.setStreet("Wallstreet") | ||
.setCity("New York") | ||
.setPatientId("patientId") | ||
.andAllOptionals() | ||
.build(); | ||
|
||
assertNotNull(patientDto); | ||
} | ||
|
||
@Test | ||
void fullPatientDtoBuilder_when_used_then_allNestedAllOfPropertiesPresent() { | ||
final PatientDto patientDto = | ||
fullPatientDtoBuilder() | ||
.setFirstName("John") | ||
.setLastName("Doe") | ||
.setBirthDate(LocalDate.of(1990, 1, 1)) | ||
.setStreet("Wallstreet") | ||
.setCity("New York") | ||
.setPatientId("patientId") | ||
.build(); | ||
|
||
assertNotNull(patientDto); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
example/src/test/java/com/github/muehmar/gradle/openapi/util/MethodList.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,15 @@ | ||
package com.github.muehmar.gradle.openapi.util; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
public class MethodList { | ||
private MethodList() {} | ||
|
||
public static String listMethodNames(Class<?> clazz) { | ||
return Arrays.stream(clazz.getDeclaredMethods()) | ||
.map(Method::getName) | ||
.collect(Collectors.joining(", ")); | ||
} | ||
} |