Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve workflow files [angular][react][vue] #733

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/workflows/jdl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,20 @@ 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:
- suite: ms-ngx-eureka-oauth2
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
Expand Down Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) { _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) { _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,36 @@ 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 {

// prettier-ignore
@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")
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
<%_ } _%>

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
<%_ } _%>
}

}
34 changes: 25 additions & 9 deletions test-integration/jdl-samples/mf-ngx-eureka-jwt/blog-store.jdl
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -27,6 +30,7 @@ application {
clientFramework angular
authenticationType jwt
prodDatabaseType postgresql
reactive true
serverPort 8081
testFrameworks [cypress]
creationTimestamp 1617901618887
Expand All @@ -42,7 +46,8 @@ application {
applicationType microservice
clientFramework angular
authenticationType jwt
prodDatabaseType postgresql
prodDatabaseType mariadb
reactive true
serverPort 8082
testFrameworks [cypress]
creationTimestamp 1617901618888
Expand All @@ -51,6 +56,11 @@ application {
entities Product
}

@ChangelogDate(20210408164809)
entity UserData {
address String
}

@ChangelogDate(20210408164810)
entity Blog {
name String required minlength(3)
Expand All @@ -74,6 +84,12 @@ entity Product {
image ImageBlob
}

/*
relationship OneToOne {
@Id UserData{user(login)} to User
}
*/

relationship ManyToOne {
Post{blog(name)} to Blog
}
Expand Down
36 changes: 27 additions & 9 deletions test-integration/jdl-samples/mf-vue-consul-oauth2/blog-store.jdl
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@

/*
* 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 {
config {
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]
Expand All @@ -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]
Expand All @@ -53,6 +61,10 @@ application {
}
entities Product
}
@ChangelogDate(20210408164809)
entity UserData {
address String
}

@ChangelogDate(20210408164810)
entity Blog {
Expand All @@ -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
Expand Down
Loading