Skip to content

Commit

Permalink
Merge pull request #25229 from mshima/microservice-check
Browse files Browse the repository at this point in the history
add check for entity microservice
  • Loading branch information
DanielFran authored Feb 17, 2024
2 parents 5ded739 + 642e4d4 commit 6918461
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
36 changes: 36 additions & 0 deletions generators/jdl/__snapshots__/generator.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,42 @@ Options:
"
`;
exports[`generator - jdl with a gateway generating json should generate expected config 1`] = `
{
".jhipster/Bar.json": {
"contents": "{
"annotations": {},
"applications": [
"gatewayApp"
],
"fields": [],
"microserviceName": "ms",
"name": "Bar",
"relationships": []
}
",
"stateCleared": "modified",
},
".yo-rc.json": {
"contents": "{
"generator-jhipster": {
"applicationIndex": 0,
"applicationType": "gateway",
"applications": {
"ms": {}
},
"baseName": "gatewayApp",
"entities": [
"Bar"
]
}
}
",
"stateCleared": "modified",
},
}
`;
exports[`generator - jdl with a microservices stack generating json should generate expected config 1`] = `
{
"gatewayApp/.jhipster/Bar.json": {
Expand Down
16 changes: 16 additions & 0 deletions generators/jdl/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,4 +472,20 @@ entity Bar
});
});
});
describe('with a gateway', () => {
const jdl = `
application { config { baseName gatewayApp applicationType gateway } entities * }
microservice Bar with ms
entity Bar
`;
describe('generating json', () => {
before(async () => {
await helpers.runJHipster(GENERATOR_JDL).withMockedGenerators(mockedGenerators).withOptions({ inline: jdl, jsonOnly: true });
});

it('should generate expected config', () => {
expect(runResult.getSnapshot()).toMatchSnapshot();
});
});
});
});
2 changes: 1 addition & 1 deletion generators/jdl/internal/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const customizeForMicroservices = (applicationsWithEntities: Record<strin
if (relatedBaseNames.length > 0) {
gateway.config.applications = Object.fromEntries(
relatedBaseNames.map(baseName => {
const appConfig = applicationsWithEntities[baseName].config;
const appConfig = applicationsWithEntities[baseName]?.config ?? {};
appConfig.gatewayServerPort = appConfig.gatewayServerPort || gatewayServerPort;
const { clientFramework, serverPort, applicationIndex, devServerPort } = appConfig;
return [baseName, { clientFramework, serverPort, applicationIndex, devServerPort }];
Expand Down

0 comments on commit 6918461

Please sign in to comment.