diff --git a/server/build.gradle b/server/build.gradle index 273daa1..3d82780 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -114,10 +114,10 @@ application { mainClass = 'dev.findfirst.FindFirstApplication' } -bootRun -{ +bootRun +{ String activeProfile = System.properties['spring.profiles.active'] - if(activeProfile == null || activeProfile.isBlank()) { + if(activeProfile == null || activeProfile.isBlank()) { systemProperty "spring.profiles.active", "dev"; } } diff --git a/server/src/main/java/dev/findfirst/core/controller/BookmarkController.java b/server/src/main/java/dev/findfirst/core/controller/BookmarkController.java index 0b96851..dd31762 100644 --- a/server/src/main/java/dev/findfirst/core/controller/BookmarkController.java +++ b/server/src/main/java/dev/findfirst/core/controller/BookmarkController.java @@ -97,8 +97,7 @@ public ResponseEntity addBookmark(@RequestBody AddBkmkReq req) @PatchMapping("/bookmark") public ResponseEntity updateBookmark( @Valid @RequestBody UpdateBookmarkReq updateBookmarkReq) throws BookmarkNotFoundException { - return new ResponseEntity<>(bookmarkService.updateBookmark(updateBookmarkReq), - HttpStatus.OK); + return new ResponseEntity<>(bookmarkService.updateBookmark(updateBookmarkReq), HttpStatus.OK); } @DeleteMapping("/bookmark") diff --git a/server/src/main/java/dev/findfirst/core/exceptions/GlobalExceptionHandler.java b/server/src/main/java/dev/findfirst/core/exceptions/GlobalExceptionHandler.java index f4a6719..86bf77e 100644 --- a/server/src/main/java/dev/findfirst/core/exceptions/GlobalExceptionHandler.java +++ b/server/src/main/java/dev/findfirst/core/exceptions/GlobalExceptionHandler.java @@ -18,9 +18,9 @@ public class GlobalExceptionHandler { protected ResponseEntity> handleResponseStatusException( ResponseStatusException ex) { // Extract log message - String logMessage = - ex instanceof ErrorResponseException errorResponseException ? errorResponseException.getServerLogMessage() - : ex.getReason(); + String logMessage = ex instanceof ErrorResponseException errorResponseException + ? errorResponseException.getServerLogMessage() + : ex.getReason(); StackTraceElement[] stackTrace = ex.getStackTrace(); // Get the first relevant stack trace element (usually the point where the exception was thrown) StackTraceElement origin = stackTrace.length > 0 ? stackTrace[0] : null; diff --git a/server/src/main/java/dev/findfirst/core/service/BookmarkService.java b/server/src/main/java/dev/findfirst/core/service/BookmarkService.java index 6e05cca..3df3067 100644 --- a/server/src/main/java/dev/findfirst/core/service/BookmarkService.java +++ b/server/src/main/java/dev/findfirst/core/service/BookmarkService.java @@ -141,8 +141,8 @@ public BookmarkDTO addBookmark(AddBkmkReq reqBkmk) var screenshotUrlOpt = Optional.of(""); boolean shouldScrape = reqBkmk.scrapable(); - // Can we scrape this? - if (reqBkmk.scrapable()) { + // Can we scrape this? + if (reqBkmk.scrapable()) { shouldScrape = webCheckService.isScrapable(reqBkmk.url()); } @@ -169,9 +169,9 @@ public BookmarkDTO addBookmark(AddBkmkReq reqBkmk) var savedTags = new HashSet(); - var newBkmkJdbc = - new BookmarkJDBC(null, user.getUserId(), new Date(), user.getUsername(), user.getUsername(), - new Date(), title, reqBkmk.url(), screenshotUrlOpt.orElse(""), reqBkmk.scrapable(), savedTags); + var newBkmkJdbc = new BookmarkJDBC(null, user.getUserId(), new Date(), user.getUsername(), + user.getUsername(), new Date(), title, reqBkmk.url(), screenshotUrlOpt.orElse(""), + reqBkmk.scrapable(), savedTags); var saved = bookmarkJDBCRepository.save(newBkmkJdbc); for (var tag : tags) { diff --git a/server/src/main/java/dev/findfirst/users/service/UserManagementService.java b/server/src/main/java/dev/findfirst/users/service/UserManagementService.java index 68c4802..9199533 100644 --- a/server/src/main/java/dev/findfirst/users/service/UserManagementService.java +++ b/server/src/main/java/dev/findfirst/users/service/UserManagementService.java @@ -111,7 +111,7 @@ public Token getPasswordToken(String pwdToken) { public User getUserFromPasswordToken(String pwdToken) throws NoUserFoundException { var userId = passwordTokenRepository.findByTokenVal(pwdToken).getUser().getId(); - if (userId == null) { + if (userId == null) { throw new NoUserFoundException(); } return userRepo.findById(userId).orElseThrow(NoUserFoundException::new); diff --git a/server/src/test/java/dev/findfirst/core/model/SearchBkmkByTagReqTest.java b/server/src/test/java/dev/findfirst/core/model/SearchBkmkByTagReqTest.java index f843399..1d30dae 100644 --- a/server/src/test/java/dev/findfirst/core/model/SearchBkmkByTagReqTest.java +++ b/server/src/test/java/dev/findfirst/core/model/SearchBkmkByTagReqTest.java @@ -1,17 +1,20 @@ package dev.findfirst.core.model; -import java.util.List; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; + +import java.util.List; + import org.junit.jupiter.api.Test; -class SearchBkmkByTagReqTest { +class SearchBkmkByTagReqTest { @Test - void tagRequestsEqual() { - assertEquals(new SearchBkmkByTagReq(List.of("tech", "docs")), new SearchBkmkByTagReq(List.of("tech", "docs"))); - assertNotEquals(new SearchBkmkByTagReq(List.of("tech", "docs")), new SearchBkmkByTagReq(List.of("tech"))); + void tagRequestsEqual() { + assertEquals(new SearchBkmkByTagReq(List.of("tech", "docs")), + new SearchBkmkByTagReq(List.of("tech", "docs"))); + assertNotEquals(new SearchBkmkByTagReq(List.of("tech", "docs")), + new SearchBkmkByTagReq(List.of("tech"))); assertNotEquals("String", new SearchBkmkByTagReq(List.of("tech", "docs"))); } } diff --git a/server/src/test/java/dev/findfirst/core/model/SearchBkmkByTitleReq.java b/server/src/test/java/dev/findfirst/core/model/SearchBkmkByTitleReq.java index 1c2df30..08b63fe 100644 --- a/server/src/test/java/dev/findfirst/core/model/SearchBkmkByTitleReq.java +++ b/server/src/test/java/dev/findfirst/core/model/SearchBkmkByTitleReq.java @@ -7,19 +7,30 @@ import org.junit.jupiter.api.Test; -class SearchBkmkByTitleReqTest { +class SearchBkmkByTitleReqTest { @Test - void titleRequestsEquality() { - assertEquals(new SearchBkmkByTitleReq(new String[]{"java", "spring"}), new SearchBkmkByTitleReq(new String[]{"java", "spring"})); - assertNotEquals(new SearchBkmkByTitleReq(new String[]{"java", "spring"}), new SearchBkmkByTitleReq(new String[]{"java"})); - assertNotEquals("String", new SearchBkmkByTitleReq(new String[]{"java", "spring"})); + void titleRequestsEquality() { + assertEquals(new SearchBkmkByTitleReq(new String[] {"java", "spring"}), + new SearchBkmkByTitleReq(new String[] {"java", "spring"})); + assertNotEquals(new SearchBkmkByTitleReq(new String[] {"java", "spring"}), + new SearchBkmkByTitleReq(new String[] {"java"})); + assertNotEquals("String", new SearchBkmkByTitleReq(new String[] {"java", "spring"})); + assertNotEquals(null, new SearchBkmkByTitleReq(new String[] {"java", "spring"})); } - @Test - void hashCodeTest() { - var keywords = new String[]{"java", "spring"}; + @Test + void hashCodeTest() { + var keywords = new String[] {"java", "spring"}; + var searchReq = new SearchBkmkByTitleReq(keywords); + assertEquals(Arrays.hashCode(keywords), searchReq.hashCode()); + } + + @Test + void toStringTest() { + var keywords = new String[] {"java", "spring"}; var searchReq = new SearchBkmkByTitleReq(keywords); - assertEquals(Arrays.hashCode(keywords), searchReq.hashCode()); + assertEquals(Arrays.toString(keywords), searchReq.toString()); + } }