Skip to content

Commit

Permalink
update snapshots and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Mar 22, 2024
1 parent 13f8bb6 commit 7a5e678
Show file tree
Hide file tree
Showing 15 changed files with 305 additions and 373 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`generator - gradle:code-quality with gradle build tool should match files snapshot 1`] = `
{
"build.gradle": {
"contents": "
dependencies {
// jhipster-needle-gradle-dependency
}
plugins {
id "jhipster.code-quality-conventions"
// jhipster-needle-gradle-plugins
}
",
"stateCleared": "modified",
},
"buildSrc/build.gradle": {
"contents": "plugins {
id 'groovy-gradle-plugin'
}
repositories {
gradlePluginPortal()
}
dependencies {
implementation libs.modernizer.plugin
implementation libs.nohttp.plugin
implementation libs.sonarqube.plugin
implementation libs.spotless.plugin
// jhipster-needle-gradle-dependency - JHipster will add additional dependencies for convention plugins here
// jhipster-needle-gradle-build-src-dependency - Deprecated: JHipster will add additional dependencies for convention plugins here
}
",
"stateCleared": "modified",
},
"buildSrc/gradle/libs.versions.toml": {
"contents": "[versions]
checkstyle = "'CHECKSTYLE-VERSION'"
# jhipster-needle-gradle-dependency-catalog-version - JHipster will add additional versions for convention plugins heref
# jhipster-needle-gradle-build-src-dependency-catalog-version - Deprecated: JHipster will add additional versions for convention plugins here
[libraries]
modernizer-plugin = { module = "com.github.andygoossens:gradle-modernizer-plugin", version = "'GRADLE-MODERNIZER-PLUGIN-VERSION'" }
nohttp-plugin = { module = "io.spring.nohttp:nohttp-gradle", version = "'NOHTTP-CHECKSTYLE-VERSION'" }
sonarqube-plugin = { module = "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin", version = "'GRADLE-SONARQUBE-VERSION'" }
spotless-plugin = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "'SPOTLESS-GRADLE-PLUGIN-VERSION'" }
# jhipster-needle-gradle-dependency-catalog-libraries - JHipster will add additional libraries versions
[plugins]
# jhipster-needle-gradle-dependency-catalog-plugins - JHipster will add additional plugins versions
",
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle": {
"contents": "plugins {
id "jacoco"
id "org.sonarqube"
id "com.diffplug.spotless"
id "com.github.andygoossens.gradle-modernizer-plugin"
id "io.spring.nohttp"
}
jacoco {
toolVersion = "\${libs.versions.jacoco.get()}"
}
jacocoTestReport {
executionData tasks.withType(Test)
classDirectories.from = files(sourceSets.main.output.classesDirs)
sourceDirectories.from = files(sourceSets.main.java.srcDirs)
reports {
xml.required = true
}
}
file("sonar-project.properties").withReader {
Properties sonarProperties = new Properties()
sonarProperties.load(it)
sonarProperties.each { key, value ->
sonarqube {
properties {
property key, value
}
}
}
}
spotless {
java {
target 'src/*/java/**/*.java'
// removeUnusedImports()
}
}
modernizer {
failOnViolations = true
includeTestClasses = true
}
checkstyle {
toolVersion "\${libs.versions.checkstyle.get()}"
configFile file("checkstyle.xml")
checkstyleTest.enabled = false
}
nohttp {
source.include "build.gradle", "README.md"
}
// workaround for https://github.com/checkstyle/checkstyle/issues/14123
configurations.checkstyle {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
select("com.google.guava:guava:0")
}
}",
"stateCleared": "modified",
},
"gradle/libs.versions.toml": {
"contents": "[versions]
jacoco = "'JACOCO-MAVEN-PLUGIN-VERSION'"
# jhipster-needle-gradle-dependency-catalog-version - JHipster will add additional versions for convention plugins heref
[libraries]
# jhipster-needle-gradle-dependency-catalog-libraries - JHipster will add additional libraries versions
[plugins]
# jhipster-needle-gradle-dependency-catalog-plugins - JHipster will add additional plugins versions
",
"stateCleared": "modified",
},
}
`;
27 changes: 27 additions & 0 deletions generators/gradle/generators/code-quality/generator.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { basename, dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { before, it, describe, expect } from 'esmocha';

import { shouldSupportFeatures, testBlueprintSupport } from '../../../../test/support/tests.js';
import Generator from './index.js';
import { defaultHelpers as helpers, result } from '../../../../testing/index.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const generator = `${basename(resolve(__dirname, '../../'))}:${basename(__dirname)}`;

describe(`generator - ${generator}`, () => {
shouldSupportFeatures(Generator);
describe('blueprint support', () => testBlueprintSupport(generator));

describe('with gradle build tool', () => {
before(async () => {
await helpers.runJHipster(generator).withGradleBuildTool();
});

it('should match files snapshot', () => {
expect(result.getSnapshot('**/{build.gradle,buildSrc/**,gradle/libs.versions.toml}')).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`generator - gradle:jib with gradle build tool should match files snapshot 1`] = `
{
"build.gradle": {
"contents": "
dependencies {
// jhipster-needle-gradle-dependency
}
plugins {
id "jhipster.docker-conventions"
// jhipster-needle-gradle-plugins
}
",
"stateCleared": "modified",
},
"buildSrc/build.gradle": {
"contents": "plugins {
id 'groovy-gradle-plugin'
}
repositories {
gradlePluginPortal()
}
dependencies {
implementation libs.jib.plugin
// jhipster-needle-gradle-dependency - JHipster will add additional dependencies for convention plugins here
// jhipster-needle-gradle-build-src-dependency - Deprecated: JHipster will add additional dependencies for convention plugins here
}
",
"stateCleared": "modified",
},
"buildSrc/gradle/libs.versions.toml": {
"contents": "[versions]
# jhipster-needle-gradle-dependency-catalog-version - JHipster will add additional versions for convention plugins heref
# jhipster-needle-gradle-build-src-dependency-catalog-version - Deprecated: JHipster will add additional versions for convention plugins here
[libraries]
jib-plugin = { module = "com.google.cloud.tools:jib-gradle-plugin", version = "'JIB-MAVEN-PLUGIN-VERSION'" }
# jhipster-needle-gradle-dependency-catalog-libraries - JHipster will add additional libraries versions
[plugins]
# jhipster-needle-gradle-dependency-catalog-plugins - JHipster will add additional plugins versions
",
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.docker-conventions.gradle": {
"contents": "plugins {
id "com.google.cloud.tools.jib"
}
jib {
from {
image = "java-jre-placeholder"
platforms {
platform {
architecture = "\${findProperty('jibArchitecture') ?: 'amd64'}"
os = "linux"
}
}
}
to {
image = "jhipster:latest"
}
container {
entrypoint = ["bash", "-c", "/entrypoint.sh"]
ports = ["8080"]
environment = [
SPRING_OUTPUT_ANSI_ENABLED: "ALWAYS",
JHIPSTER_SLEEP: "0"
]
creationTime = "USE_CURRENT_TIMESTAMP"
user = 1000
}
extraDirectories {
paths = file("src/main/docker/jib")
permissions = ["/entrypoint.sh": "755"]
}
}",
"stateCleared": "modified",
},
"gradle/libs.versions.toml": {
"contents": "[versions]
# jhipster-needle-gradle-dependency-catalog-version - JHipster will add additional versions for convention plugins heref
[libraries]
# jhipster-needle-gradle-dependency-catalog-libraries - JHipster will add additional libraries versions
[plugins]
# jhipster-needle-gradle-dependency-catalog-plugins - JHipster will add additional plugins versions
",
"stateCleared": "modified",
},
}
`;
27 changes: 27 additions & 0 deletions generators/gradle/generators/jib/generator.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { basename, dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { before, it, describe, expect } from 'esmocha';

import { shouldSupportFeatures, testBlueprintSupport } from '../../../../test/support/tests.js';
import Generator from './index.js';
import { defaultHelpers as helpers, result } from '../../../../testing/index.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const generator = `${basename(resolve(__dirname, '../../'))}:${basename(__dirname)}`;

describe(`generator - ${generator}`, () => {
shouldSupportFeatures(Generator);
describe('blueprint support', () => testBlueprintSupport(generator));

describe('with gradle build tool', () => {
before(async () => {
await helpers.runJHipster(generator).withGradleBuildTool();
});

it('should match files snapshot', () => {
expect(result.getSnapshot('**/{build.gradle,buildSrc/**,gradle/libs.versions.toml}')).toMatchSnapshot();
});
});
});
2 changes: 1 addition & 1 deletion generators/server/__test-support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const mockedGenerators = [
`jhipster:${GENERATOR_DOCKER}`,
`jhipster:${GENERATOR_GATLING}`,
`jhipster:${GENERATOR_GRADLE}`,
`jhipster:${GENERATOR_GRADLE}:docker`,
`jhipster:${GENERATOR_GRADLE}:code-quality`,
`jhipster:${GENERATOR_GRADLE}:jib`,
`jhipster:${GENERATOR_GRADLE}:node-gradle`,
`jhipster:${GENERATOR_SPRING_CLOUD_STREAM}`,
Expand Down
2 changes: 1 addition & 1 deletion generators/server/generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe(`generator - ${generator}`, () => {
});

it('should compose with gradle generator', () => {
assert(runResult.mockedGenerators['jhipster:gradle'].calledOnce);
assert(runResult.mockedGenerators['jhipster:gradle'].called);
});
it('should not compose with others buildTool generators', () => {
assert(runResult.mockedGenerators['jhipster:maven'].notCalled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ exports[`generator - cassandra gateway-jwt-gradle-enableTranslation(true)-com.my
"build.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.docker-conventions.gradle": {
"stateCleared": "modified",
},
"checkstyle.xml": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -843,12 +837,6 @@ exports[`generator - cassandra microservice-jwt-reactive(true)-gradle-enableTran
"build.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.docker-conventions.gradle": {
"stateCleared": "modified",
},
"checkstyle.xml": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -1205,12 +1193,6 @@ exports[`generator - cassandra microservice-oauth2-reactive(true)-gradle-enableT
"build.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.docker-conventions.gradle": {
"stateCleared": "modified",
},
"checkstyle.xml": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -2037,12 +2019,6 @@ exports[`generator - cassandra monolith-jwt-reactive(true)-gradle-enableTranslat
"build.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.docker-conventions.gradle": {
"stateCleared": "modified",
},
"checkstyle.xml": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -2785,12 +2761,6 @@ exports[`generator - cassandra monolith-oauth2-reactive(true)-gradle-enableTrans
"build.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.docker-conventions.gradle": {
"stateCleared": "modified",
},
"checkstyle.xml": {
"stateCleared": "modified",
},
Expand Down Expand Up @@ -3626,12 +3596,6 @@ exports[`generator - cassandra monolith-session-reactive(true)-gradle-enableTran
"build.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle": {
"stateCleared": "modified",
},
"buildSrc/src/main/groovy/jhipster.docker-conventions.gradle": {
"stateCleared": "modified",
},
"checkstyle.xml": {
"stateCleared": "modified",
},
Expand Down
Loading

0 comments on commit 7a5e678

Please sign in to comment.