Repository: ShopSmartSG/profile-service
Pull request #36: Changing path variable to request Param for userId
Author: login: thoriritu
Created: 2025-03-07T06:29:51Z | Merged: 2025-03-08T05:22:21Z



Diff:
diff --git a/src/main/java/sg/edu/nus/iss/profile_service/controller/CustomerController.java b/src/main/java/sg/edu/nus/iss/profile_service/controller/CustomerController.java
index fb30b5e..c8f8d94 100644
--- a/src/main/java/sg/edu/nus/iss/profile_service/controller/CustomerController.java
+++ b/src/main/java/sg/edu/nus/iss/profile_service/controller/CustomerController.java
@@ -44,7 +44,7 @@ public CustomerController(ProfileServiceFactory profileServiceFactory, ObjectMap
         this.mapper = mapper;
     }
 
-    @GetMapping
+    @GetMapping("/all")
     @Operation(summary = "Retrieve all customers")
     public ResponseEntity<?> getAllCustomers(
             @RequestParam(value = "page", required = false) Integer page,
@@ -67,10 +67,11 @@ public ResponseEntity<?> getAllCustomers(
         return ResponseEntity.ok(customerPage);
     }
 
-    @GetMapping("/{customer-id}")
+    @GetMapping("/")
     @Operation(summary = "Retrieve customers by ID")
-    public ResponseEntity<Customer> getCustomer(@PathVariable(name = "customer-id") UUID customerId) {
+    public ResponseEntity<Customer> getCustomer(@RequestParam("user-id") String userId) {
 
+        UUID customerId = UUID.fromString(userId);
         log.info("{\"message\": \"Fetching customer with ID: {}\"}", customerId);
 
         Optional<Profile> profile = profileServiceFactory.getProfileById(CUSTOMER_TYPE, customerId);
@@ -81,9 +82,11 @@ public ResponseEntity<Customer> getCustomer(@PathVariable(name = "customer-id")
         return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
     }
 
-    @PutMapping("/{customer-id}")
+    @PutMapping("/")
     @Operation(summary = "Update customers")
-    public ResponseEntity<String> updateCustomer(@PathVariable(name = "customer-id") UUID customerId, @Valid @RequestBody CustomerDTO customerDTO) {
+    public ResponseEntity<String> updateCustomer(@RequestParam("user-id") String userId, @Valid @RequestBody CustomerDTO customerDTO) {
+
+            UUID customerId = UUID.fromString(userId);
             Optional<Profile> existingCustomerOpt = profileServiceFactory.getProfileById(CUSTOMER_TYPE, customerId);
         log.info("{\"message\": \"Updating customer with ID: {}\"}", customerId);
             if (existingCustomerOpt.isEmpty()) {
@@ -116,9 +119,10 @@ public ResponseEntity<String> updateCustomer(@PathVariable(name = "customer-id")
             return ResponseEntity.ok("Customer updated successfully");
     }
 
-    @DeleteMapping("/{customer-id}")
+    @DeleteMapping("/")
     @Operation(summary = "Delete customer by ID")
-    public ResponseEntity<String> deleteCustomer(@PathVariable(name = "customer-id") UUID customerId) {
+    public ResponseEntity<String> deleteCustomer(@RequestParam("user-id") String userId) {
+        UUID customerId = UUID.fromString(userId);
         log.info("{\"message\": \"Deleting customer with ID: {}\"}", customerId);
         profileServiceFactory.deleteProfile(customerId);
         return ResponseEntity.ok("Delete: successful");
@@ -152,10 +156,10 @@ public ResponseEntity<?> getCustomerByEmail(@PathVariable String email) {
         return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Customer not found");
     }
 
-    @PutMapping("/{customer-id}/rewards/{order-price}")
+    @PutMapping("/rewards/{order-price}")
     @Operation(summary = "Update Customer Reward Points" , description = "Customer Order Value = Number of Reward Points")
-    public ResponseEntity<?> patchRewardPoints(@PathVariable(name = "customer-id") UUID customerId ,@PathVariable("order-price") BigDecimal amount){
-
+    public ResponseEntity<?> patchRewardPoints(@RequestParam("user-id") String userId ,@PathVariable("order-price") BigDecimal amount){
+        UUID customerId = UUID.fromString(userId);
         Optional<Profile> profile = profileServiceFactory.getProfileById(CUSTOMER_TYPE,customerId);
         if(profile.isPresent() && profile.get() instanceof Customer ){
             Customer customer = (Customer) profile.get();
@@ -170,11 +174,12 @@ public ResponseEntity<?> patchRewardPoints(@PathVariable(name = "customer-id") U
     }
 
 
-    @GetMapping("/{customer-id}/rewards")
+    @GetMapping("/rewards")
     @Operation(summary = "get reward points and reward amount equivalent for a customer" , description = "100 Reward points = 1 S$")
-    public ResponseEntity<Rewards> retrieveRewardDetails(@PathVariable(name = "customer-id") UUID customerId) {
+    public ResponseEntity<Rewards> retrieveRewardDetails(@RequestParam("user-id") String userId) {
         // get points give back amount
         // 100 reward points to 10$
+        UUID customerId = UUID.fromString(userId);
         try {
             Optional<Profile> profile = profileServiceFactory.getProfileById(CUSTOMER_TYPE, customerId);
             if (profile.isPresent() && profile.get() instanceof Customer ) {
diff --git a/src/main/java/sg/edu/nus/iss/profile_service/controller/DeliveryPartnerController.java b/src/main/java/sg/edu/nus/iss/profile_service/controller/DeliveryPartnerController.java
index 30c4438..274d8c4 100644
--- a/src/main/java/sg/edu/nus/iss/profile_service/controller/DeliveryPartnerController.java
+++ b/src/main/java/sg/edu/nus/iss/profile_service/controller/DeliveryPartnerController.java
@@ -42,7 +42,7 @@ public DeliveryPartnerController(ProfileServiceFactory profileServiceFactory, Ob
         this.mapper = mapper;
     }
 
-    @GetMapping
+    @GetMapping("/all")
     @Operation(summary = "Retrieve all delivery partners profile")
     public ResponseEntity<?> getAllDeliveryPartners(
             @RequestParam(value = "page", required = false) Integer page,
@@ -65,10 +65,10 @@ public ResponseEntity<?> getAllDeliveryPartners(
         return ResponseEntity.ok(deliveryPartnerPage);
     }
 
-    @GetMapping("/{partner-id}")
+    @GetMapping("/")
     @Operation(summary = "Retrieve delivery partner profile by ID")
-    public ResponseEntity<DeliveryPartner> getDeliveryPartnerByEmail(@PathVariable(name = "partner-id") UUID deliveryPartnerId) {
-
+    public ResponseEntity<DeliveryPartner> getDeliveryPartnerById(@RequestParam("user-id") String userId) {
+        UUID deliveryPartnerId = UUID.fromString(userId);
         log.info("{\"message\": \"Fetching delivery partner with ID: " + deliveryPartnerId + "\"}");
             Optional<Profile> profile = profileServiceFactory.getProfileById(DELIVERY_STRING, deliveryPartnerId);
             if (profile.isPresent() && profile.get() instanceof DeliveryPartner) {
@@ -78,10 +78,10 @@ public ResponseEntity<DeliveryPartner> getDeliveryPartnerByEmail(@PathVariable(n
             return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
     }
 
-    @PutMapping("/{partner-id}")
+    @PutMapping("/")
     @Operation(summary = "Update delivery partner profile")
-    public ResponseEntity<String> updateDeliveryPartner(@PathVariable(name = "partner-id") UUID deliveryPartnerId, @Valid @RequestBody DeliveryPartnerDTO deliveryPartnerDTO) {
-
+    public ResponseEntity<String> updateDeliveryPartner(@RequestParam("user-id") String userId, @Valid @RequestBody DeliveryPartnerDTO deliveryPartnerDTO) {
+        UUID deliveryPartnerId = UUID.fromString(userId);
         log.info("{\"message\": \"Updating delivery partner with ID: {}\"}", deliveryPartnerId);
         Optional<Profile> existingDeliveryPartnerOpt = profileServiceFactory.getProfileById(DELIVERY_STRING, deliveryPartnerId);
                if (existingDeliveryPartnerOpt.isEmpty()) {
@@ -109,25 +109,27 @@ public ResponseEntity<String> updateDeliveryPartner(@PathVariable(name = "partne
                return ResponseEntity.ok("Delivery Partner updated successfully");
 }
 
-    @DeleteMapping("/{partner-id}")
+    @DeleteMapping("/")
     @Operation(summary = "Delete delivery partner profile by ID")
-    public ResponseEntity<String> deleteDeliveryPartner(@PathVariable(name = "partner-id") UUID deliveryPartnerId) {
-
+    public ResponseEntity<String> deleteDeliveryPartner(@RequestParam("user-id") String userId) {
+        UUID deliveryPartnerId = UUID.fromString(userId);
         log.info("{\"message\": \"Deleting delivery partner with ID: {}\"}", deliveryPartnerId);
         profileServiceFactory.deleteProfile(deliveryPartnerId);
         return ResponseEntity.ok("Delete: successful");
     }
 
-    @PutMapping("/blacklist/{partner-id}")
+    @PutMapping("/blacklist/")
     @Operation(summary = "Blacklist a Delivery Partner")
-    public ResponseEntity<String> blacklistDeliveryPartner(@PathVariable(name = "partner-id") UUID deliveryPartnerId) {
+    public ResponseEntity<String> blacklistDeliveryPartner(@RequestParam("user-id") String userId) {
+        UUID deliveryPartnerId = UUID.fromString(userId);
         profileServiceFactory.blacklistProfile(deliveryPartnerId);
         return ResponseEntity.ok("Delivery Partner blacklisted successfully");
     }
 
-    @PutMapping("/unblacklist/{partner-id}")
+    @PutMapping("/unblacklist/")
     @Operation(summary = "Unblacklist a Delivery Partner")
-    public ResponseEntity<String> unblacklistDeliveryPartner(@PathVariable(name = "partner-id") UUID deliveryPartnerId) {
+    public ResponseEntity<String> unblacklistDeliveryPartner(@RequestParam("user-id") String userId) {
+        UUID deliveryPartnerId = UUID.fromString(userId);
         profileServiceFactory.unblacklistProfile(deliveryPartnerId);
         return ResponseEntity.ok("Delivery Partner unblacklisted successfully");
     }
diff --git a/src/main/java/sg/edu/nus/iss/profile_service/controller/MerchantController.java b/src/main/java/sg/edu/nus/iss/profile_service/controller/MerchantController.java
index 32a41d0..d7da3a0 100644
--- a/src/main/java/sg/edu/nus/iss/profile_service/controller/MerchantController.java
+++ b/src/main/java/sg/edu/nus/iss/profile_service/controller/MerchantController.java
@@ -43,7 +43,7 @@ public MerchantController(ProfileServiceFactory profileServiceFactory, ObjectMap
         this.mapper = mapper;
     }
 
-    @GetMapping
+    @GetMapping("/all")
     @Operation(summary = "Retrieve all merchants")
     public ResponseEntity<?> getAllMerchants(
             @RequestParam(value = "page", required = false) Integer page,
@@ -69,10 +69,10 @@ public ResponseEntity<?> getAllMerchants(
         return ResponseEntity.ok(merchantPage);
     }
 
-    @GetMapping("/{merchant-id}")
+    @GetMapping("/")
     @Operation(summary = "Retrieve merchants by ID")
-    public ResponseEntity<Merchant> getMerchant(@PathVariable(name = "merchant-id") UUID merchantId) {
-
+    public ResponseEntity<Merchant> getMerchant(@RequestParam("user-id") String userId) {
+        UUID merchantId = UUID.fromString(userId);
         log.info("{\"message\": \"Fetching merchant with ID: " + merchantId + "\"}");
             Optional<Profile> profile = profileServiceFactory.getProfileById(MERCHANT_STRING, merchantId);
             if (profile.isPresent() && profile.get() instanceof Merchant) {
@@ -82,10 +82,10 @@ public ResponseEntity<Merchant> getMerchant(@PathVariable(name = "merchant-id")
             return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
     }
 
-    @PutMapping("/{merchant-id}")
+    @PutMapping("/")
     @Operation(summary = "Update merchants")
-    public ResponseEntity<String> updateMerchant(@PathVariable(name = "merchant-id") UUID merchantId, @Valid @RequestBody MerchantDTO merchantDTO) {
-
+    public ResponseEntity<String> updateMerchant(@RequestParam("user-id") String userId, @Valid @RequestBody MerchantDTO merchantDTO) {
+        UUID merchantId = UUID.fromString(userId);
         log.info("{\"message\": \"Updating merchant with ID: {}\"}", merchantId);
 
                // Check if the merchant exists
@@ -120,25 +120,27 @@ public ResponseEntity<String> updateMerchant(@PathVariable(name = "merchant-id")
                return ResponseEntity.ok("Merchant updated successfully");
 }
 
-    @DeleteMapping("/{merchant-id}")
+    @DeleteMapping("/")
     @Operation(summary = "Delete merchant by ID")
-    public ResponseEntity<String> deleteMerchant(@PathVariable(name = "merchant-id") UUID merchantId) {
-
+    public ResponseEntity<String> deleteMerchant(@RequestParam("user-id") String userId) {
+        UUID merchantId = UUID.fromString(userId);
         log.info("{\"message\": \"Deleting merchant with ID: {}\"}", merchantId);
         profileServiceFactory.deleteProfile(merchantId);
         return ResponseEntity.ok("Delete: successful");
     }
 
-    @PutMapping("/blacklist/{merchant-id}")
+    @PutMapping("/blacklist/")
     @Operation(summary = "Blacklist a merchant")
-    public ResponseEntity<String> blacklistMerchant(@PathVariable(name = "merchant-id") UUID merchantId) {
+    public ResponseEntity<String> blacklistMerchant(@RequestParam("user-id") String userId) {
+        UUID merchantId = UUID.fromString(userId);
         profileServiceFactory.blacklistProfile(merchantId);
         return ResponseEntity.ok("Merchant blacklisted successfully");
     }
 
-    @PutMapping("/unblacklist/{merchant-id}")
+    @PutMapping("/unblacklist/")
     @Operation(summary = "Unblacklist a merchant")
-    public ResponseEntity<String> unblacklistMerchant(@PathVariable(name = "merchant-id") UUID merchantId) {
+    public ResponseEntity<String> unblacklistMerchant(@RequestParam(value = "user-id") String userId) {
+        UUID merchantId = UUID.fromString(userId);
         profileServiceFactory.unblacklistProfile(merchantId);
         return ResponseEntity.ok("Merchant unblacklisted successfully");
     }
@@ -172,10 +174,10 @@ public ResponseEntity<?> getMerchantByEmail(@PathVariable String email) {
         return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Merchant not found");
     }
 
-    @PutMapping("/{merchant-id}/rewards/{order-price}")
+    @PutMapping("/rewards/{order-price}")
     @Operation(summary = "Update Merchant Earnings")
-    public ResponseEntity<?> patchMerchantEarnings(@PathVariable(name = "merchant-id") UUID merchantId , @PathVariable("order-price") BigDecimal amount){
-
+    public ResponseEntity<?> patchMerchantEarnings(@RequestParam("user-id") String userId, @PathVariable("order-price") BigDecimal amount){
+        UUID merchantId = UUID.fromString(userId);
         Optional<Profile> profile = profileServiceFactory.getProfileById(MERCHANT_STRING,merchantId);
         if(profile.isPresent() && profile.get() instanceof Merchant){
             Merchant merchant = (Merchant) profile.get();
diff --git a/src/test/java/sg/edu/nus/iss/profile_service/controller/CustomerControllerTest.java b/src/test/java/sg/edu/nus/iss/profile_service/controller/CustomerControllerTest.java
index 19ca1af..325ffb1 100644
--- a/src/test/java/sg/edu/nus/iss/profile_service/controller/CustomerControllerTest.java
+++ b/src/test/java/sg/edu/nus/iss/profile_service/controller/CustomerControllerTest.java
@@ -58,7 +58,7 @@ public void testGetCustomerById_Success() {
         Customer customer = new Customer();
         when(profileServiceFactory.getProfileById(eq("customer"), any(UUID.class))).thenReturn(Optional.of(customer));
 
-        ResponseEntity<?> response = customerController.getCustomer(UUID.randomUUID());
+        ResponseEntity<?> response = customerController.getCustomer("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals(customer, response.getBody());
@@ -69,7 +69,7 @@ public void testGetCustomerById_Success() {
     public void testGetCustomerById_NotFound() {
         when(profileServiceFactory.getProfileById(eq("customer"), any(UUID.class))).thenReturn(Optional.empty());
 
-        ResponseEntity<?> response = customerController.getCustomer(UUID.randomUUID());
+        ResponseEntity<?> response = customerController.getCustomer("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
     }
@@ -77,20 +77,21 @@ public void testGetCustomerById_NotFound() {
     // Test updateCustomer - success
     @Test
     public void testUpdateCustomer_Success() {
-        UUID customerId = UUID.randomUUID();
         CustomerDTO customerDTO = new CustomerDTO();
-        customerDTO.setCustomerId(customerId);
+        String userId = "50e8400-e29b-41d4-a716-446655440000";
+        customerDTO.setCustomerId(UUID.fromString(userId));
         customerDTO.setEmailAddress("test@example.com");
         customerDTO.setName("test");
 
         Customer customer = new Customer();
-        customer.setCustomerId(customerId);
+        customer.setCustomerId(UUID.fromString(userId));
         customer.setEmailAddress("test@example.com");
         customer.setName("test");
+
         when(profileServiceFactory.getProfileById(eq("customer"), eq(customerDTO.getCustomerId()))).thenReturn(Optional.of(customer));
         when(mapper.convertValue(any(CustomerDTO.class), eq(Customer.class))).thenReturn(customer);
 
-        ResponseEntity<?> response = customerController.updateCustomer(customerDTO.getCustomerId(), customerDTO);
+        ResponseEntity<?> response = customerController.updateCustomer(userId, customerDTO);
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Customer updated successfully", response.getBody());
@@ -101,7 +102,8 @@ public void testUpdateCustomer_Success() {
     @Test
     public void testUpdateCustomer_EmailMismatch() {
         CustomerDTO customerDTO = new CustomerDTO();
-        customerDTO.setCustomerId(UUID.randomUUID());
+        String userId = "550e8400-e29b-41d4-a716-446655440000";
+        customerDTO.setCustomerId(UUID.fromString(userId));
         customerDTO.setEmailAddress("new@example.com");
         customerDTO.setName("new");
 
@@ -109,9 +111,10 @@ public void testUpdateCustomer_EmailMismatch() {
         customer.setName("new");
         customer.setEmailAddress("old@example.com");
         customer.setCustomerId(customerDTO.getCustomerId());
+
         when(profileServiceFactory.getProfileById(eq("customer"), eq(customerDTO.getCustomerId()))).thenReturn(Optional.of(customer));
 
-        ResponseEntity<?> response = customerController.updateCustomer(customerDTO.getCustomerId(), customerDTO);
+        ResponseEntity<?> response = customerController.updateCustomer(userId, customerDTO);
 
         assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
         assertEquals("Email shouldn't be changed", response.getBody());
@@ -120,9 +123,9 @@ public void testUpdateCustomer_EmailMismatch() {
     // Test deleteCustomer - success
     @Test
     public void testDeleteCustomer_Success() {
-        UUID customerId = UUID.randomUUID();
+        UUID customerId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
 
-        ResponseEntity<String> response = customerController.deleteCustomer(customerId);
+        ResponseEntity<String> response = customerController.deleteCustomer("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Delete: successful", response.getBody());
@@ -193,13 +196,13 @@ public void testGetCustomerByEmail_Success() {
     // Test patchRewardPoints - success
     @Test
     public void testPatchRewardPoints_Success() {
-        UUID customerId = UUID.randomUUID();
+        UUID customerId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
         Customer customer = new Customer();
         customer.setCustomerId(customerId);
         customer.setRewardPoints(BigDecimal.valueOf(100));
         when(profileServiceFactory.getProfileById("customer", customerId)).thenReturn(Optional.of(customer));
 
-        ResponseEntity<?> response = customerController.patchRewardPoints(customerId, BigDecimal.valueOf(100));
+        ResponseEntity<?> response = customerController.patchRewardPoints("550e8400-e29b-41d4-a716-446655440000", BigDecimal.valueOf(100));
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Reward points updated successfully", response.getBody());
@@ -213,7 +216,7 @@ public void testPatchRewardPoints_CustomerNotFound() {
         UUID customerId = UUID.randomUUID();
         when(profileServiceFactory.getProfileById("customer", customerId)).thenReturn(Optional.empty());
 
-        ResponseEntity<?> response = customerController.patchRewardPoints(customerId, BigDecimal.valueOf(100));
+        ResponseEntity<?> response = customerController.patchRewardPoints("550e8400-e29b-41d4-a716-446655440000", BigDecimal.valueOf(100));
 
         assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
         assertEquals("Customer Not found", response.getBody());
@@ -221,13 +224,13 @@ public void testPatchRewardPoints_CustomerNotFound() {
 
     @Test
     public void testRetrieveRewardDetails_Success() {
-        UUID customerId = UUID.randomUUID();
+        UUID customerId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
 
         Customer customer = new Customer();
         customer.setRewardPoints(BigDecimal.valueOf(100));
         when(profileServiceFactory.getProfileById("customer", customerId)).thenReturn(Optional.of(customer));
 
-        ResponseEntity<?> response = customerController.retrieveRewardDetails(customerId);
+        ResponseEntity<?> response = customerController.retrieveRewardDetails("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals(0, ((Rewards) response.getBody()).getRewardAmount().compareTo(BigDecimal.valueOf(1.0)));
diff --git a/src/test/java/sg/edu/nus/iss/profile_service/controller/DeliveryPartnerControllerTest.java b/src/test/java/sg/edu/nus/iss/profile_service/controller/DeliveryPartnerControllerTest.java
index 56f8352..8442f0a 100644
--- a/src/test/java/sg/edu/nus/iss/profile_service/controller/DeliveryPartnerControllerTest.java
+++ b/src/test/java/sg/edu/nus/iss/profile_service/controller/DeliveryPartnerControllerTest.java
@@ -59,7 +59,7 @@ public void testGetdeliveryPartnerById_Success() {
         DeliveryPartner deliveryPartner = new DeliveryPartner();
         when(profileServiceFactory.getProfileById(eq("deliveryPartner"), any(UUID.class))).thenReturn(Optional.of(deliveryPartner));
 
-        ResponseEntity<?> response = deliveryPartnerController.getDeliveryPartnerByEmail(UUID.randomUUID());
+        ResponseEntity<?> response = deliveryPartnerController.getDeliveryPartnerById("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals(deliveryPartner, response.getBody());
@@ -70,7 +70,7 @@ public void testGetdeliveryPartnerById_Success() {
     public void testGetdeliveryPartnerById_NotFound() {
         when(profileServiceFactory.getProfileById(eq("deliveryPartner"), any(UUID.class))).thenReturn(Optional.empty());
 
-        ResponseEntity<?> response = deliveryPartnerController.getDeliveryPartnerByEmail(UUID.randomUUID());
+        ResponseEntity<?> response = deliveryPartnerController.getDeliveryPartnerById("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
     }
@@ -78,7 +78,7 @@ public void testGetdeliveryPartnerById_NotFound() {
     // Test updatedeliveryPartner - success
     @Test
     public void testUpdatedeliveryPartner_Success() {
-        UUID deliveryPartnerId = UUID.randomUUID();
+        UUID deliveryPartnerId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
         DeliveryPartnerDTO deliveryPartnerDTO = new DeliveryPartnerDTO();
         deliveryPartnerDTO.setDeliveryPartnerId(deliveryPartnerId);
         deliveryPartnerDTO.setEmailAddress("test@example.com");
@@ -91,7 +91,7 @@ public void testUpdatedeliveryPartner_Success() {
         when(profileServiceFactory.getProfileById(eq("deliveryPartner"), eq(deliveryPartnerDTO.getDeliveryPartnerId()))).thenReturn(Optional.of(deliveryPartner));
         when(mapper.convertValue(any(DeliveryPartnerDTO.class), eq(DeliveryPartner.class))).thenReturn(deliveryPartner);
 
-        ResponseEntity<?> response = deliveryPartnerController.updateDeliveryPartner(deliveryPartnerDTO.getDeliveryPartnerId(), deliveryPartnerDTO);
+        ResponseEntity<?> response = deliveryPartnerController.updateDeliveryPartner("550e8400-e29b-41d4-a716-446655440000", deliveryPartnerDTO);
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Delivery Partner updated successfully", response.getBody());
@@ -102,7 +102,7 @@ public void testUpdatedeliveryPartner_Success() {
     @Test
     public void testUpdatedeliverypartner_EmailMismatch() {
         DeliveryPartnerDTO deliveryPartnerDTO = new DeliveryPartnerDTO();
-        deliveryPartnerDTO.setDeliveryPartnerId(UUID.randomUUID());
+        deliveryPartnerDTO.setDeliveryPartnerId(UUID.fromString("550e8400-e29b-41d4-a716-446655440000"));
         deliveryPartnerDTO.setEmailAddress("new@example.com");
         deliveryPartnerDTO.setName("new");
 
@@ -112,7 +112,7 @@ public void testUpdatedeliverypartner_EmailMismatch() {
         deliveryPartner.setDeliveryPartnerId(deliveryPartnerDTO.getDeliveryPartnerId());
         when(profileServiceFactory.getProfileById(eq("deliveryPartner"), eq(deliveryPartnerDTO.getDeliveryPartnerId()))).thenReturn(Optional.of(deliveryPartner));
 
-        ResponseEntity<?> response = deliveryPartnerController.updateDeliveryPartner(deliveryPartnerDTO.getDeliveryPartnerId(), deliveryPartnerDTO);
+        ResponseEntity<?> response = deliveryPartnerController.updateDeliveryPartner("550e8400-e29b-41d4-a716-446655440000", deliveryPartnerDTO);
 
         assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
         assertEquals("Email shouldn't be changed", response.getBody());
@@ -121,9 +121,9 @@ public void testUpdatedeliverypartner_EmailMismatch() {
     // Test deletedeliveryPartner - success
     @Test
     public void testDeletePartner_Success() {
-        UUID deliveryPartnerId = UUID.randomUUID();
+        UUID deliveryPartnerId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
 
-        ResponseEntity<String> response = deliveryPartnerController.deleteDeliveryPartner(deliveryPartnerId);
+        ResponseEntity<String> response = deliveryPartnerController.deleteDeliveryPartner("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Delete: successful", response.getBody());
@@ -178,9 +178,9 @@ public void testHandleValidationExceptions() {
     // Test blacklisting a deliveryPartner - success
     @Test
     public void testBlacklistPartner_Success() {
-        UUID deliveryPartnerId = UUID.randomUUID();
+        UUID deliveryPartnerId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
 
-        ResponseEntity<String> response = deliveryPartnerController.blacklistDeliveryPartner(deliveryPartnerId);
+        ResponseEntity<String> response = deliveryPartnerController.blacklistDeliveryPartner("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Delivery Partner blacklisted successfully", response.getBody());
@@ -190,9 +190,9 @@ public void testBlacklistPartner_Success() {
     // Test unblacklisting a deliveryPartner - success
     @Test
     public void testUnblacklistPartner_Success() {
-        UUID deliveryPartnerId = UUID.randomUUID();
+        UUID deliveryPartnerId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
 
-        ResponseEntity<String> response = deliveryPartnerController.unblacklistDeliveryPartner(deliveryPartnerId);
+        ResponseEntity<String> response = deliveryPartnerController.unblacklistDeliveryPartner("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Delivery Partner unblacklisted successfully", response.getBody());
diff --git a/src/test/java/sg/edu/nus/iss/profile_service/controller/MerchantControllerTest.java b/src/test/java/sg/edu/nus/iss/profile_service/controller/MerchantControllerTest.java
index 6714b0e..b23ef46 100644
--- a/src/test/java/sg/edu/nus/iss/profile_service/controller/MerchantControllerTest.java
+++ b/src/test/java/sg/edu/nus/iss/profile_service/controller/MerchantControllerTest.java
@@ -57,7 +57,7 @@ public void testGetMerchantById_Success() {
         Merchant merchant = new Merchant();
         when(profileServiceFactory.getProfileById(eq("merchant"), any(UUID.class))).thenReturn(Optional.of(merchant));
 
-        ResponseEntity<?> response = merchantController.getMerchant(UUID.randomUUID());
+        ResponseEntity<?> response = merchantController.getMerchant("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals(merchant, response.getBody());
@@ -68,7 +68,7 @@ public void testGetMerchantById_Success() {
     public void testGetMerchantById_NotFound() {
         when(profileServiceFactory.getProfileById(eq("merchant"), any(UUID.class))).thenReturn(Optional.empty());
 
-        ResponseEntity<?> response = merchantController.getMerchant(UUID.randomUUID());
+        ResponseEntity<?> response = merchantController.getMerchant("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
     }
@@ -76,7 +76,7 @@ public void testGetMerchantById_NotFound() {
     // Test updatemerchant - success
     @Test
     public void testUpdateMerchant_Success() {
-        UUID merchantId = UUID.randomUUID();
+        UUID merchantId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
         MerchantDTO merchantDTO = new MerchantDTO();
         merchantDTO.setMerchantId(merchantId);
         merchantDTO.setEmailAddress("test@example.com");
@@ -89,7 +89,7 @@ public void testUpdateMerchant_Success() {
         when(profileServiceFactory.getProfileById(eq("merchant"), eq(merchantDTO.getMerchantId()))).thenReturn(Optional.of(merchant));
         when(mapper.convertValue(any(MerchantDTO.class), eq(Merchant.class))).thenReturn(merchant);
 
-        ResponseEntity<?> response = merchantController.updateMerchant(merchantDTO.getMerchantId(), merchantDTO);
+        ResponseEntity<?> response = merchantController.updateMerchant("550e8400-e29b-41d4-a716-446655440000", merchantDTO);
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Merchant updated successfully", response.getBody());
@@ -100,7 +100,7 @@ public void testUpdateMerchant_Success() {
     @Test
     public void testUpdatemerchant_EmailMismatch() {
         MerchantDTO merchantDTO = new MerchantDTO();
-        merchantDTO.setMerchantId(UUID.randomUUID());
+        merchantDTO.setMerchantId(UUID.fromString("550e8400-e29b-41d4-a716-446655440000"));
         merchantDTO.setEmailAddress("new@example.com");
         merchantDTO.setName("new");
 
@@ -110,7 +110,7 @@ public void testUpdatemerchant_EmailMismatch() {
         merchant.setMerchantId(merchantDTO.getMerchantId());
         when(profileServiceFactory.getProfileById(eq("merchant"), eq(merchantDTO.getMerchantId()))).thenReturn(Optional.of(merchant));
 
-        ResponseEntity<?> response = merchantController.updateMerchant(merchantDTO.getMerchantId(), merchantDTO);
+        ResponseEntity<?> response = merchantController.updateMerchant("550e8400-e29b-41d4-a716-446655440000", merchantDTO);
 
         assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
         assertEquals("Email shouldn't be changed", response.getBody());
@@ -119,9 +119,9 @@ public void testUpdatemerchant_EmailMismatch() {
     // Test deletemerchant - success
     @Test
     public void testDeleteMerchant_Success() {
-        UUID merchantId = UUID.randomUUID();
+        UUID merchantId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
 
-        ResponseEntity<String> response = merchantController.deleteMerchant(merchantId);
+        ResponseEntity<String> response = merchantController.deleteMerchant("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Delete: successful", response.getBody());
@@ -176,9 +176,9 @@ public void testHandleValidationExceptions() {
     // Test blacklisting a merchant - success
     @Test
     public void testBlacklistMerchant_Success() {
-        UUID merchantId = UUID.randomUUID();
+        UUID merchantId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
 
-        ResponseEntity<String> response = merchantController.blacklistMerchant(merchantId);
+        ResponseEntity<String> response = merchantController.blacklistMerchant("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Merchant blacklisted successfully", response.getBody());
@@ -188,9 +188,9 @@ public void testBlacklistMerchant_Success() {
     // Test unblacklisting a merchant - success
     @Test
     public void testUnblacklistMerchant_Success() {
-        UUID merchantId = UUID.randomUUID();
+        UUID merchantId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
 
-        ResponseEntity<String> response = merchantController.unblacklistMerchant(merchantId);
+        ResponseEntity<String> response = merchantController.unblacklistMerchant("550e8400-e29b-41d4-a716-446655440000");
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Merchant unblacklisted successfully", response.getBody());
@@ -215,7 +215,7 @@ public void testGetMerchantByEmail_Success() {
     // Test patchMerchantEarnings
     @Test
     public void testPatchMerchantEarnings_Success() {
-        UUID merchantId = UUID.randomUUID();
+        UUID merchantId = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
         BigDecimal amount = BigDecimal.valueOf(100);
 
         Merchant merchant = new Merchant();
@@ -223,7 +223,7 @@ public void testPatchMerchantEarnings_Success() {
         merchant.setEarnings(BigDecimal.valueOf(100));
         when(profileServiceFactory.getProfileById("merchant", merchantId)).thenReturn(Optional.of(merchant));
 
-        ResponseEntity<?> response = merchantController.patchMerchantEarnings(merchantId, amount);
+        ResponseEntity<?> response = merchantController.patchMerchantEarnings("550e8400-e29b-41d4-a716-446655440000", amount);
 
         assertEquals(HttpStatus.OK, response.getStatusCode());
         assertEquals("Merchant Earnings updated successfully", response.getBody());


Reviews:
user: login: Arkmati
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-08T04:57:08Z
user: login: Anvisimi
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-08T05:21:25Z

Review comments:
diff_hunk: @@ -120,25 +120,27 @@ public ResponseEntity<String> updateMerchant(@PathVariable(name = "merchant-id")
                return ResponseEntity.ok("Merchant updated successfully");
 }
 
-    @DeleteMapping("/{merchant-id}")
+    @DeleteMapping("/")
     @Operation(summary = "Delete merchant by ID")
-    public ResponseEntity<String> deleteMerchant(@PathVariable(name = "merchant-id") UUID merchantId) {
-
+    public ResponseEntity<String> deleteMerchant(@RequestParam("user-id") String userId) {
+        UUID merchantId = UUID.fromString(userId);
         log.info("{\"message\": \"Deleting merchant with ID: {}\"}", merchantId);
         profileServiceFactory.deleteProfile(merchantId);
         return ResponseEntity.ok("Delete: successful");
     }
 
-    @PutMapping("/blacklist/{merchant-id}")
+    @PutMapping("/blacklist/")
     @Operation(summary = "Blacklist a merchant")
-    public ResponseEntity<String> blacklistMerchant(@PathVariable(name = "merchant-id") UUID merchantId) {
+    public ResponseEntity<String> blacklistMerchant(@RequestParam("user-id") String userId) {
+        UUID merchantId = UUID.fromString(userId);
path: src/main/java/sg/edu/nus/iss/profile_service/controller/MerchantController.java
user: login: Arkmati
body: No need to read merchantId from RequestParam here as its needed that merchantId be provided in path variable.
This api will be invoked by admin and hence in session and user-context will be of admin, hence central hub cant dynamically provide required merchantId in as request params.
created_at: 2025-03-08T04:36:28Z
author_association: CONTRIBUTOR
diff_hunk: @@ -120,25 +120,27 @@ public ResponseEntity<String> updateMerchant(@PathVariable(name = "merchant-id")
                return ResponseEntity.ok("Merchant updated successfully");
 }
 
-    @DeleteMapping("/{merchant-id}")
+    @DeleteMapping("/")
     @Operation(summary = "Delete merchant by ID")
-    public ResponseEntity<String> deleteMerchant(@PathVariable(name = "merchant-id") UUID merchantId) {
-
+    public ResponseEntity<String> deleteMerchant(@RequestParam("user-id") String userId) {
+        UUID merchantId = UUID.fromString(userId);
         log.info("{\"message\": \"Deleting merchant with ID: {}\"}", merchantId);
         profileServiceFactory.deleteProfile(merchantId);
         return ResponseEntity.ok("Delete: successful");
     }
 
-    @PutMapping("/blacklist/{merchant-id}")
+    @PutMapping("/blacklist/")
     @Operation(summary = "Blacklist a merchant")
-    public ResponseEntity<String> blacklistMerchant(@PathVariable(name = "merchant-id") UUID merchantId) {
+    public ResponseEntity<String> blacklistMerchant(@RequestParam("user-id") String userId) {
+        UUID merchantId = UUID.fromString(userId);
         profileServiceFactory.blacklistProfile(merchantId);
         return ResponseEntity.ok("Merchant blacklisted successfully");
     }
 
-    @PutMapping("/unblacklist/{merchant-id}")
+    @PutMapping("/unblacklist/")
     @Operation(summary = "Unblacklist a merchant")
-    public ResponseEntity<String> unblacklistMerchant(@PathVariable(name = "merchant-id") UUID merchantId) {
+    public ResponseEntity<String> unblacklistMerchant(@RequestParam(value = "user-id") String userId) {
path: src/main/java/sg/edu/nus/iss/profile_service/controller/MerchantController.java
user: login: Arkmati
body: No need to read merchantId from RequestParam here as its needed that merchantId be provided in path variable.
This api will be invoked by admin and hence in session and user-context will be of admin, hence central hub cant dynamically provide required merchantId in as request params.
created_at: 2025-03-08T04:36:38Z
author_association: CONTRIBUTOR
diff_hunk: @@ -109,25 +109,27 @@ public ResponseEntity<String> updateDeliveryPartner(@PathVariable(name = "partne
                return ResponseEntity.ok("Delivery Partner updated successfully");
 }
 
-    @DeleteMapping("/{partner-id}")
+    @DeleteMapping("/")
     @Operation(summary = "Delete delivery partner profile by ID")
-    public ResponseEntity<String> deleteDeliveryPartner(@PathVariable(name = "partner-id") UUID deliveryPartnerId) {
-
+    public ResponseEntity<String> deleteDeliveryPartner(@RequestParam("user-id") String userId) {
+        UUID deliveryPartnerId = UUID.fromString(userId);
         log.info("{\"message\": \"Deleting delivery partner with ID: {}\"}", deliveryPartnerId);
         profileServiceFactory.deleteProfile(deliveryPartnerId);
         return ResponseEntity.ok("Delete: successful");
     }
 
-    @PutMapping("/blacklist/{partner-id}")
+    @PutMapping("/blacklist/")
     @Operation(summary = "Blacklist a Delivery Partner")
-    public ResponseEntity<String> blacklistDeliveryPartner(@PathVariable(name = "partner-id") UUID deliveryPartnerId) {
+    public ResponseEntity<String> blacklistDeliveryPartner(@RequestParam("user-id") String userId) {
+        UUID deliveryPartnerId = UUID.fromString(userId);
         profileServiceFactory.blacklistProfile(deliveryPartnerId);
         return ResponseEntity.ok("Delivery Partner blacklisted successfully");
     }
 
-    @PutMapping("/unblacklist/{partner-id}")
+    @PutMapping("/unblacklist/")
     @Operation(summary = "Unblacklist a Delivery Partner")
-    public ResponseEntity<String> unblacklistDeliveryPartner(@PathVariable(name = "partner-id") UUID deliveryPartnerId) {
+    public ResponseEntity<String> unblacklistDeliveryPartner(@RequestParam("user-id") String userId) {
path: src/main/java/sg/edu/nus/iss/profile_service/controller/DeliveryPartnerController.java
user: login: Arkmati
body: No need to read merchantId from RequestParam here as its needed that partnerId be provided in path variable.
This api will be invoked by admin and hence in session and user-context will be of admin, hence central hub cant dynamically provide required partnerId in as request params.
created_at: 2025-03-08T04:37:10Z
author_association: CONTRIBUTOR
diff_hunk: @@ -109,25 +109,27 @@ public ResponseEntity<String> updateDeliveryPartner(@PathVariable(name = "partne
                return ResponseEntity.ok("Delivery Partner updated successfully");
 }
 
-    @DeleteMapping("/{partner-id}")
+    @DeleteMapping("/")
     @Operation(summary = "Delete delivery partner profile by ID")
-    public ResponseEntity<String> deleteDeliveryPartner(@PathVariable(name = "partner-id") UUID deliveryPartnerId) {
-
+    public ResponseEntity<String> deleteDeliveryPartner(@RequestParam("user-id") String userId) {
+        UUID deliveryPartnerId = UUID.fromString(userId);
         log.info("{\"message\": \"Deleting delivery partner with ID: {}\"}", deliveryPartnerId);
         profileServiceFactory.deleteProfile(deliveryPartnerId);
         return ResponseEntity.ok("Delete: successful");
     }
 
-    @PutMapping("/blacklist/{partner-id}")
+    @PutMapping("/blacklist/")
     @Operation(summary = "Blacklist a Delivery Partner")
-    public ResponseEntity<String> blacklistDeliveryPartner(@PathVariable(name = "partner-id") UUID deliveryPartnerId) {
+    public ResponseEntity<String> blacklistDeliveryPartner(@RequestParam("user-id") String userId) {
path: src/main/java/sg/edu/nus/iss/profile_service/controller/DeliveryPartnerController.java
user: login: Arkmati
body: No need to read merchantId from RequestParam here as its needed that partnerId be provided in path variable.
This api will be invoked by admin and hence in session and user-context will be of admin, hence central hub cant dynamically provide required partnerId in as request params.
created_at: 2025-03-08T04:37:17Z
author_association: CONTRIBUTOR

PR comments:
user: login: sonarqubecloud[bot]
created_at: 2025-03-08T05:01:16Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=ShopSmartSG_profile-service&pullRequest=36) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=ShopSmartSG_profile-service&pullRequest=36&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=ShopSmartSG_profile-service&pullRequest=36&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=ShopSmartSG_profile-service&pullRequest=36&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=ShopSmartSG_profile-service&pullRequest=36&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=ShopSmartSG_profile-service&pullRequest=36&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=ShopSmartSG_profile-service&pullRequest=36)


author_association: NONE