File tree Expand file tree Collapse file tree
main/java/org/zalando/riptide
test/java/org/example/application Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public <T> Optional<T> retrieve(final Class<T> type) {
3737 return retrieve (TypeToken .of (type ));
3838 }
3939
40- public <T > Optional <T > retrieve (final TypeToken <? > type ) {
40+ public <T > Optional <T > retrieve (final TypeToken <T > type ) {
4141 return Optional .ofNullable (captured .getValue ())
4242 .filter (v -> this .hasRetrieved (type ))
4343 .map (v -> {
Original file line number Diff line number Diff line change @@ -137,6 +137,26 @@ public void shouldRetrieveParameterizedType() throws IOException {
137137 assertThat (result .get (0 ), isA (String .class ));
138138 }
139139
140+ @ Test
141+ public void shouldRetrieveParameterizedTypeWithTypeInference () throws IOException {
142+ setUp (new PassThroughResponseErrorHandler ());
143+
144+ server .expect (requestTo (url )).andRespond (withSuccess ()
145+ .contentType (MediaType .APPLICATION_JSON )
146+ .body ("[\" a\" ,\" b\" ]" ));
147+
148+ final TypeToken <List <String >> typeToken = new TypeToken <List <String >>() {
149+ };
150+ final List <String > result = unit .execute (GET , url ).dispatch (status (),
151+ on (OK , typeToken ).capture (),
152+ anyStatus ().call (this ::error ))
153+ .retrieve (typeToken ).orElseThrow (() -> new RuntimeException ("Unable to retrieve List<String>" ));
154+
155+ assertThat (result , is (not (nullValue ())));
156+ assertThat (result , hasSize (2 ));
157+ assertThat (result .get (0 ), isA (String .class ));
158+ }
159+
140160 @ Test
141161 public void shouldNotRetrieveMappedParameterizedType () throws IOException {
142162 setUp (new PassThroughResponseErrorHandler ());
You can’t perform that action at this time.
0 commit comments