use of com.viadee.sonarQuest.entities.Participation in project sonarQuest by viadee.
the class TaskController method addParticipation.
@RequestMapping(value = "/{taskId}/addParticipation/{questId}/{developerId}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public TaskDto addParticipation(@PathVariable(value = "taskId") final Long taskId, @PathVariable(value = "questId") final Long questId, @PathVariable(value = "developerId") final Long developerId) {
Task task = this.taskRepository.findOne(taskId);
final Participation participation = participationService.findParticipationByQuestIdAndDeveloperId(questId, developerId);
if (task != null && participation != null) {
task.setParticipation(participation);
task.setStatus(TaskStates.PROCESSED);
task = this.taskRepository.save(task);
}
return toTaskDto(task);
}
use of com.viadee.sonarQuest.entities.Participation in project sonarQuest by viadee.
the class ParticipationController method createParticipation.
@CrossOrigin
@RequestMapping(value = "/{questid}/{developerid}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public Participation createParticipation(@PathVariable(value = "questid") Long questid, @PathVariable(value = "developerid") Long developerid) {
Quest foundQuest = questRepository.findOne(questid);
Developer foundDeveloper = developerRepository.findOne(developerid);
Participation foundParticipation = participationRepository.findByQuestAndDeveloper(foundQuest, foundDeveloper);
Participation participation = null;
if ((foundQuest != null) && (foundDeveloper != null) && (foundParticipation == null)) {
participation = new Participation(foundQuest, foundDeveloper);
participation = participationRepository.save(participation);
}
return participation;
}
use of com.viadee.sonarQuest.entities.Participation in project sonarQuest by viadee.
the class GratificationService method rewardDeveloperForSolvingTask.
@Override
public void rewardDeveloperForSolvingTask(final Task task) {
final Participation participation = task.getParticipation();
if (participation != null) {
Developer developer = participation.getDeveloper();
final Developer developer1 = developer;
final Developer rewardedDeveloper = developer1;
rewardedDeveloper.addXp(task.getXp());
rewardedDeveloper.addGold(task.getGold());
developer = rewardedDeveloper;
developer = addSkillReward(developer, task);
developer.setLevel(levelService.getLevelByDeveloperXp(developer.getXp()));
developerRepository.save(developer);
}
}
use of com.viadee.sonarQuest.entities.Participation in project sonarQuest by viadee.
the class ParticipationService method findParticipationByQuestIdAndDeveloperId.
public Participation findParticipationByQuestIdAndDeveloperId(Long questId, Long developerId) {
Quest foundQuest = questRepository.findOne(questId);
Developer foundDeveloper = developerRepository.findOne(developerId);
Participation foundParticipation = null;
if ((foundQuest != null) && (foundDeveloper != null)) {
foundParticipation = participationRepository.findByQuestAndDeveloper(foundQuest, foundDeveloper);
}
return foundParticipation;
}
use of com.viadee.sonarQuest.entities.Participation in project sonarQuest by viadee.
the class SonarQuestApplicationIT method developersCanParticipateInQuestsAndIssues.
/**
* Walk through the participation on the backend with a developer perspective.
* This test assumes a spring environment including a simulated sonar server and
* database access.
*/
// There is hardly any data to fetch - this should be quick, altough there are
@Test(timeout = 1000)
public // write operations included
void developersCanParticipateInQuestsAndIssues() {
// Join in on a quest.
// Add Participation sonarHero123, Quest1
participationController.createParticipation((long) 1, (long) 1);
final Quest epicQuest = questRepository.findOne((long) 1);
final List<Participation> participations = epicQuest.getParticipations();
assertEquals("createParticipation does not work (Quest)", "Quest1", participations.get(0).getQuest().getTitle());
assertEquals("createParticipation does not work (Developer)", "sonarHero123", participations.get(0).getDeveloper().getUsername());
// Get to work on issue 1
Task issue1 = taskRepository.findOne((long) 1);
assertNull("addParticipationToTask does not work (Quest)", issue1.getParticipation());
taskController.addParticipation((long) 1, (long) 1, (long) 1);
issue1 = taskRepository.findOne((long) 1);
assertEquals("addParticipation does not work (Quest)", "Quest1", issue1.getParticipation().getQuest().getTitle());
assertEquals("addParticipation does not work (Developer)", "sonarHero123", issue1.getParticipation().getDeveloper().getUsername());
assertEquals("addParticipation does not work (Status)", TaskStates.PROCESSED, issue1.getStatus());
// no effect expected
adventureService.updateAdventures();
}
Aggregations