From c078853e4abcbed22c67289e7b7bdefe640805ec Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Tue, 16 Jan 2024 14:01:29 -0800 Subject: [PATCH] fix(FSADT1-1141): updating username that is saved --- backend/src/main/java/ca/bc/gov/app/ApplicationConstant.java | 1 + .../app/controller/client/ClientSubmissionController.java | 4 +++- .../bc/gov/app/service/client/ClientSubmissionService.java | 5 +++-- .../client/ClientSubmissionControllerIntegrationTest.java | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/ApplicationConstant.java b/backend/src/main/java/ca/bc/gov/app/ApplicationConstant.java index 84db79eec2..29f3ce2821 100644 --- a/backend/src/main/java/ca/bc/gov/app/ApplicationConstant.java +++ b/backend/src/main/java/ca/bc/gov/app/ApplicationConstant.java @@ -15,6 +15,7 @@ public final class ApplicationConstant { public static final String POSTGRES_ATTRIBUTE_SCHEMA = "nrfc"; public static final String USERID_HEADER = "x-user-id"; + public static final String BUSINESSID_HEADER = "x-user-businessid"; public static final String USERMAIL_HEADER = "x-user-email"; public static final String USERNAME_HEADER = "x-user-name"; diff --git a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientSubmissionController.java b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientSubmissionController.java index 9c976ea80c..f6def36c16 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientSubmissionController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientSubmissionController.java @@ -13,6 +13,7 @@ import ca.bc.gov.app.validator.client.ClientSubmitRequestValidator; import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.server.reactive.ServerHttpResponse; @@ -77,6 +78,7 @@ public Flux listSubmissions( public Mono submit( @RequestBody ClientSubmissionDto request, @RequestHeader(ApplicationConstant.USERID_HEADER) String userId, + @RequestHeader(name = ApplicationConstant.BUSINESSID_HEADER, defaultValue = StringUtils.EMPTY) String businessId, @RequestHeader(ApplicationConstant.USERMAIL_HEADER) String userEmail, @RequestHeader(ApplicationConstant.USERNAME_HEADER) String userName, ServerHttpResponse serverResponse) { @@ -85,7 +87,7 @@ public Mono submit( Mono.error(new InvalidRequestObjectException("no request body was provided")) ) .doOnNext(this::validate) - .flatMap(submissionDto -> clientService.submit(submissionDto, userId, userEmail, userName)) + .flatMap(submissionDto -> clientService.submit(submissionDto, userId, userEmail, userName,businessId)) .doOnNext(submissionId -> serverResponse .getHeaders() diff --git a/backend/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionService.java b/backend/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionService.java index da79f90f74..5c222ad498 100644 --- a/backend/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionService.java +++ b/backend/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionService.java @@ -128,7 +128,8 @@ public Mono submit( ClientSubmissionDto clientSubmissionDto, String userId, String userEmail, - String userName + String userName, + String businessId ) { return @@ -140,7 +141,7 @@ public Mono submit( .submissionType(SubmissionTypeCodeEnum.SPP) .submissionDate(LocalDateTime.now()) .createdBy(userId) - .updatedBy(userId) + .updatedBy(userName) .build() ) //Save submission to begin with diff --git a/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java index 48edf92daf..d0f22dfd72 100644 --- a/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java @@ -213,7 +213,7 @@ void shouldListAndSearch( .jsonPath("$.[0].requestType").isEqualTo("Submission pending processing") .jsonPath("$.[0].status").isEqualTo("New") .jsonPath("$.[0].clientType").isEqualTo("Registered sole proprietorship") - .jsonPath("$.[0].user").isEqualTo("testUserId"); + .jsonPath("$.[0].user").isEqualTo("Test User"); } } @@ -229,7 +229,7 @@ void shouldGetSubmissionDetails() { .expectStatus().isOk() .expectBody() .jsonPath("$.submissionId").isEqualTo(1) - .jsonPath("$.updateUser").isEqualTo("testUserId") + .jsonPath("$.updateUser").isEqualTo("Test User") .jsonPath("$.submissionType").isEqualTo("Submission pending processing"); }