From 3db5e91eb8c0c84e4e773d06cda43d5a4006b992 Mon Sep 17 00:00:00 2001 From: KronosDP <darrel.danadyaksa19@gmail.com> Date: Fri, 28 Feb 2025 22:01:32 +0700 Subject: [PATCH] [REFACTOR] Simplify response messages in postContent method and update corresponding tests --- .../authentication/service/AuthenticationService.java | 6 +++--- .../authentication/service/AuthenticationServiceTest.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/safetypin/authentication/service/AuthenticationService.java b/src/main/java/com/safetypin/authentication/service/AuthenticationService.java index 4dd868e..71e3683 100644 --- a/src/main/java/com/safetypin/authentication/service/AuthenticationService.java +++ b/src/main/java/com/safetypin/authentication/service/AuthenticationService.java @@ -135,7 +135,7 @@ public class AuthenticationService { } // Example method representing posting content that requires a verified account - public String postContent(String email, String content) { + public String postContent(String email, String content) { // NOSONAR User user = userRepository.findByEmail(email); if (user == null) { return "User not found. Please register."; @@ -143,9 +143,9 @@ public class AuthenticationService { if (!user.isVerified()) { return "Your account is not verified. Please complete OTP verification. You may request a new OTP after 2 minutes."; } - logger.info("AuthenticationService.postContent :: Content posted by user with email: {}", email); + logger.info("Content posted successfully by user"); // For demo purposes, we assume the post is successful. - return String.format("Content '%s' posted successfully.", content); + return "Content posted successfully"; } private int calculateAge(LocalDate birthdate) { diff --git a/src/test/java/com/safetypin/authentication/service/AuthenticationServiceTest.java b/src/test/java/com/safetypin/authentication/service/AuthenticationServiceTest.java index 1dbe0c1..97b3d10 100644 --- a/src/test/java/com/safetypin/authentication/service/AuthenticationServiceTest.java +++ b/src/test/java/com/safetypin/authentication/service/AuthenticationServiceTest.java @@ -430,7 +430,7 @@ class AuthenticationServiceTest { user.setSocialId(null); when(userRepository.findByEmail("test@example.com")).thenReturn(user); - String response = authenticationService.postContent("test@example.com", "ThisIsAContent"); - assertEquals("Content 'ThisIsAContent' posted successfully.", response); + String response = authenticationService.postContent("test@example.com", "Content"); + assertEquals("Content posted successfully", response); } } -- GitLab