Skip to content

Commit

Permalink
Upgrading to java 23
Browse files Browse the repository at this point in the history
  • Loading branch information
surajcm committed Nov 10, 2024
1 parent d1510ee commit 3850c59
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22
23
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ buildscript {
plugins {
id 'java'
id 'idea'
id 'org.springframework.boot' version '3.3.2'
id 'io.spring.dependency-management' version '1.1.5'
id 'org.springframework.boot' version '3.3.5'
id 'io.spring.dependency-management' version '1.1.6'
id 'net.ltgt.errorprone' version '4.0.1'
id 'com.github.spotbugs' version '6.0.18' apply false
id 'com.github.spotbugs' version '6.0.26' apply false
id 'de.aaschmid.cpd' version '3.3'
id "org.sonarqube" version "5.0.0.4638"
id "org.sonarqube" version "5.1.0.4882"
}

group = 'com.quiz.darkhold'
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-23.jdk/Contents/Home"
export JAVA_OPTS="-Xms512m -Xmx512m"
exec ./gradlew "$@"
4 changes: 2 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-log4j2")
runtimeOnly("org.springframework.boot:spring-boot-devtools")

implementation("org.apache.poi:poi-ooxml:5.2.5")
implementation("org.apache.commons:commons-lang3:3.14.0")
implementation("org.apache.poi:poi-ooxml:5.3.0")
implementation("org.apache.commons:commons-lang3:3.17.0")
implementation("com.h2database:h2:2.1.214")
implementation("org.dizitart:nitrite:3.4.4")

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.quiz.darkhold.challenge.exception.ChallengeException;
import com.quiz.darkhold.challenge.repository.ChallengeRepository;
import com.quiz.darkhold.challenge.repository.QuestionSetRepository;
import com.quiz.darkhold.user.repository.UserRepository;
import com.quiz.darkhold.user.entity.DarkholdUserDetails;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException;
Expand All @@ -29,14 +29,11 @@ public class ChallengeService {
private final Logger logger = LogManager.getLogger(ChallengeService.class);
private final ChallengeRepository challengeRepository;
private final QuestionSetRepository questionSetRepository;
private final UserRepository userRepository;

public ChallengeService(final ChallengeRepository challengeRepository,
final QuestionSetRepository questionSetRepository,
final UserRepository userRepository) {
final QuestionSetRepository questionSetRepository) {
this.challengeRepository = challengeRepository;
this.questionSetRepository = questionSetRepository;
this.userRepository = userRepository;
}

/**
Expand Down Expand Up @@ -78,9 +75,8 @@ public Boolean deleteChallenge(final Long challengeId) {

private Long currentUserId() {
var auth = SecurityContextHolder.getContext().getAuthentication();
var username = auth.getName();
var user = userRepository.findByEmail(username);
return user.getId();
var principal = auth.getPrincipal();
return ((DarkholdUserDetails) principal).getUser().getId();
}

//replace LinkedList with ArrayDeque as the return type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public GameController(final GameService gameService) {
public String startInterstitial(final Model model, @RequestParam("quiz_pin") final String quizPin) {
var sanitizedPin = CommonUtils.sanitizedString(quizPin);
logger.info("On to interstitial : {}", sanitizedPin);
model.addAttribute("quizPin", quizPin);
return "interstitial";
}

Expand All @@ -48,8 +49,9 @@ public String startInterstitial(final Model model, @RequestParam("quiz_pin") fin
* @return question page
*/
@PostMapping("/question")
public String question(final Model model, final Principal principal) {
logger.info("On to question :");
public String question(final Model model,
final Principal principal) {
//logger.info("On to question :" + quizPin);
var questionPointer = gameService.getCurrentQuestionPointer();
if (questionPointer.getCurrentQuestionNumber() == questionPointer.getTotalQuestionCount()) {
return finalScore(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public String scoreCheck(final Model model) {
logger.info("On to the scoreboard screen");
var score = new CurrentScore();
var scores = gameService.getCurrentScore();
logger.info("Total uses are {}", scores.size());
logger.info("Current score is {}", scores.size());
scores.forEach((key, value) ->
logger.info("key is:" + key +
", and value is :" + value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ public boolean isCredentialsNonExpired() {
public boolean isEnabled() {
return user.getEnabled();
}

public User getUser() {
return this.user;
}
}
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ spring.h2.console.enabled=true
#spring.datasource.url=jdbc:h2:file:/tmp/db/darkhold
#spring.datasource.driver-class-name=org.h2.Driver
spring.flyway.enabled=false
admin.as_participant=true
1 change: 0 additions & 1 deletion src/main/resources/static/scripts/publish-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function startGame() {
});
}


function gotoMyGame() {
document.forms[0].action = "/interstitial";
document.forms[0].submit();
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/templates/interstitial.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
setTimeout(function(){ askQuestion(); }, 5000);
}
function askQuestion() {
let quizPin = document.getElementById('quizPin').value;
console.log('triggering quiz of ' + quizPin);
document.getElementById('quizPin').value = quizPin;
document.forms[0].action="/question";
document.forms[0].submit();
}
</script>
</head>
<body onload="loading()">
<form action="#" method="post">
<input type="hidden" th:value="${quizPin}" id="quizPin" />
<div class="container">
<div class="row">
<div class="container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.quiz.darkhold.challenge.exception.ChallengeException;
import com.quiz.darkhold.challenge.repository.ChallengeRepository;
import com.quiz.darkhold.challenge.repository.QuestionSetRepository;
import com.quiz.darkhold.user.repository.UserRepository;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -22,10 +21,8 @@
class ChallengeServiceTest {
private final ChallengeRepository challengeRepository = Mockito.mock(ChallengeRepository.class);
private final QuestionSetRepository questionSetRepository = Mockito.mock(QuestionSetRepository.class);
private final UserRepository userRepository = Mockito.mock(UserRepository.class);
private final ChallengeService challengeService = new ChallengeService(challengeRepository,
questionSetRepository,
userRepository);
questionSetRepository);


@Test
Expand Down

0 comments on commit 3850c59

Please sign in to comment.