[JAVA-26374-boot-data] Moved "Spring Boot: Customize the Jackson ObjectMapper" article to spring-boot-data (#15095)

This commit is contained in:
panos-kakos
2023-10-29 18:54:02 +02:00
committed by GitHub
parent 346350db14
commit 05230cf79d
18 changed files with 40 additions and 29 deletions
@@ -0,0 +1,34 @@
package com.baeldung.boot.jackson.app;
import static com.baeldung.boot.jackson.config.CoffeeConstants.FIXED_DATE;
import static org.assertj.core.api.Assertions.assertThat;
import java.time.format.DateTimeFormatter;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import com.baeldung.boot.jackson.config.CoffeeConstants;
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public abstract class AbstractCoffeeIntegrationTest {
@Autowired
protected TestRestTemplate restTemplate;
@Test
public void whenGetCoffee_thenSerializedWithDateAndNonNull() {
String formattedDate = DateTimeFormatter.ofPattern(CoffeeConstants.DATETIME_FORMAT)
.format(FIXED_DATE);
String brand = "Lavazza";
String url = "/coffee?brand=" + brand;
String response = restTemplate.getForObject(url, String.class);
assertThat(response).isEqualTo(
"{\"brand\":\"" + brand + "\",\"date\":\"" + formattedDate + "\"}");
}
}
@@ -0,0 +1,9 @@
package com.baeldung.boot.jackson.app;
import org.springframework.context.annotation.Import;
import com.baeldung.boot.jackson.config.CoffeeCustomizerConfig;
@Import(CoffeeCustomizerConfig.class)
public class CoffeeCustomizerIntegrationTest extends AbstractCoffeeIntegrationTest {
}
@@ -0,0 +1,9 @@
package com.baeldung.boot.jackson.app;
import org.springframework.context.annotation.Import;
import com.baeldung.boot.jackson.config.CoffeeHttpConverterConfiguration;
@Import(CoffeeHttpConverterConfiguration.class)
public class CoffeeHttpConverterIntegrationTest extends AbstractCoffeeIntegrationTest {
}
@@ -0,0 +1,9 @@
package com.baeldung.boot.jackson.app;
import org.springframework.context.annotation.Import;
import com.baeldung.boot.jackson.config.CoffeeJacksonBuilderConfig;
@Import(CoffeeJacksonBuilderConfig.class)
public class CoffeeJacksonBuilderIntegrationTest extends AbstractCoffeeIntegrationTest {
}
@@ -0,0 +1,9 @@
package com.baeldung.boot.jackson.app;
import org.springframework.context.annotation.Import;
import com.baeldung.boot.jackson.config.CoffeeObjectMapperConfig;
@Import(CoffeeObjectMapperConfig.class)
public class CoffeeObjectMapperIntegrationTest extends AbstractCoffeeIntegrationTest {
}
@@ -0,0 +1,9 @@
package com.baeldung.boot.jackson.app;
import org.springframework.context.annotation.Import;
import com.baeldung.boot.jackson.config.CoffeeRegisterModuleConfig;
@Import(CoffeeRegisterModuleConfig.class)
public class CoffeeRegisterModuleIntegrationTest extends AbstractCoffeeIntegrationTest {
}