diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000000..27ad37a22cfc --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +open_collective: generator-jhipster +custom: https://www.jhipster.tech/sponsors/ diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md index 3cd3ebb4fd4e..6611162f20c4 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.md +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md @@ -44,8 +44,17 @@ To provide all information we need, you should run `jhipster info` in the projec copy/paste the result here. The `.yo-rc.json` file generated in the root folder is mandatory for bug reports. This will help us to replicate the scenario. You should remove any sensitive information like the rememberMe key or the jwtSecretKey key. +--- +If you have a JDL please wrap it in below structure +
+ JDL definitions +
+     JDL content here
+  
+
--> + ##### **Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory** - -
  • HasAnyAuthority="'ROLE_ADMIN'" ngbDropdown class="nav-item dropdown pointer" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}"> +
  • HasAnyAuthority="'ROLE_ADMIN'" ngbDropdown class="nav-item dropdown pointer" display="dynamic" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}"> @@ -98,7 +98,7 @@ Configuration
  • - <%_ if (databaseType !== 'no' && databaseType !== 'cassandra') { _%> + <%_ if ((databaseType !== 'no' || authenticationType === 'uaa') && databaseType !== 'cassandra') { _%>
  • @@ -130,7 +130,7 @@
  • <%_ if (enableTranslation) { _%> - <%_ } _%> - ' - ); - }); - - it('admin menu contains the admin element added by needle api', () => { - assert.fileContent( - `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.component.html`, - '
  • \n' + - ' \n' + - '  \n' + - ' Router Name 2\n' + - ' \n' + - '
  • ' - ); - }); - - it('entity menu contains the entity added by needle api', () => { - assert.fileContent( - `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.component.html`, - '
  • \n' + - ' \n' + - ' \n' + - ' Router Name 3\n' + - ' \n' + - '
  • ' - ); - }); - - it('entity module contains the microservice object added by needle api', () => { - assert.fileContent( - `${CLIENT_MAIN_SRC_DIR}app/entities/entity.module.ts`, - ' {\n' + - " path: 'entityUrl',\n" + - " loadChildren: './entityFolderName/entityFileName.module#MicroServiceNameentityNameModule'\n" + - ' }' - ); - }); +describe('needle API Angular: JHipster client generator with blueprint', () => { + before(done => { + helpers + .run(path.join(__dirname, '../../generators/client')) + .withOptions({ + 'from-cli': true, + build: 'maven', + auth: 'jwt', + db: 'mysql', + skipInstall: true, + blueprint: 'myblueprint', + skipChecks: true + }) + .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:client']]) + .withPrompts({ + baseName: 'jhipster', + clientFramework: 'angularX', + enableTranslation: true, + nativeLanguage: 'en', + languages: ['fr'] + }) + .on('end', done); + }); - it('admin module contains the import and the module added by needle api', () => { - assert.fileContent( - `${CLIENT_MAIN_SRC_DIR}app/admin/admin.module.ts`, - "import { appNameadminAngularNameModule } from './adminFolderName/adminFileName.module';" - ); - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/admin/admin.module.ts`, 'appNameadminAngularNameModule,'); - }); + it('vendor.scss contains the specific change (without comment) added by needle api', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}content/scss/vendor.scss`, /@import style_without_comment/); + }); - it('app module contains the import and the module added by needle api', () => { - assert.fileContent( - `${CLIENT_MAIN_SRC_DIR}app/app.module.ts`, - "import { appNameangularNameModule } from './folderName/fileName.module';" - ); - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/app.module.ts`, 'appNameangularNameModule,'); - }); - }); + it('global.scss contains the specific change (without comment) added by needle api', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}content/scss/global.scss`, /@import style_without_comment/); + }); + + it('vendor.scss contains the specific change added by needle api', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}content/scss/vendor.scss`, /@import style/); + assert.fileContent( + `${CLIENT_MAIN_SRC_DIR}content/scss/vendor.scss`, + '* ==========================================================================\n' + + 'my comment\n' + + '========================================================================== */\n' + ); + }); + + it('global.scss contains the specific change added by needle api', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}content/scss/global.scss`, /@import style/); + assert.fileContent( + `${CLIENT_MAIN_SRC_DIR}content/scss/global.scss`, + '* ==========================================================================\n' + + 'my comment\n' + + '========================================================================== */\n' + ); + }); + + it('menu contains the element added by needle api', () => { + assert.fileContent( + `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.component.html`, + ' ' + ); + }); + + it('admin menu contains the admin element added by needle api', () => { + assert.fileContent( + `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.component.html`, + '
  • \n' + + ' \n' + + '  \n' + + ' Router Name 2\n' + + ' \n' + + '
  • ' + ); + }); + + it('entity menu contains the entity added by needle api', () => { + assert.fileContent( + `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.component.html`, + '
  • \n' + + ' \n' + + ' \n' + + ' Router Name 3\n' + + ' \n' + + '
  • ' + ); + }); + + it('entity module contains the microservice object added by needle api', () => { + assert.fileContent( + `${CLIENT_MAIN_SRC_DIR}app/entities/entity.module.ts`, + ' {\n' + + " path: 'entityUrl',\n" + + " loadChildren: () => import('./entityFolderName/entityFileName.module').then(m => m.MicroServiceNameentityNameModule)\n" + + ' }' + ); + }); + + it('admin module contains the import and the module added by needle api', () => { + assert.fileContent( + `${CLIENT_MAIN_SRC_DIR}app/admin/admin.module.ts`, + "import { appNameadminAngularNameModule } from './adminFolderName/adminFileName.module';" + ); + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/admin/admin.module.ts`, 'appNameadminAngularNameModule,'); }); -}); -describe('needle API CSS: JHipster client generator with blueprint', () => { - const blueprintNames = ['generator-jhipster-myblueprint', 'myblueprint']; - - blueprintNames.forEach(blueprintName => { - describe(`generate client with blueprint option '${blueprintName}'`, () => { - before(done => { - helpers - .run(path.join(__dirname, '../../generators/client')) - .withOptions({ - 'from-cli': true, - build: 'maven', - auth: 'jwt', - db: 'mysql', - skipInstall: true, - blueprint: blueprintName, - skipChecks: true - }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:client']]) - .withPrompts({ - baseName: 'jhipster', - clientFramework: 'angularX', - enableTranslation: true, - nativeLanguage: 'en', - languages: ['fr'] - }) - .on('end', done); - }); - }); + it('app module contains the import and the module added by needle api', () => { + assert.fileContent( + `${CLIENT_MAIN_SRC_DIR}app/app.module.ts`, + "import { appNameangularNameModule } from './folderName/fileName.module';" + ); + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/app.module.ts`, 'appNameangularNameModule,'); }); }); diff --git a/test/needle-api/needle-client-i18n.spec.js b/test/needle-api/needle-client-i18n.spec.js index 4d8e1aae7154..36109a5895f7 100644 --- a/test/needle-api/needle-client-i18n.spec.js +++ b/test/needle-api/needle-client-i18n.spec.js @@ -59,59 +59,53 @@ const mockBlueprintSubGen = class extends LanguagesGenerator { }; describe('needle API i18n: JHipster language generator with blueprint', () => { - const blueprintNames = ['generator-jhipster-myblueprint', 'myblueprint']; - - blueprintNames.forEach(blueprintName => { - describe(`generate client with blueprint option '${blueprintName}'`, () => { - before(done => { - helpers - .run(path.join(__dirname, '../../generators/languages')) - .inTmpDir(dir => { - fse.copySync(path.join(__dirname, '../../test/templates/ngx-blueprint'), dir); - }) - .withOptions({ - 'from-cli': true, - build: 'maven', - auth: 'jwt', - db: 'mysql', - skipInstall: true, - blueprint: blueprintName, - skipChecks: true - }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:languages']]) - .withPrompts({ - baseName: 'jhipster', - clientFramework: 'angularX', - enableTranslation: true, - nativeLanguage: 'en', - languages: ['en', 'fr'] - }) - .on('end', done); - }); - - it('Assert english global.json contain the new key', () => { - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/en/global.json`, '"my_key": "My Value",'); - }); - - it('Assert french global.json contain the new key', () => { - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/fr/global.json`, '"ma_cle": "Ma Valeur",'); - }); - - it('Assert english admin global.json contain the new key', () => { - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/en/global.json`, '"my_admin_key": "My Admin Value",'); - }); - - it('Assert french admin global.json contain the new key', () => { - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/fr/global.json`, '"ma_cle_admin": "Ma Valeur Admin",'); - }); - - it('Assert english entity global.json contain the new key', () => { - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/en/global.json`, '"my_entity_key": "My Entity Value",'); - }); - - it('Assert french entity global.json contain the new key', () => { - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/fr/global.json`, '"ma_cle_entite": "Ma Valeur Entite",'); - }); - }); + before(done => { + helpers + .run(path.join(__dirname, '../../generators/languages')) + .inTmpDir(dir => { + fse.copySync(path.join(__dirname, '../../test/templates/ngx-blueprint'), dir); + }) + .withOptions({ + 'from-cli': true, + build: 'maven', + auth: 'jwt', + db: 'mysql', + skipInstall: true, + blueprint: 'myblueprint', + skipChecks: true + }) + .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:languages']]) + .withPrompts({ + baseName: 'jhipster', + clientFramework: 'angularX', + enableTranslation: true, + nativeLanguage: 'en', + languages: ['en', 'fr'] + }) + .on('end', done); + }); + + it('Assert english global.json contain the new key', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/en/global.json`, '"my_key": "My Value",'); + }); + + it('Assert french global.json contain the new key', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/fr/global.json`, '"ma_cle": "Ma Valeur",'); + }); + + it('Assert english admin global.json contain the new key', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/en/global.json`, '"my_admin_key": "My Admin Value",'); + }); + + it('Assert french admin global.json contain the new key', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/fr/global.json`, '"ma_cle_admin": "Ma Valeur Admin",'); + }); + + it('Assert english entity global.json contain the new key', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/en/global.json`, '"my_entity_key": "My Entity Value",'); + }); + + it('Assert french entity global.json contain the new key', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}i18n/fr/global.json`, '"ma_cle_entite": "Ma Valeur Entite",'); }); }); diff --git a/test/needle-api/needle-client-react.spec.js b/test/needle-api/needle-client-react.spec.js index f2b8c776fb6d..b5ebc336a76d 100644 --- a/test/needle-api/needle-client-react.spec.js +++ b/test/needle-api/needle-client-react.spec.js @@ -66,99 +66,62 @@ const mockBlueprintSubGen = class extends ClientGenerator { }; describe('needle API React: JHipster client generator with blueprint', () => { - const blueprintNames = ['generator-jhipster-myblueprint', 'myblueprint']; - - blueprintNames.forEach(blueprintName => { - describe(`generate client with blueprint option '${blueprintName}'`, () => { - before(done => { - helpers - .run(path.join(__dirname, '../../generators/client')) - .withOptions({ - 'from-cli': true, - build: 'maven', - auth: 'jwt', - db: 'mysql', - skipInstall: true, - blueprint: blueprintName, - skipChecks: true - }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:client']]) - .withPrompts({ - baseName: 'jhipster', - clientFramework: 'react', - enableTranslation: true, - nativeLanguage: 'en', - languages: ['en', 'fr'] - }) - .on('end', done); - }); - - it('Assert entity is added to menu', () => { - assert.fileContent( - `${CLIENT_MAIN_SRC_DIR}app/shared/layout/menus/entities.tsx`, - '\n Router Name\n ' - ); - }); - - it('Assert entity is added to module', () => { - const indexModulePath = `${CLIENT_MAIN_SRC_DIR}app/entities/index.tsx`; - const indexReducerPath = `${CLIENT_MAIN_SRC_DIR}app/shared/reducers/index.ts`; + before(done => { + helpers + .run(path.join(__dirname, '../../generators/client')) + .withOptions({ + 'from-cli': true, + build: 'maven', + auth: 'jwt', + db: 'mysql', + skipInstall: true, + blueprint: 'myblueprint', + skipChecks: true + }) + .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:client']]) + .withPrompts({ + baseName: 'jhipster', + clientFramework: 'react', + enableTranslation: true, + nativeLanguage: 'en', + languages: ['en', 'fr'] + }) + .on('end', done); + }); - assert.fileContent(indexModulePath, "import entityName from './entityFolderName';"); - assert.fileContent(indexModulePath, ''); // eslint-disable-line + it('Assert entity is added to menu', () => { + assert.fileContent( + `${CLIENT_MAIN_SRC_DIR}app/shared/layout/menus/entities.tsx`, + '\n Router Name\n ' + ); + }); - assert.fileContent( - indexReducerPath, - '// prettier-ignore\n' + - 'import entityInstance, {\n' + - ' entityNameState\n' + - "} from 'app/entities/entityFolderName/entityFileName.reducer';" - ); - assert.fileContent(indexReducerPath, 'readonly entityInstance: entityNameState;'); - assert.fileContent(indexReducerPath, 'entityInstance,'); - }); - }); + it('Assert entity is added to module', () => { + const indexModulePath = `${CLIENT_MAIN_SRC_DIR}app/entities/index.tsx`; + const indexReducerPath = `${CLIENT_MAIN_SRC_DIR}app/shared/reducers/index.ts`; + + assert.fileContent(indexModulePath, "import entityName from './entityFolderName';"); + assert.fileContent(indexModulePath, ''); // eslint-disable-line + + assert.fileContent( + indexReducerPath, + '// prettier-ignore\n' + + 'import entityInstance, {\n' + + ' entityNameState\n' + + "} from 'app/entities/entityFolderName/entityFileName.reducer';" + ); + assert.fileContent(indexReducerPath, 'readonly entityInstance: entityNameState;'); + assert.fileContent(indexReducerPath, 'entityInstance,'); }); -}); -describe('needle API React: JHipster client generator with blueprint', () => { - const blueprintNames = ['generator-jhipster-myblueprint', 'myblueprint']; - - blueprintNames.forEach(blueprintName => { - describe(`generate client with blueprint option '${blueprintName}'`, () => { - before(done => { - helpers - .run(path.join(__dirname, '../../generators/client')) - .withOptions({ - 'from-cli': true, - build: 'maven', - auth: 'jwt', - db: 'mysql', - skipInstall: true, - blueprint: blueprintName, - skipChecks: true - }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:client']]) - .withPrompts({ - baseName: 'jhipster', - clientFramework: 'react', - enableTranslation: true, - nativeLanguage: 'en', - languages: ['en', 'fr'] - }) - .on('end', done); - }); - - it('Assert app.scss is updated', () => { - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/app.scss`, '@import without-comment'); - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/app.scss`, '@import with-comment'); - assert.fileContent( - `${CLIENT_MAIN_SRC_DIR}app/app.scss`, - '* ==========================================================================\n' + - 'my comment\n' + - '========================================================================== */\n' - ); - }); - }); + it('Assert app.scss is updated', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/app.scss`, '@import without-comment'); + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}app/app.scss`, '@import with-comment'); + assert.fileContent( + `${CLIENT_MAIN_SRC_DIR}app/app.scss`, + '* ==========================================================================\n' + + 'my comment\n' + + '========================================================================== */\n' + ); }); }); diff --git a/test/needle-api/needle-client-webpack.spec.js b/test/needle-api/needle-client-webpack.spec.js index a9a4032eccfc..5cfce94113b1 100644 --- a/test/needle-api/needle-client-webpack.spec.js +++ b/test/needle-api/needle-client-webpack.spec.js @@ -52,38 +52,32 @@ const mockBlueprintSubGen = class extends ClientGenerator { }; describe('needle API Webpack: JHipster client generator with blueprint', () => { - const blueprintNames = ['generator-jhipster-myblueprint', 'myblueprint']; - - blueprintNames.forEach(blueprintName => { - describe(`generate client with blueprint option '${blueprintName}'`, () => { - before(done => { - helpers - .run(path.join(__dirname, '../../generators/client')) - .withOptions({ - 'from-cli': true, - build: 'maven', - auth: 'jwt', - db: 'mysql', - skipInstall: true, - blueprint: blueprintName, - skipChecks: true - }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:client']]) - .withPrompts({ - baseName: 'jhipster', - clientFramework: 'angularX', - enableTranslation: true, - nativeLanguage: 'en', - languages: ['en', 'fr'] - }) - .on('end', done); - }); - it('Assert external asset is added to webpack.common.js', () => { - const from = `${CLIENT_MAIN_SRC_DIR}content/${assetFrom}/`; - const to = `content/${assetTo}/`; + before(done => { + helpers + .run(path.join(__dirname, '../../generators/client')) + .withOptions({ + 'from-cli': true, + build: 'maven', + auth: 'jwt', + db: 'mysql', + skipInstall: true, + blueprint: 'myblueprint', + skipChecks: true + }) + .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:client']]) + .withPrompts({ + baseName: 'jhipster', + clientFramework: 'angularX', + enableTranslation: true, + nativeLanguage: 'en', + languages: ['en', 'fr'] + }) + .on('end', done); + }); + it('Assert external asset is added to webpack.common.js', () => { + const from = `${CLIENT_MAIN_SRC_DIR}content/${assetFrom}/`; + const to = `content/${assetTo}/`; - assert.fileContent(`${CLIENT_WEBPACK_DIR}/webpack.common.js`, `{ from: './${from}', to: '${to}' },`); - }); - }); + assert.fileContent(`${CLIENT_WEBPACK_DIR}/webpack.common.js`, `{ from: './${from}', to: '${to}' },`); }); }); diff --git a/test/needle-api/needle-client.spec.js b/test/needle-api/needle-client.spec.js index de5b8b6ff0ad..cd159e3ffd4f 100644 --- a/test/needle-api/needle-client.spec.js +++ b/test/needle-api/needle-client.spec.js @@ -49,37 +49,31 @@ const mockBlueprintSubGen = class extends ClientGenerator { }; describe('needle API Client: JHipster client generator with blueprint', () => { - const blueprintNames = ['generator-jhipster-myblueprint', 'myblueprint']; - - blueprintNames.forEach(blueprintName => { - describe(`generate client with blueprint option '${blueprintName}'`, () => { - before(done => { - helpers - .run(path.join(__dirname, '../../generators/client')) - .withOptions({ - 'from-cli': true, - build: 'maven', - auth: 'jwt', - db: 'mysql', - skipInstall: true, - blueprint: blueprintName, - skipChecks: true - }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:client']]) - .withPrompts({ - baseName: 'jhipster', - clientFramework: 'angularX', - enableTranslation: true, - nativeLanguage: 'en', - languages: ['en', 'fr'] - }) - .on('end', done); - }); + before(done => { + helpers + .run(path.join(__dirname, '../../generators/client')) + .withOptions({ + 'from-cli': true, + build: 'maven', + auth: 'jwt', + db: 'mysql', + skipInstall: true, + blueprint: 'myblueprint', + skipChecks: true + }) + .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:client']]) + .withPrompts({ + baseName: 'jhipster', + clientFramework: 'angularX', + enableTranslation: true, + nativeLanguage: 'en', + languages: ['en', 'fr'] + }) + .on('end', done); + }); - it('Assert index.html contain the comment and the resource added', () => { - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}index.html`, ''); - assert.fileContent(`${CLIENT_MAIN_SRC_DIR}index.html`, ''); - }); - }); + it('Assert index.html contain the comment and the resource added', () => { + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}index.html`, ''); + assert.fileContent(`${CLIENT_MAIN_SRC_DIR}index.html`, ''); }); }); diff --git a/test/needle-api/needle-server-cache.spec.js b/test/needle-api/needle-server-cache.spec.js index 11acfdb9d506..c592b6e38d56 100644 --- a/test/needle-api/needle-server-cache.spec.js +++ b/test/needle-api/needle-server-cache.spec.js @@ -75,128 +75,118 @@ const mockBlueprintSubGen = class extends ServerGenerator { }; describe('needle API server cache: JHipster server generator with blueprint', () => { - const blueprintNames = ['generator-jhipster-myblueprint', 'myblueprint']; - - blueprintNames.forEach(blueprintName => { - describe(`generate server with blueprint option '${blueprintName}'`, () => { - before(done => { - helpers - .run(path.join(__dirname, '../../generators/server')) - .withOptions({ - 'from-cli': true, - skipInstall: true, - blueprint: blueprintName, - skipChecks: true - }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:server']]) - .withPrompts({ - baseName: 'jhipster', - packageName: 'com.mycompany.myapp', - packageFolder: 'com/mycompany/myapp', - serviceDiscoveryType: false, - authenticationType: 'jwt', - cacheProvider: 'ehcache', - enableHibernateCache: true, - databaseType: 'sql', - devDatabaseType: 'h2Memory', - prodDatabaseType: 'mysql', - enableTranslation: true, - nativeLanguage: 'en', - languages: ['fr'], - buildTool: 'maven', - rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277', - serverSideOptions: [] - }) - .on('end', done); - }); - - it('Assert ehCache configuration has entry added', () => { - assert.fileContent(`${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, 'createCache(cm, entry);'); - }); - - it('Assert ehCache configuration has entity added', () => { - assert.fileContent( - `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, - 'createCache(cm, com.mycompany.myapp.domain.entityClass.class.getName());' - ); - assert.fileContent( - `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, - 'createCache(cm, com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesOneToMany");' - ); - assert.fileContent( - `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, - 'createCache(cm, com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesManoToMany");' - ); - }); + describe('ehcache', () => { + before(done => { + helpers + .run(path.join(__dirname, '../../generators/server')) + .withOptions({ + 'from-cli': true, + skipInstall: true, + blueprint: 'myblueprint', + skipChecks: true + }) + .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:server']]) + .withPrompts({ + baseName: 'jhipster', + packageName: 'com.mycompany.myapp', + packageFolder: 'com/mycompany/myapp', + serviceDiscoveryType: false, + authenticationType: 'jwt', + cacheProvider: 'ehcache', + enableHibernateCache: true, + databaseType: 'sql', + devDatabaseType: 'h2Memory', + prodDatabaseType: 'mysql', + enableTranslation: true, + nativeLanguage: 'en', + languages: ['fr'], + buildTool: 'maven', + rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277', + serverSideOptions: [] + }) + .on('end', done); + }); + + it('Assert ehCache configuration has entry added', () => { + assert.fileContent(`${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, 'createCache(cm, entry);'); + }); + + it('Assert ehCache configuration has entity added', () => { + assert.fileContent( + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, + 'createCache(cm, com.mycompany.myapp.domain.entityClass.class.getName());' + ); + assert.fileContent( + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, + 'createCache(cm, com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesOneToMany");' + ); + assert.fileContent( + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, + 'createCache(cm, com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesManoToMany");' + ); }); }); -}); -describe('needle API server cache: JHipster server generator with blueprint', () => { - const blueprintNames = ['generator-jhipster-myblueprint', 'myblueprint']; - - blueprintNames.forEach(blueprintName => { - describe(`generate server with blueprint option '${blueprintName}'`, () => { - before(done => { - helpers - .run(path.join(__dirname, '../../generators/server')) - .withOptions({ - 'from-cli': true, - skipInstall: true, - blueprint: blueprintName, - skipChecks: true - }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:server']]) - .withPrompts({ - baseName: 'jhipster', - packageName: 'com.mycompany.myapp', - packageFolder: 'com/mycompany/myapp', - serviceDiscoveryType: false, - authenticationType: 'jwt', - cacheProvider: 'infinispan', - enableHibernateCache: true, - databaseType: 'sql', - devDatabaseType: 'h2Memory', - prodDatabaseType: 'mysql', - enableTranslation: true, - nativeLanguage: 'en', - languages: ['fr'], - buildTool: 'maven', - rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277', - serverSideOptions: [] - }) - .on('end', done); - }); - - it('Assert Infinispan configuration has entity added', () => { - assert.fileContent( - `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, - ' registerPredefinedCache(entry, new JCache(\n' + - ' cacheManager.getCache(entry).getAdvancedCache(), this,\n' + - ' ConfigurationAdapter.create()));' - ); - }); - - it('Assert Infinispan configuration has entity added', () => { - assert.fileContent( - `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, - ' registerPredefinedCache(com.mycompany.myapp.domain.entityClass.class.getName(), new JCache(\n' + - ' cacheManager.getCache(com.mycompany.myapp.domain.entityClass.class.getName()).getAdvancedCache(), this,\n' + - ' ConfigurationAdapter.create()));' - ); - assert.fileContent( - `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, - ' registerPredefinedCache(com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesOneToMany", new JCache(\n' + - ' cacheManager.getCache(com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesOneToMany").getAdvancedCache(), this,\n' + - ' ConfigurationAdapter.create()));' - ); - assert.fileContent( - `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, - ' registerPredefinedCache(com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesManoToMany", new JCache(\n' + - ' cacheManager.getCache(com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesManoToMany").getAdvancedCache(), this,\n' + - ' ConfigurationAdapter.create()));' - ); - }); + describe('infinispan', () => { + before(done => { + helpers + .run(path.join(__dirname, '../../generators/server')) + .withOptions({ + 'from-cli': true, + skipInstall: true, + blueprint: 'myblueprint', + skipChecks: true + }) + .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:server']]) + .withPrompts({ + baseName: 'jhipster', + packageName: 'com.mycompany.myapp', + packageFolder: 'com/mycompany/myapp', + serviceDiscoveryType: false, + authenticationType: 'jwt', + cacheProvider: 'infinispan', + enableHibernateCache: true, + databaseType: 'sql', + devDatabaseType: 'h2Memory', + prodDatabaseType: 'mysql', + enableTranslation: true, + nativeLanguage: 'en', + languages: ['fr'], + buildTool: 'maven', + rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277', + serverSideOptions: [] + }) + .on('end', done); + }); + + it('Assert Infinispan configuration has entity added', () => { + assert.fileContent( + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, + ' registerPredefinedCache(entry, new JCache(\n' + + ' cacheManager.getCache(entry).getAdvancedCache(), this,\n' + + ' ConfigurationAdapter.create()));' + ); + }); + + it('Assert Infinispan configuration has entity added', () => { + assert.fileContent( + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, + ' registerPredefinedCache(com.mycompany.myapp.domain.entityClass.class.getName(), new JCache(\n' + + ' cacheManager.getCache(com.mycompany.myapp.domain.entityClass.class.getName()).getAdvancedCache(), this,\n' + + ' ConfigurationAdapter.create()));' + ); + assert.fileContent( + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, + ' registerPredefinedCache(com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesOneToMany", new JCache(\n' + + ' cacheManager.getCache(com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesOneToMany").getAdvancedCache(), this,\n' + + ' ConfigurationAdapter.create()));' + ); + assert.fileContent( + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, + ' registerPredefinedCache(com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesManoToMany", new JCache(\n' + + ' cacheManager.getCache(com.mycompany.myapp.domain.entityClass.class.getName() + ".entitiesManoToMany").getAdvancedCache(), this,\n' + + ' ConfigurationAdapter.create()));' + ); }); }); }); diff --git a/test/needle-api/needle-server-gradle.spec.js b/test/needle-api/needle-server-gradle.spec.js index f9fe488b67cc..5c9949dbc1b3 100644 --- a/test/needle-api/needle-server-gradle.spec.js +++ b/test/needle-api/needle-server-gradle.spec.js @@ -54,85 +54,79 @@ const mockBlueprintSubGen = class extends ServerGenerator { }; describe('needle API server gradle: JHipster server generator with blueprint', () => { - const blueprintNames = ['generator-jhipster-myblueprint', 'myblueprint']; - - blueprintNames.forEach(blueprintName => { - describe(`generate server with blueprint option '${blueprintName}'`, () => { - before(done => { - helpers - .run(path.join(__dirname, '../../generators/server')) - .withOptions({ - 'from-cli': true, - skipInstall: true, - blueprint: blueprintName, - skipChecks: true - }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:server']]) - .withPrompts({ - baseName: 'jhipster', - packageName: 'com.mycompany.myapp', - packageFolder: 'com/mycompany/myapp', - serviceDiscoveryType: false, - authenticationType: 'jwt', - cacheProvider: 'ehcache', - enableHibernateCache: true, - databaseType: 'sql', - devDatabaseType: 'h2Memory', - prodDatabaseType: 'mysql', - enableTranslation: true, - nativeLanguage: 'en', - languages: ['fr'], - buildTool: 'gradle', - rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277', - serverSideOptions: [] - }) - .on('end', done); - }); - - it('Assert gradle.properties has the property added', () => { - assert.fileContent('gradle.properties', 'name=value'); - }); - - it('Assert gradle.properties has the plugin added', () => { - assert.fileContent('build.gradle', 'classpath "group:name:version"'); - }); - - it('Assert gradle.properties has the PluginToPluginsBlock added', () => { - assert.fileContent('build.gradle', 'id "id" version "version"'); - }); - - it('Assert gradle.properties has the Dependency with version added', () => { - assert.fileContent('build.gradle', 'scope3 "group3:name3:version3"'); - }); - - it('Assert gradle.properties has the Dependency without version added', () => { - assert.fileContent('build.gradle', 'scope4 "group4:name4"'); - }); - - it('Assert gradle.properties has the Dependency in directory with version added', () => { - assert.fileContent('build.gradle', 'scope5 "group5:name5:version5"'); - }); - - it('Assert gradle.properties has the Dependency without version added', () => { - assert.fileContent('build.gradle', 'scope6 "group6:name6"'); - }); - - it('Assert gradle.properties has the apply gradle script added', () => { - assert.fileContent('build.gradle', "apply from: 'name.gradle'"); - }); - - it('Assert gradle.properties has the maven repository added', () => { - assert.fileContent( - 'build.gradle', - ' maven {\n' + - ' url "url"\n' + - ' credentials {\n' + - ' username = "username"\n' + - ' password = "password"\n' + - ' }\n' + - ' }' - ); - }); - }); + before(done => { + helpers + .run(path.join(__dirname, '../../generators/server')) + .withOptions({ + 'from-cli': true, + skipInstall: true, + blueprint: 'myblueprint', + skipChecks: true + }) + .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:server']]) + .withPrompts({ + baseName: 'jhipster', + packageName: 'com.mycompany.myapp', + packageFolder: 'com/mycompany/myapp', + serviceDiscoveryType: false, + authenticationType: 'jwt', + cacheProvider: 'ehcache', + enableHibernateCache: true, + databaseType: 'sql', + devDatabaseType: 'h2Memory', + prodDatabaseType: 'mysql', + enableTranslation: true, + nativeLanguage: 'en', + languages: ['fr'], + buildTool: 'gradle', + rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277', + serverSideOptions: [] + }) + .on('end', done); + }); + + it('Assert gradle.properties has the property added', () => { + assert.fileContent('gradle.properties', 'name=value'); + }); + + it('Assert gradle.properties has the plugin added', () => { + assert.fileContent('build.gradle', 'classpath "group:name:version"'); + }); + + it('Assert gradle.properties has the PluginToPluginsBlock added', () => { + assert.fileContent('build.gradle', 'id "id" version "version"'); + }); + + it('Assert gradle.properties has the Dependency with version added', () => { + assert.fileContent('build.gradle', 'scope3 "group3:name3:version3"'); + }); + + it('Assert gradle.properties has the Dependency without version added', () => { + assert.fileContent('build.gradle', 'scope4 "group4:name4"'); + }); + + it('Assert gradle.properties has the Dependency in directory with version added', () => { + assert.fileContent('build.gradle', 'scope5 "group5:name5:version5"'); + }); + + it('Assert gradle.properties has the Dependency without version added', () => { + assert.fileContent('build.gradle', 'scope6 "group6:name6"'); + }); + + it('Assert gradle.properties has the apply gradle script added', () => { + assert.fileContent('build.gradle', "apply from: 'name.gradle'"); + }); + + it('Assert gradle.properties has the maven repository added', () => { + assert.fileContent( + 'build.gradle', + ' maven {\n' + + ' url "url"\n' + + ' credentials {\n' + + ' username = "username"\n' + + ' password = "password"\n' + + ' }\n' + + ' }' + ); }); }); diff --git a/test/needle-api/needle-server-liquibase.spec.js b/test/needle-api/needle-server-liquibase.spec.js index a48fe2f0fc40..9b32e33b4f41 100644 --- a/test/needle-api/needle-server-liquibase.spec.js +++ b/test/needle-api/needle-server-liquibase.spec.js @@ -80,6 +80,12 @@ const mockBlueprintSubGen = class extends ServerGenerator { ' \n' + ' ' ); + }, + addLoadColumnStep() { + this.addLoadColumnToLiquibaseEntityChangeSet( + `${SERVER_MAIN_RES_DIR}config/liquibase/changelog/dummy_changelog.xml`, + ' ' + ); } }; return { ...phaseFromJHipster, ...customPhaseSteps }; @@ -87,89 +93,90 @@ const mockBlueprintSubGen = class extends ServerGenerator { }; describe('needle API server liquibase: JHipster server generator with blueprint', () => { - const blueprintNames = ['generator-jhipster-myblueprint', 'myblueprint']; - - blueprintNames.forEach(blueprintName => { - describe(`generate server with blueprint option '${blueprintName}'`, () => { - before(done => { - helpers - .run(path.join(__dirname, '../../generators/server')) - .inTmpDir(dir => { - fse.copySync( - path.join(__dirname, 'templates/src/main/resources/config/liquibase/changelog/'), - `${dir}/templates/src/main/resources/config/liquibase/changelog/` - ); - }) - .withOptions({ - 'from-cli': true, - skipInstall: true, - blueprint: blueprintName, - skipChecks: true - }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:server']]) - .withPrompts({ - baseName: 'jhipster', - packageName: 'com.mycompany.myapp', - packageFolder: 'com/mycompany/myapp', - serviceDiscoveryType: false, - authenticationType: 'jwt', - cacheProvider: 'ehcache', - enableHibernateCache: true, - databaseType: 'sql', - devDatabaseType: 'h2Memory', - prodDatabaseType: 'mysql', - enableTranslation: true, - nativeLanguage: 'en', - languages: ['fr'], - buildTool: 'maven', - rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277', - serverSideOptions: [] - }) - .on('end', done); - }); - - it('Assert changelog is added to master.xml', () => { - assert.fileContent( - `${SERVER_MAIN_RES_DIR}config/liquibase/master.xml`, - '' + before(done => { + helpers + .run(path.join(__dirname, '../../generators/server')) + .inTmpDir(dir => { + fse.copySync( + path.join(__dirname, 'templates/src/main/resources/config/liquibase/changelog/'), + `${dir}/templates/src/main/resources/config/liquibase/changelog/` ); - }); + }) + .withOptions({ + 'from-cli': true, + skipInstall: true, + blueprint: 'myblueprint', + skipChecks: true + }) + .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:server']]) + .withPrompts({ + baseName: 'jhipster', + packageName: 'com.mycompany.myapp', + packageFolder: 'com/mycompany/myapp', + serviceDiscoveryType: false, + authenticationType: 'jwt', + cacheProvider: 'ehcache', + enableHibernateCache: true, + databaseType: 'sql', + devDatabaseType: 'h2Memory', + prodDatabaseType: 'mysql', + enableTranslation: true, + nativeLanguage: 'en', + languages: ['fr'], + buildTool: 'maven', + rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277', + serverSideOptions: [] + }) + .on('end', done); + }); - it('Assert constraints changelog is added to master.xml', () => { - assert.fileContent( - `${SERVER_MAIN_RES_DIR}config/liquibase/master.xml`, - '' - ); - }); + it('Assert changelog is added to master.xml', () => { + assert.fileContent( + `${SERVER_MAIN_RES_DIR}config/liquibase/master.xml`, + '' + ); + }); - it('Assert constraints with needle changelog is added to master.xml', () => { - assert.fileContent( - `${SERVER_MAIN_RES_DIR}config/liquibase/master.xml`, - '' - ); - }); + it('Assert constraints changelog is added to master.xml', () => { + assert.fileContent( + `${SERVER_MAIN_RES_DIR}config/liquibase/master.xml`, + '' + ); + }); - it('Assert that column is added to an existing changelog', () => { - assert.fileContent( - `${SERVER_MAIN_RES_DIR}config/liquibase/changelog/dummy_changelog.xml`, - ' \n' + - ' \n' + - ' ' - ); - }); + it('Assert constraints with needle changelog is added to master.xml', () => { + assert.fileContent( + `${SERVER_MAIN_RES_DIR}config/liquibase/master.xml`, + '' + ); + }); - it('Assert that changeSet is added to an existing changelog', () => { - assert.fileContent( - `${SERVER_MAIN_RES_DIR}config/liquibase/changelog/dummy_changelog.xml`, - ' \n' + - ' \n' + - ' \n' + // eslint-disable-line - ' \n' + - ' \n' + - ' \n' + - ' ' - ); - }); - }); + it('Assert that column is added to an existing changelog', () => { + assert.fileContent( + `${SERVER_MAIN_RES_DIR}config/liquibase/changelog/dummy_changelog.xml`, + ' \n' + + ' \n' + + ' ' + ); + }); + + it('Assert that load column is added to an existing changelog', () => { + assert.fileContent( + `${SERVER_MAIN_RES_DIR}config/liquibase/changelog/dummy_changelog.xml`, + ' ' + ); + }); + + it('Assert that changeSet is added to an existing changelog', () => { + assert.fileContent( + `${SERVER_MAIN_RES_DIR}config/liquibase/changelog/dummy_changelog.xml`, + ' \n' + + ' \n' + + ' \n' + // eslint-disable-line + ' \n' + + ' \n' + + ' \n' + + ' ' + ); }); }); diff --git a/test/needle-api/needle-server-maven.spec.js b/test/needle-api/needle-server-maven.spec.js index aa3e0020254a..5f2db8fe8e0e 100644 --- a/test/needle-api/needle-server-maven.spec.js +++ b/test/needle-api/needle-server-maven.spec.js @@ -90,6 +90,11 @@ const mockBlueprintSubGen = class extends ServerGenerator { ' \n' + ' ' ); + this.addMavenAnnotationProcessor( + 'annotationProcessorGroupId', + 'annotationProcessorArtifactId', + 'annotationProcessorVersion' + ); this.addMavenProfile('profileId', ' other'); } }; @@ -98,135 +103,134 @@ const mockBlueprintSubGen = class extends ServerGenerator { }; describe('needle API server maven: JHipster server generator with blueprint', () => { - const blueprintNames = ['generator-jhipster-myblueprint', 'myblueprint']; - - blueprintNames.forEach(blueprintName => { - describe(`generate server with blueprint option '${blueprintName}'`, () => { - before(done => { - helpers - .run(path.join(__dirname, '../../generators/server')) - .withOptions({ - 'from-cli': true, - skipInstall: true, - blueprint: blueprintName, - skipChecks: true - }) - .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:server']]) - .withPrompts({ - baseName: 'jhipster', - packageName: 'com.mycompany.myapp', - packageFolder: 'com/mycompany/myapp', - serviceDiscoveryType: false, - authenticationType: 'jwt', - cacheProvider: 'ehcache', - enableHibernateCache: true, - databaseType: 'sql', - devDatabaseType: 'h2Memory', - prodDatabaseType: 'mysql', - enableTranslation: true, - nativeLanguage: 'en', - languages: ['fr'], - buildTool: 'maven', - rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277', - serverSideOptions: [] - }) - .on('end', done); - }); - - it('Assert pom.xml has the dependency management added', () => { - assert.fileContent( - 'pom.xml', - ' \n' + - ' groupId\n' + - ' artifactId\n' + - ' version\n' + - ' type\n' + - ' scope\n' + - ' \n' + - ' \n' + - ' aGroupId\n' + - ' anArtifactId\n' + - ' \n' + - ' \n' + - ' ' - ); - }); + before(done => { + helpers + .run(path.join(__dirname, '../../generators/server')) + .withOptions({ + 'from-cli': true, + skipInstall: true, + blueprint: 'myblueprint', + skipChecks: true + }) + .withGenerators([[mockBlueprintSubGen, 'jhipster-myblueprint:server']]) + .withPrompts({ + baseName: 'jhipster', + packageName: 'com.mycompany.myapp', + packageFolder: 'com/mycompany/myapp', + serviceDiscoveryType: false, + authenticationType: 'jwt', + cacheProvider: 'ehcache', + enableHibernateCache: true, + databaseType: 'sql', + devDatabaseType: 'h2Memory', + prodDatabaseType: 'mysql', + enableTranslation: true, + nativeLanguage: 'en', + languages: ['fr'], + buildTool: 'maven', + rememberMeKey: '5c37379956bd1242f5636c8cb322c2966ad81277', + serverSideOptions: [] + }) + .on('end', done); + }); - it('Assert pom.xml has the repository added', () => { - assert.fileContent( - 'pom.xml', - ' \n id\n url\n ' - ); - }); - - it('Assert pom.xml has the plugin repository added', () => { - assert.fileContent( - 'pom.xml', - ' \n' + - ' id\n' + - ' url\n' + - ' ' - ); - }); - - it('Assert pom.xml has the distributionManagement added', () => { - assert.fileContent( - 'pom.xml', - ' \n' + - ' releasesId\n' + - ' releasesUrl\n' + - ' ' - ); - }); - - it('Assert pom.xml has the property added', () => { - assert.fileContent('pom.xml', 'value'); - }); - - it('Assert pom.xml has the dependencyManagement added', () => { - assert.fileContent('pom.xml', ''); - }); - - it('Assert pom.xml has the dependency added', () => { - assert.fileContent( - 'pom.xml', - ' \n' + - ' groupId\n' + - ' artifactId\n' + - ' version\n' + - ' \n' + - ' \n' + - ' aGroupId\n' + - ' anArtifactId\n' + - ' \n' + - ' \n' + - ' ' - ); - }); - - it('Assert pom.xml has the dependency in directory added', () => { - assert.fileContent( - 'pom.xml', - ' \n' + - ' groupId2\n' + - ' artifactId2\n' + - ' version2\n' + - ' \n' + - ' \n' + - ' aGroupId\n' + - ' anArtifactId\n' + - ' \n' + - ' \n' + - ' ' - ); - }); + it('Assert pom.xml has the dependency management added', () => { + assert.fileContent( + 'pom.xml', + ' \n' + + ' groupId\n' + + ' artifactId\n' + + ' version\n' + + ' type\n' + + ' scope\n' + + ' \n' + + ' \n' + + ' aGroupId\n' + + ' anArtifactId\n' + + ' \n' + + ' \n' + + ' ' + ); + }); - it('Assert pom.xml has the profile added', () => { - assert.fileContent( - 'pom.xml', - ' \n profileId\n other\n ' - ); - }); - }); + it('Assert pom.xml has the repository added', () => { + assert.fileContent('pom.xml', ' \n id\n url\n '); + }); + + it('Assert pom.xml has the plugin repository added', () => { + assert.fileContent( + 'pom.xml', + ' \n id\n url\n ' + ); + }); + + it('Assert pom.xml has the distributionManagement added', () => { + assert.fileContent( + 'pom.xml', + ' \n' + + ' releasesId\n' + + ' releasesUrl\n' + + ' ' + ); + }); + + it('Assert pom.xml has the property added', () => { + assert.fileContent('pom.xml', 'value'); + }); + + it('Assert pom.xml has the dependencyManagement added', () => { + assert.fileContent('pom.xml', ''); + }); + + it('Assert pom.xml has the dependency added', () => { + assert.fileContent( + 'pom.xml', + ' \n' + + ' groupId\n' + + ' artifactId\n' + + ' version\n' + + ' \n' + + ' \n' + + ' aGroupId\n' + + ' anArtifactId\n' + + ' \n' + + ' \n' + + ' ' + ); + }); + + it('Assert pom.xml has the dependency in directory added', () => { + assert.fileContent( + 'pom.xml', + ' \n' + + ' groupId2\n' + + ' artifactId2\n' + + ' version2\n' + + ' \n' + + ' \n' + + ' aGroupId\n' + + ' anArtifactId\n' + + ' \n' + + ' \n' + + ' ' + ); + }); + + it('Assert pom.xml has the annotation processor added', () => { + assert.fileContent( + 'pom.xml', + ' \n' + + ' annotationProcessorGroupId\n' + + ' annotationProcessorArtifactId\n' + + ' annotationProcessorVersion\n' + + ' ' + ); + }); + + it('Assert pom.xml has the profile added', () => { + assert.fileContent( + 'pom.xml', + ' \n profileId\n other\n ' + ); }); }); diff --git a/test/needle-api/templates/src/main/resources/config/liquibase/changelog/dummy_changelog.xml.ejs b/test/needle-api/templates/src/main/resources/config/liquibase/changelog/dummy_changelog.xml.ejs index c6ac59f83ad4..b7ee406100d0 100644 --- a/test/needle-api/templates/src/main/resources/config/liquibase/changelog/dummy_changelog.xml.ejs +++ b/test/needle-api/templates/src/main/resources/config/liquibase/changelog/dummy_changelog.xml.ejs @@ -49,4 +49,16 @@ + + + + + + + + diff --git a/test/templates/all-languages/.yo-rc.json b/test/templates/all-languages/.yo-rc.json index ba5a03ccdfc3..d41cc2a1ebeb 100644 --- a/test/templates/all-languages/.yo-rc.json +++ b/test/templates/all-languages/.yo-rc.json @@ -41,6 +41,7 @@ "nl", "et", "fa", + "fi", "fr", "gl", "de", diff --git a/test/templates/compose/09-kafka/src/main/docker/app.yml b/test/templates/compose/09-kafka/src/main/docker/app.yml index 38b3ba7b7614..689c9567ade1 100644 --- a/test/templates/compose/09-kafka/src/main/docker/app.yml +++ b/test/templates/compose/09-kafka/src/main/docker/app.yml @@ -6,8 +6,8 @@ services: - SPRING_PROFILES_ACTIVE=prod,swagger - SPRING_DATASOURCE_URL=jdbc:mysql://samplekafka-mysql:3306/samplekafka?useUnicode=true&characterEncoding=utf8&useSSL=false - JHIPSTER_SLEEP=10 # gives time for the database to boot before the application - - SPRING_CLOUD_STREAM_KAFKA_BINDER_BROKERS=kafka - - SPRING_CLOUD_STREAM_KAFKA_BINDER_ZK_NODES=zookeeper + - SPRING_KAFKA_CONSUMER_BOOTSTRAP_SERVERS=kafka:9092 + - SPRING_KAFKA_PRODUCER_BOOTSTRAP_SERVERS=kafka:9092 ports: - 8080:8080 samplekafka-mysql: diff --git a/test/templates/compose/09-kafka/src/main/docker/kafka.yml b/test/templates/compose/09-kafka/src/main/docker/kafka.yml index b1542f320e88..a66bfe8c2524 100644 --- a/test/templates/compose/09-kafka/src/main/docker/kafka.yml +++ b/test/templates/compose/09-kafka/src/main/docker/kafka.yml @@ -1,15 +1,17 @@ version: '2' services: zookeeper: - image: wurstmeister/zookeeper:3.4.6 - ports: - - 2181:2181 + image: confluentinc/cp-zookeeper:5.2.1 + environment: + ZOOKEEPER_CLIENT_PORT: 2181 + ZOOKEEPER_TICK_TIME: 2000 + ZOOKEEPER_SYNC_LIMIT: 2 kafka: - image: wurstmeister/kafka:1.0.0 + image: confluentinc/cp-kafka:5.2.1 environment: - KAFKA_ADVERTISED_HOST_NAME: localhost - KAFKA_ADVERTISED_PORT: 9092 + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_CREATE_TOPICS: "topic-jhipster:1:1" + KAFKA_BROKER_ID: 2 + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 ports: - 9092:9092 diff --git a/test/templates/export-jdl/.jhipster/Employee.json b/test/templates/export-jdl/.jhipster/Employee.json index 25582d4aa38f..9a064a710d21 100644 --- a/test/templates/export-jdl/.jhipster/Employee.json +++ b/test/templates/export-jdl/.jhipster/Employee.json @@ -24,6 +24,10 @@ "fieldName": "employeeId", "fieldType": "Long" }, + { + "fieldName": "employeeUuid", + "fieldType": "UUID" + }, { "fieldName": "firstName", "javadoc": "The firstname attribute.", diff --git a/test/templates/import-jdl/jdl.jdl b/test/templates/import-jdl/jdl.jdl index ebedec62b9c6..a13fcdacf018 100644 --- a/test/templates/import-jdl/jdl.jdl +++ b/test/templates/import-jdl/jdl.jdl @@ -1,5 +1,6 @@ entity Region { regionName String + guid UUID } entity Country { diff --git a/test/templates/ngx-blueprint/.yo-rc.json b/test/templates/ngx-blueprint/.yo-rc.json index 37e1f060e5c9..5f8dbe720496 100644 --- a/test/templates/ngx-blueprint/.yo-rc.json +++ b/test/templates/ngx-blueprint/.yo-rc.json @@ -22,7 +22,7 @@ "enableSwaggerCodegen": false, "jwtSecretKey": "147e04cf224f52908a60d7a2902e19e0648d0a8c52503b4624f1708478dd29ba2885a9bb823c85873a76b27964a90e22f1e8", "clientFramework": "angularX", - "clientPackageManager": "npm" + "clientPackageManager": "npm" }, "generator-jhipster": { "promptValues": { diff --git a/test/templates/ngx-blueprint/HelloKotlin.kt.ejs b/test/templates/ngx-blueprint/HelloKotlin.kt.ejs new file mode 100644 index 000000000000..c3ba925a965d --- /dev/null +++ b/test/templates/ngx-blueprint/HelloKotlin.kt.ejs @@ -0,0 +1,17 @@ +<%# + Copyright 2013-2019 the original author or authors from the JHipster project. + This file is part of the JHipster project, see http://www.jhipster.tech/ + for more information. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +-%> +package <%=packageName%>.test + +fun main() = println("Hello <%= name %>!!!") diff --git a/test/templates/ngx-blueprint/HelloVue.html.ejs b/test/templates/ngx-blueprint/HelloVue.html.ejs new file mode 100644 index 000000000000..a340c097d65a --- /dev/null +++ b/test/templates/ngx-blueprint/HelloVue.html.ejs @@ -0,0 +1,44 @@ +<%# + Copyright 2013-2019 the original author or authors from the JHipster project. + This file is part of the JHipster project, see http://www.jhipster.tech/ + for more information. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +-%> + + + + + Hello World in Vue.js + + + + +
    +

    {{ msg }}

    +
    + + + + + + + diff --git a/test/templates/ngx-blueprint/custom-i18n.json.ejs b/test/templates/ngx-blueprint/custom-i18n.json.ejs new file mode 100644 index 000000000000..c624619b7156 --- /dev/null +++ b/test/templates/ngx-blueprint/custom-i18n.json.ejs @@ -0,0 +1,23 @@ +<%# + Copyright 2013-2019 the original author or authors from the JHipster project. + + This file is part of the JHipster project, see https://www.jhipster.tech/ + for more information. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +-%> +{ + "<%= angularAppName %>": { + "name" : "<%= name %>" + } +} diff --git a/test/upgrade.spec.js.disable b/test/upgrade.spec.js similarity index 88% rename from test/upgrade.spec.js.disable rename to test/upgrade.spec.js index 237ff6d0ae1c..40159ba87a55 100644 --- a/test/upgrade.spec.js.disable +++ b/test/upgrade.spec.js @@ -5,10 +5,12 @@ const shelljs = require('shelljs'); const fse = require('fs-extra'); const expect = require('chai').expect; const expectedFiles = require('./utils/expected-files'); +const packageJson = require('../package.json'); describe('JHipster upgrade generator', function() { this.timeout(200000); describe('default application', () => { + const cwd = process.cwd(); before(done => { let workingDirectory; helpers @@ -44,7 +46,12 @@ describe('JHipster upgrade generator', function() { .on('end', () => { helpers .run(path.join(__dirname, '../generators/upgrade')) - .withOptions({ 'from-cli': true, force: true, silent: false }) + .withOptions({ + 'from-cli': true, + force: true, + silent: false, + 'target-version': packageJson.version + }) .inTmpDir(() => { /* eslint-disable-next-line no-console */ console.log('Upgrading the JHipster application'); @@ -71,8 +78,13 @@ describe('JHipster upgrade generator', function() { // - master: merge commit of jhipster_upgrade expect(commitsCount).to.equal('5'); }); + + after(() => { + process.chdir(cwd); + }); }); describe('blueprint application', () => { + const cwd = process.cwd(); const blueprintName = 'generator-jhipster-sample-blueprint'; const blueprintVersion = '0.1.1'; before(done => { @@ -118,7 +130,12 @@ describe('JHipster upgrade generator', function() { .on('end', () => { helpers .run(path.join(__dirname, '../generators/upgrade')) - .withOptions({ 'from-cli': true, force: true, silent: false }) + .withOptions({ + 'from-cli': true, + force: true, + silent: false, + 'target-version': packageJson.version + }) .inTmpDir(() => { /* eslint-disable-next-line no-console */ console.log('Upgrading the JHipster application'); @@ -147,9 +164,14 @@ describe('JHipster upgrade generator', function() { }); it('still contains blueprint information', () => { - assert.fileContent('.yo-rc.json', new RegExp(`"blueprint": "${blueprintName}"`)); - assert.fileContent('.yo-rc.json', new RegExp(`"blueprintVersion": "${blueprintVersion}"`)); + assert.JSONFileContent('.yo-rc.json', { + 'generator-jhipster': { blueprints: [{ name: blueprintName, version: blueprintVersion }] } + }); assert.fileContent('package.json', new RegExp(`"${blueprintName}": "${blueprintVersion}"`)); }); + + after(() => { + process.chdir(cwd); + }); }); }); diff --git a/test/utils.spec.js b/test/utils.spec.js index 54a680736e2e..eafc5b106f0c 100644 --- a/test/utils.spec.js +++ b/test/utils.spec.js @@ -1,4 +1,5 @@ const assert = require('yeoman-assert'); +const helpers = require('yeoman-test'); const utils = require('../generators/utils'); describe('JHipster Utils', () => { @@ -74,6 +75,37 @@ describe('JHipster Utils', () => { }); }); }); + describe('::parseBluePrints', () => { + it('does nothing if an array', () => { + const expected = [{ name: 'generator-jhipster-foo', version: 'latest' }]; + const actual = utils.parseBluePrints(expected); + assert.deepStrictEqual(actual, expected); + }); + it('adds generator-jhipster prefix if it is absent', () => { + const expected = [{ name: 'generator-jhipster-foo', version: 'latest' }]; + const actual = utils.parseBluePrints('foo'); + assert.deepStrictEqual(actual, expected); + }); + it('keeps generator-jhipster prefix if it is present', () => { + const expected = [{ name: 'generator-jhipster-foo', version: '1.0.1' }]; + const actual = utils.parseBluePrints('generator-jhipster-foo@1.0.1'); + assert.deepStrictEqual(actual, expected); + }); + it("doesn't modify scoped package and extracts version", () => { + const expected = [{ name: '@corp/foo', version: '1.0.1' }]; + const actual = utils.parseBluePrints('@corp/foo@1.0.1'); + assert.deepStrictEqual(actual, expected); + }); + it('parses comma separated list', () => { + const expected = [ + { name: 'generator-jhipster-foo', version: 'latest' }, + { name: 'generator-jhipster-bar', version: '1.0.1' }, + { name: '@corp/foo', version: 'latest' } + ]; + const actual = utils.parseBluePrints('foo,bar@1.0.1,@corp/foo'); + assert.deepStrictEqual(actual, expected); + }); + }); describe('::normalizeBlueprintName', () => { it('adds generator-jhipster prefix if it is absent', () => { const generatorName = utils.normalizeBlueprintName('foo'); @@ -88,4 +120,40 @@ describe('JHipster Utils', () => { assert.textEqual(generatorName, '@corp/foo'); }); }); + describe('::getAllJhipsterConfig', () => { + const cwd = process.cwd(); + const configRootDir = './test/templates/default'; + const expectedConfig = { + applicationType: 'monolith', + baseName: 'sampleMysql', + packageName: 'com.mycompany.myapp', + packageFolder: 'com/mycompany/myapp', + authenticationType: 'session', + cacheProvider: 'ehcache', + websocket: 'no', + databaseType: 'sql', + devDatabaseType: 'h2Disk', + prodDatabaseType: 'mysql', + searchEngine: 'no', + buildTool: 'maven', + enableTranslation: true, + nativeLanguage: 'en', + languages: ['en', 'fr'], + rememberMeKey: '2bb60a80889aa6e6767e9ccd8714982681152aa5', + testFrameworks: ['gatling'] + }; + + it('load config from alternate directory', () => { + const loadedConfig = utils.getAllJhipsterConfig(helpers.createDummyGenerator(), true, configRootDir); + assert.objectContent(loadedConfig, expectedConfig); + }); + it('load config from current working directory', () => { + process.chdir(configRootDir); + const loadedConfig = utils.getAllJhipsterConfig(helpers.createDummyGenerator(), true); + assert.objectContent(loadedConfig, expectedConfig); + }); + after(() => { + process.chdir(cwd); + }); + }); }); diff --git a/test/utils/expected-files.js b/test/utils/expected-files.js index 3112ef91c001..bfb8b1405658 100644 --- a/test/utils/expected-files.js +++ b/test/utils/expected-files.js @@ -569,12 +569,21 @@ const expectedFiles = { oauth2: [ `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/SecurityConfiguration.java`, + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/security/oauth2/JwtAuthorityExtractor.java`, + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/security/oauth2/AudienceValidator.java`, + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/security/oauth2/OAuthIdpTokenResponseDTO.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/domain/User.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/AccountResource.java`, `${DOCKER_DIR}keycloak.yml` ], - messageBroker: [`${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/MessagingConfiguration.java`, `${DOCKER_DIR}kafka.yml`], + messageBroker: [ + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/JhipsterKafkaResource.java`, + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/JhipsterKafkaConsumer.java`, + `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/JhipsterKafkaProducer.java`, + `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/JhipsterKafkaResourceIT.java`, + `${DOCKER_DIR}kafka.yml` + ], swaggerCodegen: [`${SERVER_MAIN_RES_DIR}swagger/api.yml`], @@ -595,7 +604,6 @@ const expectedFiles = { `${SERVER_TEST_RES_DIR}config/bootstrap.yml`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/GatewayConfiguration.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/apidoc/GatewaySwaggerResourcesProvider.java`, - `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/gateway/ratelimiting/RateLimitingFilter.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/gateway/accesscontrol/AccessControlFilter.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/gateway/responserewriting/SwaggerBasePathRewritingFilter.java`, `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/gateway/responserewriting/SwaggerBasePathRewritingFilterTest.java`, @@ -607,6 +615,8 @@ const expectedFiles = { `${CLIENT_MAIN_SRC_DIR}app/admin/gateway/gateway-routes.service.ts` ], + rateLimitingFilesForGateways: [`${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/gateway/ratelimiting/RateLimitingFilter.java`], + gatewayWithUaa: [ `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`, `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/AuthResource.java`,