From d671bb3668f6261ca04ea90fa66660ee22acec03 Mon Sep 17 00:00:00 2001 From: Scott Leberknight <174812+sleberknight@users.noreply.github.com> Date: Fri, 29 Jul 2022 19:52:37 -0400 Subject: [PATCH] Add SET_OF_STRING_GENERIC_TYPE constant to KiwiGenericTypes Add a new constant to KiwiGenericTypes to support the somewhat common Set type. At least, it is common for us... --- .../kiwiproject/jaxrs/KiwiGenericTypes.java | 5 +++++ .../jaxrs/KiwiGenericTypesTest.java | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/main/java/org/kiwiproject/jaxrs/KiwiGenericTypes.java b/src/main/java/org/kiwiproject/jaxrs/KiwiGenericTypes.java index 522a3741..e4262a7c 100644 --- a/src/main/java/org/kiwiproject/jaxrs/KiwiGenericTypes.java +++ b/src/main/java/org/kiwiproject/jaxrs/KiwiGenericTypes.java @@ -5,6 +5,7 @@ import javax.ws.rs.core.GenericType; import java.util.List; import java.util.Map; +import java.util.Set; /** * Utilities/constants for containing common, re-usable types of {@link GenericType} objects. @@ -43,4 +44,8 @@ public class KiwiGenericTypes { public static final GenericType> LIST_OF_BOOLEAN_GENERIC_TYPE = new GenericType<>() { }; + + public static final GenericType> SET_OF_STRING_GENERIC_TYPE = + new GenericType<>() { + }; } diff --git a/src/test/java/org/kiwiproject/jaxrs/KiwiGenericTypesTest.java b/src/test/java/org/kiwiproject/jaxrs/KiwiGenericTypesTest.java index 072f229c..5b7c759a 100644 --- a/src/test/java/org/kiwiproject/jaxrs/KiwiGenericTypesTest.java +++ b/src/test/java/org/kiwiproject/jaxrs/KiwiGenericTypesTest.java @@ -19,6 +19,7 @@ import javax.ws.rs.core.Response; import java.util.List; import java.util.Map; +import java.util.Set; @DisplayName("KiwiGenericTypes") @ExtendWith(DropwizardExtensionsSupport.class) @@ -73,6 +74,13 @@ public Response getOnSale() { var onSale = List.of(true, false, false); return Response.ok(onSale).build(); } + + @GET + @Path("/bodyTypes") + public Response getBodyTypes() { + var types = List.of("sedan", "sedan", "SUV"); + return Response.ok(types).build(); + } } private static final ResourceExtension RESOURCES = ResourceExtension.builder() @@ -176,4 +184,14 @@ void shouldSupportListOfBooleans() { assertThat(onSale).containsExactly(true, false, false); } + + @Test + void shouldSupportSetOfStrings() { + Set models = RESOURCES.client() + .target("/genericTypes/bodyTypes") + .request() + .get(KiwiGenericTypes.SET_OF_STRING_GENERIC_TYPE); + + assertThat(models).containsExactlyInAnyOrder("sedan", "SUV"); + } }