Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual upgrade to JHLite v1.23.0 #120

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .jhipster/modules/history.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@
"indentSize": 2,
"baseName": "jhliteExtensionSample"
}
},
{
"module": "custom-jhlite",
"date": "2024-12-09T15:09:55.910860780Z",
"properties": {
"endOfLine": "lf",
"springConfigurationFormat": "yaml",
"packageName": "tech.jhipster.lite.extension",
"projectName": "JHLite Extension Sample",
"serverPort": 8080,
"indentSize": 2,
"baseName": "jhliteExtensionSample"
}
}
]
}
7 changes: 5 additions & 2 deletions documentation/cucumber.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,15 @@ Behind the scene, your last service will be recalled until the assertions are OK

## Mocking beans

You may need to mock beans for your component tests, but you won't be able to do it in a "classic" way (using `@MockBean`) since the application context will be already loaded. A way to achieve that is to overload beans to have mocks:
You may need to mock beans for your component tests, but you won't be able to do it in a "classic" way (using `@MockitoBean`) since the application context will be already loaded. A way to achieve that is to overload beans to have mocks:

```java
@ActiveProfiles("test")
@CucumberContextConfiguration
@SpringBootTest(classes = { JhliteExtensionSampleApp.class, CucumberMocksConfiguration.class }, webEnvironment = WebEnvironment.RANDOM_PORT)
@SpringBootTest(
classes = { JhipsterSampleApplicationApp.class, CucumberMocksConfiguration.class },
webEnvironment = WebEnvironment.RANDOM_PORT
)
public class CucumberConfiguration {

// other code omitted
Expand Down
8 changes: 4 additions & 4 deletions documentation/module-creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class MyModuleFactoryTest {
@Test
void shouldBuildModule() {
JHipsterModuleProperties properties = JHipsterModulesFixture.propertiesBuilder(TestFileUtils.tmpDirForTest())
.basePackage("com.jhipster.test")
.basePackage("tech.jhipster.jhlitest")
.build();

JHipsterModule module = factory.buildModule(properties);

assertThatModule(module).hasPrefixedFiles("src/main/java/com/jhipster/test/my_package", "Dummy.java");
assertThatModule(module).hasPrefixedFiles("src/main/java/tech/jhipster/jhlitest/my_package", "Dummy.java");
}
}

Expand Down Expand Up @@ -207,8 +207,8 @@ In your `JHipsterModuleResource` you can define additional properties and an org

You can hide modules from your custom instance in project configuration with:

- `jhlite-hidden-resources.slugs`: To disable including its dependencies by slugs
- `jhlite-hidden-resources.tags`: To disable by tags
- `jhlite.hidden-resources.slugs`: To disable including its dependencies by slugs
- `jhlite.hidden-resources.tags`: To disable by tags

## Docker versions

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<failsafe-plugin.version>3.5.2</failsafe-plugin.version>
<spring-boot.version>3.4.0</spring-boot.version>
<cucumber.version>7.20.1</cucumber.version>
<jhlite.version>1.22.0</jhlite.version>
<jhlite.version>1.23.0</jhlite.version>
<maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
<jacoco.version>0.8.12</jacoco.version>
<properties-maven-plugin.version>1.2.1</properties-maven-plugin.version>
Expand Down
10 changes: 6 additions & 4 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sonar.junit.reportPaths=target/surefire-reports,target/failsafe-reports
sonar.sourceEncoding=UTF-8
sonar.exclusions=src/main/webapp/main.ts, src/main/webapp/app/main.ts, src/main/webapp/content/**/*.*, src/main/webapp/i18n/*.js, target/classes/static/**/*.*, src/main/webapp/app/index.tsx

sonar.issue.ignore.multicriteria=S117,S119,S125,S3437,S4502,S4684,S4032,S5778,S1133,S6206,S2699,S6548,S6471,UndocumentedApi
sonar.issue.ignore.multicriteria=S117,S119,S125_1,S125_2,S3437,S4502,S4684,S4032,S5778,S1133,S6206,S2699,S6548,S6471,UndocumentedApi

# Rule: Local variable and method parameter names should comply with a naming convention
# Handled with checkstyle. Should be revisited with java 25 once Unnamed Patterns and Variables are available (JEP 443)
Expand Down Expand Up @@ -64,9 +64,11 @@ sonar.issue.ignore.multicriteria.S6206.ruleKey=java:S6206
sonar.issue.ignore.multicriteria.S2699.resourceKey=src/test/javascript/**
sonar.issue.ignore.multicriteria.S2699.ruleKey=typescript:S2699

# Rule: Delete commented out code in liquibase example
sonar.issue.ignore.multicriteria.S125.resourceKey=src/main/resources/config/liquibase/master.xml
sonar.issue.ignore.multicriteria.S125.ruleKey=xml:S125
# Rule: Sections of code should not be commented out
sonar.issue.ignore.multicriteria.S125_1.ruleKey=xml:S125
sonar.issue.ignore.multicriteria.S125_1.resourceKey=**/logback-spring.xml
sonar.issue.ignore.multicriteria.S125_2.ruleKey=xml:S125
sonar.issue.ignore.multicriteria.S125_2.resourceKey=**/config/liquibase/master.xml

# Rule: Use Singleton pattern with care
sonar.issue.ignore.multicriteria.S6548.resourceKey=src/main/java/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public enum JhliteExtensionSampleFeatureSlug implements JHipsterFeatureSlugFacto

private final String slug;

@SuppressWarnings("java:S1144")
JhliteExtensionSampleFeatureSlug(String slug) {
this.slug = slug;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package tech.jhipster.lite.extension.shared.slug.domain;

import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import tech.jhipster.lite.extension.shared.generation.domain.ExcludeFromGeneratedCodeCoverage;
import tech.jhipster.lite.module.domain.resource.JHipsterModuleSlugFactory;

@ExcludeFromGeneratedCodeCoverage
public enum JhliteExtensionSampleModuleSlug implements JHipsterModuleSlugFactory {
BANNER_JHIPSTER_V2("banner-jhipster-v2"),
BANNER_JHIPSTER_V3("banner-jhipster-v3"),
Expand All @@ -11,8 +18,12 @@ public enum JhliteExtensionSampleModuleSlug implements JHipsterModuleSlugFactory
PRETTIER_PLUGIN_PROPERTIES("prettier-plugin-properties"),
SPRING_BOOT_STARTUP_REPORT("spring-boot-startup-report");

private static final Map<String, JhliteExtensionSampleModuleSlug> moduleSlugMap = Stream.of(values()).collect(
Collectors.toMap(JhliteExtensionSampleModuleSlug::get, Function.identity())
);
private final String slug;

@SuppressWarnings("java:S1144")
JhliteExtensionSampleModuleSlug(String slug) {
this.slug = slug;
}
Expand All @@ -21,4 +32,8 @@ public enum JhliteExtensionSampleModuleSlug implements JHipsterModuleSlugFactory
public String get() {
return slug;
}

public static Optional<JhliteExtensionSampleModuleSlug> fromString(String slug) {
return Optional.ofNullable(moduleSlugMap.get(slug));
}
}
7 changes: 4 additions & 3 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ logging:
jhipster:
lite:
extension: INFO
jhlite-hidden-resources:
# Disable the modules and its dependencies by slugs
slugs: custom-jhlite
jhlite:
hidden-resources:
# Disable the modules and its dependencies by slugs
slugs: custom-jhlite
server:
port: 8080
1 change: 1 addition & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>
<configuration scan="true">
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<springProperty name="log.level" source="logging.level.root" defaultValue="INFO" />
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.cucumber.spring.CucumberContextConfiguration;
import java.nio.charset.StandardCharsets;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.context.TestConfiguration;
Expand All @@ -31,8 +30,11 @@
)
public class CucumberConfiguration {

@Autowired
private TestRestTemplate rest;
private final TestRestTemplate rest;

CucumberConfiguration(TestRestTemplate rest) {
this.rest = rest;
}

@Before
public void resetTestContext() {
Expand All @@ -46,7 +48,7 @@ public void loadInterceptors() {
RestTemplate template = rest.getRestTemplate();
template.setRequestFactory(requestFactory);
template.setInterceptors(List.of(saveLastResultInterceptor()));
template.getMessageConverters().add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
template.getMessageConverters().addFirst(new StringHttpMessageConverter(StandardCharsets.UTF_8));
}

private ClientHttpRequestInterceptor saveLastResultInterceptor() {
Expand All @@ -62,11 +64,8 @@ private ClientHttpRequestInterceptor saveLastResultInterceptor() {
@TestConfiguration
static class CucumberRestTemplateConfiguration {

@Autowired
private TestRestTemplate rest;

@Bean
CucumberRestTemplate cucumberRestTemplate() {
CucumberRestTemplate cucumberRestTemplate(TestRestTemplate rest) {
return new CucumberRestTemplate(rest);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>
<configuration scan="true">
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<include resource="org/springframework/boot/logging/logback/base.xml" />

<logger name="tech.jhipster.lite.extension" level="OFF" />
Expand Down
Loading