Skip to content

Commit

Permalink
fix: address case where both login.properties and `login.example.pr…
Browse files Browse the repository at this point in the history
…operties` exist
  • Loading branch information
double-beep authored Aug 28, 2024
1 parent 5ddb661 commit 91e37a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,25 @@ public class PropertyService {
private Properties prop;

public PropertyService() {
loadProperties(getFilePath());
}

// added for testing
public PropertyService(String filename) {
loadProperties(filename);
}

public String getFilePath() {
File propertiesFile = new File(FileUtils.LOGIN_PROPERTIES_FILE);

// for testing
if (propertiesFile.isFile()) {
loadProperties(FileUtils.LOGIN_PROPERTIES_FILE);
return FileUtils.LOGIN_PROPERTIES_FILE;
} else {
loadProperties(FileUtils.LOGIN_PROPERTIES_EXAMPLE_FILE);
return FileUtils.LOGIN_PROPERTIES_EXAMPLE_FILE;
}
}

// added for testing
public PropertyService(String filename) {
loadProperties(filename);
}

public String getProperty(String name) {
String property = prop.getProperty(name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class FileUtilsTest {
private final PropertyService propertyService = new PropertyService();
private final Path propertiesFilePath = Paths.get(FileUtils.LOGIN_PROPERTIES_EXAMPLE_FILE);
private final Path propertiesFilePath = Paths.get(propertyService.getFilePath());

@Test
public void readFileTest() {
Expand Down

0 comments on commit 91e37a3

Please sign in to comment.