Skip to content

Commit

Permalink
Merge pull request #10587 from jhipster/revert-10578-10553-define-pre…
Browse files Browse the repository at this point in the history
…set-json-file-name-at-spring-boot-application

Revert "define preset json file name at spring boot application config"
  • Loading branch information
pascalgrimaud authored Aug 17, 2024
2 parents be7bc89 + dfcd170 commit 08fd33c
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 83 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
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;

Expand All @@ -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();
Expand Down Expand Up @@ -109,6 +102,6 @@ public Collection<Preset> getPresets() {
}

private String presetFilePath() {
return PRESET_FOLDER + presetFile.name();
return PRESET_FOLDER + PRESET_FILE;
}
}

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ jhlite-hidden-resources:
slugs:
- svelte-core

jhlite-preset-file:
name: preset.json

server:
port: 7471

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@
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 {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
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
Expand All @@ -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
Expand Down Expand Up @@ -150,8 +148,7 @@ void shouldHandleSerializationError() throws JsonProcessingException {
FileSystemProjectsRepository fileSystemProjectsRepository = new FileSystemProjectsRepository(
json,
mock(ProjectFormatter.class),
mock(ProjectFiles.class),
mock(JHipsterPresetFile.class)
mock(ProjectFiles.class)
);

assertThatThrownBy(() -> fileSystemProjectsRepository.save(projectHistory())).isExactlyInstanceOf(GeneratorException.class);
Expand Down Expand Up @@ -194,8 +191,7 @@ void shouldHandleDeserializationErrors() throws IOException {
FileSystemProjectsRepository fileSystemProjectsRepository = new FileSystemProjectsRepository(
json,
mock(ProjectFormatter.class),
mock(ProjectFiles.class),
mock(JHipsterPresetFile.class)
mock(ProjectFiles.class)
);

assertThatThrownBy(() -> fileSystemProjectsRepository.getHistory(path)).isExactlyInstanceOf(GeneratorException.class);
Expand Down Expand Up @@ -233,8 +229,7 @@ void shouldHandleDeserializationErrors() throws IOException {
FileSystemProjectsRepository fileSystemProjectsRepository = new FileSystemProjectsRepository(
json,
mock(ProjectFormatter.class),
mockProjectFilesWithValidPresetJson(),
new JHipsterPresetFile("preset.json")
mockProjectFilesWithValidPresetJson()
);

assertThatThrownBy(fileSystemProjectsRepository::getPresets).isExactlyInstanceOf(GeneratorException.class);
Expand All @@ -247,8 +242,7 @@ void shouldNotReturnPresetFromUnknownFile() {
FileSystemProjectsRepository fileSystemProjectsRepository = new FileSystemProjectsRepository(
JsonHelper.jsonMapper(),
mock(ProjectFormatter.class),
projectFiles,
new JHipsterPresetFile("preset.json")
projectFiles
);

assertThatThrownBy(fileSystemProjectsRepository::getPresets).isExactlyInstanceOf(GeneratorException.class);
Expand All @@ -259,8 +253,7 @@ void shouldGetExistingPreset() {
FileSystemProjectsRepository fileSystemProjectsRepository = new FileSystemProjectsRepository(
JsonHelper.jsonMapper(),
mock(ProjectFormatter.class),
mockProjectFilesWithValidPresetJson(),
new JHipsterPresetFile("preset.json")
mockProjectFilesWithValidPresetJson()
);

Collection<Preset> presets = fileSystemProjectsRepository.getPresets();
Expand Down

0 comments on commit 08fd33c

Please sign in to comment.