Skip to content

Commit

Permalink
refactor(preset): set preset file name property to singular instead o…
Browse files Browse the repository at this point in the history
…f plural
  • Loading branch information
renanfranca committed Aug 17, 2024
1 parent db3805a commit d6503b6
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package tech.jhipster.lite.project.domain.resource;

public record JHipsterPresetsFile(String name) {}
public record JHipsterPresetFile(String name) {}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
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.JHipsterPresetsFile;
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 @@ -31,20 +31,20 @@ class FileSystemProjectsRepository implements ProjectsRepository {
private final ObjectMapper json;
private final ProjectFormatter formatter;
private final ProjectFiles projectFiles;
private final JHipsterPresetsFile presetsFile;
private final JHipsterPresetFile presetFile;
private final ObjectWriter writer;
private final FileSystemProjectDownloader downloader;

public FileSystemProjectsRepository(
ObjectMapper json,
ProjectFormatter formatter,
ProjectFiles projectFiles,
JHipsterPresetsFile presetsFile
JHipsterPresetFile presetFile
) {
this.json = json;
this.formatter = formatter;
this.projectFiles = projectFiles;
this.presetsFile = presetsFile;
this.presetFile = presetFile;

writer = json.writerWithDefaultPrettyPrinter();
downloader = new FileSystemProjectDownloader();
Expand Down Expand Up @@ -109,6 +109,6 @@ public Collection<Preset> getPresets() {
}

private String presetFilePath() {
return PRESET_FOLDER + presetsFile.name();
return PRESET_FOLDER + presetFile.name();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties("jhlite-presets-file")
class JHipsterPresetsFileProperties {
@ConfigurationProperties("jhlite-preset-file")
class JHipsterPresetFileProperties {

private String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
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.JHipsterPresetsFile;
import tech.jhipster.lite.project.domain.resource.JHipsterPresetFile;

@Configuration
@EnableConfigurationProperties(JHipsterPresetsFileProperties.class)
class JHipsterPresetsFilePropertiesConfiguration {
@EnableConfigurationProperties(JHipsterPresetFileProperties.class)
class JHipsterPresetFilePropertiesConfiguration {

@Bean
JHipsterPresetsFile jhipsterPresetsFile() {
return new JHipsterPresetsFile(new JHipsterPresetsFileProperties().getName());
JHipsterPresetFile jhipsterPresetFile() {
return new JHipsterPresetFile(new JHipsterPresetFileProperties().getName());
}
}
2 changes: 1 addition & 1 deletion src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jhlite-hidden-resources:
slugs:
- svelte-core

jhlite-presets-file:
jhlite-preset-file:
name: preset.json

server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
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.FakedJHipsterPresetsFilePropertiesConfiguration;
import tech.jhipster.lite.project.infrastructure.secondary.FakedJHipsterPresetFilePropertiesConfiguration;
import tech.jhipster.lite.project.infrastructure.secondary.MockedProjectFormatterConfiguration;

@ActiveProfiles("test")
Expand All @@ -25,7 +25,7 @@
JHLiteApp.class,
MockedProjectFormatterConfiguration.class,
FakedFileSystemProjectFilesConfiguration.class,
FakedJHipsterPresetsFilePropertiesConfiguration.class,
FakedJHipsterPresetFilePropertiesConfiguration.class,
},
webEnvironment = WebEnvironment.RANDOM_PORT
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import tech.jhipster.lite.project.domain.resource.JHipsterPresetsFile;
import tech.jhipster.lite.project.domain.resource.JHipsterPresetFile;

@TestConfiguration
public class FakedJHipsterPresetsFilePropertiesConfiguration {
public class FakedJHipsterPresetFilePropertiesConfiguration {

@Bean
JHipsterPresetsFile jhipsterPresetsFile() {
return new JHipsterPresetsFile("preset.json");
JHipsterPresetFile jhipsterPresetFile() {
return new JHipsterPresetFile("preset.json");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
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.JHipsterPresetsFile;
import tech.jhipster.lite.project.domain.resource.JHipsterPresetFile;
import tech.jhipster.lite.shared.error.domain.GeneratorException;

@UnitTest
Expand All @@ -43,7 +43,7 @@ class FileSystemProjectsRepositoryTest {
JsonHelper.jsonMapper(),
mock(ProjectFormatter.class),
mock(ProjectFiles.class),
mock(JHipsterPresetsFile.class)
mock(JHipsterPresetFile.class)
);

@Nested
Expand Down Expand Up @@ -151,7 +151,7 @@ void shouldHandleSerializationError() throws JsonProcessingException {
json,
mock(ProjectFormatter.class),
mock(ProjectFiles.class),
mock(JHipsterPresetsFile.class)
mock(JHipsterPresetFile.class)
);

assertThatThrownBy(() -> fileSystemProjectsRepository.save(projectHistory())).isExactlyInstanceOf(GeneratorException.class);
Expand Down Expand Up @@ -195,7 +195,7 @@ void shouldHandleDeserializationErrors() throws IOException {
json,
mock(ProjectFormatter.class),
mock(ProjectFiles.class),
mock(JHipsterPresetsFile.class)
mock(JHipsterPresetFile.class)
);

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

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

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

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

0 comments on commit d6503b6

Please sign in to comment.