From e135299316e8437d7ea1110033d9fb44a375cec6 Mon Sep 17 00:00:00 2001 From: kameshsr <47484458+kameshsr@users.noreply.github.com> Date: Mon, 25 Nov 2024 13:49:22 +0530 Subject: [PATCH] MOSIP-37784 Fixed name issue (#1360) * MOSIP-37784 Fixed name issue Signed-off-by: kameshsr * MOSIP-37784 Fixed name issue Signed-off-by: kameshsr * MOSIP-37784 Fixed test case failure Signed-off-by: kameshsr * MOSIP-37784 Fixed claims issue Signed-off-by: kameshsr --------- Signed-off-by: kameshsr --- .../sql/1.2.1.0_to_1.2.1.1_rollback.sql | 1 + .../sql/1.2.1.0_to_1.2.1.1_upgrade.sql | 1 + .../service/impl/IdentityServiceImpl.java | 19 ++++++++++--------- .../controller/IdAuthControllerTest.java | 4 +++- 4 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 db_upgrade_scripts/mosip_resident/sql/1.2.1.0_to_1.2.1.1_rollback.sql create mode 100644 db_upgrade_scripts/mosip_resident/sql/1.2.1.0_to_1.2.1.1_upgrade.sql diff --git a/db_upgrade_scripts/mosip_resident/sql/1.2.1.0_to_1.2.1.1_rollback.sql b/db_upgrade_scripts/mosip_resident/sql/1.2.1.0_to_1.2.1.1_rollback.sql new file mode 100644 index 00000000000..381e2be11c1 --- /dev/null +++ b/db_upgrade_scripts/mosip_resident/sql/1.2.1.0_to_1.2.1.1_rollback.sql @@ -0,0 +1 @@ +\echo 'Upgrade Queries not required for transition from $CURRENT_VERSION to $UPGRADE_VERSION' \ No newline at end of file diff --git a/db_upgrade_scripts/mosip_resident/sql/1.2.1.0_to_1.2.1.1_upgrade.sql b/db_upgrade_scripts/mosip_resident/sql/1.2.1.0_to_1.2.1.1_upgrade.sql new file mode 100644 index 00000000000..381e2be11c1 --- /dev/null +++ b/db_upgrade_scripts/mosip_resident/sql/1.2.1.0_to_1.2.1.1_upgrade.sql @@ -0,0 +1 @@ +\echo 'Upgrade Queries not required for transition from $CURRENT_VERSION to $UPGRADE_VERSION' \ No newline at end of file diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/IdentityServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/IdentityServiceImpl.java index eb040c2e800..45db1426933 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/IdentityServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/IdentityServiceImpl.java @@ -23,6 +23,7 @@ import io.mosip.resident.validator.RequestValidator; import reactor.util.function.Tuple2; import reactor.util.function.Tuples; +import io.mosip.resident.constant.RegistrationConstants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -30,7 +31,6 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.LocalDate; @@ -148,17 +148,17 @@ public IdentityDTO getIdentity(String id, boolean fetchFace, String langCode) th return identityDTO; } - public String getFullName(Map identity, String langCode) throws ResidentServiceCheckedException, IOException { - if(nameValueList==null){ - nameValueList= getNameValueFromIdentityMapping(); + public String getFullName(Map identity, String langCode) + throws ResidentServiceCheckedException, IOException { + if (nameValueList == null) { + nameValueList = getNameValueFromIdentityMapping(); } - StringBuilder nameValue = new StringBuilder(); - for (String nameString : nameValueList) { - nameValue.append(getValueFromIdentityMapping(nameString, identity, langCode)); - } - return String.valueOf(nameValue); + return nameValueList.stream() + .map(nameString -> getValueFromIdentityMapping(nameString, identity, langCode)) + .collect(Collectors.joining(RegistrationConstants.SPACE)); } + private String getValueFromIdentityMapping(String nameString, Map identity, String langCode) { if (nameString == null || identity == null || langCode == null) { return ""; // Return early if any input is null @@ -206,6 +206,7 @@ public List getNameValueFromIdentityMapping() throws ResidentServiceChec } return nameValueList; } + @Override public Map getIdentityAttributes(String id, String schemaType) throws ResidentServiceCheckedException, IOException { diff --git a/resident/resident-service/src/test/java/io/mosip/resident/controller/IdAuthControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/controller/IdAuthControllerTest.java index 58f72fd8b2c..f1c20816545 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/controller/IdAuthControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/controller/IdAuthControllerTest.java @@ -2,8 +2,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import java.io.IOException; import java.util.Map; +import io.mosip.resident.exception.ResidentServiceCheckedException; import io.mosip.resident.util.Utility; import org.junit.Before; import org.junit.Test; @@ -92,7 +94,7 @@ public class IdAuthControllerTest { private RequestWrapper requestWrapper; @Before - public void setUp() { + public void setUp() throws ResidentServiceCheckedException, IOException { MockitoAnnotations.initMocks(this); this.mockMvc = MockMvcBuilders.standaloneSetup(idAuthController).build(); requestWrapper = new RequestWrapper();