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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
StepVerifier.create(result).expectComplete().verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test // gh-27511
|
||||||
public void noDefaultConstructor() {
|
public void noDefaultConstructor() {
|
||||||
Flux<DataBuffer> input = Flux.from(stringBuffer("{\"property1\":\"foo\",\"property2\":\"bar\"}"));
|
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);
|
ResolvableType elementType = ResolvableType.forClass(BeanWithNoDefaultConstructor.class);
|
||||||
Flux<Object> flux = new Jackson2JsonDecoder().decode(input, elementType, null, Collections.emptyMap());
|
Flux<Object> flux = new Jackson2JsonDecoder().decode(input, elementType, null, Collections.emptyMap());
|
||||||
StepVerifier.create(flux).verifyError(CodecException.class);
|
StepVerifier.create(flux).verifyError(CodecException.class);
|
||||||
|
|
|
||||||
|
|
@ -498,14 +498,15 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||||
assertThat(result).contains("\"number\":123");
|
assertThat(result).contains("\"number\":123");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test // gh-27511
|
||||||
public void readWithNoDefaultConstructor() throws Exception {
|
public void readWithNoDefaultConstructor() throws Exception {
|
||||||
String body = "{\"property1\":\"foo\",\"property2\":\"bar\"}";
|
String body = "{\"property1\":\"foo\",\"property2\":\"bar\"}";
|
||||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes(StandardCharsets.UTF_8));
|
||||||
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
inputMessage.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
||||||
assertThatExceptionOfType(HttpMessageConversionException.class).isThrownBy(() ->
|
BeanWithNoDefaultConstructor bean =
|
||||||
converter.read(BeanWithNoDefaultConstructor.class, inputMessage))
|
(BeanWithNoDefaultConstructor)converter.read(BeanWithNoDefaultConstructor.class, inputMessage);
|
||||||
.withMessageStartingWith("Type definition error:");
|
assertThat(bean.property1).isEqualTo("foo");
|
||||||
|
assertThat(bean.property2).isEqualTo("bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue