diff --git a/src/main/java/tech/jhipster/lite/generator/JHLiteFeatureSlug.java b/src/main/java/tech/jhipster/lite/generator/JHLiteFeatureSlug.java index acbdb34a0f9..1c8765c8066 100644 --- a/src/main/java/tech/jhipster/lite/generator/JHLiteFeatureSlug.java +++ b/src/main/java/tech/jhipster/lite/generator/JHLiteFeatureSlug.java @@ -20,6 +20,7 @@ public enum JHLiteFeatureSlug implements JHipsterFeatureSlugFactory { OAUTH_PROVIDER_SPRINGDOC("oauth-provider-springdoc"), SERVICE_DISCOVERY("service-discovery"), SPRING_SERVER("spring-server"), + SPRING_MVC_SERVER("spring-mvc-server"), SPRINGDOC("springdoc"); private final String slug; diff --git a/src/main/java/tech/jhipster/lite/generator/JHLiteModuleSlug.java b/src/main/java/tech/jhipster/lite/generator/JHLiteModuleSlug.java index 3e249ded143..bacb8eab2bd 100644 --- a/src/main/java/tech/jhipster/lite/generator/JHLiteModuleSlug.java +++ b/src/main/java/tech/jhipster/lite/generator/JHLiteModuleSlug.java @@ -87,8 +87,10 @@ public enum JHLiteModuleSlug implements JHipsterModuleSlugFactory { SPRING_BOOT_OAUTH_2_AUTH_0("spring-boot-oauth2-auth0"), SPRING_BOOT_OAUTH_2_OKTA("spring-boot-oauth2-okta"), SPRING_BOOT_PULSAR("spring-boot-pulsar"), + SPRING_BOOT_MVC("spring-boot-mvc"), SPRING_BOOT_TOMCAT("spring-boot-tomcat"), SPRING_BOOT_UNDERTOW("spring-boot-undertow"), + SPRING_BOOT_WEBFLUX("spring-boot-webflux"), SPRING_BOOT_WEBFLUX_NETTY("spring-boot-webflux-netty"), SPRING_CLOUD("spring-cloud"), SPRINGDOC_JWT("springdoc-jwt"), diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/apidocumentation/springdoccore/infrastructure/primary/SpringdocModuleConfiguration.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/apidocumentation/springdoccore/infrastructure/primary/SpringdocModuleConfiguration.java index d123108d25f..80f144325e7 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/apidocumentation/springdoccore/infrastructure/primary/SpringdocModuleConfiguration.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/apidocumentation/springdoccore/infrastructure/primary/SpringdocModuleConfiguration.java @@ -27,7 +27,7 @@ JHipsterModuleResource springdocMvcModule(SpringdocApplicationService springdocA .slug(SPRINGDOC_MVC_OPENAPI) .propertiesDefinition(buildPropertiesDefinition()) .apiDoc(API_GROUP, "Add springdoc-openapi for spring MVC") - .organization(JHipsterModuleOrganization.builder().feature(SPRINGDOC).addDependency(SPRING_BOOT_TOMCAT).build()) + .organization(JHipsterModuleOrganization.builder().feature(SPRINGDOC).addDependency(SPRING_MVC_SERVER).build()) .tags(SERVER_TAG, SPRING_TAG, SPRING_BOOT_TAG, DOCUMENTATION_TAG, SWAGGER_TAG) .factory(springdocApplicationService::buildSpringdocMvcModule); } diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/application/SpringBootMvcApplicationService.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/application/SpringBootMvcApplicationService.java index f8bfda29bd7..5ef24c177cf 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/application/SpringBootMvcApplicationService.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/application/SpringBootMvcApplicationService.java @@ -21,4 +21,8 @@ public JHipsterModule buildTomcatModule(JHipsterModuleProperties properties) { public JHipsterModule buildUndertowModule(JHipsterModuleProperties properties) { return factory.buildUndertowModule(properties); } + + public JHipsterModule buildEmptyModule(JHipsterModuleProperties properties) { + return factory.buildEmptyModule(properties); + } } diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/domain/SpringBootMvcsModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/domain/SpringBootMvcsModulesFactory.java index 22440a02721..1d427720f81 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/domain/SpringBootMvcsModulesFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/domain/SpringBootMvcsModulesFactory.java @@ -26,6 +26,10 @@ public class SpringBootMvcsModulesFactory { private static final String CORS_PRIMARY = "security/infrastructure/primary"; + public JHipsterModule buildEmptyModule(JHipsterModuleProperties properties) { + return moduleBuilder(properties).build(); + } + public JHipsterModule buildTomcatModule(JHipsterModuleProperties properties) { Assert.notNull("properties", properties); diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/infrastructure/primary/SpringBootMvcModulesConfiguration.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/infrastructure/primary/SpringBootMvcModulesConfiguration.java index 134b53aa4f3..f6b4b78084c 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/infrastructure/primary/SpringBootMvcModulesConfiguration.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/mvc/web/infrastructure/primary/SpringBootMvcModulesConfiguration.java @@ -13,7 +13,23 @@ @Configuration class SpringBootMvcModulesConfiguration { + private static final String SERVER_TAG = "server"; private static final String SPRING_BOOT_TAG = "spring-boot"; + private static final String SPRING_TAG = "spring"; + private static final String MVC_TAG = "mvc"; + private static final String WEB_TAG = "web"; + + @Bean + JHipsterModuleResource springBootMvcModule(SpringBootMvcApplicationService springBootMvc) { + return JHipsterModuleResource + .builder() + .slug(SPRING_BOOT_MVC) + .propertiesDefinition(properties()) + .apiDoc("Spring Boot MVC", "Add Spring Boot MVC") + .organization(JHipsterModuleOrganization.builder().feature(SPRING_SERVER).addDependency(SPRING_BOOT).build()) + .tags(SERVER_TAG, SPRING_TAG, SPRING_BOOT_TAG, MVC_TAG, WEB_TAG) + .factory(springBootMvc::buildEmptyModule); + } @Bean JHipsterModuleResource springBootTomcatMvcModule(SpringBootMvcApplicationService springBootMvc) { @@ -22,8 +38,8 @@ JHipsterModuleResource springBootTomcatMvcModule(SpringBootMvcApplicationService .slug(SPRING_BOOT_TOMCAT) .propertiesDefinition(properties()) .apiDoc("Spring Boot - MVC", "Add Spring Boot MVC with Tomcat") - .organization(organization()) - .tags("server", "spring", SPRING_BOOT_TAG, "mvc", "web", "tomcat") + .organization(mvcServerOrganization()) + .tags(SERVER_TAG, SPRING_TAG, SPRING_BOOT_TAG, MVC_TAG, WEB_TAG, "tomcat") .factory(springBootMvc::buildTomcatModule); } @@ -34,8 +50,8 @@ JHipsterModuleResource springBootUndertowMvcModule(SpringBootMvcApplicationServi .slug(SPRING_BOOT_UNDERTOW) .propertiesDefinition(properties()) .apiDoc("Spring Boot - MVC", "Add Spring Boot MVC with Undertow") - .organization(organization()) - .tags("server", "spring", SPRING_BOOT_TAG, "mvc", "web", "undertow") + .organization(mvcServerOrganization()) + .tags(SERVER_TAG, SPRING_TAG, SPRING_BOOT_TAG, MVC_TAG, WEB_TAG, "undertow") .factory(springBootMvc::buildUndertowModule); } @@ -43,7 +59,7 @@ private JHipsterModulePropertiesDefinition properties() { return JHipsterModulePropertiesDefinition.builder().addBasePackage().addIndentation().addServerPort().build(); } - private JHipsterModuleOrganization organization() { - return JHipsterModuleOrganization.builder().feature(SPRING_SERVER).addDependency(SPRING_BOOT).build(); + private JHipsterModuleOrganization mvcServerOrganization() { + return JHipsterModuleOrganization.builder().feature(SPRING_MVC_SERVER).addDependency(SPRING_BOOT_MVC).build(); } } diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/application/SpringBootWebfluxApplicationService.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/application/SpringBootWebfluxApplicationService.java index 2a8a9843180..aa2616075c9 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/application/SpringBootWebfluxApplicationService.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/application/SpringBootWebfluxApplicationService.java @@ -14,7 +14,11 @@ public SpringBootWebfluxApplicationService() { factory = new SpringBootWebfluxModuleFactory(); } - public JHipsterModule buildModule(JHipsterModuleProperties properties) { - return factory.buildModule(properties); + public JHipsterModule buildNettyModule(JHipsterModuleProperties properties) { + return factory.buildNettyModule(properties); + } + + public JHipsterModule buildEmptyModule(JHipsterModuleProperties properties) { + return factory.buildEmptyModule(properties); } } diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/domain/SpringBootWebfluxModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/domain/SpringBootWebfluxModuleFactory.java index 588b0e240e1..a4fb272b377 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/domain/SpringBootWebfluxModuleFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/domain/SpringBootWebfluxModuleFactory.java @@ -22,7 +22,11 @@ public class SpringBootWebfluxModuleFactory { private static final String EXCEPTION_PRIMARY = "technical/infrastructure/primary/exception"; - public JHipsterModule buildModule(JHipsterModuleProperties properties) { + public JHipsterModule buildEmptyModule(JHipsterModuleProperties properties) { + return moduleBuilder(properties).build(); + } + + public JHipsterModule buildNettyModule(JHipsterModuleProperties properties) { Assert.notNull("properties", properties); String packagePath = properties.packagePath(); diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/infrastructure/primary/SpringBootWebfluxModuleConfiguration.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/infrastructure/primary/SpringBootWebfluxModuleConfiguration.java index ee6e6347c4a..cca54cbf7e6 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/infrastructure/primary/SpringBootWebfluxModuleConfiguration.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/webflux/web/infrastructure/primary/SpringBootWebfluxModuleConfiguration.java @@ -15,13 +15,29 @@ class SpringBootWebfluxModuleConfiguration { @Bean JHipsterModuleResource springBootWebfluxModule(SpringBootWebfluxApplicationService webflux) { + return JHipsterModuleResource + .builder() + .slug(SPRING_BOOT_WEBFLUX) + .propertiesDefinition(properties()) + .apiDoc("Spring Boot - Webflux", "Add Spring Boot Webflux") + .organization(JHipsterModuleOrganization.builder().feature(SPRING_SERVER).addDependency(SPRING_BOOT).build()) + .tags("server", "webflux") + .factory(webflux::buildEmptyModule); + } + + @Bean + JHipsterModuleResource springBootWebfluxNettyModule(SpringBootWebfluxApplicationService webflux) { return JHipsterModuleResource .builder() .slug(SPRING_BOOT_WEBFLUX_NETTY) - .propertiesDefinition(JHipsterModulePropertiesDefinition.builder().addBasePackage().addIndentation().addServerPort().build()) + .propertiesDefinition(properties()) .apiDoc("Spring Boot - Webflux", "Add Spring Boot Webflux with Netty") - .organization(JHipsterModuleOrganization.builder().feature(SPRING_SERVER).addDependency(SPRING_BOOT).build()) + .organization(JHipsterModuleOrganization.builder().addDependency(SPRING_BOOT_WEBFLUX).build()) .tags("server", "webflux") - .factory(webflux::buildModule); + .factory(webflux::buildNettyModule); + } + + private static JHipsterModulePropertiesDefinition properties() { + return JHipsterModulePropertiesDefinition.builder().addBasePackage().addIndentation().addServerPort().build(); } } diff --git a/src/test/features/spring-mvc.feature b/src/test/features/spring-mvc.feature index 9cd3100adbc..2664c2d37e1 100644 --- a/src/test/features/spring-mvc.feature +++ b/src/test/features/spring-mvc.feature @@ -1,11 +1,17 @@ Feature: Spring MVC Scenario: Should apply spring mvc tomcat module - When I apply "spring-boot-tomcat" module to default project with maven file - | packageName | tech.jhipster.chips | + When I apply modules to default project + | maven-java | + | spring-boot | + | spring-boot-mvc | + | spring-boot-tomcat | Then I should have "spring-boot-starter-web" in "pom.xml" Scenario: Should apply spring mvc undertow module - When I apply "spring-boot-undertow" module to default project with maven file - | packageName | tech.jhipster.chips | + When I apply modules to default project + | maven-java | + | spring-boot | + | spring-boot-mvc | + | spring-boot-undertow | Then I should have "spring-boot-starter-undertow" in "pom.xml" diff --git a/src/test/features/webflux.feature b/src/test/features/webflux.feature index ce786c97ae7..d9e6c3be853 100644 --- a/src/test/features/webflux.feature +++ b/src/test/features/webflux.feature @@ -1,8 +1,11 @@ Feature: Webflux module Scenario: Should apply webflux module - When I apply "spring-boot-webflux-netty" module to default project with maven file - | packageName | tech.jhipster.chips | - | serverPort | 9000 | + When I apply modules to default project + | maven-java | + | spring-boot | + | spring-boot-webflux | + | spring-boot-webflux-netty | + Then I should have "spring-boot-starter-webflux" in "pom.xml" Then I should have files in "src/main/java/tech/jhipster/chips/technical/infrastructure/primary/exception/" | FieldErrorDTO.java | diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/webflux/web/domain/SpringBootWebfluxModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/webflux/web/domain/SpringBootWebfluxModuleFactoryTest.java index 13763cdf12a..55d7919589a 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/webflux/web/domain/SpringBootWebfluxModuleFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/webflux/web/domain/SpringBootWebfluxModuleFactoryTest.java @@ -15,14 +15,14 @@ class SpringBootWebfluxModuleFactoryTest { private static final SpringBootWebfluxModuleFactory factory = new SpringBootWebfluxModuleFactory(); @Test - void shouldBuildModule() { + void shouldBuildWebfluxNettyModule() { JHipsterModuleProperties properties = JHipsterModulesFixture .propertiesBuilder(TestFileUtils.tmpDirForTest()) .basePackage("com.jhipster.test") .put("serverPort", 9000) .build(); - JHipsterModule module = factory.buildModule(properties); + JHipsterModule module = factory.buildNettyModule(properties); assertThatModuleWithFiles(module, pomFile()) .hasFile("pom.xml")