diff --git a/generators/base/api.d.ts b/generators/base/api.d.ts index 5e861c0ad8f0..3c164ea41c24 100644 --- a/generators/base/api.d.ts +++ b/generators/base/api.d.ts @@ -142,7 +142,7 @@ export type WriteFileTemplate = binary?: boolean; /** ejs options. Refer to https://ejs.co/#docs */ options?: Record; - override?: (this: Generator, data: DataType) => boolean; + override?: boolean | ((this: Generator, data: DataType) => boolean); }; export type WriteFileBlock = { diff --git a/generators/init/templates/.eslintignore.jhi.ejs b/generators/init/templates/.eslintignore.jhi.ejs deleted file mode 100644 index 7c1eebab2d85..000000000000 --- a/generators/init/templates/.eslintignore.jhi.ejs +++ /dev/null @@ -1,21 +0,0 @@ -<%# - Copyright 2013-2024 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 - - https://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. --%> -node_modules/ - -<&- fragments.render({ join: '\n\n' }) &> diff --git a/generators/server/__snapshots__/generator.spec.js.snap b/generators/server/__snapshots__/generator.spec.js.snap index e03f1d726dc7..e8dd7cb3f427 100644 --- a/generators/server/__snapshots__/generator.spec.js.snap +++ b/generators/server/__snapshots__/generator.spec.js.snap @@ -17,9 +17,6 @@ exports[`generator - server composing databaseType option no with jwt should mat "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/myapp/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -253,9 +250,6 @@ exports[`generator - server composing databaseType option no with oauth2 should "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/myapp/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -489,9 +483,6 @@ exports[`generator - server composing databaseType option no with session should "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/myapp/ApplicationWebXml.java": { "stateCleared": "modified", }, diff --git a/generators/server/__test-support/index.ts b/generators/server/__test-support/index.ts index 5cd396dd5bf6..7f45d20c380c 100644 --- a/generators/server/__test-support/index.ts +++ b/generators/server/__test-support/index.ts @@ -3,58 +3,17 @@ import assert from 'assert'; import { messageBrokerTypes, databaseTypes } from '../../../jdl/jhipster/index.js'; import { - GENERATOR_CUCUMBER, - GENERATOR_GATLING, - GENERATOR_SPRING_CACHE, - GENERATOR_SPRING_WEBSOCKET, - GENERATOR_SPRING_DATA_RELATIONAL, - GENERATOR_SPRING_DATA_CASSANDRA, - GENERATOR_SPRING_DATA_COUCHBASE, - GENERATOR_SPRING_DATA_MONGODB, - GENERATOR_MAVEN, - GENERATOR_LIQUIBASE, - GENERATOR_LANGUAGES, GENERATOR_SPRING_CLOUD_STREAM, - GENERATOR_GRADLE, - GENERATOR_DOCKER, - GENERATOR_COMMON, GENERATOR_JAVA, + GENERATOR_PROJECT_NAME, + GENERATOR_SERVER, + GENERATOR_SPRING_BOOT, + GENERATOR_BOOTSTRAP, } from '../../generator-list.js'; const { KAFKA, PULSAR } = messageBrokerTypes; const { SQL, COUCHBASE } = databaseTypes; -export const mockedGenerators = [ - `jhipster:${GENERATOR_COMMON}`, - `jhipster:${GENERATOR_SPRING_DATA_COUCHBASE}`, - `jhipster:${GENERATOR_CUCUMBER}`, - `jhipster:${GENERATOR_DOCKER}`, - `jhipster:${GENERATOR_GATLING}`, - `jhipster:${GENERATOR_GRADLE}`, - `jhipster:${GENERATOR_GRADLE}:code-quality`, - `jhipster:${GENERATOR_GRADLE}:jib`, - `jhipster:${GENERATOR_GRADLE}:node-gradle`, - `jhipster:${GENERATOR_SPRING_CLOUD_STREAM}`, - // `jhipster:${GENERATOR_JAVA}`, - // `jhipster:${GENERATOR_JAVA}:domain`, - // `jhipster:${GENERATOR_JAVA}:bootstrap`, - `jhipster:${GENERATOR_JAVA}:build-tool`, - `jhipster:${GENERATOR_JAVA}:code-quality`, - `jhipster:${GENERATOR_JAVA}:node`, - `jhipster:${GENERATOR_LANGUAGES}`, - `jhipster:${GENERATOR_LIQUIBASE}`, - `jhipster:${GENERATOR_MAVEN}`, - `jhipster:${GENERATOR_MAVEN}:code-quality`, - `jhipster:${GENERATOR_MAVEN}:jib`, - `jhipster:${GENERATOR_MAVEN}:node`, - 'jhipster:spring-cloud:gateway', - `jhipster:${GENERATOR_SPRING_DATA_CASSANDRA}`, - `jhipster:${GENERATOR_SPRING_DATA_MONGODB}`, - `jhipster:${GENERATOR_SPRING_DATA_RELATIONAL}`, - `jhipster:${GENERATOR_SPRING_CACHE}`, - `jhipster:${GENERATOR_SPRING_WEBSOCKET}`, -]; - export const shouldComposeWithLiquibase = (testSample, runResultSupplier) => { const liquibaseEnabled = typeof testSample === 'boolean' ? testSample : testSample?.databaseType === SQL; if (liquibaseEnabled) { @@ -97,3 +56,14 @@ const shouldComposeWithDatabasetype = (databaseType: string, shouldCompose: bool export const shouldComposeWithCouchbase = (shouldCompose: boolean, runResultSupplier) => shouldComposeWithDatabasetype(COUCHBASE, shouldCompose, runResultSupplier); + +export const filterBasicServerGenerators = (ns: string) => + !ns.startsWith(`jhipster:${GENERATOR_BOOTSTRAP}`) && + ![ + `jhipster:${GENERATOR_PROJECT_NAME}`, + `jhipster:${GENERATOR_JAVA}`, + `jhipster:${GENERATOR_JAVA}:bootstrap`, + `jhipster:${GENERATOR_JAVA}:domain`, + `jhipster:${GENERATOR_SERVER}`, + `jhipster:${GENERATOR_SPRING_BOOT}`, + ].includes(ns); diff --git a/generators/server/generator.spec.js b/generators/server/generator.spec.js index fc29e3417037..ff59637adab3 100644 --- a/generators/server/generator.spec.js +++ b/generators/server/generator.spec.js @@ -24,7 +24,7 @@ import { snakeCase } from 'lodash-es'; import { shouldSupportFeatures, testBlueprintSupport, checkEnforcements } from '../../test/support/index.js'; import { defaultHelpers as helpers, result as runResult } from '../../testing/index.js'; import { GENERATOR_SERVER, GENERATOR_SPRING_BOOT } from '../generator-list.js'; -import { mockedGenerators, shouldComposeWithCouchbase, shouldComposeWithSpringCloudStream } from './__test-support/index.js'; +import { filterBasicServerGenerators, shouldComposeWithCouchbase, shouldComposeWithSpringCloudStream } from './__test-support/index.js'; import Generator from './index.js'; const __filename = fileURLToPath(import.meta.url); @@ -52,7 +52,7 @@ describe(`generator - ${generator}`, () => { messageBroker: 'no', }) .withSkipWritingPriorities() - .withMockedGenerators(mockedGenerators); + .withMockedJHipsterGenerators({ filter: filterBasicServerGenerators }); }); shouldComposeWithSpringCloudStream(false, () => runResult); @@ -66,7 +66,7 @@ describe(`generator - ${generator}`, () => { messageBroker: 'kafka', }) .withSkipWritingPriorities() - .withMockedGenerators(mockedGenerators); + .withMockedJHipsterGenerators({ filter: filterBasicServerGenerators }); }); shouldComposeWithSpringCloudStream(true, () => runResult); }); @@ -79,7 +79,7 @@ describe(`generator - ${generator}`, () => { messageBroker: 'pulsar', }) .withSkipWritingPriorities() - .withMockedGenerators(mockedGenerators); + .withMockedJHipsterGenerators({ filter: filterBasicServerGenerators }); }); shouldComposeWithSpringCloudStream(true, () => runResult); }); @@ -94,7 +94,7 @@ describe(`generator - ${generator}`, () => { databaseType: 'no', authenticationType: 'jwt', }) - .withMockedGenerators(mockedGenerators); + .withMockedJHipsterGenerators({ filter: filterBasicServerGenerators }); }); it('should match generated files', () => { @@ -111,7 +111,7 @@ describe(`generator - ${generator}`, () => { databaseType: 'no', authenticationType: 'session', }) - .withMockedGenerators(mockedGenerators); + .withMockedJHipsterGenerators({ filter: filterBasicServerGenerators }); }); it('should match generated files', () => { @@ -128,7 +128,7 @@ describe(`generator - ${generator}`, () => { databaseType: 'no', authenticationType: 'oauth2', }) - .withMockedGenerators(mockedGenerators); + .withMockedJHipsterGenerators({ filter: filterBasicServerGenerators }); }); it('should match generated files', () => { @@ -146,7 +146,7 @@ describe(`generator - ${generator}`, () => { databaseType: 'couchbase', }) .withSkipWritingPriorities() - .withMockedGenerators(mockedGenerators); + .withMockedJHipsterGenerators({ filter: filterBasicServerGenerators }); }); shouldComposeWithCouchbase(true, () => runResult); }); diff --git a/generators/spring-boot/__snapshots__/generator.spec.ts.snap b/generators/spring-boot/__snapshots__/generator.spec.ts.snap index b91aeda885d0..c236029ef722 100644 --- a/generators/spring-boot/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-boot/__snapshots__/generator.spec.ts.snap @@ -17,9 +17,6 @@ exports[`generator - spring-boot with jwt should match generated files snapshot "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/myapp/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -388,9 +385,6 @@ exports[`generator - spring-boot with oauth2 should match generated files snapsh "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/myapp/ApplicationWebXml.java": { "stateCleared": "modified", }, diff --git a/generators/spring-boot/generator.spec.ts b/generators/spring-boot/generator.spec.ts index bd73f27d436b..db8ba27ba08b 100644 --- a/generators/spring-boot/generator.spec.ts +++ b/generators/spring-boot/generator.spec.ts @@ -6,7 +6,7 @@ import { defaultHelpers as helpers, runResult } from '../../testing/index.js'; import { shouldSupportFeatures, testBlueprintSupport, checkEnforcements } from '../../test/support/index.js'; import Generator from '../server/index.js'; -import { mockedGenerators } from '../server/__test-support/index.js'; +import { filterBasicServerGenerators } from '../server/__test-support/index.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -23,7 +23,10 @@ describe(`generator - ${generator}`, () => { describe('with jwt', () => { before(async () => { - await helpers.runJHipster(generator).withJHipsterConfig({ authenticationType: 'jwt' }).withMockedGenerators(mockedGenerators); + await helpers + .runJHipster(generator) + .withJHipsterConfig({ authenticationType: 'jwt' }) + .withMockedJHipsterGenerators({ filter: filterBasicServerGenerators }); }); it('should match generated files snapshot', () => { @@ -33,7 +36,10 @@ describe(`generator - ${generator}`, () => { describe('with oauth2', () => { before(async () => { - await helpers.runJHipster(generator).withJHipsterConfig({ authenticationType: 'oauth2' }).withMockedGenerators(mockedGenerators); + await helpers + .runJHipster(generator) + .withJHipsterConfig({ authenticationType: 'oauth2' }) + .withMockedJHipsterGenerators({ filter: filterBasicServerGenerators }); }); it('should match generated files snapshot', () => { diff --git a/generators/spring-data-cassandra/__snapshots__/generator.spec.ts.snap b/generators/spring-data-cassandra/__snapshots__/generator.spec.ts.snap index 4447fad2e902..3838a9226980 100644 --- a/generators/spring-data-cassandra/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-cassandra/__snapshots__/generator.spec.ts.snap @@ -41,9 +41,6 @@ exports[`generator - cassandra gateway-jwt-gradle-enableTranslation(true)-com.my "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -493,9 +490,6 @@ exports[`generator - cassandra microservice-jwt-reactive(false)-maven-enableTran "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -837,9 +831,6 @@ exports[`generator - cassandra microservice-jwt-reactive(true)-gradle-enableTran "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -1190,9 +1181,6 @@ exports[`generator - cassandra microservice-oauth2-reactive(true)-gradle-enableT "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -1510,9 +1498,6 @@ exports[`generator - cassandra monolith-jwt-reactive(false)-maven-enableTranslat "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -1998,9 +1983,6 @@ exports[`generator - cassandra monolith-jwt-reactive(true)-gradle-enableTranslat "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -2345,9 +2327,6 @@ exports[`generator - cassandra monolith-oauth2-reactive(false)-maven-enableTrans "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -2719,9 +2698,6 @@ exports[`generator - cassandra monolith-oauth2-reactive(true)-gradle-enableTrans "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -3075,9 +3051,6 @@ exports[`generator - cassandra monolith-session-reactive(false)-maven-enableTran "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -3530,9 +3503,6 @@ exports[`generator - cassandra monolith-session-reactive(true)-gradle-enableTran "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, diff --git a/generators/spring-data-cassandra/generator.spec.ts b/generators/spring-data-cassandra/generator.spec.ts index b89c5c69970a..eb93dd421bec 100644 --- a/generators/spring-data-cassandra/generator.spec.ts +++ b/generators/spring-data-cassandra/generator.spec.ts @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { basename, dirname, join } from 'path'; +import { basename, dirname } from 'path'; import { fileURLToPath } from 'url'; import { before, it, describe, expect } from 'esmocha'; import { snakeCase } from 'lodash-es'; @@ -27,24 +27,19 @@ import Generator from '../server/index.js'; import { databaseTypes } from '../../jdl/jhipster/index.js'; import { - mockedGenerators as serverGenerators, + filterBasicServerGenerators, shouldComposeWithSpringCloudStream, shouldComposeWithLiquibase, } from '../server/__test-support/index.js'; -import { GENERATOR_SPRING_DATA_CASSANDRA } from '../generator-list.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const generator = basename(__dirname); -// compose with server generator, many conditionals at server generator -const generatorFile = join(__dirname, '../server/index.js'); const { CASSANDRA: databaseType } = databaseTypes; const commonConfig = { databaseType, baseName: 'jhipster', nativeLanguage: 'en', languages: ['fr', 'en'] }; -const mockedGenerators = serverGenerators.filter(generator => generator !== `jhipster:${GENERATOR_SPRING_DATA_CASSANDRA}`); - const testSamples = buildServerSamples(commonConfig); describe(`generator - ${databaseType}`, () => { @@ -67,14 +62,20 @@ describe(`generator - ${databaseType}`, () => { (sampleConfig.reactive || sampleConfig.applicationType === 'microservice' || sampleConfig.applicationType === 'gateway') ) { it('should throw an error', async () => { - await expect(helpers.runJHipster(generatorFile).withJHipsterConfig(sampleConfig)).rejects.toThrow(); + await expect(helpers.runJHipster('server').withJHipsterConfig(sampleConfig)).rejects.toThrow(); }); return; } before(async () => { - await helpers.run(generatorFile).withJHipsterConfig(sampleConfig, entities).withMockedGenerators(mockedGenerators); + await helpers + .runJHipster('server') + .withJHipsterConfig(sampleConfig, entities) + .withMockedJHipsterGenerators({ + except: ['jhipster:spring-data-cassandra'], + filter: filterBasicServerGenerators, + }); }); it('should match generated files snapshot', () => { diff --git a/generators/spring-data-couchbase/__snapshots__/generator.spec.ts.snap b/generators/spring-data-couchbase/__snapshots__/generator.spec.ts.snap index 18a7866296c5..79ae3b43f30b 100644 --- a/generators/spring-data-couchbase/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-couchbase/__snapshots__/generator.spec.ts.snap @@ -41,9 +41,6 @@ exports[`generator - couchbase gateway-jwt-gradle-enableTranslation(true)-com.my "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -532,9 +529,6 @@ exports[`generator - couchbase microservice-jwt-reactive(false)-maven-enableTran "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -873,9 +867,6 @@ exports[`generator - couchbase microservice-jwt-reactive(true)-gradle-enableTran "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -1226,9 +1217,6 @@ exports[`generator - couchbase microservice-oauth2-reactive(true)-gradle-enableT "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -1546,9 +1534,6 @@ exports[`generator - couchbase monolith-jwt-reactive(false)-maven-enableTranslat "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -2064,9 +2049,6 @@ exports[`generator - couchbase monolith-jwt-reactive(true)-gradle-enableTranslat "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -2417,9 +2399,6 @@ exports[`generator - couchbase monolith-oauth2-reactive(false)-maven-enableTrans "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -2788,9 +2767,6 @@ exports[`generator - couchbase monolith-oauth2-reactive(true)-gradle-enableTrans "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -3150,9 +3126,6 @@ exports[`generator - couchbase monolith-session-reactive(false)-maven-enableTran "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -3635,9 +3608,6 @@ exports[`generator - couchbase monolith-session-reactive(true)-gradle-enableTran "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, diff --git a/generators/spring-data-couchbase/generator.spec.ts b/generators/spring-data-couchbase/generator.spec.ts index d4527e441ae5..fdb3ee4a686e 100644 --- a/generators/spring-data-couchbase/generator.spec.ts +++ b/generators/spring-data-couchbase/generator.spec.ts @@ -33,11 +33,10 @@ import { shouldSupportFeatures, testBlueprintSupport } from '../../test/support/ import { databaseTypes } from '../../jdl/jhipster/index.js'; import { - mockedGenerators as serverGenerators, + filterBasicServerGenerators, shouldComposeWithSpringCloudStream, shouldComposeWithLiquibase, } from '../server/__test-support/index.js'; -import { GENERATOR_SPRING_DATA_COUCHBASE } from '../generator-list.js'; import Generator from './generator.js'; const __filename = fileURLToPath(import.meta.url); @@ -54,8 +53,6 @@ const couchbaseSamples = extendMatrix(buildServerMatrix(), { searchEngine: ['no', 'couchbase'], }); -const mockedGenerators = serverGenerators.filter(generator => generator !== `jhipster:${GENERATOR_SPRING_DATA_COUCHBASE}`); - const testSamples = buildSamplesFromMatrix(couchbaseSamples, { commonConfig }); describe(`generator - ${databaseType}`, () => { @@ -85,7 +82,13 @@ describe(`generator - ${databaseType}`, () => { } before(async () => { - await helpers.run(generatorFile).withJHipsterConfig(sampleConfig, entities).withMockedGenerators(mockedGenerators); + await helpers + .runJHipster('server') + .withJHipsterConfig(sampleConfig, entities) + .withMockedJHipsterGenerators({ + except: ['jhipster:spring-data-couchbase'], + filter: filterBasicServerGenerators, + }); }); it('should match generated files snapshot', () => { diff --git a/generators/spring-data-elasticsearch/__snapshots__/generator.spec.ts.snap b/generators/spring-data-elasticsearch/__snapshots__/generator.spec.ts.snap index d84885ad3a16..fa53fc70234f 100644 --- a/generators/spring-data-elasticsearch/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-elasticsearch/__snapshots__/generator.spec.ts.snap @@ -47,9 +47,6 @@ exports[`generator - elasticsearch gateway-jwt-gradle-enableTranslation(true)-co "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -550,9 +547,6 @@ exports[`generator - elasticsearch microservice-jwt-reactive(false)-maven-enable "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -945,9 +939,6 @@ exports[`generator - elasticsearch microservice-jwt-reactive(true)-gradle-enable "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -972,9 +963,6 @@ exports[`generator - elasticsearch microservice-jwt-reactive(true)-gradle-enable "src/main/java/com/mycompany/config/Constants.java": { "stateCleared": "modified", }, - "src/main/java/com/mycompany/config/DatabaseConfiguration.java": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/config/DateTimeFormatConfiguration.java": { "stateCleared": "modified", }, @@ -1014,12 +1002,6 @@ exports[`generator - elasticsearch microservice-jwt-reactive(true)-gradle-enable "src/main/java/com/mycompany/custom/domain/package-info.java": { "stateCleared": "modified", }, - "src/main/java/com/mycompany/custom/repository/EntityWithCustomIdRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/custom/repository/package-info.java": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/custom/web/rest/EntityWithCustomIdResource.java": { "stateCleared": "modified", }, @@ -1050,18 +1032,6 @@ exports[`generator - elasticsearch microservice-jwt-reactive(true)-gradle-enable "src/main/java/com/mycompany/package-info.java": { "stateCleared": "modified", }, - "src/main/java/com/mycompany/repository/AnotherSimpleRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/repository/MicroserviceRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/repository/SimpleRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/repository/package-info.java": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/security/AuthoritiesConstants.java": { "stateCleared": "modified", }, @@ -1185,18 +1155,9 @@ exports[`generator - elasticsearch microservice-jwt-reactive(true)-gradle-enable "src/test/java/com/mycompany/config/EmbeddedElasticsearch.java": { "stateCleared": "modified", }, - "src/test/java/com/mycompany/config/EmbeddedNeo4j.java": { - "stateCleared": "modified", - }, "src/test/java/com/mycompany/config/JHipsterBlockHoundIntegration.java": { "stateCleared": "modified", }, - "src/test/java/com/mycompany/config/Neo4jTestContainer.java": { - "stateCleared": "modified", - }, - "src/test/java/com/mycompany/config/Neo4jTestContainersSpringContextCustomizerFactory.java": { - "stateCleared": "modified", - }, "src/test/java/com/mycompany/config/SpringBootTestClassOrderer.java": { "stateCleared": "modified", }, @@ -1364,9 +1325,6 @@ exports[`generator - elasticsearch microservice-oauth2-reactive(true)-gradle-ena "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -1720,9 +1678,6 @@ exports[`generator - elasticsearch monolith-jwt-reactive(false)-maven-enableTran "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -2253,9 +2208,6 @@ exports[`generator - elasticsearch monolith-jwt-reactive(true)-gradle-enableTran "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -2651,9 +2603,6 @@ exports[`generator - elasticsearch monolith-oauth2-reactive(false)-maven-enableT "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -3091,9 +3040,6 @@ exports[`generator - elasticsearch monolith-oauth2-reactive(true)-gradle-enableT "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -3118,9 +3064,6 @@ exports[`generator - elasticsearch monolith-oauth2-reactive(true)-gradle-enableT "src/main/java/com/mycompany/config/Constants.java": { "stateCleared": "modified", }, - "src/main/java/com/mycompany/config/DatabaseConfiguration.java": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/config/DateTimeFormatConfiguration.java": { "stateCleared": "modified", }, @@ -3160,12 +3103,6 @@ exports[`generator - elasticsearch monolith-oauth2-reactive(true)-gradle-enableT "src/main/java/com/mycompany/custom/domain/package-info.java": { "stateCleared": "modified", }, - "src/main/java/com/mycompany/custom/repository/EntityWithCustomIdRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/custom/repository/package-info.java": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/custom/repository/search/EntityWithCustomIdSearchRepository.java": { "stateCleared": "modified", }, @@ -3196,18 +3133,6 @@ exports[`generator - elasticsearch monolith-oauth2-reactive(true)-gradle-enableT "src/main/java/com/mycompany/package-info.java": { "stateCleared": "modified", }, - "src/main/java/com/mycompany/repository/AnotherSimpleRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/repository/MicroserviceRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/repository/SimpleRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/repository/package-info.java": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/repository/search/AnotherSimpleSearchRepository.java": { "stateCleared": "modified", }, @@ -3364,18 +3289,9 @@ exports[`generator - elasticsearch monolith-oauth2-reactive(true)-gradle-enableT "src/test/java/com/mycompany/config/EmbeddedElasticsearch.java": { "stateCleared": "modified", }, - "src/test/java/com/mycompany/config/EmbeddedNeo4j.java": { - "stateCleared": "modified", - }, "src/test/java/com/mycompany/config/JHipsterBlockHoundIntegration.java": { "stateCleared": "modified", }, - "src/test/java/com/mycompany/config/Neo4jTestContainer.java": { - "stateCleared": "modified", - }, - "src/test/java/com/mycompany/config/Neo4jTestContainersSpringContextCustomizerFactory.java": { - "stateCleared": "modified", - }, "src/test/java/com/mycompany/config/SpringBootTestClassOrderer.java": { "stateCleared": "modified", }, @@ -3528,9 +3444,6 @@ exports[`generator - elasticsearch monolith-session-reactive(false)-maven-enable "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -4067,9 +3980,6 @@ exports[`generator - elasticsearch monolith-session-reactive(true)-gradle-enable "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -4094,9 +4004,6 @@ exports[`generator - elasticsearch monolith-session-reactive(true)-gradle-enable "src/main/java/com/mycompany/config/Constants.java": { "stateCleared": "modified", }, - "src/main/java/com/mycompany/config/DatabaseConfiguration.java": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/config/DateTimeFormatConfiguration.java": { "stateCleared": "modified", }, @@ -4130,12 +4037,6 @@ exports[`generator - elasticsearch monolith-session-reactive(true)-gradle-enable "src/main/java/com/mycompany/custom/domain/package-info.java": { "stateCleared": "modified", }, - "src/main/java/com/mycompany/custom/repository/EntityWithCustomIdRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/custom/repository/package-info.java": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/custom/repository/search/EntityWithCustomIdSearchRepository.java": { "stateCleared": "modified", }, @@ -4166,18 +4067,6 @@ exports[`generator - elasticsearch monolith-session-reactive(true)-gradle-enable "src/main/java/com/mycompany/package-info.java": { "stateCleared": "modified", }, - "src/main/java/com/mycompany/repository/AnotherSimpleRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/repository/MicroserviceRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/repository/SimpleRepository.java": { - "stateCleared": "modified", - }, - "src/main/java/com/mycompany/repository/package-info.java": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/repository/search/AnotherSimpleSearchRepository.java": { "stateCleared": "modified", }, @@ -4316,18 +4205,9 @@ exports[`generator - elasticsearch monolith-session-reactive(true)-gradle-enable "src/test/java/com/mycompany/config/EmbeddedElasticsearch.java": { "stateCleared": "modified", }, - "src/test/java/com/mycompany/config/EmbeddedNeo4j.java": { - "stateCleared": "modified", - }, "src/test/java/com/mycompany/config/JHipsterBlockHoundIntegration.java": { "stateCleared": "modified", }, - "src/test/java/com/mycompany/config/Neo4jTestContainer.java": { - "stateCleared": "modified", - }, - "src/test/java/com/mycompany/config/Neo4jTestContainersSpringContextCustomizerFactory.java": { - "stateCleared": "modified", - }, "src/test/java/com/mycompany/config/SpringBootTestClassOrderer.java": { "stateCleared": "modified", }, diff --git a/generators/spring-data-elasticsearch/generator.spec.ts b/generators/spring-data-elasticsearch/generator.spec.ts index 216ee8356d5d..f2c65a309f55 100644 --- a/generators/spring-data-elasticsearch/generator.spec.ts +++ b/generators/spring-data-elasticsearch/generator.spec.ts @@ -31,7 +31,7 @@ import { } from '../../testing/index.js'; import { shouldSupportFeatures, testBlueprintSupport } from '../../test/support/tests.js'; import { databaseTypes, searchEngineTypes, authenticationTypes, applicationTypes } from '../../jdl/jhipster/index.js'; -import { mockedGenerators, shouldComposeWithSpringCloudStream } from '../server/__test-support/index.js'; +import { filterBasicServerGenerators, shouldComposeWithSpringCloudStream } from '../server/__test-support/index.js'; import Generator from './generator.js'; import { matchElasticSearch, matchElasticSearchUser } from './__test-support/elastic-search-matcher.js'; @@ -84,7 +84,13 @@ describe('generator - elasticsearch', () => { } before(async () => { - await helpers.run(serverGeneratorFile).withJHipsterConfig(sampleConfig, entities).withMockedGenerators(mockedGenerators); + await helpers + .runJHipster('server') + .withJHipsterConfig(sampleConfig, entities) + .withMockedJHipsterGenerators({ + except: ['jhipster:spring-data-elasticsearch'], + filter: filterBasicServerGenerators, + }); }); it('should compose with jhipster:common', () => { diff --git a/generators/spring-data-mongodb/__snapshots__/generator.spec.ts.snap b/generators/spring-data-mongodb/__snapshots__/generator.spec.ts.snap index a9cd9ccbb51e..a7300810b57c 100644 --- a/generators/spring-data-mongodb/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-mongodb/__snapshots__/generator.spec.ts.snap @@ -41,9 +41,6 @@ exports[`generator - mongodb gateway-jwt-gradle-enableTranslation(true)-com.myco "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -499,9 +496,6 @@ exports[`generator - mongodb microservice-jwt-reactive(false)-maven-enableTransl "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -831,9 +825,6 @@ exports[`generator - mongodb microservice-jwt-reactive(true)-gradle-enableTransl "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -1169,9 +1160,6 @@ exports[`generator - mongodb microservice-oauth2-reactive(true)-gradle-enableTra "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -1474,9 +1462,6 @@ exports[`generator - mongodb monolith-jwt-reactive(false)-maven-enableTranslatio "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -1971,9 +1956,6 @@ exports[`generator - mongodb monolith-jwt-reactive(true)-gradle-enableTranslatio "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -2303,9 +2285,6 @@ exports[`generator - mongodb monolith-oauth2-reactive(false)-maven-enableTransla "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -2665,9 +2644,6 @@ exports[`generator - mongodb monolith-oauth2-reactive(true)-gradle-enableTransla "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -3006,9 +2982,6 @@ exports[`generator - mongodb monolith-session-reactive(false)-maven-enableTransl "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -3470,9 +3443,6 @@ exports[`generator - mongodb monolith-session-reactive(true)-gradle-enableTransl "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, diff --git a/generators/spring-data-mongodb/generator.spec.ts b/generators/spring-data-mongodb/generator.spec.ts index 65ea65d6caec..a8f276b43296 100644 --- a/generators/spring-data-mongodb/generator.spec.ts +++ b/generators/spring-data-mongodb/generator.spec.ts @@ -33,11 +33,10 @@ import Generator from '../server/index.js'; import { databaseTypes } from '../../jdl/jhipster/index.js'; import { - mockedGenerators as serverGenerators, + filterBasicServerGenerators, shouldComposeWithSpringCloudStream, shouldComposeWithLiquibase, } from '../server/__test-support/index.js'; -import { GENERATOR_SPRING_DATA_MONGODB } from '../generator-list.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -49,8 +48,6 @@ const generatorFile = join(__dirname, '../server/index.js'); const { MONGODB: databaseType } = databaseTypes; const commonConfig = { databaseType, baseName: 'jhipster', nativeLanguage: 'en', languages: ['fr', 'en'] }; -const mockedGenerators = serverGenerators.filter(generator => generator !== `jhipster:${GENERATOR_SPRING_DATA_MONGODB}`); - const testSamples = buildSamplesFromMatrix(buildServerMatrix(), { commonConfig }); describe(`generator - ${databaseType}`, () => { @@ -80,7 +77,13 @@ describe(`generator - ${databaseType}`, () => { } before(async () => { - await helpers.run(generatorFile).withJHipsterConfig(sampleConfig, entities).withMockedGenerators(mockedGenerators); + await helpers + .runJHipster('server') + .withJHipsterConfig(sampleConfig, entities) + .withMockedJHipsterGenerators({ + except: ['jhipster:spring-data-mongodb'], + filter: filterBasicServerGenerators, + }); }); it('should match generated files snapshot', () => { diff --git a/generators/spring-data-neo4j/__snapshots__/generator.spec.ts.snap b/generators/spring-data-neo4j/__snapshots__/generator.spec.ts.snap index c0dd3464b836..dcce3f457757 100644 --- a/generators/spring-data-neo4j/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-neo4j/__snapshots__/generator.spec.ts.snap @@ -41,9 +41,6 @@ exports[`generator - neo4j gateway-jwt-gradle-enableTranslation(true)-com.mycomp "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -505,9 +502,6 @@ exports[`generator - neo4j microservice-jwt-reactive(false)-maven-enableTranslat "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -834,9 +828,6 @@ exports[`generator - neo4j microservice-jwt-reactive(true)-gradle-enableTranslat "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -1172,9 +1163,6 @@ exports[`generator - neo4j microservice-oauth2-reactive(true)-gradle-enableTrans "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -1477,9 +1465,6 @@ exports[`generator - neo4j monolith-jwt-reactive(false)-maven-enableTranslation( "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -1977,9 +1962,6 @@ exports[`generator - neo4j monolith-jwt-reactive(true)-gradle-enableTranslation( "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -2309,9 +2291,6 @@ exports[`generator - neo4j monolith-oauth2-reactive(false)-maven-enableTranslati "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -2668,9 +2647,6 @@ exports[`generator - neo4j monolith-oauth2-reactive(true)-gradle-enableTranslati "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -3009,9 +2985,6 @@ exports[`generator - neo4j monolith-session-reactive(false)-maven-enableTranslat "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -3476,9 +3449,6 @@ exports[`generator - neo4j monolith-session-reactive(true)-gradle-enableTranslat "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, diff --git a/generators/spring-data-neo4j/generator.spec.ts b/generators/spring-data-neo4j/generator.spec.ts index f757766a7c28..6db56dfaeeec 100644 --- a/generators/spring-data-neo4j/generator.spec.ts +++ b/generators/spring-data-neo4j/generator.spec.ts @@ -12,7 +12,11 @@ import { shouldSupportFeatures, testBlueprintSupport } from '../../test/support/ import Generator from '../server/index.js'; import { databaseTypes } from '../../jdl/jhipster/index.js'; -import { mockedGenerators, shouldComposeWithSpringCloudStream, shouldComposeWithLiquibase } from '../server/__test-support/index.js'; +import { + filterBasicServerGenerators, + shouldComposeWithSpringCloudStream, + shouldComposeWithLiquibase, +} from '../server/__test-support/index.js'; import { GENERATOR_SERVER } from '../generator-list.js'; const __filename = fileURLToPath(import.meta.url); @@ -52,7 +56,13 @@ describe(`generator - ${databaseType}`, () => { } before(async () => { - await helpers.runJHipster(GENERATOR_SERVER).withJHipsterConfig(sampleConfig, entities).withMockedGenerators(mockedGenerators); + await helpers + .runJHipster('server') + .withJHipsterConfig(sampleConfig, entities) + .withMockedJHipsterGenerators({ + except: ['jhipster:spring-data-neo4j'], + filter: filterBasicServerGenerators, + }); }); it('should match generated files snapshot', () => { diff --git a/generators/spring-data-relational/__snapshots__/generator.spec.ts.snap b/generators/spring-data-relational/__snapshots__/generator.spec.ts.snap index a71796b42a26..63ad9da2cffd 100644 --- a/generators/spring-data-relational/__snapshots__/generator.spec.ts.snap +++ b/generators/spring-data-relational/__snapshots__/generator.spec.ts.snap @@ -35,9 +35,6 @@ exports[`generator - sql gateway-jwt-mysql-gradle-enableTranslation(true)-com.my "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -469,9 +466,6 @@ exports[`generator - sql gateway-jwt-oracle-gradle-enableTranslation(true)-com.m "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -903,9 +897,6 @@ exports[`generator - sql gateway-jwt-postgresql-gradle-enableTranslation(true)-c "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -1328,9 +1319,6 @@ exports[`generator - sql gateway-oauth2-mariadb-gradle-enableTranslation(true)-c "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -1693,9 +1681,6 @@ exports[`generator - sql gateway-oauth2-mssql-gradle-enableTranslation(true)-com "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -2061,9 +2046,6 @@ exports[`generator - sql microservice-jwt-mariadb-reactive(true)-gradle-enableTr "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -2318,9 +2300,6 @@ exports[`generator - sql microservice-jwt-mssql-reactive(true)-gradle-enableTran "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -2569,9 +2548,6 @@ exports[`generator - sql microservice-jwt-mysql-reactive(false)-maven-enableTran "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -2847,9 +2823,6 @@ exports[`generator - sql microservice-jwt-mysql-reactive(true)-gradle-enableTran "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -3095,9 +3068,6 @@ exports[`generator - sql microservice-jwt-oracle-reactive(false)-maven-enableTra "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -3367,9 +3337,6 @@ exports[`generator - sql microservice-jwt-oracle-reactive(true)-gradle-enableTra "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -3603,9 +3570,6 @@ exports[`generator - sql microservice-jwt-postgresql-reactive(false)-maven-enabl "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -3869,9 +3833,6 @@ exports[`generator - sql microservice-jwt-postgresql-reactive(true)-gradle-enabl "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -4120,9 +4081,6 @@ exports[`generator - sql microservice-oauth2-mariadb-reactive(false)-maven-enabl "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -4383,9 +4341,6 @@ exports[`generator - sql microservice-oauth2-mariadb-reactive(true)-gradle-enabl "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -4622,9 +4577,6 @@ exports[`generator - sql microservice-oauth2-mssql-reactive(false)-maven-enableT "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -4882,9 +4834,6 @@ exports[`generator - sql microservice-oauth2-mssql-reactive(true)-gradle-enableT "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -5130,9 +5079,6 @@ exports[`generator - sql microservice-oauth2-mysql-reactive(true)-gradle-enableT "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -5390,9 +5336,6 @@ exports[`generator - sql microservice-oauth2-oracle-reactive(true)-gradle-enable "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -5644,9 +5587,6 @@ exports[`generator - sql microservice-oauth2-postgresql-reactive(true)-gradle-en "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -5874,9 +5814,6 @@ exports[`generator - sql monolith-jwt-mariadb-reactive(false)-maven-enableTransl "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -6305,9 +6242,6 @@ exports[`generator - sql monolith-jwt-mariadb-reactive(true)-gradle-enableTransl "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -6583,9 +6517,6 @@ exports[`generator - sql monolith-jwt-mssql-reactive(false)-maven-enableTranslat "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -7026,9 +6957,6 @@ exports[`generator - sql monolith-jwt-mssql-reactive(true)-gradle-enableTranslat "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -7301,9 +7229,6 @@ exports[`generator - sql monolith-jwt-mysql-reactive(false)-maven-enableTranslat "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -7741,9 +7666,6 @@ exports[`generator - sql monolith-jwt-mysql-reactive(true)-gradle-enableTranslat "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -8007,9 +7929,6 @@ exports[`generator - sql monolith-jwt-oracle-reactive(false)-maven-enableTransla "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -8435,9 +8354,6 @@ exports[`generator - sql monolith-jwt-oracle-reactive(true)-gradle-enableTransla "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -8710,9 +8626,6 @@ exports[`generator - sql monolith-jwt-postgresql-reactive(false)-maven-enableTra "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -9153,9 +9066,6 @@ exports[`generator - sql monolith-jwt-postgresql-reactive(true)-gradle-enableTra "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -9428,9 +9338,6 @@ exports[`generator - sql monolith-oauth2-mariadb-reactive(false)-maven-enableTra "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -9733,9 +9640,6 @@ exports[`generator - sql monolith-oauth2-mariadb-reactive(true)-gradle-enableTra "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -9999,9 +9903,6 @@ exports[`generator - sql monolith-oauth2-mssql-reactive(false)-maven-enableTrans "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -10295,9 +10196,6 @@ exports[`generator - sql monolith-oauth2-mssql-reactive(true)-gradle-enableTrans "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -10573,9 +10471,6 @@ exports[`generator - sql monolith-oauth2-mysql-reactive(false)-maven-enableTrans "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -10881,9 +10776,6 @@ exports[`generator - sql monolith-oauth2-mysql-reactive(true)-gradle-enableTrans "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -11156,9 +11048,6 @@ exports[`generator - sql monolith-oauth2-oracle-reactive(false)-maven-enableTran "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -11458,9 +11347,6 @@ exports[`generator - sql monolith-oauth2-oracle-reactive(true)-gradle-enableTran "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -11721,9 +11607,6 @@ exports[`generator - sql monolith-oauth2-postgresql-reactive(false)-maven-enable "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -12017,9 +11900,6 @@ exports[`generator - sql monolith-oauth2-postgresql-reactive(true)-gradle-enable "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -12295,9 +12175,6 @@ exports[`generator - sql monolith-session-mariadb-reactive(false)-maven-enableTr "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -12702,9 +12579,6 @@ exports[`generator - sql monolith-session-mariadb-reactive(true)-gradle-enableTr "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -12944,9 +12818,6 @@ exports[`generator - sql monolith-session-mssql-reactive(false)-maven-enableTran "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -13351,9 +13222,6 @@ exports[`generator - sql monolith-session-mssql-reactive(true)-gradle-enableTran "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -13593,9 +13461,6 @@ exports[`generator - sql monolith-session-mysql-reactive(false)-maven-enableTran "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -14000,9 +13865,6 @@ exports[`generator - sql monolith-session-mysql-reactive(true)-gradle-enableTran "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -14242,9 +14104,6 @@ exports[`generator - sql monolith-session-oracle-reactive(false)-maven-enableTra "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -14646,9 +14505,6 @@ exports[`generator - sql monolith-session-oracle-reactive(true)-gradle-enableTra "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, @@ -14885,9 +14741,6 @@ exports[`generator - sql monolith-session-postgresql-reactive(false)-maven-enabl "pom.xml": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/tech/jhipster/ApplicationWebXml.java": { "stateCleared": "modified", }, @@ -15292,9 +15145,6 @@ exports[`generator - sql monolith-session-postgresql-reactive(true)-gradle-enabl "settings.gradle": { "stateCleared": "modified", }, - "src/main/docker/jib/entrypoint.sh": { - "stateCleared": "modified", - }, "src/main/java/com/mycompany/GeneratedByJHipster.java": { "stateCleared": "modified", }, diff --git a/generators/spring-data-relational/generator.spec.ts b/generators/spring-data-relational/generator.spec.ts index f21e5379c1d8..2472c3789b23 100644 --- a/generators/spring-data-relational/generator.spec.ts +++ b/generators/spring-data-relational/generator.spec.ts @@ -16,13 +16,11 @@ import Generator from '../server/index.js'; import { databaseTypes, cacheTypes } from '../../jdl/jhipster/index.js'; import { - mockedGenerators as serverGenerators, + filterBasicServerGenerators, shouldComposeWithSpringCloudStream, shouldComposeWithLiquibase, } from '../server/__test-support/index.js'; -import { GENERATOR_SERVER, GENERATOR_SPRING_DATA_RELATIONAL } from '../generator-list.js'; - -const mockedGenerators = serverGenerators.filter(generator => generator !== `jhipster:${GENERATOR_SPRING_DATA_RELATIONAL}`); +import { GENERATOR_SERVER } from '../generator-list.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -92,7 +90,13 @@ describe(`generator - ${databaseType}`, () => { return; } before(async () => { - await helpers.runJHipster(GENERATOR_SERVER).withJHipsterConfig(sampleConfig).withMockedGenerators(mockedGenerators); + await helpers + .runJHipster('server') + .withJHipsterConfig(sampleConfig) + .withMockedJHipsterGenerators({ + except: ['jhipster:spring-data-relational'], + filter: filterBasicServerGenerators, + }); }); it('should compose with jhipster:common', () => { diff --git a/generators/spring-data-relational/sql-entities.spec.ts b/generators/spring-data-relational/sql-entities.spec.ts index bfbbc0f64506..e91f926598a3 100644 --- a/generators/spring-data-relational/sql-entities.spec.ts +++ b/generators/spring-data-relational/sql-entities.spec.ts @@ -8,12 +8,10 @@ import { defaultHelpers as helpers, runResult, } from '../../testing/index.js'; -import { mockedGenerators as serverGenerators } from '../server/__test-support/index.js'; +import { filterBasicServerGenerators } from '../server/__test-support/index.js'; import { databaseTypes, cacheTypes } from '../../jdl/jhipster/index.js'; -import { GENERATOR_SERVER, GENERATOR_SPRING_DATA_RELATIONAL } from '../generator-list.js'; - -const mockedGenerators = serverGenerators.filter(generator => generator !== `jhipster:${GENERATOR_SPRING_DATA_RELATIONAL}`); +import { GENERATOR_SERVER } from '../generator-list.js'; const { SQL: databaseType, H2_DISK, H2_MEMORY, POSTGRESQL, MARIADB, MYSQL, MSSQL, ORACLE } = databaseTypes; const commonConfig = { databaseType, baseName: 'jhipster', nativeLanguage: 'en', languages: ['fr', 'en'] }; @@ -78,7 +76,7 @@ describe(`generator - ${databaseType} - entities`, () => { .runJHipster(GENERATOR_SERVER) .withJHipsterConfig(sampleConfig, entities) .withOptions({ skipPriorities }) - .withMockedGenerators(mockedGenerators); + .withMockedJHipsterGenerators({ except: ['jhipster:spring-data-relational'], filter: filterBasicServerGenerators }); }); it('should compose with jhipster:common', () => { diff --git a/test/support/tests.js b/test/support/tests.js index 6c2b9f3f672e..3ff28ba810f7 100644 --- a/test/support/tests.js +++ b/test/support/tests.js @@ -4,7 +4,6 @@ import { before, it, describe, after, expect } from 'esmocha'; import { buildJHipster } from '../../cli/index.mjs'; import { GENERATOR_JHIPSTER } from '../../generators/generator-constants.js'; import { getGenerator, skipPrettierHelpers as helpers } from '../../testing/index.js'; -import * as GeneratorList from '../../generators/generator-list.js'; import { PRIORITY_NAMES, ENTITY_PRIORITY_NAMES, PRIORITY_NAMES_LIST } from '../../generators/base-application/priorities.js'; import { WORKSPACES_PRIORITY_NAMES } from '../../generators/base-workspaces/priorities.js'; @@ -275,13 +274,8 @@ export const testBlueprintSupport = (generatorName, options = {}) => { before(async () => { result = await helpers .run(generatorPath) - .withMockedGenerators([ - `jhipster-foo:${generatorName}`, - // Mock every generator except the generator been tested - ...Object.values(GeneratorList) - .filter(gen => gen !== generatorName) - .map(gen => `jhipster:${gen}`), - ]) + .withMockedJHipsterGenerators({ filter: () => true }) + .withMockedGenerators([`jhipster-foo:${generatorName}`]) .withJHipsterConfig() .withOptions({ blueprint: 'foo' }) .onGenerator(generator => { @@ -307,13 +301,8 @@ export const testBlueprintSupport = (generatorName, options = {}) => { } const context = helpers .run(generatorPath) - .withMockedGenerators([ - `jhipster-foo-sbs:${generatorName}`, - // Mock every generator except the generator been tested and bootstrap- generators - ...Object.values(GeneratorList) - .filter(gen => gen !== generatorName && !gen.startsWith('bootstrap-')) - .map(gen => `jhipster:${gen}`), - ]) + .withMockedJHipsterGenerators({ filter: () => true }) + .withMockedGenerators([`jhipster-foo-sbs:${generatorName}`]) .withJHipsterConfig( {}, entity diff --git a/testing/helpers.ts b/testing/helpers.ts index 37704562d087..1b2b4705fccc 100644 --- a/testing/helpers.ts +++ b/testing/helpers.ts @@ -1,8 +1,8 @@ /* eslint-disable max-classes-per-file */ import { basename, dirname, join } from 'path'; import { fileURLToPath } from 'url'; +import { merge, set, snakeCase } from 'lodash-es'; import { YeomanTest, RunContext, RunContextSettings, RunResult, result } from 'yeoman-test'; -import { merge, set } from 'lodash-es'; import { globSync } from 'glob'; import type { BaseEnvironmentOptions, GetGeneratorConstructor, BaseGenerator as YeomanGenerator } from '@yeoman/types'; @@ -42,13 +42,16 @@ const DEFAULT_TEST_OPTIONS = { skipInstall: true }; const DEFAULT_TEST_ENV_OPTIONS = { skipInstall: true, dryRun: false }; const generatorsDir = join(fileURLToPath(import.meta.url), '../../generators'); -const mockedGenerators = [ +const allGenerators = [ ...globSync('*/index.{j,t}s', { cwd: generatorsDir, posix: true }).map(file => dirname(file)), ...globSync('*/generators/*/index.{j,t}s', { cwd: generatorsDir, posix: true }).map(file => dirname(file).replace('/generators/', ':')), ] - .filter(gen => !gen.startsWith('bootstrap-')) .map(gen => `jhipster:${gen}`) .sort(); +const filterBootstrapGenerators = (gen: string): boolean => !gen.startsWith('jhipster:bootstrap-'); +const composedGeneratorsToCheck = allGenerators + .filter(filterBootstrapGenerators) + .filter(gen => !['jhipster:bootstrap', 'jhipster:project-name'].includes(gen)); const defaultSharedApplication = Object.fromEntries(['CLIENT_WEBPACK_DIR'].map(key => [key, undefined])); @@ -246,17 +249,30 @@ class JHipsterRunContext extends RunContext { return this.withSharedData({ sharedApplication: this.sharedApplication }); } + withMockedNodeDependencies() { + return this.withSharedApplication({ + nodeDependencies: new Proxy({}, { get: (_target, prop) => `${snakeCase(prop.toString()).toUpperCase()}_VERSION` }), + }); + } + /** - * Mock every built-in generators except the ones in the exceptList and bootstrap-* generators. + * Mock every built-in generators except the ones in the except and bootstrap-* generators. * Note: Boostrap generator is mocked by default. * @example - * withMockedJHipsterGenerators(['jhipster:bootstrap']) + * withMockedJHipsterGenerators({ except: ['jhipster:bootstrap'] }) * @example - * withMockedJHipsterGenerators(['bootstrap', 'server']) + * withMockedJHipsterGenerators({ except: ['bootstrap', 'server'] }) + * @example + * // Mock every generator including bootstrap-* + * withMockedJHipsterGenerators({ filter: () => true }) */ - withMockedJHipsterGenerators(exceptList: string[] = []): this { - exceptList = exceptList.map(gen => (gen.startsWith('jhipster:') ? gen : `jhipster:${gen}`)); - return this.withMockedGenerators(mockedGenerators.filter(gen => !exceptList.includes(gen) && (this as any).Generator !== gen)); + withMockedJHipsterGenerators(options: string[] | { except?: string[]; filter?: (string) => boolean } = {}): this { + const optionsObj = Array.isArray(options) ? { except: options } : options; + const { except = [], filter = filterBootstrapGenerators } = optionsObj; + const jhipsterExceptList = except.map(gen => (gen.startsWith('jhipster:') ? gen : `jhipster:${gen}`)); + return this.withMockedGenerators( + allGenerators.filter(filter).filter(gen => !jhipsterExceptList.includes(gen) && (this as any).Generator !== gen), + ); } withGradleBuildTool(): this { @@ -306,9 +322,7 @@ plugins { runResult.sourceCallsArg = sourceCallsArg; } - runResult.composedMockedGenerators = mockedGenerators.filter( - gen => runResult.mockedGenerators[gen]?.called && !['jhipster:bootstrap', 'jhipster:project-name'].includes(gen), - ); + runResult.composedMockedGenerators = composedGeneratorsToCheck.filter(gen => runResult.mockedGenerators[gen]?.called); return runResult as any; } diff --git a/testing/support/matrix-utils.ts b/testing/support/matrix-utils.ts index aef5cf1b4dd0..a99689dbc571 100644 --- a/testing/support/matrix-utils.ts +++ b/testing/support/matrix-utils.ts @@ -7,6 +7,17 @@ const appendTitle = (title: string, config: string, value: boolean | string | nu return `${title}${title.length === 0 ? '' : '-'}${newTitle}`; }; +/** + * Create a matrix from a options + * @example + * const matrix = fromMatrix({ a: [true, false], b: [true, false] }); + * // { + * // 'a(true)-b(true)': { a: true, b: true }, + * // 'a(true)-b(false)': { a: true, b: false }, + * // 'a(false)-b(true)': { a: false, b: true }, + * // 'a(false)-b(false)': { a: false, b: false }, + * // } + */ export const fromMatrix = (configMatrix: Record) => { const configEntries = Object.entries(configMatrix); const samples = configEntries.reduce( @@ -67,6 +78,15 @@ const applyExtendedMatrix = (matrixEntries, configMatrix) => { return matrixEntries; }; +/** + * Apply new matrix value to existing matrix + * @example + * const matrix = extendMatrix(fromMatrix({ initialMatrix: [true, false] }), { toBeMerged: [true, false] }); + * // { + * // 'initialMatrix(true)-toBeMerged(true)': { initialMatrix: true, toBeMerged: true }, + * // 'initialMatrix(false)-toBeMerged(false)': { initialMatrix: false, toBeMerged: false }, + * // } + */ export const extendMatrix = (matrix, configMatrix) => { return Object.fromEntries(applyExtendedMatrix(Object.entries(matrix), configMatrix)); };