From 5a6113906fb07710cea46536cd6bcffda2a61045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Mon, 16 Sep 2024 22:32:27 +0200 Subject: [PATCH 1/7] Apply module: approval-tests --- pom.xml | 7 +++++++ src/test/java/tech/jhipster/lite/PackageSettings.java | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/test/java/tech/jhipster/lite/PackageSettings.java diff --git a/pom.xml b/pom.xml index 32546d8a011..49f6b6e748b 100644 --- a/pom.xml +++ b/pom.xml @@ -82,6 +82,7 @@ 1.15.0 1.11 3.1.0 + 24.4.0 @@ -256,6 +257,12 @@ mongodb test + + com.approvaltests + approvaltests + ${approvaltests.version} + test + diff --git a/src/test/java/tech/jhipster/lite/PackageSettings.java b/src/test/java/tech/jhipster/lite/PackageSettings.java new file mode 100644 index 00000000000..4b381276ec2 --- /dev/null +++ b/src/test/java/tech/jhipster/lite/PackageSettings.java @@ -0,0 +1,9 @@ +package tech.jhipster.lite; + +/** + * ApprovalTests.Java configuration. + * */ +public class PackageSettings { + + private static final String ApprovalBaseDirectory = "../resources"; +} From c416ae6b6eb5a9116c15435eeae52794aae2cce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Mon, 16 Sep 2024 23:10:20 +0200 Subject: [PATCH 2/7] feat(module-assertions): add the ability to check file content against a saved snapshot in module tests --- .../secondary/JHipsterModulesAssertions.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java index cb33baf5c79..b2ded593ed6 100644 --- a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java +++ b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java @@ -12,6 +12,7 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.approvaltests.Approvals; import org.assertj.core.api.SoftAssertions; import tech.jhipster.lite.module.domain.JHipsterModule; import tech.jhipster.lite.module.domain.JHipsterModuleUpgrade; @@ -332,6 +333,13 @@ private void assertFileExists() { assertThat(Files.exists(path)).as(fileNotFoundMessage(path, projectFolder)).isTrue(); } + public JHipsterModuleFileAsserter matchingSavedSnapshot() { + String shortFileName = Arrays.stream(file.split("/")).toList().getLast(); + Approvals.verify(contentNormalizingNewLines(projectFolder.filePath(file)), Approvals.NAMES.withParameters(shortFileName)); + + return this; + } + public JHipsterModuleFileAsserter containing(String content) { assertThat(content).as("Can't check blank content").isNotBlank(); From d63447ae27be2ffcd0262cd99f21fd3a623928f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Mon, 16 Sep 2024 23:11:28 +0200 Subject: [PATCH 3/7] test: add some snapshot tests --- .../core/domain/VueModulesFactoryTest.java | 3 + ...leSystemJHipsterModulesRepositoryTest.java | 9 +- ...ateVueModule.eslint.config.js.approved.txt | 39 +++ ...CreateVueModule.tsconfig.json.approved.txt | 13 + ...ateVueModule.vitest.config.ts.approved.txt | 50 ++++ ...radleProject.build.gradle.kts.approved.txt | 109 ++++++++ ...dleProject.libs.versions.toml.approved.txt | 69 +++++ ...eToGradleProject.package.json.approved.txt | 25 ++ ...yModuleToMavenProject.pom.xml.approved.txt | 259 +++++++++++++++++ ...ModulesToMavenProject.pom.xml.approved.txt | 260 ++++++++++++++++++ 10 files changed, 832 insertions(+), 4 deletions(-) create mode 100644 src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.eslint.config.js.approved.txt create mode 100644 src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.tsconfig.json.approved.txt create mode 100644 src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.vitest.config.ts.approved.txt create mode 100644 src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.build.gradle.kts.approved.txt create mode 100644 src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.libs.versions.toml.approved.txt create mode 100644 src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.package.json.approved.txt create mode 100644 src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.pom.xml.approved.txt create mode 100644 src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyTwoModulesToMavenProject.pom.xml.approved.txt diff --git a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java index 4aa78c54eff..8b8bee8fa51 100644 --- a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java @@ -62,12 +62,14 @@ void shouldCreateVueModule() { .and() .hasPrefixedFiles("", "eslint.config.js", "tsconfig.build.json", "vite.config.ts", "vitest.config.ts") .hasFile("tsconfig.json") + .matchingSavedSnapshot() .containing("\"extends\": \"@vue/tsconfig/tsconfig.dom.json\"") .containing("\"allowJs\": true,") .containing("\"sourceMap\": true,") .containing("\"types\": [\"vite/client\", ") .and() .hasFile("vitest.config.ts") + .matchingSavedSnapshot() .containing("import vue from '@vitejs/plugin-vue';") .containing("plugins: [vue(), tsconfigPaths()],") .containing("environment: 'jsdom',") @@ -82,6 +84,7 @@ void shouldCreateVueModule() { ) .and() .hasFile("eslint.config.js") + .matchingSavedSnapshot() .containing("import vue from 'eslint-plugin-vue';") .containing(""" ...vue.configs['flat/recommended'], diff --git a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java index cf3d18c16da..4ab065a5f84 100644 --- a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java +++ b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java @@ -6,10 +6,7 @@ import ch.qos.logback.classic.Level; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import tech.jhipster.lite.Logs; -import tech.jhipster.lite.LogsSpy; -import tech.jhipster.lite.LogsSpyExtension; -import tech.jhipster.lite.UnitTest; +import tech.jhipster.lite.*; import tech.jhipster.lite.module.domain.JHipsterModule; @UnitTest @@ -81,6 +78,7 @@ void shouldApplyModuleToMavenProject() { .containing("com.test.myapp") .and() .hasFile("pom.xml") + .matchingSavedSnapshot() .containing("local") .notContaining( """ @@ -470,12 +468,14 @@ void shouldApplyModuleToGradleProject() { .containing("com.test.myapp") .and() .hasFile("gradle/libs.versions.toml") + .matchingSavedSnapshot() .containing("spring-boot = \"") .containing("json-web-token = \"") .containing("cassandraunit = \"") .containing("git-properties = \"") .and() .hasFile("build.gradle.kts") + .matchingSavedSnapshot() .notContaining("implementation(libs.logstash.logback.encoder)") .notContaining("implementation(libs.springdoc.openapi.ui)") .containing("implementation(platform(libs.spring.boot.dependencies))") @@ -603,6 +603,7 @@ val springProfilesActive by extra("local") ) .and() .hasFile("package.json") + .matchingSavedSnapshot() .containing(" \"jestSonar\": {\n \"reportPath\": \"build/test-results\",\n \"reportFile\": \"TESTS-results-sonar.xml\"\n }") .containing( """ diff --git a/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.eslint.config.js.approved.txt b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.eslint.config.js.approved.txt new file mode 100644 index 00000000000..9608b0fe025 --- /dev/null +++ b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.eslint.config.js.approved.txt @@ -0,0 +1,39 @@ +import js from '@eslint/js'; +import globals from 'globals'; +import typescript from 'typescript-eslint'; +import vue from 'eslint-plugin-vue'; + +export default typescript.config( + { + languageOptions: { + globals: { + ...globals.node, + }, + }, + }, + { + ignores: ['target/'], + }, + js.configs.recommended, + ...typescript.configs.recommended.map(config => (config.name === 'typescript-eslint/base' ? config : { ...config, files: ['**/*.ts'] })), + ...vue.configs['flat/recommended'], + { + files: ['**/*.vue'], + languageOptions: { + parserOptions: { parser: '@typescript-eslint/parser' }, + globals: { ...globals.browser }, + }, + }, + { + files: ['src/*/webapp/**/*.vue', 'src/*/webapp/**/*.ts'], + languageOptions: { + globals: { ...globals.browser }, + }, + rules: { + quotes: ['error', 'single', { avoidEscape: true }], + '@typescript-eslint/no-empty-object-type': 'off', + '@typescript-eslint/no-explicit-any': 'off', + 'vue/html-self-closing': 'off', + }, + }, +); diff --git a/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.tsconfig.json.approved.txt b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.tsconfig.json.approved.txt new file mode 100644 index 00000000000..6bef65ee0e8 --- /dev/null +++ b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.tsconfig.json.approved.txt @@ -0,0 +1,13 @@ +{ + "extends": "@vue/tsconfig/tsconfig.dom.json", + "compilerOptions": { + "allowJs": true, + "sourceMap": true, + "types": ["vite/client", "vitest/globals"], + "baseUrl": ".", + "paths": { + "@/*": ["src/main/webapp/app/*"] + } + }, + "include": ["src/main/webapp/**/*", "src/test/webapp/unit/**/*"] +} diff --git a/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.vitest.config.ts.approved.txt b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.vitest.config.ts.approved.txt new file mode 100644 index 00000000000..d66cc33dce1 --- /dev/null +++ b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.vitest.config.ts.approved.txt @@ -0,0 +1,50 @@ +/// + +import tsconfigPaths from 'vite-tsconfig-paths'; +import { defineConfig, configDefaults } from 'vitest/config'; +import vue from '@vitejs/plugin-vue'; + +export default defineConfig({ + plugins: [vue(), tsconfigPaths()], + test: { + reporters: ['verbose', 'vitest-sonar-reporter'], + outputFile: { + 'vitest-sonar-reporter': 'target/test-results/TESTS-results-sonar.xml', + }, + globals: true, + logHeapUsage: true, + poolOptions: { + threads: { + minThreads: 1, + maxThreads: 2, + }, + }, + environment: 'jsdom', + cache: false, + include: ['src/test/webapp/unit/**/*.{test,spec}.?(c|m)[jt]s?(x)'], + coverage: { + thresholds: { + perFile: true, + autoUpdate: true, + 100: true, + }, + include: ['src/main/webapp/**/*.ts?(x)'], + exclude: [ + ...configDefaults.coverage.exclude as string[], + 'src/main/webapp/app/main.ts', + 'src/main/webapp/app/injections.ts', + 'src/main/webapp/app/router.ts', + 'src/main/webapp/**/*.component.ts', + ], + provider: 'istanbul', + reportsDirectory: 'target/test-results/', + reporter: ['html', 'json-summary', 'text', 'text-summary', 'lcov', 'clover'], + watermarks: { + statements: [100, 100], + branches: [100, 100], + functions: [100, 100], + lines: [100, 100], + }, + }, + }, +}); diff --git a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.build.gradle.kts.approved.txt b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.build.gradle.kts.approved.txt new file mode 100644 index 00000000000..ee3b40e7995 --- /dev/null +++ b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.build.gradle.kts.approved.txt @@ -0,0 +1,109 @@ +import java.util.Properties +// jhipster-needle-gradle-imports + +plugins { + java + jacoco + checkstyle + // jhipster-needle-gradle-plugins +} + +val springProfilesActive by extra("local") +// jhipster-needle-gradle-properties + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + + +jacoco { + toolVersion = libs.versions.jacoco.get() +} + +tasks.jacocoTestReport { + dependsOn("test", "integrationTest") + reports { + xml.required.set(true) + html.required.set(false) + } + executionData.setFrom(fileTree(buildDir).include("**/jacoco/test.exec", "**/jacoco/integrationTest.exec")) +} + + +checkstyle { + toolVersion = libs.versions.checkstyle.get() +} + +// jhipster-needle-gradle-plugins-configurations + +repositories { + mavenCentral() + // jhipster-needle-gradle-repositories +} + +group = "tech.jhipster.jhlitest" +version = "0.0.1-SNAPSHOT" + +val profiles = (project.findProperty("profiles") as String? ?: "") + .split(",") + .map { it.trim() } + .filter { it.isNotEmpty() } +if (profiles.contains("local")) { + apply(plugin = "profile-local") +} +// jhipster-needle-profile-activation + +dependencies { + implementation(platform(libs.spring.boot.dependencies)) + implementation(libs.spring.boot.starter) + implementation(libs.jjwt.api) + implementation(libs.spring.boot.starter.web) { + exclude(group = "org.springframework.boot", module = "spring-boot-starter-tomcat") + } + // jhipster-needle-gradle-implementation-dependencies + // jhipster-needle-gradle-compile-dependencies + // jhipster-needle-gradle-runtime-dependencies + testImplementation(libs.commons.lang3) + testImplementation(libs.reflections) + testImplementation(libs.junit.jupiter.engine) + // jhipster-needle-gradle-test-dependencies +} + + +tasks.build { + dependsOn("processResources") +} + +tasks.processResources { + filesMatching("**/*.yml", "**/*.properties") { + filter { + it.replace("@spring.profiles.active@", springProfilesActive) + } + } +} + +// jhipster-needle-gradle-free-configuration-blocks + +tasks.test { + filter { + includeTestsMatching("**Test*") + excludeTestsMatching("**IT*") + excludeTestsMatching("**CucumberTest*") + } + useJUnitPlatform() + finalizedBy("jacocoTestReport") + // jhipster-needle-gradle-tasks-test +} + +val integrationTest = task("integrationTest") { + description = "Runs integration tests." + group = "verification" + shouldRunAfter("test") + filter { + includeTestsMatching("**IT*") + includeTestsMatching("**CucumberTest*") + } + useJUnitPlatform() +} diff --git a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.libs.versions.toml.approved.txt b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.libs.versions.toml.approved.txt new file mode 100644 index 00000000000..841ba9d96f1 --- /dev/null +++ b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.libs.versions.toml.approved.txt @@ -0,0 +1,69 @@ +plugins = {} +bundles = {} + +[versions] + json-web-token = "0.12.6" + reflections = "0.10.2" + cassandraunit = "4.3.1.0" + git-properties = "2.4.2" + jacoco = "0.8.11" + spring-boot = "3.3.3" + commons-lang3 = "3.17.0" + checkstyle = "10.18.1" + + [libraries.jjwt-api] + name = "jjwt-api" + group = "io.jsonwebtoken" + + [libraries.jjwt-api.version] + ref = "json-web-token" + + [libraries.junit-jupiter-engine] + name = "junit-jupiter-engine" + group = "org.junit.jupiter" + + [libraries.junit-jupiter-engine.version] + ref = "spring-boot" + + [libraries.spring-boot-starter] + name = "spring-boot-starter" + group = "org.springframework.boot" + + [libraries.spring-boot-starter-web] + name = "spring-boot-starter-web" + group = "org.springframework.boot" + + [libraries.reflections] + name = "reflections" + group = "org.reflections" + + [libraries.reflections.version] + ref = "reflections" + + [libraries.spring-boot-dependencies] + name = "spring-boot-dependencies" + group = "org.springframework.boot" + + [libraries.spring-boot-dependencies.version] + ref = "spring-boot" + + [libraries.commons-lang3] + name = "commons-lang3" + group = "org.apache.commons" + + [libraries.commons-lang3.version] + ref = "commons-lang3" + + [libraries.cassandra-unit] + name = "cassandra-unit" + group = "org.cassandraunit" + + [libraries.cassandra-unit.version] + ref = "cassandraunit" + + [libraries.gradle-git-properties] + name = "gradle-git-properties" + group = "com.gorylenko.gradle-git-properties" + + [libraries.gradle-git-properties.version] + ref = "git-properties" diff --git a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.package.json.approved.txt b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.package.json.approved.txt new file mode 100644 index 00000000000..eb73a7317da --- /dev/null +++ b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.package.json.approved.txt @@ -0,0 +1,25 @@ +{ + "name": "test-jhipster-project", + "version": "0.0.0", + "private": true, + "description": "JHipster Project", + "license": "UNLICENSED", + "jestSonar": { + "reportPath": "build/test-results", + "reportFile": "TESTS-results-sonar.xml" + }, + + "engines": { + "node": ">=16.13.0" + }, + "scripts": { + "build": "ng build --output-path=build/classes/static", + "serve": "tikui-core serve" + }, + "devDependencies": { + "@playwright/test": "1.47.0" + }, + "dependencies": { + "@angular/animations": "18.2.4" + } +} diff --git a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.pom.xml.approved.txt b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.pom.xml.approved.txt new file mode 100644 index 00000000000..ee73315d79b --- /dev/null +++ b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.pom.xml.approved.txt @@ -0,0 +1,259 @@ + + + 4.0.0 + + jhlite-test-maven-project + 0.0.1 + Test project + pom + + + 0.12.6 + 7.2 + 3.3.3 + 3.17.0 + 0.10.2 + 3.5.0 + local + 4.3.1.0 + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + import + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + test + + + + + + + io.jsonwebtoken + jjwt-api + ${json-web-token.version} + classif + test + true + + + org.reflections + reflections + ${reflections.version} + test + + + org.springframework.boot + spring-boot-starter + + + io.jsonwebtoken + jjwt-api + ${json-web-token.version} + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + org.junit.jupiter + junit-jupiter-engine + ${spring-boot.version} + test + test + true + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + maven-enforcer-plugin + + + org.asciidoctor + asciidoctor-maven-plugin + + + org.asciidoctor + asciidoctorj-screenshot + + + org.asciidoctor + asciidoctorj-diagram + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + repackage + + + + + ${start-class} + + + + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + enforce-versions + + enforce + + + + enforce-dependencyConvergence + + enforce + + + + + + false + + + + + + io.jsonwebtoken + jjwt-jackson + ${json-web-token.version} + + + com.fasterxml.jackson.core + jackson-databind + + + + + + + + You are running an older version of Maven. JHipster requires at least Maven ${maven.version} + [${maven.version},) + + + You are running an incompatible version of Java. JHipster engine supports JDK 21+. + [21,22) + + + + + + + + + + local + + + + + + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + enforce-versions + + enforce + + + + enforce-dependencyConvergence + + enforce + + + + + + false + + + + + + io.jsonwebtoken + jjwt-jackson + ${json-web-token.version} + + + com.fasterxml.jackson.core + jackson-databind + + + + + + + + You are running an older version of Maven. JHipster requires at least Maven ${maven.version} + [${maven.version},) + + + You are running an incompatible version of Java. JHipster engine supports JDK 21+. + [21,22) + + + + + + + + + maven-enforcer-plugin + + + + + local + + + + org.cassandraunit + cassandra-unit + ${cassandraunit.version} + test + + + + + diff --git a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyTwoModulesToMavenProject.pom.xml.approved.txt b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyTwoModulesToMavenProject.pom.xml.approved.txt new file mode 100644 index 00000000000..64efb63606b --- /dev/null +++ b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyTwoModulesToMavenProject.pom.xml.approved.txt @@ -0,0 +1,260 @@ + + + 4.0.0 + + jhlite-test-maven-project + 0.0.1 + Test project + pom + + + 0.12.6 + 7.2 + 3.3.3 + + + 3.5.0 + local + 4.3.1.0 + 3.17.0 + 0.10.2 + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + import + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + import + + + + + + + io.jsonwebtoken + jjwt-api + ${json-web-token.version} + classif + test + true + + + org.springframework.boot + spring-boot-starter + + + io.jsonwebtoken + jjwt-api + ${json-web-token.version} + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + org.reflections + reflections + ${reflections.version} + + + org.junit.jupiter + junit-jupiter-engine + ${spring-boot.version} + test + test + true + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + maven-enforcer-plugin + + + org.asciidoctor + asciidoctor-maven-plugin + + + org.asciidoctor + asciidoctorj-screenshot + + + org.asciidoctor + asciidoctorj-diagram + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + repackage + + + + + ${start-class} + + + + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + enforce-versions + + enforce + + + + enforce-dependencyConvergence + + enforce + + + + + + false + + + + + + io.jsonwebtoken + jjwt-jackson + ${json-web-token.version} + + + com.fasterxml.jackson.core + jackson-databind + + + + + + + + You are running an older version of Maven. JHipster requires at least Maven ${maven.version} + [${maven.version},) + + + You are running an incompatible version of Java. JHipster engine supports JDK 21+. + [21,22) + + + + + + + + + + local + + + + + + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + enforce-versions + + enforce + + + + enforce-dependencyConvergence + + enforce + + + + + + false + + + + + + io.jsonwebtoken + jjwt-jackson + ${json-web-token.version} + + + com.fasterxml.jackson.core + jackson-databind + + + + + + + + You are running an older version of Maven. JHipster requires at least Maven ${maven.version} + [${maven.version},) + + + You are running an incompatible version of Java. JHipster engine supports JDK 21+. + [21,22) + + + + + + + + + maven-enforcer-plugin + + + + + local + + + + org.cassandraunit + cassandra-unit + ${cassandraunit.version} + test + + + + + From de991c90ffb05adb2a9b9cc5a5524d91781efc75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Tue, 17 Sep 2024 10:02:19 +0200 Subject: [PATCH 4/7] test(snapshot-testing): configure ApprovalTests scrubbers to ignore dependencies versions --- ...leSystemJHipsterModulesRepositoryTest.java | 1 + .../secondary/JHipsterModulesAssertions.java | 32 ++++++++++++++++++- ...dleProject.libs.versions.toml.approved.txt | 16 +++++----- ...eToGradleProject.package.json.approved.txt | 6 ++-- ...leToMavenProject.package.json.approved.txt | 25 +++++++++++++++ ...yModuleToMavenProject.pom.xml.approved.txt | 18 +++++------ 6 files changed, 77 insertions(+), 21 deletions(-) create mode 100644 src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.package.json.approved.txt diff --git a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java index 4ab065a5f84..153cea9065e 100644 --- a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java +++ b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java @@ -352,6 +352,7 @@ void shouldApplyModuleToMavenProject() { ) .and() .hasFile("package.json") + .matchingSavedSnapshot() .containing(" \"jestSonar\": {\n \"reportPath\": \"target/test-results\",\n \"reportFile\": \"TESTS-results-sonar.xml\"\n }") .containing( """ diff --git a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java index b2ded593ed6..53058efacc8 100644 --- a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java +++ b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java @@ -13,6 +13,11 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.approvaltests.Approvals; +import org.approvaltests.core.ApprovalFailureReporter; +import org.approvaltests.core.Scrubber; +import org.approvaltests.reporters.*; +import org.approvaltests.scrubbers.NoOpScrubber; +import org.approvaltests.scrubbers.RegExScrubber; import org.assertj.core.api.SoftAssertions; import tech.jhipster.lite.module.domain.JHipsterModule; import tech.jhipster.lite.module.domain.JHipsterModuleUpgrade; @@ -335,11 +340,36 @@ private void assertFileExists() { public JHipsterModuleFileAsserter matchingSavedSnapshot() { String shortFileName = Arrays.stream(file.split("/")).toList().getLast(); - Approvals.verify(contentNormalizingNewLines(projectFolder.filePath(file)), Approvals.NAMES.withParameters(shortFileName)); + ApprovalFailureReporter reporter = new FirstWorkingReporter(new AutoApproveWhenEmptyReporter(), new DiffReporter()); + Approvals.verify( + contentNormalizingNewLines(projectFolder.filePath(file)), + Approvals.NAMES.withParameters(shortFileName).withScrubber(scrubberFor(file)).addReporter(reporter) + ); return this; } + private Scrubber scrubberFor(String file) { + return switch (file) { + case "pom.xml" -> mavenVersionScrubber(); + case "package.json" -> npmVersionScrubber(); + case "gradle/libs.versions.toml" -> gradleCatalogVersionScrubber(); + default -> NoOpScrubber.INSTANCE; + }; + } + + private Scrubber npmVersionScrubber() { + return new RegExScrubber("\": \"[^~]?(\\d+\\.?)+\"", "\": \"[version]\""); + } + + private Scrubber mavenVersionScrubber() { + return new RegExScrubber(">(\\d+\\.?)+[version] containing(String content) { assertThat(content).as("Can't check blank content").isNotBlank(); diff --git a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.libs.versions.toml.approved.txt b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.libs.versions.toml.approved.txt index 841ba9d96f1..4b30db6010d 100644 --- a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.libs.versions.toml.approved.txt +++ b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.libs.versions.toml.approved.txt @@ -2,14 +2,14 @@ plugins = {} bundles = {} [versions] - json-web-token = "0.12.6" - reflections = "0.10.2" - cassandraunit = "4.3.1.0" - git-properties = "2.4.2" - jacoco = "0.8.11" - spring-boot = "3.3.3" - commons-lang3 = "3.17.0" - checkstyle = "10.18.1" + json-web-token = "[version]" + reflections = "[version]" + cassandraunit = "[version]" + git-properties = "[version]" + jacoco = "[version]" + spring-boot = "[version]" + commons-lang3 = "[version]" + checkstyle = "[version]" [libraries.jjwt-api] name = "jjwt-api" diff --git a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.package.json.approved.txt b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.package.json.approved.txt index eb73a7317da..f0984d20573 100644 --- a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.package.json.approved.txt +++ b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToGradleProject.package.json.approved.txt @@ -1,6 +1,6 @@ { "name": "test-jhipster-project", - "version": "0.0.0", + "version": "[version]", "private": true, "description": "JHipster Project", "license": "UNLICENSED", @@ -17,9 +17,9 @@ "serve": "tikui-core serve" }, "devDependencies": { - "@playwright/test": "1.47.0" + "@playwright/test": "[version]" }, "dependencies": { - "@angular/animations": "18.2.4" + "@angular/animations": "[version]" } } diff --git a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.package.json.approved.txt b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.package.json.approved.txt new file mode 100644 index 00000000000..02545080cf9 --- /dev/null +++ b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.package.json.approved.txt @@ -0,0 +1,25 @@ +{ + "name": "test-jhipster-project", + "version": "[version]", + "private": true, + "description": "JHipster Project", + "license": "UNLICENSED", + "jestSonar": { + "reportPath": "target/test-results", + "reportFile": "TESTS-results-sonar.xml" + }, + + "engines": { + "node": ">=16.13.0" + }, + "scripts": { + "build": "ng build --output-path=target/classes/static", + "serve": "tikui-core serve" + }, + "devDependencies": { + "@playwright/test": "[version]" + }, + "dependencies": { + "@angular/animations": "[version]" + } +} diff --git a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.pom.xml.approved.txt b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.pom.xml.approved.txt index ee73315d79b..197f8bae4cd 100644 --- a/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.pom.xml.approved.txt +++ b/src/test/resources/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.shouldApplyModuleToMavenProject.pom.xml.approved.txt @@ -1,21 +1,21 @@ - 4.0.0 + [version] jhlite-test-maven-project - 0.0.1 + [version] Test project pom - 0.12.6 - 7.2 - 3.3.3 - 3.17.0 - 0.10.2 - 3.5.0 + [version] + [version] + [version] + [version] + [version] + [version] local - 4.3.1.0 + [version] From aeffff190635939ca4381e785a0410147b9d3eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Tue, 17 Sep 2024 10:45:23 +0200 Subject: [PATCH 5/7] docs: document matchingSavedSnapshot() method --- .../infrastructure/secondary/JHipsterModulesAssertions.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java index 53058efacc8..eb376f5a3d2 100644 --- a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java +++ b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java @@ -338,6 +338,9 @@ private void assertFileExists() { assertThat(Files.exists(path)).as(fileNotFoundMessage(path, projectFolder)).isTrue(); } + /** + * Verifies that the file content matches the saved snapshot, using ApprovalTests. + */ public JHipsterModuleFileAsserter matchingSavedSnapshot() { String shortFileName = Arrays.stream(file.split("/")).toList().getLast(); ApprovalFailureReporter reporter = new FirstWorkingReporter(new AutoApproveWhenEmptyReporter(), new DiffReporter()); From abcfa2a0c30766e5eca0b7e67991937a12633799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Tue, 17 Sep 2024 10:46:57 +0200 Subject: [PATCH 6/7] chore: make ApprovalTests reporter configuration global --- src/test/java/tech/jhipster/lite/PackageSettings.java | 7 +++++++ .../secondary/JHipsterModulesAssertions.java | 5 +---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/test/java/tech/jhipster/lite/PackageSettings.java b/src/test/java/tech/jhipster/lite/PackageSettings.java index 4b381276ec2..5b4a4654079 100644 --- a/src/test/java/tech/jhipster/lite/PackageSettings.java +++ b/src/test/java/tech/jhipster/lite/PackageSettings.java @@ -1,9 +1,16 @@ package tech.jhipster.lite; +import org.approvaltests.core.ApprovalFailureReporter; +import org.approvaltests.reporters.*; + /** * ApprovalTests.Java configuration. * */ public class PackageSettings { private static final String ApprovalBaseDirectory = "../resources"; + private static final ApprovalFailureReporter UseReporter = new FirstWorkingReporter( + new AutoApproveWhenEmptyReporter(), + new DiffReporter() + ); } diff --git a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java index eb376f5a3d2..1395fcde16b 100644 --- a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java +++ b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/JHipsterModulesAssertions.java @@ -13,9 +13,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.approvaltests.Approvals; -import org.approvaltests.core.ApprovalFailureReporter; import org.approvaltests.core.Scrubber; -import org.approvaltests.reporters.*; import org.approvaltests.scrubbers.NoOpScrubber; import org.approvaltests.scrubbers.RegExScrubber; import org.assertj.core.api.SoftAssertions; @@ -343,10 +341,9 @@ private void assertFileExists() { */ public JHipsterModuleFileAsserter matchingSavedSnapshot() { String shortFileName = Arrays.stream(file.split("/")).toList().getLast(); - ApprovalFailureReporter reporter = new FirstWorkingReporter(new AutoApproveWhenEmptyReporter(), new DiffReporter()); Approvals.verify( contentNormalizingNewLines(projectFolder.filePath(file)), - Approvals.NAMES.withParameters(shortFileName).withScrubber(scrubberFor(file)).addReporter(reporter) + Approvals.NAMES.withParameters(shortFileName).withScrubber(scrubberFor(file)) ); return this; From 97a6a0a044d12adeab82d6000b096cbc927d56c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Wed, 18 Sep 2024 18:15:47 +0200 Subject: [PATCH 7/7] test: remove redundant partial assertions, already covered by the matchingSavedSnapshot() assertion --- .../core/domain/VueModulesFactoryTest.java | 36 -- ...leSystemJHipsterModulesRepositoryTest.java | 366 ------------------ 2 files changed, 402 deletions(-) diff --git a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java index 8b8bee8fa51..a0ba30e1cb3 100644 --- a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java @@ -63,48 +63,12 @@ void shouldCreateVueModule() { .hasPrefixedFiles("", "eslint.config.js", "tsconfig.build.json", "vite.config.ts", "vitest.config.ts") .hasFile("tsconfig.json") .matchingSavedSnapshot() - .containing("\"extends\": \"@vue/tsconfig/tsconfig.dom.json\"") - .containing("\"allowJs\": true,") - .containing("\"sourceMap\": true,") - .containing("\"types\": [\"vite/client\", ") .and() .hasFile("vitest.config.ts") .matchingSavedSnapshot() - .containing("import vue from '@vitejs/plugin-vue';") - .containing("plugins: [vue(), tsconfigPaths()],") - .containing("environment: 'jsdom',") - .containing(""" - exclude: [ - ...configDefaults.coverage.exclude as string[], - 'src/main/webapp/app/main.ts', - 'src/main/webapp/app/injections.ts', - 'src/main/webapp/app/router.ts', - 'src/main/webapp/**/*.component.ts', - """ - ) .and() .hasFile("eslint.config.js") .matchingSavedSnapshot() - .containing("import vue from 'eslint-plugin-vue';") - .containing(""" - ...vue.configs['flat/recommended'], - { - files: ['**/*.vue'], - languageOptions: { - parserOptions: { parser: '@typescript-eslint/parser' }, - globals: { ...globals.browser }, - }, - }, - """ - ) - .containing(""" - rules: { - quotes: ['error', 'single', { avoidEscape: true }], - '@typescript-eslint/no-empty-object-type': 'off', - '@typescript-eslint/no-explicit-any': 'off', - 'vue/html-self-closing': 'off', - """ - ) .and() .hasFiles("src/main/webapp/app/shared/http/infrastructure/secondary/AxiosHttp.ts") .hasFiles("src/main/webapp/index.html") diff --git a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java index 153cea9065e..859dd61304d 100644 --- a/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java +++ b/src/test/java/tech/jhipster/lite/module/infrastructure/secondary/FileSystemJHipsterModulesRepositoryTest.java @@ -79,291 +79,9 @@ void shouldApplyModuleToMavenProject() { .and() .hasFile("pom.xml") .matchingSavedSnapshot() - .containing("local") - .notContaining( - """ - - net.logstash.logback - logstash-logback-encoder - - """ - ) - .notContaining( - """ - - org.springdoc - springdoc-openapi-ui - ${springdoc-openapi.version} - - """ - ) - .containing("") - .containing("") - .containing( - """ - - org.reflections - reflections - ${reflections.version} - test - - """ - ) - .containing( - """ - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - import - - """ - ) - .containing( - """ - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - - - - """ - ) - .containing( - """ - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - """ - ) - .containing( - """ - - org.junit.jupiter - junit-jupiter-engine - ${spring-boot.version} - test - test - true - - """ - ) - .containing("") - .containing("") - .containing("spring-boot-starter") - .notContaining( - """ - - org.assertj - assertj-core - ${assertj.version} - test - - """ - ) - .containing("") - .containing("") - .containing( - """ - - - - org.springframework.boot - spring-boot-maven-plugin - - - maven-enforcer-plugin - - - org.asciidoctor - asciidoctor-maven-plugin - - - org.asciidoctor - asciidoctorj-screenshot - - - org.asciidoctor - asciidoctorj-diagram - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot.version} - - - - repackage - - - - - ${start-class} - - - - maven-enforcer-plugin - ${maven-enforcer-plugin.version} - - - enforce-versions - - enforce - - - - enforce-dependencyConvergence - - enforce - - - - - - false - - - - - - io.jsonwebtoken - jjwt-jackson - ${json-web-token.version} - - - com.fasterxml.jackson.core - jackson-databind - - - - - - - - You are running an older version of Maven. JHipster requires at least Maven ${maven.version} - [${maven.version},) - - - You are running an incompatible version of Java. JHipster engine supports JDK 21+. - [21,22) - - - - - - - - """ - ) - .containing("") - .containing( - """ - - - local - - - - - - maven-enforcer-plugin - ${maven-enforcer-plugin.version} - - - enforce-versions - - enforce - - - - enforce-dependencyConvergence - - enforce - - - - - - false - - - - - - io.jsonwebtoken - jjwt-jackson - ${json-web-token.version} - - - com.fasterxml.jackson.core - jackson-databind - - - - - - - - You are running an older version of Maven. JHipster requires at least Maven ${maven.version} - [${maven.version},) - - - You are running an incompatible version of Java. JHipster engine supports JDK 21+. - [21,22) - - - - - - - - - maven-enforcer-plugin - - - - - local - - - - org.cassandraunit - cassandra-unit - ${cassandraunit.version} - test - - - - - """ - ) .and() .hasFile("package.json") .matchingSavedSnapshot() - .containing(" \"jestSonar\": {\n \"reportPath\": \"target/test-results\",\n \"reportFile\": \"TESTS-results-sonar.xml\"\n }") - .containing( - """ - "scripts": { - "build": "ng build --output-path=target/classes/static", - "serve": "tikui-core serve" - }, - """ - ) - .containing("\"dependencies\": {\n \"@angular/animations\": \"") - .containing("\"devDependencies\": {\n \"@playwright/test\": \"") .and() .hasFile("src/main/java/com/company/myapp/errors/Assert.java") .containing("Dummy replacement") @@ -470,82 +188,9 @@ void shouldApplyModuleToGradleProject() { .and() .hasFile("gradle/libs.versions.toml") .matchingSavedSnapshot() - .containing("spring-boot = \"") - .containing("json-web-token = \"") - .containing("cassandraunit = \"") - .containing("git-properties = \"") .and() .hasFile("build.gradle.kts") .matchingSavedSnapshot() - .notContaining("implementation(libs.logstash.logback.encoder)") - .notContaining("implementation(libs.springdoc.openapi.ui)") - .containing("implementation(platform(libs.spring.boot.dependencies))") - .containing("implementation(libs.spring.boot.starter.web)") - .containing("testImplementation(libs.junit.jupiter.engine)") - .containing("implementation(libs.spring.boot.starter)") - .notContaining("testImplementation(libs.assertj.core)") - .containing( - """ - import java.util.Properties - // jhipster-needle-gradle-imports - """ - ) - .containing(""" - plugins { - java - jacoco - checkstyle - // jhipster-needle-gradle-plugins - } - """ - ) - .containing(""" - checkstyle { - toolVersion = libs.versions.checkstyle.get() - } - """ - ) - .containing( - """ - val profiles = (project.findProperty("profiles") as String? ?: "") - .split(",") - .map { it.trim() } - .filter { it.isNotEmpty() } - if (profiles.contains("local")) { - apply(plugin = "profile-local") - } - // jhipster-needle-profile-activation\ - """ - ) - .containing( - """ - val springProfilesActive by extra("local") - // jhipster-needle-gradle-properties - """ - ) - .containing( - """ - tasks.build { - dependsOn("processResources") - } - - tasks.processResources { - filesMatching("**/*.yml", "**/*.properties") { - filter { - it.replace("@spring.profiles.active@", springProfilesActive) - } - } - } - - // jhipster-needle-gradle-free-configuration-blocks - """ - ) - .containing( - """ - finalizedBy("jacocoTestReport") - // jhipster-needle-gradle-tasks-test - """ - ) .and() .hasFile("buildSrc/build.gradle.kts") .containing( @@ -605,17 +250,6 @@ val springProfilesActive by extra("local") .and() .hasFile("package.json") .matchingSavedSnapshot() - .containing(" \"jestSonar\": {\n \"reportPath\": \"build/test-results\",\n \"reportFile\": \"TESTS-results-sonar.xml\"\n }") - .containing( - """ - "scripts": { - "build": "ng build --output-path=build/classes/static", - "serve": "tikui-core serve" - }, - """ - ) - .containing("\"dependencies\": {\n \"@angular/animations\": \"") - .containing("\"devDependencies\": {\n \"@playwright/test\": \"") .and() .hasFile("src/main/java/com/company/myapp/errors/Assert.java") .containing("Dummy replacement")