From d5c49352299a65c6c0ec00de613ecc98ffd4d214 Mon Sep 17 00:00:00 2001 From: davidmartinezbarua Date: Mon, 17 Aug 2020 11:52:28 -0300 Subject: [PATCH] Revert "BAEL-4321 demo app for yaml to pojo" --- spring-boot-modules/pom.xml | 1 - .../spring-boot-properties-3/pom.xml | 54 ------------------- .../boot/properties/DemoApplication.java | 16 ------ .../properties/config/TshirtSizeConfig.java | 27 ---------- .../controller/TshirtSizeController.java | 21 -------- .../properties/service/SizeConverterImpl.java | 22 -------- .../service/SizeConverterService.java | 8 --- .../src/main/resources/application.yml | 30 ----------- .../controller/TshirtSizeControllerTest.java | 38 ------------- 9 files changed, 217 deletions(-) delete mode 100644 spring-boot-modules/spring-boot-properties-3/pom.xml delete mode 100644 spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/DemoApplication.java delete mode 100644 spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/config/TshirtSizeConfig.java delete mode 100644 spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/controller/TshirtSizeController.java delete mode 100644 spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/service/SizeConverterImpl.java delete mode 100644 spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/service/SizeConverterService.java delete mode 100644 spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml delete mode 100644 spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/controller/TshirtSizeControllerTest.java diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index b4cabaaedf..3a2f14f5df 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -56,7 +56,6 @@ spring-boot-performance spring-boot-properties spring-boot-properties-2 - spring-boot-properties-3 spring-boot-property-exp spring-boot-runtime spring-boot-security diff --git a/spring-boot-modules/spring-boot-properties-3/pom.xml b/spring-boot-modules/spring-boot-properties-3/pom.xml deleted file mode 100644 index 1e3d627b19..0000000000 --- a/spring-boot-modules/spring-boot-properties-3/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - 4.0.0 - - com.baeldung.spring-boot-modules - spring-boot-modules - 1.0.0-SNAPSHOT - ../ - - - spring-boot-properties-3 - 0.0.1-SNAPSHOT - spring-boot-properties-3 - Spring Boot Properties Module - - - 1.8 - - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - - - - - org.springframework.boot - spring-boot-starter-web - RELEASE - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/DemoApplication.java b/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/DemoApplication.java deleted file mode 100644 index cf2fb7f981..0000000000 --- a/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/DemoApplication.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.boot.properties; - -import com.baeldung.boot.properties.config.TshirtSizeConfig; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.EnableConfigurationProperties; - -@SpringBootApplication -@EnableConfigurationProperties(TshirtSizeConfig.class) -public class DemoApplication { - - public static void main(String[] args) { - SpringApplication.run(DemoApplication.class, args); - } - -} diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/config/TshirtSizeConfig.java b/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/config/TshirtSizeConfig.java deleted file mode 100644 index 690763ab7b..0000000000 --- a/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/config/TshirtSizeConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baeldung.boot.properties.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -import java.util.Map; - -@ConfigurationProperties(prefix = "t-shirt-size") -public class TshirtSizeConfig { - - private final Map simpleMapping; - - private final Map> complexMapping; - - - public TshirtSizeConfig(Map simpleMapping, Map> complexMapping) { - this.simpleMapping = simpleMapping; - this.complexMapping = complexMapping; - } - - public Map getSimpleMapping() { - return simpleMapping; - } - - public Map> getComplexMapping() { - return complexMapping; - } -} diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/controller/TshirtSizeController.java b/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/controller/TshirtSizeController.java deleted file mode 100644 index 6b713c5be8..0000000000 --- a/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/controller/TshirtSizeController.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.boot.properties.controller; - -import org.springframework.web.bind.annotation.*; -import com.baeldung.boot.properties.service.SizeConverterService; - -@RestController -@RequestMapping(value = "/") -public class TshirtSizeController { - - private final SizeConverterService service; - - public TshirtSizeController(SizeConverterService service) { - this.service = service; - } - - @RequestMapping(value ="convertSize", method = RequestMethod.GET) - public int convertSize(@RequestParam(value = "label") final String label, @RequestParam(value = "countryCode", required = false) final String countryCode) { - return service.convertSize(label, countryCode); - } - -} diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/service/SizeConverterImpl.java b/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/service/SizeConverterImpl.java deleted file mode 100644 index 34f7fe2ded..0000000000 --- a/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/service/SizeConverterImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.boot.properties.service; - -import org.springframework.stereotype.Service; -import com.baeldung.boot.properties.config.TshirtSizeConfig; - - -@Service -public class SizeConverterImpl implements SizeConverterService { - - private final TshirtSizeConfig tshirtSizeConfig; - - public SizeConverterImpl(TshirtSizeConfig tshirtSizeConfig) { - this.tshirtSizeConfig = tshirtSizeConfig; - } - - public int convertSize(String label, String countryCode) { - if(countryCode == null) { - return tshirtSizeConfig.getSimpleMapping().get(label); - } - return tshirtSizeConfig.getComplexMapping().get(label).get(countryCode.toLowerCase()); - } -} diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/service/SizeConverterService.java b/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/service/SizeConverterService.java deleted file mode 100644 index 412199b176..0000000000 --- a/spring-boot-modules/spring-boot-properties-3/src/main/java/com/baeldung/boot/properties/service/SizeConverterService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.boot.properties.service; - - -public interface SizeConverterService { - - int convertSize(String label, String countryCode); - -} diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml deleted file mode 100644 index 8779cb6b0c..0000000000 --- a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml +++ /dev/null @@ -1,30 +0,0 @@ - t-shirt-size: - simple-mapping: - XS: 6 - S: 8 - M: 10 - L: 12 - XL: 14 - - - complex-mapping: - XS: - uk: 6 - fr: 34 - us: 2 - S: - uk: 8 - fr: 36 - us: 4 - M: - uk: 10 - fr: 38 - us: 6 - L: - uk: 12 - fr: 40 - us: 8 - XL: - uk: 14 - fr: 42 - us: 10 diff --git a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/controller/TshirtSizeControllerTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/controller/TshirtSizeControllerTest.java deleted file mode 100644 index 0b70ed8622..0000000000 --- a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/controller/TshirtSizeControllerTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.baeldung.boot.properties.controller; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import com.baeldung.boot.properties.service.SizeConverterService; - -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.when; - -@ExtendWith(MockitoExtension.class) -class TshirtSizeControllerUnitTest { - - @Mock - private SizeConverterService service; - - @InjectMocks - private TshirtSizeController tested; - - @Test - void whenConvertSize_thenOK() { - - // Given - String label = "S"; - String countryCode = "fr"; - int result = 36; - - // When - when(service.convertSize(label, countryCode)).thenReturn(result); - int actual = tested.convertSize(label, countryCode); - - // Then - assertEquals(actual, result); - - } -} \ No newline at end of file