Adapt tests for Jackson ParameterNamesModule
Closes gh-27511
This commit is contained in:
parent
2f43f77dd1
commit
349674ef5e
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -229,9 +229,22 @@ public class Jackson2JsonDecoderTests extends AbstractDecoderTests<Jackson2JsonD
|
|||
StepVerifier.create(result).expectComplete().verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // gh-27511
|
||||
public void noDefaultConstructor() {
|
||||
Flux<DataBuffer> input = Flux.from(stringBuffer("{\"property1\":\"foo\",\"property2\":\"bar\"}"));
|
||||
|
||||
testDecode(input, BeanWithNoDefaultConstructor.class, step -> step
|
||||
.consumeNextWith(o -> {
|
||||
assertThat(o.getProperty1()).isEqualTo("foo");
|
||||
assertThat(o.getProperty2()).isEqualTo("bar");
|
||||
})
|
||||
.verifyComplete()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void codecException() {
|
||||
Flux<DataBuffer> input = Flux.from(stringBuffer("["));
|
||||
ResolvableType elementType = ResolvableType.forClass(BeanWithNoDefaultConstructor.class);
|
||||
Flux<Object> flux = new Jackson2JsonDecoder().decode(input, elementType, null, Collections.emptyMap());
|
||||
StepVerifier.create(flux).verifyError(CodecException.class);
|
||||
|
|
|
|||
|
|
@ -498,14 +498,15 @@ public class MappingJackson2HttpMessageConverterTests {
|
|||
assertThat(result).contains("\"number\":123");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // gh-27511
|
||||
public void readWithNoDefaultConstructor() throws Exception {
|
||||
String body = "{\"property1\":\"foo\",\"property2\":\"bar\"}";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
||||
assertThatExceptionOfType(HttpMessageConversionException.class).isThrownBy(() ->
|
||||
converter.read(BeanWithNoDefaultConstructor.class, inputMessage))
|
||||
.withMessageStartingWith("Type definition error:");
|
||||
BeanWithNoDefaultConstructor bean =
|
||||
(BeanWithNoDefaultConstructor)converter.read(BeanWithNoDefaultConstructor.class, inputMessage);
|
||||
assertThat(bean.property1).isEqualTo("foo");
|
||||
assertThat(bean.property2).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue