Browse Source
We now reinstantiate the serialization of Unpaged instances as plain INSTANCE strings as they were rendered before Unpaged was changed from an enum into a class. Note, that we still strongly advise, not to serialize Page instances directly as it's a domain type, its Jackson-level surface is subject to change if we need to change the type's API for unrelated reasons. Fixes: GH-2987.pull/3028/head
2 changed files with 97 additions and 0 deletions
@ -0,0 +1,45 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2024 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. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package org.springframework.data.web; |
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.*; |
||||||
|
|
||||||
|
import java.util.Collections; |
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
import org.springframework.data.domain.PageImpl; |
||||||
|
import org.springframework.data.web.config.SpringDataJacksonConfiguration; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* Unit tests for PageImpl serialization. |
||||||
|
* |
||||||
|
* @author Oliver Drotbohm |
||||||
|
*/ |
||||||
|
class PageImplJsonSerializationUnitTests { |
||||||
|
|
||||||
|
@Test |
||||||
|
void serializesPageImplAsJson() { |
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper(); |
||||||
|
mapper.registerModule(new SpringDataJacksonConfiguration.PageModule()); |
||||||
|
|
||||||
|
assertThatNoException().isThrownBy(() -> { |
||||||
|
mapper.writeValueAsString(new PageImpl<>(Collections.emptyList())); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue