-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement Comparable interface for TagObject and ExternalDocumentation
- Loading branch information
1 parent
8f454f3
commit 81b3e44
Showing
4 changed files
with
103 additions
and
2 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
35 changes: 35 additions & 0 deletions
35
...openapi/src/test/java/software/amazon/smithy/openapi/model/ExternalDocumentationTest.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,35 @@ | ||
package software.amazon.smithy.openapi.model; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
class ExternalDocumentationTest { | ||
private static final ExternalDocumentation DOC_1 = | ||
ExternalDocumentation.builder() | ||
.url("url1") | ||
.description("description1") | ||
.build(); | ||
|
||
private static Stream<Arguments> testData() { | ||
return Stream.of( | ||
Arguments.of(ExternalDocumentation.builder().url("url1").description("description1").build(), 0), | ||
Arguments.of(ExternalDocumentation.builder().url("url1").description("description0").build(), 1), | ||
Arguments.of(ExternalDocumentation.builder().url("url1").description("description2").build(), -1), | ||
Arguments.of(ExternalDocumentation.builder().url("url0").description("description1").build(), 1), | ||
Arguments.of(ExternalDocumentation.builder().url("url2").description("description1").build(), -1), | ||
Arguments.of(ExternalDocumentation.builder().url("url1").build(), 1) | ||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("testData") | ||
void testCompareTo(ExternalDocumentation doc2, int expected) { | ||
assertThat(DOC_1.compareTo(doc2), equalTo(expected)); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
smithy-openapi/src/test/java/software/amazon/smithy/openapi/model/TagObjectTest.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,38 @@ | ||
package software.amazon.smithy.openapi.model; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
class TagObjectTest { | ||
private static final TagObject TAG_OBJECT_1 = | ||
TagObject.builder() | ||
.name("tag1") | ||
.description("description1") | ||
.externalDocs(ExternalDocumentation.builder().url("url1").build()) | ||
.build(); | ||
|
||
private static Stream<Arguments> testData() { | ||
return Stream.of( | ||
Arguments.of("tag1", "description1", ExternalDocumentation.builder().url("url1").build(), 0), | ||
Arguments.of("tag0", "description1", ExternalDocumentation.builder().url("url1").build(), 1), | ||
Arguments.of("tag1", "description1", ExternalDocumentation.builder().url("url2").build(), -1), | ||
Arguments.of("tag2", "description1", ExternalDocumentation.builder().url("url1").build(), -1), | ||
Arguments.of("tag1", "description2", ExternalDocumentation.builder().url("url1").build(), -1), | ||
Arguments.of("tag1", null, ExternalDocumentation.builder().url("url1").build(), 1), | ||
Arguments.of("tag1", "description1", null, 1) | ||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("testData") | ||
void testCompareTo(String name, String description, ExternalDocumentation doc, int expected) { | ||
TagObject tagObject2 = TagObject.builder().name(name).description(description).externalDocs(doc).build(); | ||
assertThat(TAG_OBJECT_1.compareTo(tagObject2), equalTo(expected)); | ||
} | ||
} |