use of cn.taketoday.http.codec.json.JacksonViewBean.MyJacksonView1 in project today-framework by TAKETODAY.
the class Jackson2JsonDecoderTests method fieldLevelJsonView.
@Test
public void fieldLevelJsonView() {
Flux<DataBuffer> input = Flux.from(stringBuffer("{\"withView1\" : \"with\", \"withView2\" : \"with\", \"withoutView\" : \"without\"}"));
ResolvableType elementType = ResolvableType.fromClass(JacksonViewBean.class);
Map<String, Object> hints = Collections.singletonMap(JSON_VIEW_HINT, MyJacksonView1.class);
testDecode(input, elementType, step -> step.consumeNextWith(value -> {
JacksonViewBean bean = (JacksonViewBean) value;
assertThat(bean.getWithView1()).isEqualTo("with");
assertThat(bean.getWithView2()).isNull();
assertThat(bean.getWithoutView()).isNull();
}), null, hints);
}
use of cn.taketoday.http.codec.json.JacksonViewBean.MyJacksonView1 in project today-infrastructure by TAKETODAY.
the class Jackson2JsonDecoderTests method fieldLevelJsonView.
@Test
public void fieldLevelJsonView() {
Flux<DataBuffer> input = Flux.from(stringBuffer("{\"withView1\" : \"with\", \"withView2\" : \"with\", \"withoutView\" : \"without\"}"));
ResolvableType elementType = ResolvableType.fromClass(JacksonViewBean.class);
Map<String, Object> hints = Collections.singletonMap(JSON_VIEW_HINT, MyJacksonView1.class);
testDecode(input, elementType, step -> step.consumeNextWith(value -> {
JacksonViewBean bean = (JacksonViewBean) value;
assertThat(bean.getWithView1()).isEqualTo("with");
assertThat(bean.getWithView2()).isNull();
assertThat(bean.getWithoutView()).isNull();
}), null, hints);
}
Aggregations