Repository: jhipster/jhipster-lite
Pull request #10587 (2024-08-17 15:54:33)

Revert "define preset json file name at spring boot application config"
Reverts jhipster/jhipster-lite#10578


Patch:
diff --git a/src/main/java/tech/jhipster/lite/project/domain/resource/JHipsterPresetFile.java b/src/main/java/tech/jhipster/lite/project/domain/resource/JHipsterPresetFile.java
deleted file mode 100644
index f47e6e3ba..000000000
--- a/src/main/java/tech/jhipster/lite/project/domain/resource/JHipsterPresetFile.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package tech.jhipster.lite.project.domain.resource;
-
-public record JHipsterPresetFile(String name) {}
diff --git a/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepository.java b/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepository.java
index 34215e22d..be5c1dc38 100644
--- a/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepository.java
+++ b/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepository.java
@@ -15,7 +15,6 @@ import tech.jhipster.lite.project.domain.ProjectsRepository;
 import tech.jhipster.lite.project.domain.download.Project;
 import tech.jhipster.lite.project.domain.history.ProjectHistory;
 import tech.jhipster.lite.project.domain.preset.Preset;
-import tech.jhipster.lite.project.domain.resource.JHipsterPresetFile;
 import tech.jhipster.lite.shared.error.domain.Assert;
 import tech.jhipster.lite.shared.error.domain.GeneratorException;
 
@@ -27,24 +26,18 @@ class FileSystemProjectsRepository implements ProjectsRepository {
   private static final String HISTORY_FOLDER = ".jhipster/modules";
   private static final String HISTORY_FILE = "history.json";
   private static final String PRESET_FOLDER = "/";
+  private static final String PRESET_FILE = "preset.json";
 
   private final ObjectMapper json;
   private final ProjectFormatter formatter;
   private final ProjectFiles projectFiles;
-  private final JHipsterPresetFile presetFile;
   private final ObjectWriter writer;
   private final FileSystemProjectDownloader downloader;
 
-  public FileSystemProjectsRepository(
-    ObjectMapper json,
-    ProjectFormatter formatter,
-    ProjectFiles projectFiles,
-    JHipsterPresetFile presetFile
-  ) {
+  public FileSystemProjectsRepository(ObjectMapper json, ProjectFormatter formatter, ProjectFiles projectFiles) {
     this.json = json;
     this.formatter = formatter;
     this.projectFiles = projectFiles;
-    this.presetFile = presetFile;
 
     writer = json.writerWithDefaultPrettyPrinter();
     downloader = new FileSystemProjectDownloader();
@@ -109,6 +102,6 @@ class FileSystemProjectsRepository implements ProjectsRepository {
   }
 
   private String presetFilePath() {
-    return PRESET_FOLDER + presetFile.name();
+    return PRESET_FOLDER + PRESET_FILE;
   }
 }
diff --git a/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/JHipsterPresetFileProperties.java b/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/JHipsterPresetFileProperties.java
deleted file mode 100644
index 4c9627666..000000000
--- a/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/JHipsterPresetFileProperties.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package tech.jhipster.lite.project.infrastructure.secondary;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-@ConfigurationProperties("jhlite-preset-file")
-class JHipsterPresetFileProperties {
-
-  private String name;
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public String getName() {
-    return name;
-  }
-}
diff --git a/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/JHipsterPresetFilePropertiesConfiguration.java b/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/JHipsterPresetFilePropertiesConfiguration.java
deleted file mode 100644
index 8cb2a1a7a..000000000
--- a/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/JHipsterPresetFilePropertiesConfiguration.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package tech.jhipster.lite.project.infrastructure.secondary;
-
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import tech.jhipster.lite.project.domain.resource.JHipsterPresetFile;
-
-@Configuration
-@EnableConfigurationProperties(JHipsterPresetFileProperties.class)
-class JHipsterPresetFilePropertiesConfiguration {
-
-  @Bean
-  JHipsterPresetFile jhipsterPresetFile() {
-    return new JHipsterPresetFile(new JHipsterPresetFileProperties().getName());
-  }
-}
diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml
index 364a4bbc1..b8d18f725 100644
--- a/src/main/resources/config/application.yml
+++ b/src/main/resources/config/application.yml
@@ -69,9 +69,6 @@ jhlite-hidden-resources:
   slugs:
     - svelte-core
 
-jhlite-preset-file:
-  name: preset.json
-
 server:
   port: 7471
 


Test patch:
diff --git a/src/test/java/tech/jhipster/lite/cucumber/CucumberConfiguration.java b/src/test/java/tech/jhipster/lite/cucumber/CucumberConfiguration.java
index e78d24cdd..35a5b75ed 100644
--- a/src/test/java/tech/jhipster/lite/cucumber/CucumberConfiguration.java
+++ b/src/test/java/tech/jhipster/lite/cucumber/CucumberConfiguration.java
@@ -15,18 +15,12 @@ import org.springframework.web.client.RestTemplate;
 import tech.jhipster.lite.JHLiteApp;
 import tech.jhipster.lite.cucumber.rest.CucumberRestTestContext;
 import tech.jhipster.lite.project.infrastructure.secondary.FakedFileSystemProjectFilesConfiguration;
-import tech.jhipster.lite.project.infrastructure.secondary.FakedJHipsterPresetFilePropertiesConfiguration;
 import tech.jhipster.lite.project.infrastructure.secondary.MockedProjectFormatterConfiguration;
 
 @ActiveProfiles("test")
 @CucumberContextConfiguration
 @SpringBootTest(
-  classes = {
-    JHLiteApp.class,
-    MockedProjectFormatterConfiguration.class,
-    FakedFileSystemProjectFilesConfiguration.class,
-    FakedJHipsterPresetFilePropertiesConfiguration.class,
-  },
+  classes = { JHLiteApp.class, MockedProjectFormatterConfiguration.class, FakedFileSystemProjectFilesConfiguration.class },
   webEnvironment = WebEnvironment.RANDOM_PORT
 )
 public class CucumberConfiguration {
diff --git a/src/test/java/tech/jhipster/lite/project/infrastructure/secondary/FakedJHipsterPresetFilePropertiesConfiguration.java b/src/test/java/tech/jhipster/lite/project/infrastructure/secondary/FakedJHipsterPresetFilePropertiesConfiguration.java
deleted file mode 100644
index cf4d34188..000000000
--- a/src/test/java/tech/jhipster/lite/project/infrastructure/secondary/FakedJHipsterPresetFilePropertiesConfiguration.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package tech.jhipster.lite.project.infrastructure.secondary;
-
-import org.springframework.boot.test.context.TestConfiguration;
-import org.springframework.context.annotation.Bean;
-import tech.jhipster.lite.project.domain.resource.JHipsterPresetFile;
-
-@TestConfiguration
-public class FakedJHipsterPresetFilePropertiesConfiguration {
-
-  @Bean
-  JHipsterPresetFile jhipsterPresetFile() {
-    return new JHipsterPresetFile("preset.json");
-  }
-}
diff --git a/src/test/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepositoryTest.java b/src/test/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepositoryTest.java
index 8d8c13b8e..cb5e06cad 100644
--- a/src/test/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepositoryTest.java
+++ b/src/test/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepositoryTest.java
@@ -33,7 +33,6 @@ import tech.jhipster.lite.project.domain.download.ProjectName;
 import tech.jhipster.lite.project.domain.history.ProjectHistory;
 import tech.jhipster.lite.project.domain.preset.Preset;
 import tech.jhipster.lite.project.domain.preset.PresetName;
-import tech.jhipster.lite.project.domain.resource.JHipsterPresetFile;
 import tech.jhipster.lite.shared.error.domain.GeneratorException;
 
 @UnitTest
@@ -42,8 +41,7 @@ class FileSystemProjectsRepositoryTest {
   private static final FileSystemProjectsRepository projects = new FileSystemProjectsRepository(
     JsonHelper.jsonMapper(),
     mock(ProjectFormatter.class),
-    mock(ProjectFiles.class),
-    mock(JHipsterPresetFile.class)
+    mock(ProjectFiles.class)
   );
 
   @Nested
@@ -150,8 +148,7 @@ class FileSystemProjectsRepositoryTest {
       FileSystemProjectsRepository fileSystemProjectsRepository = new FileSystemProjectsRepository(
         json,
         mock(ProjectFormatter.class),
-        mock(ProjectFiles.class),
-        mock(JHipsterPresetFile.class)
+        mock(ProjectFiles.class)
       );
 
       assertThatThrownBy(() -> fileSystemProjectsRepository.save(projectHistory())).isExactlyInstanceOf(GeneratorException.class);
@@ -194,8 +191,7 @@ class FileSystemProjectsRepositoryTest {
       FileSystemProjectsRepository fileSystemProjectsRepository = new FileSystemProjectsRepository(
         json,
         mock(ProjectFormatter.class),
-        mock(ProjectFiles.class),
-        mock(JHipsterPresetFile.class)
+        mock(ProjectFiles.class)
       );
 
       assertThatThrownBy(() -> fileSystemProjectsRepository.getHistory(path)).isExactlyInstanceOf(GeneratorException.class);
@@ -233,8 +229,7 @@ class FileSystemProjectsRepositoryTest {
       FileSystemProjectsRepository fileSystemProjectsRepository = new FileSystemProjectsRepository(
         json,
         mock(ProjectFormatter.class),
-        mockProjectFilesWithValidPresetJson(),
-        new JHipsterPresetFile("preset.json")
+        mockProjectFilesWithValidPresetJson()
       );
 
       assertThatThrownBy(fileSystemProjectsRepository::getPresets).isExactlyInstanceOf(GeneratorException.class);
@@ -247,8 +242,7 @@ class FileSystemProjectsRepositoryTest {
       FileSystemProjectsRepository fileSystemProjectsRepository = new FileSystemProjectsRepository(
         JsonHelper.jsonMapper(),
         mock(ProjectFormatter.class),
-        projectFiles,
-        new JHipsterPresetFile("preset.json")
+        projectFiles
       );
 
       assertThatThrownBy(fileSystemProjectsRepository::getPresets).isExactlyInstanceOf(GeneratorException.class);
@@ -259,8 +253,7 @@ class FileSystemProjectsRepositoryTest {
       FileSystemProjectsRepository fileSystemProjectsRepository = new FileSystemProjectsRepository(
         JsonHelper.jsonMapper(),
         mock(ProjectFormatter.class),
-        mockProjectFilesWithValidPresetJson(),
-        new JHipsterPresetFile("preset.json")
+        mockProjectFilesWithValidPresetJson()
       );
 
       Collection<Preset> presets = fileSystemProjectsRepository.getPresets();