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

add check for entity microservice #25229

Merged
merged 1 commit into from
Feb 17, 2024
Merged
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
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
Loading