From a348dd91ac080557614851a960f91aef4e75d28e Mon Sep 17 00:00:00 2001 From: = Date: Wed, 27 Feb 2019 18:44:55 +0100 Subject: [PATCH 1/2] Issue161 - SonstQubeServerTest korrigiert. --- .../com/viadee/sonarquest/services/SonarConfigService.java | 2 +- .../viadee/sonarquest/services/SonarConfigServiceTest.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sonarQuest-backend/src/main/java/com/viadee/sonarquest/services/SonarConfigService.java b/sonarQuest-backend/src/main/java/com/viadee/sonarquest/services/SonarConfigService.java index af2ba0bd..0f42e6ca 100644 --- a/sonarQuest-backend/src/main/java/com/viadee/sonarquest/services/SonarConfigService.java +++ b/sonarQuest-backend/src/main/java/com/viadee/sonarquest/services/SonarConfigService.java @@ -53,7 +53,7 @@ public boolean checkSonarQubeURL(final SonarConfig sonarConfig) { result = true; } } catch (final Exception e) { - LOGGER.error(e.getMessage(), e); + LOGGER.debug(e.getMessage(), e); } return result; } diff --git a/sonarQuest-backend/src/test/java/com/viadee/sonarquest/services/SonarConfigServiceTest.java b/sonarQuest-backend/src/test/java/com/viadee/sonarquest/services/SonarConfigServiceTest.java index 1ea97590..c3b84ccc 100644 --- a/sonarQuest-backend/src/test/java/com/viadee/sonarquest/services/SonarConfigServiceTest.java +++ b/sonarQuest-backend/src/test/java/com/viadee/sonarquest/services/SonarConfigServiceTest.java @@ -10,18 +10,17 @@ import org.springframework.test.context.junit4.SpringRunner; import com.viadee.sonarquest.entities.SonarConfig; -import com.viadee.sonarquest.services.SonarConfigService; @RunWith(SpringRunner.class) @SpringBootTest public class SonarConfigServiceTest { @Autowired - SonarConfigService sonarConfigService; + private SonarConfigService sonarConfigService; @Test public void testSonarQubeServerURLCheck() { - SonarConfig sonarConfig = new SonarConfig(); + final SonarConfig sonarConfig = new SonarConfig(); sonarConfig.setSonarServerUrl("https://www.sonarcloud.io"); assertTrue(sonarConfigService.checkSonarQubeURL(sonarConfig)); From 42936f6e1f39bf2368efdb02b85a6008a5d2ce6d Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Wed, 27 Feb 2019 20:29:08 +0100 Subject: [PATCH 2/2] Issue #168 --- README.md | 33 ++++ .../controllers/WorldController.java | 153 ++++++++---------- .../sonarquest/services/WorldService.java | 25 ++- .../edit-world/edit-world.component.ts | 10 +- 4 files changed, 134 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index 77a8733d..57c92f8a 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,39 @@ A tool for extending [SonarQube](https://www.sonarqube.org/) by a gamification s * more about SonarQuest's game concepts and application scenarios: https://www.viadee.de/sonarquest_en * Sonar Quest info package: https://github.com/viadee/sonarQuest/blob/master/docs/SonarQuest_info_package.pdf +## NEWS - 1st SonarQuest Coding Night + +*2019-02-27 / 4.19pm* + +Checklist before Takeoff +* Git pull executed, Eclipse updated and Visual Studio Code prepared - CHECK +* Beverages cooled - CHECK +* Laptop stickers prepared - CHECK +* Giant dragon invited - CHECK +* Ink quill readied for extreme pizza ordering - CHECK +* Armor & Sword polished - CHECK + +Guess we are good to go :) + +(Chris) + +*2019-02-27 / 1.49pm* + +I have preselected some issues for tonight that are a perfect place to start coding. They have their own label and you can just pick one of them and assign yourself or by adding a comment like "Issue #125" when you commit the source code. + +https://github.com/viadee/sonarQuest/issues?q=is%3Aissue+is%3Aopen+label%3A%221st+Coding+Night%22 + +(Chris) + +*2019-02-27 / 7.23am* + +German SonarQuest Coders are invited to the 1st Coding Night: https://lp.viadee.de/sonar-quest-coding-night-anmeldung +Coding Night starts at 1800 hrs today! + +Watch this site for updates! + +(Chris) + ## Goal Reduce technical debts in your code project by converting the refactoring process into a game. Create quests from SonarQube issues and write your own story. diff --git a/sonarQuest-backend/src/main/java/com/viadee/sonarquest/controllers/WorldController.java b/sonarQuest-backend/src/main/java/com/viadee/sonarquest/controllers/WorldController.java index 16eff153..61265c11 100644 --- a/sonarQuest-backend/src/main/java/com/viadee/sonarquest/controllers/WorldController.java +++ b/sonarQuest-backend/src/main/java/com/viadee/sonarquest/controllers/WorldController.java @@ -15,7 +15,6 @@ import com.viadee.sonarquest.entities.User; import com.viadee.sonarquest.entities.World; -import com.viadee.sonarquest.repositories.WorldRepository; import com.viadee.sonarquest.services.UserService; import com.viadee.sonarquest.services.WorldService; @@ -23,86 +22,76 @@ @RequestMapping("/world") public class WorldController { - @Autowired - private WorldRepository worldRepository; - - @Autowired - private UserService userService; - - @Autowired - private WorldService worldService; - - @GetMapping(value = "/current") - public World getCurrentWorld(final Principal principal) { - final User user = userService.findByUsername(principal.getName()); - return user.getCurrentWorld(); - } - - @PostMapping(value = "/current") - public World setCurrentWorld(final Principal principal, @RequestBody final World world) { - final User user = userService.findByUsername(principal.getName()); - return userService.updateUsersCurrentWorld(user, world.getId()); - } - - @PreAuthorize("hasAuthority('FULL_WORLD_ACCESS')") - @GetMapping(value = "/user/{id}") - public List getWorldsForUser(@PathVariable(value = "id") final Long id) { - final User user = userService.findById(id); - return user.getWorlds(); - } - - @GetMapping(value = "/worlds") - public List getWorlds(final Principal principal) { - final User user = userService.findByUsername(principal.getName()); - return user.getWorlds(); - } - - @PreAuthorize("hasAuthority('FULL_WORLD_ACCESS')") - @GetMapping(value = "/all") - public List getAllWorlds(final Principal principal) { - return worldService.findAll(); - } - - @PreAuthorize("hasAuthority('FULL_WORLD_ACCESS')") - @GetMapping(value = "/active") - public List activeWorlds(final Principal principal) { - return worldService.findAllActiveWorlds(); - } - - @GetMapping(value = "/world/{id}") - public World getWorldById(@PathVariable(value = "id") final Long id) { - return worldRepository.findOne(id); - } - - @PreAuthorize("hasAuthority('FULL_WORLD_ACCESS')") - @PostMapping(value = "/world") - public World updateWorld(@RequestBody final World data) { - World world = worldRepository.findOne(data.getId()); - if (world != null) { - world.setName(data.getName()); - world.setActive(data.getActive()); - world.setUsequestcards(data.getUsequestcards()); - world = worldRepository.save(world); - } - return world; - } - - @PreAuthorize("hasAuthority('ACTIVE_WORLD_ACCESS')") - @PutMapping(value = "/world/{id}/image") - public World updateBackground(@PathVariable(value = "id") final Long id, @RequestBody final String image) { - World world = worldRepository.findOne(id); - if (world != null) { - world.setImage(image); - world = worldRepository.save(world); - } - return world; - } - - @PreAuthorize("hasAuthority('FULL_WORLD_ACCESS')") - @GetMapping(value = "/generate") - public List generateWorlds() { - worldService.updateWorlds(); - return worldRepository.findAll(); - } + @Autowired + private UserService userService; + + @Autowired + private WorldService worldService; + + @GetMapping(value = "/current") + public World getCurrentWorld(final Principal principal) { + final User user = userService.findByUsername(principal.getName()); + return user.getCurrentWorld(); + } + + @PostMapping(value = "/current") + public World setCurrentWorld(final Principal principal, @RequestBody final World world) { + final User user = userService.findByUsername(principal.getName()); + return userService.updateUsersCurrentWorld(user, world.getId()); + } + + @PreAuthorize("hasAuthority('FULL_WORLD_ACCESS')") + @GetMapping(value = "/user/{id}") + public List getWorldsForUser(@PathVariable(value = "id") final Long id) { + final User user = userService.findById(id); + return user.getWorlds(); + } + + @GetMapping(value = "/worlds") + public List getWorlds(final Principal principal) { + final User user = userService.findByUsername(principal.getName()); + return user.getWorlds(); + } + + @PreAuthorize("hasAuthority('FULL_WORLD_ACCESS')") + @GetMapping(value = "/all") + public List getAllWorlds(final Principal principal) { + return worldService.findAll(); + } + + @PreAuthorize("hasAuthority('FULL_WORLD_ACCESS')") + @GetMapping(value = "/active") + public List activeWorlds(final Principal principal) { + return worldService.findAllActiveWorlds(); + } + + @GetMapping(value = "/world/{id}") + public World getWorldById(@PathVariable(value = "id") final Long id) { + return worldService.findById(id); + } + + @PreAuthorize("hasAuthority('FULL_WORLD_ACCESS')") + @PostMapping(value = "/world") + public World updateWorld(@RequestBody final World data) { + return worldService.updateWorld(data); + } + + @PreAuthorize("hasAuthority('ACTIVE_WORLD_ACCESS')") + @PutMapping(value = "/world/{id}/image") + public World updateBackground(@PathVariable(value = "id") final Long id, @RequestBody final String image) { + World world = worldService.findById(id); + if (world != null) { + world.setImage(image); + world = worldService.save(world); + } + return world; + } + + @PreAuthorize("hasAuthority('FULL_WORLD_ACCESS')") + @GetMapping(value = "/generate") + public List generateWorlds() { + worldService.updateWorlds(); + return worldService.findAll(); + } } diff --git a/sonarQuest-backend/src/main/java/com/viadee/sonarquest/services/WorldService.java b/sonarQuest-backend/src/main/java/com/viadee/sonarquest/services/WorldService.java index 21b5e459..e934b90e 100644 --- a/sonarQuest-backend/src/main/java/com/viadee/sonarquest/services/WorldService.java +++ b/sonarQuest-backend/src/main/java/com/viadee/sonarquest/services/WorldService.java @@ -17,16 +17,23 @@ public class WorldService { @Autowired private WorldRepository worldRepository; + @Autowired + private StandardTaskService standardTaskService; + public List findAll() { return worldRepository.findAll(); } + public World save(final World world) { + return worldRepository.save(world); + } + public void updateWorlds() { final List externalWorlds = externalRessourceService.generateWorldsFromSonarQubeProjects(); - externalWorlds.forEach(this::updateWorld); + externalWorlds.forEach(this::saveWorldIfNotExists); } - private void updateWorld(final World externalWorld) { + private void saveWorldIfNotExists(final World externalWorld) { final World internalWorld = worldRepository.findByProject(externalWorld.getProject()); if (internalWorld == null) { worldRepository.save(externalWorld); @@ -37,7 +44,7 @@ public void setExternalRessourceService(final ExternalRessourceService externalR this.externalRessourceService = externalRessourceService; } - public List findAllActiveWorlds(){ + public List findAllActiveWorlds() { return worldRepository.findByActiveTrue(); } @@ -45,4 +52,16 @@ public World findById(final Long id) { return worldRepository.findOne(id); } + public World updateWorld(final World world) { + World currentWorld = worldRepository.findOne(world.getId()); + if (world != null) { + currentWorld.setName(world.getName()); + currentWorld.setActive(world.getActive()); + currentWorld.setUsequestcards(world.getUsequestcards()); + currentWorld = worldRepository.save(currentWorld); + standardTaskService.updateStandardTasks(currentWorld); + } + return currentWorld; + } + } diff --git a/sonarQuest-frontend/src/app/pages/admin-page/components/admin-world/components/edit-world/edit-world.component.ts b/sonarQuest-frontend/src/app/pages/admin-page/components/admin-world/components/edit-world/edit-world.component.ts index 6e5c998a..8d00c0ad 100644 --- a/sonarQuest-frontend/src/app/pages/admin-page/components/admin-world/components/edit-world/edit-world.component.ts +++ b/sonarQuest-frontend/src/app/pages/admin-page/components/admin-world/components/edit-world/edit-world.component.ts @@ -3,6 +3,7 @@ import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material'; import {World} from '../../../../../../Interfaces/World'; import {WorldService} from '../../../../../../services/world.service'; import {SelectBackgroundComponent} from './select-background/select-background.component'; +import {LoadingService} from '../../../../../../services/loading.service'; @Component({ selector: 'app-edit-world', @@ -14,14 +15,19 @@ export class EditWorldComponent implements OnInit { constructor(private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public world: World, private worldService: WorldService, - private dialog: MatDialog) { + private dialog: MatDialog, + private loadingService: LoadingService) { } ngOnInit() { } updateWorld() { - this.worldService.updateWorld(this.world).then(() => this.dialogRef.close()) + const loading = this.loadingService.getLoadingSpinner(); + this.worldService.updateWorld(this.world).then(() => { + this.dialogRef.close(); + loading.close(); + }).catch(() => loading.close()); } selectBackground() {