Compare commits

...
3 Commits
8 changed files with 71 additions and 16 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign</artifactId>
<version>3.0.8-SNAPSHOT</version>
<version>3.0.8</version>
</parent>
<artifactId>spring-cloud-openfeign-docs</artifactId>
<packaging>jar</packaging>
@@ -197,7 +197,7 @@ feign:
Default configurations can be specified in the `@EnableFeignClients` attribute `defaultConfiguration` in a similar manner as described above. The difference is that this configuration will apply to _all_ feign clients.
If you prefer using configuration properties to configured all `@FeignClient`, you can create configuration properties with `default` feign name.
If you prefer using configuration properties to configure all `@FeignClient`, you can create configuration properties with `default` feign name.
You can use `feign.client.config.feignName.defaultQueryParameters` and `feign.client.config.feignName.defaultRequestHeaders` to specify query parameters and headers that will be sent with every request of the client named `feignName`.
+2 -2
View File
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-openfeign</artifactId>
<version>3.0.8-SNAPSHOT</version>
<version>3.0.8</version>
<packaging>pom</packaging>
<name>Spring Cloud OpenFeign</name>
<description>Spring Cloud OpenFeign</description>
@@ -26,7 +26,7 @@
<properties>
<main.basedir>${basedir}</main.basedir>
<jackson.version>2.11.3</jackson.version>
<spring-cloud-commons.version>3.0.7-SNAPSHOT</spring-cloud-commons.version>
<spring-cloud-commons.version>3.0.6</spring-cloud-commons.version>
<!-- Plugin versions -->
<maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign</artifactId>
<version>3.0.8-SNAPSHOT</version>
<version>3.0.8</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>
<artifactId>spring-cloud-openfeign-core</artifactId>
@@ -22,6 +22,7 @@ import java.util.function.Function;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.Module;
@@ -59,6 +60,7 @@ public class PageJacksonModule extends Module {
}
@JsonDeserialize(as = SimplePageImpl.class)
@JsonIgnoreProperties(ignoreUnknown = true)
private interface PageMixIn {
}
@@ -86,7 +88,7 @@ public class PageJacksonModule extends Module {
}
}
@JsonIgnore
@JsonProperty
@Override
public int getTotalPages() {
return delegate.getTotalPages();
@@ -110,7 +112,7 @@ public class PageJacksonModule extends Module {
return delegate.getSize();
}
@JsonIgnore
@JsonProperty
@Override
public int getNumberOfElements() {
return delegate.getNumberOfElements();
@@ -134,13 +136,13 @@ public class PageJacksonModule extends Module {
return delegate.getSort();
}
@JsonIgnore
@JsonProperty
@Override
public boolean isFirst() {
return delegate.isFirst();
}
@JsonIgnore
@JsonProperty
@Override
public boolean isLast() {
return delegate.isLast();
@@ -82,10 +82,10 @@ public class PageJacksonModuleTests {
@Test
public void serializeAndDeserializeFilledMultiple() throws JsonProcessingException {
// Given
ArrayList<Object> strings0 = new ArrayList<>();
strings0.add("first element");
strings0.add("second element");
PageImpl<Object> objects = new PageImpl<>(strings0, PageRequest.of(6, 2), 100);
ArrayList<Object> pageElements = new ArrayList<>();
pageElements.add("first element");
pageElements.add("second element");
PageImpl<Object> objects = new PageImpl<>(pageElements, PageRequest.of(6, 2), 100);
assertThat(objects.getContent()).hasSize(2);
assertThat(objects.getPageable().getPageSize()).isEqualTo(2);
@@ -102,4 +102,57 @@ public class PageJacksonModuleTests {
assertThat(result.getPageable().getPageNumber()).isEqualTo(6);
}
@Test
public void serializeAndDeserializeEmptyCascade() throws JsonProcessingException {
// Given
PageImpl<Object> objects = new PageImpl<>(new ArrayList<>());
String pageJson = objectMapper.writeValueAsString(objects);
// When
Page<?> result = objectMapper.readValue(pageJson, Page.class);
// Then
assertThat(result).isNotNull();
assertThat(result.getTotalElements()).isEqualTo(0);
assertThat(result.getContent()).hasSize(0);
String cascadedPageJson = objectMapper.writeValueAsString(result);
Page<?> cascadedResult = objectMapper.readValue(cascadedPageJson, Page.class);
assertThat(cascadedResult).isNotNull();
assertThat(cascadedResult.getTotalElements()).isEqualTo(0);
assertThat(cascadedResult.getContent()).hasSize(0);
}
@Test
public void serializeAndDeserializeFilledMultipleCascade() throws JsonProcessingException {
// Given
ArrayList<Object> pageElements = new ArrayList<>();
pageElements.add("first element in cascaded serialization");
pageElements.add("second element in cascaded serialization");
PageImpl<Object> objects = new PageImpl<>(pageElements, PageRequest.of(6, 2), 100);
assertThat(objects.getContent()).hasSize(2);
assertThat(objects.getPageable().getPageSize()).isEqualTo(2);
String pageJson = objectMapper.writeValueAsString(objects);
// When
Page<?> result = objectMapper.readValue(pageJson, Page.class);
// Then
assertThat(result).isNotNull();
assertThat(result.getTotalElements()).isEqualTo(100);
assertThat(result.getContent()).hasSize(2);
assertThat(result.getContent().get(0)).isEqualTo("first element in cascaded serialization");
assertThat(result.getContent().get(1)).isEqualTo("second element in cascaded serialization");
assertThat(result.getPageable().getPageSize()).isEqualTo(2);
assertThat(result.getPageable().getPageNumber()).isEqualTo(6);
String cascadedPageJson = objectMapper.writeValueAsString(result);
Page<?> cascadedResult = objectMapper.readValue(cascadedPageJson, Page.class);
// Then
assertThat(cascadedResult).isNotNull();
assertThat(cascadedResult.getTotalElements()).isEqualTo(100);
assertThat(cascadedResult.getContent()).hasSize(2);
assertThat(cascadedResult.getContent().get(0)).isEqualTo("first element in cascaded serialization");
assertThat(cascadedResult.getContent().get(1)).isEqualTo("second element in cascaded serialization");
assertThat(cascadedResult.getPageable().getPageSize()).isEqualTo(2);
assertThat(cascadedResult.getPageable().getPageNumber()).isEqualTo(6);
}
}
+2 -2
View File
@@ -6,11 +6,11 @@
<parent>
<artifactId>spring-cloud-dependencies-parent</artifactId>
<groupId>org.springframework.cloud</groupId>
<version>3.0.6-SNAPSHOT</version>
<version>3.0.5</version>
<relativePath/>
</parent>
<artifactId>spring-cloud-openfeign-dependencies</artifactId>
<version>3.0.8-SNAPSHOT</version>
<version>3.0.8</version>
<packaging>pom</packaging>
<name>spring-cloud-openfeign-dependencies</name>
<description>Spring Cloud OpenFeign Dependencies</description>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign</artifactId>
<version>3.0.8-SNAPSHOT</version>
<version>3.0.8</version>
<relativePath>..</relativePath>
</parent>
<artifactId>spring-cloud-starter-openfeign</artifactId>