From cc7c3195e86e4eebc20fdcd73c5b39f03b13bb52 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sun, 20 Feb 2022 14:52:41 -0300 Subject: [PATCH 1/5] Fix structure test for reactive microservice --- .../java/package/TechnicalStructureTest.java.ejs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/generators/server/templates/src/test/java/package/TechnicalStructureTest.java.ejs b/generators/server/templates/src/test/java/package/TechnicalStructureTest.java.ejs index 9a83f41fc681..af139075dd45 100644 --- a/generators/server/templates/src/test/java/package/TechnicalStructureTest.java.ejs +++ b/generators/server/templates/src/test/java/package/TechnicalStructureTest.java.ejs @@ -27,6 +27,10 @@ import static com.tngtech.archunit.base.DescribedPredicate.alwaysTrue; import static com.tngtech.archunit.core.domain.JavaClass.Predicates.belongToAnyOf; import static com.tngtech.archunit.library.Architectures.layeredArchitecture; +<%_ + const hasClientLayer = !reactive && (applicationTypeMicroservice || applicationTypeGateway); + const hasDomainLayer = !databaseTypeNo; +_%> @AnalyzeClasses(packagesOf = <%= mainClass %>.class, importOptions = DoNotIncludeTests.class) class TechnicalStructureTest { @@ -34,25 +38,25 @@ class TechnicalStructureTest { @ArchTest static final ArchRule respectsTechnicalArchitectureLayers = layeredArchitecture() .layer("Config").definedBy("..config..") -<%_ if (applicationTypeMicroservice) { _%> +<%_ if (hasClientLayer) { _%> .layer("Client").definedBy("..client..") <%_ } _%> .layer("Web").definedBy("..web..") .optionalLayer("Service").definedBy("..service..") .layer("Security").definedBy("..security..") -<%_ if (!databaseTypeNo) { _%> +<%_ if (hasDomainLayer) { _%> .layer("Persistence").definedBy("..repository..") .layer("Domain").definedBy("..domain..") <%_ } _%> .whereLayer("Config").mayNotBeAccessedByAnyLayer() -<%_ if (applicationTypeMicroservice) { _%> +<%_ if (hasClientLayer) { _%> .whereLayer("Client").mayNotBeAccessedByAnyLayer() <%_ } _%> .whereLayer("Web").mayOnlyBeAccessedByLayers("Config") .whereLayer("Service").mayOnlyBeAccessedByLayers("Web", "Config") - .whereLayer("Security").mayOnlyBeAccessedByLayers("Config", <% if (applicationTypeMicroservice) { %>"Client", <% } %>"Service", "Web") -<%_ if (!databaseTypeNo) { _%> + .whereLayer("Security").mayOnlyBeAccessedByLayers("Config", <% if (hasClientLayer) { %>"Client", <% } %>"Service", "Web") +<%_ if (hasDomainLayer) { _%> .whereLayer("Persistence").mayOnlyBeAccessedByLayers("Service", "Security", "Web", "Config") .whereLayer("Domain").mayOnlyBeAccessedByLayers("Persistence", "Service", "Security", "Web", "Config") <%_ } _%> From 6924432cd7e5233ef8b477d9d7448c4d09a884da Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Sun, 20 Feb 2022 20:25:17 -0300 Subject: [PATCH 2/5] Fix UserStepDefs cocumber test --- .../cucumber/stepdefs/StepDefs.java.ejs | 8 ++++++++ .../cucumber/stepdefs/UserStepDefs.java.ejs | 20 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/generators/server/templates/src/test/java/package/cucumber/stepdefs/StepDefs.java.ejs b/generators/server/templates/src/test/java/package/cucumber/stepdefs/StepDefs.java.ejs index 161e1ea32108..99b8e2337e4a 100644 --- a/generators/server/templates/src/test/java/package/cucumber/stepdefs/StepDefs.java.ejs +++ b/generators/server/templates/src/test/java/package/cucumber/stepdefs/StepDefs.java.ejs @@ -18,10 +18,18 @@ -%> package <%= packageName %>.cucumber.stepdefs; +<%_ if (reactive) { _%> +import org.springframework.test.web.reactive.server.WebTestClient; +<%_ } else { _%> import org.springframework.test.web.servlet.ResultActions; +<%_ } _%> public abstract class StepDefs { +<%_ if (reactive) { _%> + protected WebTestClient.ResponseSpec actions; +<%_ } else { _%> protected ResultActions actions; +<%_ } _%> } diff --git a/generators/server/templates/src/test/java/package/cucumber/stepdefs/UserStepDefs.java.ejs b/generators/server/templates/src/test/java/package/cucumber/stepdefs/UserStepDefs.java.ejs index 77427e1184f4..0a3ef7a08d27 100644 --- a/generators/server/templates/src/test/java/package/cucumber/stepdefs/UserStepDefs.java.ejs +++ b/generators/server/templates/src/test/java/package/cucumber/stepdefs/UserStepDefs.java.ejs @@ -40,6 +40,7 @@ import <%= packageName %>.security.AuthoritiesConstants; <%_ if (reactive) { _%> import org.springframework.test.web.reactive.server.WebTestClient; +import static org.hamcrest.Matchers.is; <%_ } else { _%> import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.test.web.servlet.MockMvc; @@ -72,29 +73,42 @@ public class UserStepDefs extends StepDefs { SecurityContext context = SecurityContextHolder.createEmptyContext(); context.setAuthentication(authentication); SecurityContextHolder.setContext(context); +<%_ if (reactive) { _%> + this.userResourceMock = WebTestClient.bindToController(userResource).build(); +<%_ } else { _%> this.userResourceMock = MockMvcBuilders.standaloneSetup(userResource).build(); +<%_ } _%> } @When("I search user {string}") public void i_search_user(String userId) throws Throwable { <%_ if (reactive) { _%> - actions = userResourceMock.get().uri("/api/admin/users/" + userId) + actions = userResourceMock.get().uri("/api/admin/users/" + userId).accept(MediaType.APPLICATION_JSON).exchange(); <%_ } else { _%> - actions = userResourceMock.perform(get("/api/admin/users/" + userId) + actions = userResourceMock.perform(get("/api/admin/users/" + userId).accept(MediaType.APPLICATION_JSON)); <%_ } _%> - .accept(MediaType.APPLICATION_JSON)<% if (!reactive) { %>)<%_ } _%>; } @Then("the user is found") public void the_user_is_found() throws Throwable { +<%_ if (reactive) { _%> + actions + .expectStatus().isOk() + .expectHeader().contentTypeCompatibleWith(MediaType.APPLICATION_JSON_VALUE); +<%_ } else { _%> actions .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); +<%_ } _%> } @Then("his last name is {string}") public void his_last_name_is(String lastName) throws Throwable { +<%_ if (reactive) { _%> + actions.expectBody().jsonPath("$.lastName").value(is(lastName)); +<%_ } else { _%> actions.andExpect(jsonPath("$.lastName").value(lastName)); +<%_ } _%> } } From abb7606cab7ab28596db119b4333cab8bf39b1d8 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 21 Feb 2022 13:45:05 -0300 Subject: [PATCH 3/5] jdl --- .github/workflows/jdl.yml | 17 +++-- .../ms-ngx-eureka-oauth2/blog-store.jdl | 62 ++++++++++++++--- .../blog-store.jdl | 69 +++++++++++++++---- 3 files changed, 119 insertions(+), 29 deletions(-) rename test-integration/jdl-samples/{ms-react-jwt-consul => ms-react-consul-jwt}/blog-store.jdl (59%) diff --git a/.github/workflows/jdl.yml b/.github/workflows/jdl.yml index 999243059ac8..c7dc391fb2a1 100644 --- a/.github/workflows/jdl.yml +++ b/.github/workflows/jdl.yml @@ -74,7 +74,8 @@ jobs: cache: [angular] suite: - ms-ngx-eureka-oauth2 - - ms-react-jwt-consul + - ms-react-consul-jwt + - ms-vue-eureka-jwt - mf-ngx-eureka-jwt - mf-vue-consul-oauth2 include: @@ -82,7 +83,11 @@ jobs: extra-args: --workspaces --monorepository # Scripts wait for gateway to start, delay for microservices to start. e2e-delay: 120 - - suite: ms-react-jwt-consul + - suite: ms-react-consul-jwt + extra-args: --workspaces --monorepository + # Scripts wait for gateway to start, delay for microservices to start. + e2e-delay: 120 + - suite: ms-vue-eureka-jwt extra-args: --workspaces --monorepository # Scripts wait for gateway to start, delay for microservices to start. e2e-delay: 120 @@ -172,16 +177,16 @@ jobs: - name: 'MERGE: generate base' continue-on-error: true id: base-app - if: >- - github.event.pull_request && - !contains(github.event.pull_request.labels.*.name, 'pr: jdl-disable-compare') + if: github.event.pull_request uses: ./generator-jhipster/.github/actions/compare-base with: extra-args: '--skip-jhipster-dependencies ${{ matrix.extra-args }}' - name: 'MERGE: compare changes' continue-on-error: true id: compare - if: steps.base-app.outcome == 'success' + if: >- + steps.base-app.outcome == 'success' && + !contains(github.event.pull_request.labels.*.name, 'pr: jdl-disable-compare') uses: ./generator-jhipster/.github/actions/compare with: application-path: ${{ steps.base-app.outputs.application-path }} diff --git a/test-integration/jdl-samples/ms-ngx-eureka-oauth2/blog-store.jdl b/test-integration/jdl-samples/ms-ngx-eureka-oauth2/blog-store.jdl index 85e0f8054c7e..a59539d5e1e1 100644 --- a/test-integration/jdl-samples/ms-ngx-eureka-oauth2/blog-store.jdl +++ b/test-integration/jdl-samples/ms-ngx-eureka-oauth2/blog-store.jdl @@ -1,21 +1,26 @@ - /* - * This is a microservice blog sample with Gateway and two microservice applications - * This uses JHipster registry for service discovery and OIDC authentication + * This is a microservice stack sample to test compilation + * - buildTool: maven + * - serviceDiscovery: eureka + * - authenticationType: oauth2 + * - databaseType: sql + * - prodDatabaseType: postgresql, mysql, mariadb + * - enableHibernateCache: true + * - cacheProvider: ehcache, hazelcast, caffeine */ application { config { - baseName gateway - packageName com.okta.developer.gateway applicationType gateway authenticationType oauth2 + baseName gateway + packageName com.okta.developer.gateway prodDatabaseType postgresql - testFrameworks [cypress] + testFrameworks [cypress, cucumber, gatling] creationTimestamp 1617901618886 jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" } - entities Blog, Post, Tag, Product + entities UserData, Blog, Post, Tag, Product } application { @@ -25,8 +30,9 @@ application { applicationType microservice authenticationType oauth2 prodDatabaseType postgresql - searchEngine elasticsearch + cacheProvider ehcache serverPort 8081 + testFrameworks [cucumber, gatling] creationTimestamp 1617901618887 jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" } @@ -39,15 +45,39 @@ application { packageName com.okta.developer.store applicationType microservice authenticationType oauth2 - prodDatabaseType postgresql - enableHibernateCache false + prodDatabaseType mysql + cacheProvider hazelcast serverPort 8082 + testFrameworks [cucumber, gatling] creationTimestamp 1617901618888 jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" } entities Product } +application { + config { + baseName notification, + packageName com.okta.developer.notification + applicationType microservice + authenticationType oauth2 + prodDatabaseType mariadb + cacheProvider caffeine + serverPort 8083 + entitySuffix Entity + dtoSuffix Rest + testFrameworks [cucumber, gatling] + creationTimestamp 1617901618889 + jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" + } + entities Notification +} + +@ChangelogDate(20210408164809) +entity UserData { + address String +} + @ChangelogDate(20210408164810) entity Blog { name String required minlength(3) @@ -71,6 +101,15 @@ entity Product { image ImageBlob } +@ChangelogDate(20210408164814) +entity Notification { + title String required +} + +relationship OneToOne { + @Id UserData{user(login)} to User +} + relationship ManyToOne { Post{blog(name)} to Blog } @@ -84,10 +123,11 @@ paginate Product with pagination microservice Product with store microservice Blog, Post, Tag with blog +microservice Notification with notification deployment { deploymentType docker-compose, - appsFolders [store, blog, gateway] + appsFolders [gateway, store, blog, notification] dockerRepositoryName "hipsterslabs" monitoring no serviceDiscoveryType eureka diff --git a/test-integration/jdl-samples/ms-react-jwt-consul/blog-store.jdl b/test-integration/jdl-samples/ms-react-consul-jwt/blog-store.jdl similarity index 59% rename from test-integration/jdl-samples/ms-react-jwt-consul/blog-store.jdl rename to test-integration/jdl-samples/ms-react-consul-jwt/blog-store.jdl index b826c7c41838..a7319fdd3e19 100644 --- a/test-integration/jdl-samples/ms-react-jwt-consul/blog-store.jdl +++ b/test-integration/jdl-samples/ms-react-consul-jwt/blog-store.jdl @@ -1,23 +1,29 @@ - /* - * This is a microservice blog sample with Gateway and two microservice applications - * This uses JHipster registry for service discovery and OIDC authentication + * This is a microservice stack sample to test compilation + * - buildTool: gradle + * - serviceDiscovery: consul + * - authenticationType: jwt + * - databaseType: sql + * - prodDatabaseType: postgresql, mysql, mariadb + * - enableHibernateCache: false + * - cacheProvider: infinispan, memcached, redis */ - + application { config { - baseName gateway - packageName com.okta.developer.gateway applicationType gateway - clientFramework react authenticationType jwt + baseName gateway + buildTool gradle + clientFramework react + packageName com.okta.developer.gateway prodDatabaseType postgresql serviceDiscoveryType consul - testFrameworks [cypress] + testFrameworks [cypress, cucumber, gatling] creationTimestamp 1617901618886 jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" } - entities Blog, Post, Tag, Product + entities UserData, Blog, Post, Tag, Product } application { @@ -27,9 +33,11 @@ application { applicationType microservice authenticationType jwt prodDatabaseType postgresql + cacheProvider infinispan serviceDiscoveryType consul - searchEngine elasticsearch + enableHibernateCache false serverPort 8081 + testFrameworks [cucumber, gatling] creationTimestamp 1617901618887 jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" } @@ -42,16 +50,43 @@ application { packageName com.okta.developer.store applicationType microservice authenticationType jwt - prodDatabaseType postgresql + prodDatabaseType mysql + cacheProvider memcached serviceDiscoveryType consul enableHibernateCache false serverPort 8082 + testFrameworks [cucumber, gatling] creationTimestamp 1617901618888 jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" } entities Product } +application { + config { + baseName notification, + packageName com.okta.developer.notification + applicationType microservice + authenticationType jwt + prodDatabaseType mariadb + cacheProvider redis + serviceDiscoveryType consul + enableHibernateCache false + serverPort 8083 + entitySuffix Entity + dtoSuffix Rest + testFrameworks [cucumber, gatling] + creationTimestamp 1617901618889 + jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" + } + entities Notification +} + +@ChangelogDate(20210408164809) +entity UserData { + address String +} + @ChangelogDate(20210408164810) entity Blog { name String required minlength(3) @@ -75,6 +110,15 @@ entity Product { image ImageBlob } +@ChangelogDate(20210408164814) +entity Notification { + title String required +} + +relationship OneToOne { + @Id UserData{user(login)} to User +} + relationship ManyToOne { Post{blog(name)} to Blog } @@ -88,11 +132,12 @@ paginate Product with pagination microservice Product with store microservice Blog, Post, Tag with blog +microservice Notification with notification service all with serviceImpl deployment { deploymentType docker-compose, - appsFolders [store, blog, gateway] + appsFolders [gateway, store, blog, notification] dockerRepositoryName "hipsterslabs" monitoring no serviceDiscoveryType consul From 1b1d62767bd488eebb1064800fb4f4cf68e3f0a3 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 21 Feb 2022 13:45:24 -0300 Subject: [PATCH 4/5] jdl2 --- .../mf-ngx-eureka-jwt/blog-store.jdl | 34 +++-- .../mf-vue-consul-oauth2/blog-store.jdl | 36 +++-- .../ms-vue-eureka-jwt/blog-store.jdl | 128 ++++++++++++++++++ 3 files changed, 180 insertions(+), 18 deletions(-) create mode 100644 test-integration/jdl-samples/ms-vue-eureka-jwt/blog-store.jdl diff --git a/test-integration/jdl-samples/mf-ngx-eureka-jwt/blog-store.jdl b/test-integration/jdl-samples/mf-ngx-eureka-jwt/blog-store.jdl index 0a7e22aeb3c3..63d38651c251 100644 --- a/test-integration/jdl-samples/mf-ngx-eureka-jwt/blog-store.jdl +++ b/test-integration/jdl-samples/mf-ngx-eureka-jwt/blog-store.jdl @@ -1,22 +1,25 @@ - /* - * This is a microservice blog sample with Gateway and two microservice applications - * This uses JHipster registry for service discovery and OIDC authentication + * This is a microfrontend stack sample to test compilation + * - buildTool: maven + * - serviceDiscovery: eureka + * - authenticationType: jwt + * - databaseType: sql + * - prodDatabaseType: postgresql, mysql, mariadb */ application { config { - baseName gateway - packageName com.okta.developer.gateway applicationType gateway - clientFramework angular authenticationType jwt - prodDatabaseType postgresql + baseName gateway + clientFramework angular + prodDatabaseType mysql + packageName com.okta.developer.gateway testFrameworks [cypress] creationTimestamp 1617901618886 jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" } - entities Blog, Post, Tag, Product + entities UserData, Blog, Post, Tag, Product } application { @@ -27,6 +30,7 @@ application { clientFramework angular authenticationType jwt prodDatabaseType postgresql + reactive true serverPort 8081 testFrameworks [cypress] creationTimestamp 1617901618887 @@ -42,7 +46,8 @@ application { applicationType microservice clientFramework angular authenticationType jwt - prodDatabaseType postgresql + prodDatabaseType mariadb + reactive true serverPort 8082 testFrameworks [cypress] creationTimestamp 1617901618888 @@ -51,6 +56,11 @@ application { entities Product } +@ChangelogDate(20210408164809) +entity UserData { + address String +} + @ChangelogDate(20210408164810) entity Blog { name String required minlength(3) @@ -74,6 +84,12 @@ entity Product { image ImageBlob } +/* +relationship OneToOne { + @Id UserData{user(login)} to User +} +*/ + relationship ManyToOne { Post{blog(name)} to Blog } diff --git a/test-integration/jdl-samples/mf-vue-consul-oauth2/blog-store.jdl b/test-integration/jdl-samples/mf-vue-consul-oauth2/blog-store.jdl index 4d071c2a8268..98333c991ea9 100644 --- a/test-integration/jdl-samples/mf-vue-consul-oauth2/blog-store.jdl +++ b/test-integration/jdl-samples/mf-vue-consul-oauth2/blog-store.jdl @@ -1,23 +1,27 @@ - /* - * This is a microservice blog sample with Gateway and two microservice applications - * This uses JHipster registry for service discovery and OIDC authentication + * This is a microfrontend stack sample to test compilation + * - buildTool: gradle + * - serviceDiscovery: consul + * - authenticationType: oauth2 + * - databaseType: sql + * - prodDatabaseType: postgresql, mysql, mariadb */ application { config { - baseName gateway - packageName com.okta.developer.gateway applicationType gateway - clientFramework vue authenticationType oauth2 - prodDatabaseType postgresql + baseName gateway + buildTool gradle + clientFramework vue + prodDatabaseType mysql + packageName com.okta.developer.gateway serviceDiscoveryType consul testFrameworks [cypress] creationTimestamp 1617901618886 jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" } - entities Blog, Post, Tag, Product + entities UserData, Blog, Post, Tag, Product } application { @@ -25,9 +29,11 @@ application { baseName blog packageName com.okta.developer.blog applicationType microservice + buildTool gradle clientFramework vue authenticationType oauth2 prodDatabaseType postgresql + reactive true serverPort 8081 serviceDiscoveryType consul testFrameworks [cypress] @@ -42,9 +48,11 @@ application { baseName store, packageName com.okta.developer.store applicationType microservice + buildTool gradle clientFramework vue authenticationType oauth2 - prodDatabaseType postgresql + prodDatabaseType mariadb + reactive true serverPort 8082 serviceDiscoveryType consul testFrameworks [cypress] @@ -53,6 +61,10 @@ application { } entities Product } +@ChangelogDate(20210408164809) +entity UserData { + address String +} @ChangelogDate(20210408164810) entity Blog { @@ -77,6 +89,12 @@ entity Product { image ImageBlob } +/* +relationship OneToOne { + @Id UserData{user(login)} to User +} +*/ + relationship ManyToOne { Blog{user(login)} to User Post{blog(name)} to Blog diff --git a/test-integration/jdl-samples/ms-vue-eureka-jwt/blog-store.jdl b/test-integration/jdl-samples/ms-vue-eureka-jwt/blog-store.jdl new file mode 100644 index 000000000000..fdbcb6394e58 --- /dev/null +++ b/test-integration/jdl-samples/ms-vue-eureka-jwt/blog-store.jdl @@ -0,0 +1,128 @@ +/* + * This is a microservice stack sample to test compilation + * - buildTool: maven, gradle + * - serviceDiscovery: eureka + * - authenticationType: jwt + * - databaseType: cassandra + * - enableHibernateCache: true + * - cacheProvider: ehcache, hazelcast, caffeine + */ + +application { + config { + applicationType gateway + authenticationType jwt + baseName gateway + clientFramework vue + databaseType cassandra + packageName com.okta.developer.gateway + testFrameworks [cypress] + creationTimestamp 1617901618886 + jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" + } + entities UserData, Blog, Post, Tag, Product +} + +application { + config { + applicationType microservice + authenticationType jwt + baseName blog + buildTool gradle + databaseType cassandra + packageName com.okta.developer.blog + reactive true + serverPort 8081 + creationTimestamp 1617901618887 + jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" + } + entities Blog, Post, Tag +} + +application { + config { + applicationType microservice + authenticationType jwt + baseName store, + cacheProvider ehcache + databaseType cassandra + packageName com.okta.developer.store + serverPort 8082 + creationTimestamp 1617901618888 + jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" + } + entities Product +} + +application { + config { + applicationType microservice + authenticationType jwt + baseName notification, + buildTool gradle + cacheProvider caffeine + databaseType couchbase + packageName com.okta.developer.notification + serverPort 8083 + creationTimestamp 1617901618889 + jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" + } + entities Notification +} + +@ChangelogDate(20210408164809) +entity UserData { + address String +} + +@ChangelogDate(20210408164810) +entity Blog { + name String required minlength(3) + handle String required minlength(2) +} + +@ChangelogDate(20210408164811) +entity Post { + title String required +} + +@ChangelogDate(20210408164812) +entity Tag { + name String required minlength(2) +} + +@ChangelogDate(20210408164813) +entity Product { + title String required + price BigDecimal required min(0) + image ImageBlob +} + +@ChangelogDate(20210408164814) +entity Notification { + title String required +} + +relationship OneToOne { + @Id UserData{user(login)} to User +} + +relationship ManyToOne { + Post{blog(name)} to Blog +} + +relationship ManyToMany { + Post{tag(name)} to Tag{post} +} + +microservice Product with store +microservice Blog, Post, Tag with blog +microservice Notification with notification + +deployment { + deploymentType docker-compose, + appsFolders [gateway, store, blog, notification] + dockerRepositoryName "hipsterslabs" + monitoring no + serviceDiscoveryType eureka +} From 97c115157aa3f75cf0e60055499b0d486a39f363 Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Mon, 21 Feb 2022 13:45:40 -0300 Subject: [PATCH 5/5] fixes --- .../main/java/package/service/impl/EntityServiceImpl.java.ejs | 2 +- .../src/main/java/package/web/rest/EntityResource.java.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs b/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs index 21faa8c4c473..fe0b19b8af1d 100644 --- a/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/service/impl/EntityServiceImpl.java.ejs @@ -213,7 +213,7 @@ public class <%= serviceClassName %><% if (serviceImpl) { %> implements <%= enti @Transactional(readOnly = true) <%_ } _%> public <%= optionalOrMono %><<%= instanceType %>> findOne(<%= primaryKey.type %> id) { - log.debug("Request to get <%= entityClass %> : {}", id);<%- include('../../common/get_template', {asEntity, asDto, viaService: false, returnDirectly:true}); -%> + log.debug("Request to get <%= entityClass %> : {}", id);<%- include('../../common/get_template', {asEntity, asDto, viaService: false, returnDirectly:true, relationshipsContainEagerLoad}); -%> } <%_ if (!serviceImpl) { _%> diff --git a/generators/entity-server/templates/src/main/java/package/web/rest/EntityResource.java.ejs b/generators/entity-server/templates/src/main/java/package/web/rest/EntityResource.java.ejs index d7dab3f784d7..95ef74c42320 100644 --- a/generators/entity-server/templates/src/main/java/package/web/rest/EntityResource.java.ejs +++ b/generators/entity-server/templates/src/main/java/package/web/rest/EntityResource.java.ejs @@ -392,7 +392,7 @@ public class <%= entityClass %>Resource { @Transactional(readOnly = true) <%_ } _%> public <% if (reactive) { %>Mono<<% } %>ResponseEntity<<%= instanceType %>><% if (reactive) { %>><% } %> get<%= entityClass %>(@PathVariable <%= primaryKey.type %> id) { - log.debug("REST request to get <%= entityClass %> : {}", id);<%- include('../../common/get_template', {asEntity, asDto, viaService, returnDirectly:false}); -%> + log.debug("REST request to get <%= entityClass %> : {}", id);<%- include('../../common/get_template', {asEntity, asDto, viaService, returnDirectly:false, relationshipsContainEagerLoad}); -%> return ResponseUtil.wrapOrNotFound(<%= instanceName %>); } <%_ if (!readOnly) { _%>