generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
9 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,15 @@ public InsertSampleDataService(PlayerService playerService, QuestionService ques | |
@Transactional | ||
@EventListener(ApplicationReadyEvent.class) // Uncomment this line to insert sample data on startup | ||
public void insertSampleQuestions() { | ||
if (!playerService.getUserByEmail("[email protected]").isPresent()) { | ||
PlayerDto player = new PlayerDto(); | ||
player.setEmail("[email protected]"); | ||
player.setUsername("test"); | ||
player.setPassword("test"); | ||
player.setRoles(new String[]{"ROLE_USER"}); | ||
playerService.generateApiKey(playerService.addNewPlayer(player)); | ||
} | ||
|
||
if (Arrays.stream(environment.getActiveProfiles()).anyMatch(env -> (env.equalsIgnoreCase("test")))) { | ||
log.info("Test profile active, skipping sample data insertion"); | ||
return; | ||
|
@@ -60,14 +69,6 @@ public void insertSampleQuestions() { | |
|
||
@Transactional | ||
public void generateSampleData() { | ||
if (!playerService.getUserByEmail("[email protected]").isPresent()) { | ||
PlayerDto player = new PlayerDto(); | ||
player.setEmail("[email protected]"); | ||
player.setUsername("test"); | ||
player.setPassword("test"); | ||
player.setRoles(new String[]{"ROLE_USER"}); | ||
playerService.generateApiKey(playerService.addNewPlayer(player)); | ||
} | ||
|
||
questionRepository.deleteAll(); | ||
|
||
|