diff --git a/registration-processor/pre-processor/registration-processor-introducer-validator-stage/src/main/java/io/mosip/registration/processor/stages/introducervalidator/IntroducerValidator.java b/registration-processor/pre-processor/registration-processor-introducer-validator-stage/src/main/java/io/mosip/registration/processor/stages/introducervalidator/IntroducerValidator.java index e957c160d2f..396888c5b04 100644 --- a/registration-processor/pre-processor/registration-processor-introducer-validator-stage/src/main/java/io/mosip/registration/processor/stages/introducervalidator/IntroducerValidator.java +++ b/registration-processor/pre-processor/registration-processor-introducer-validator-stage/src/main/java/io/mosip/registration/processor/stages/introducervalidator/IntroducerValidator.java @@ -1,267 +1,308 @@ -package io.mosip.registration.processor.stages.introducervalidator; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.commons.collections.CollectionUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.xml.sax.SAXException; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.biometrics.constant.BiometricType; -import io.mosip.kernel.biometrics.entities.BIR; -import io.mosip.kernel.biometrics.entities.BiometricRecord; -import io.mosip.kernel.core.bioapi.exception.BiometricException; -import io.mosip.kernel.core.exception.BaseCheckedException; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; -import io.mosip.registration.processor.core.constant.MappingJsonConstants; -import io.mosip.registration.processor.core.constant.ProviderStageName; -import io.mosip.registration.processor.core.constant.RegistrationType; -import io.mosip.registration.processor.core.exception.IntroducerOnHoldException; -import io.mosip.registration.processor.core.exception.PacketDecryptionFailureException; -import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; -import io.mosip.registration.processor.core.exception.ValidationFailedException; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.status.util.StatusUtil; -import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; -import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; -import io.mosip.registration.processor.packet.storage.utils.BioSdkUtil; -import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; -import io.mosip.registration.processor.packet.storage.utils.Utilities; -import io.mosip.registration.processor.status.code.RegistrationStatusCode; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.service.RegistrationStatusService; - -@Service -public class IntroducerValidator { - - private static Logger regProcLogger = RegProcessorLogger.getLogger(IntroducerValidator.class); - - public static final String INDIVIDUAL_TYPE_UIN = "UIN"; - - @Autowired - RegistrationExceptionMapperUtil registrationExceptionMapperUtil; - - @Autowired - private PriorityBasedPacketManagerService packetManagerService; - - @Autowired - private IdRepoService idRepoService; - - @Autowired - RegistrationStatusService registrationStatusService; - - @Autowired - ObjectMapper mapper; - - - - @Autowired - private Utilities utility; - - @Autowired - private BioSdkUtil bioUtil; - - /** - * Checks if is valid introducer. - * - * @param registrationId the registration id - * @param registrationStatusDto - * @throws SAXException - * @throws ParserConfigurationException - * @throws BiometricException - * @throws io.mosip.kernel.core.exception.IOException - * @throws Exception - * @throws PacketDecryptionFailureException - * @throws RegistrationProcessorCheckedException - */ - public void validate(String registrationId, InternalRegistrationStatusDto registrationStatusDto) throws Exception { - - regProcLogger.debug("validate called for registrationId {}", registrationId); - - String introducerUIN = packetManagerService.getFieldByMappingJsonKey(registrationId, - MappingJsonConstants.INTRODUCER_UIN, registrationStatusDto.getRegistrationType(), - ProviderStageName.INTRODUCER_VALIDATOR); - String introducerRID = packetManagerService.getFieldByMappingJsonKey(registrationId, - MappingJsonConstants.INTRODUCER_RID, registrationStatusDto.getRegistrationType(), - ProviderStageName.INTRODUCER_VALIDATOR); - - if (isValidIntroducer(introducerUIN, introducerRID)) { - registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.INTRODUCER_UIN_AND_RID_NOT_IN_PACKET)); - registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.toString()); - regProcLogger.debug("validate called for registrationId {} {}", registrationId, - StatusUtil.UIN_RID_NOT_FOUND.getMessage()); - throw new BaseCheckedException(StatusUtil.UIN_RID_NOT_FOUND.getMessage(), - StatusUtil.UIN_RID_NOT_FOUND.getCode()); - } - - if ((introducerUIN == null || introducerUIN.isEmpty()) - && isValidIntroducerRid(introducerRID, registrationId, registrationStatusDto)) { - - introducerUIN = idRepoService.getUinByRid(introducerRID, utility.getGetRegProcessorDemographicIdentity()); - - if (introducerUIN == null) { - registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.INTRODUCER_UIN_NOT_AVAIALBLE)); - registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); - regProcLogger.debug("validate called for registrationId {} {}", registrationId, - StatusUtil.INTRODUCER_UIN_NOT_FOUND.getMessage()); - throw new BaseCheckedException(StatusUtil.INTRODUCER_UIN_NOT_FOUND.getMessage(), - StatusUtil.INTRODUCER_UIN_NOT_FOUND.getCode()); - } - - } - if (introducerUIN != null && !introducerUIN.isEmpty()) { - validateIntroducerBiometric(registrationId, registrationStatusDto, introducerUIN); - } else { - throw new ValidationFailedException(StatusUtil.INTRODUCER_AUTHENTICATION_FAILED.getMessage(), - StatusUtil.INTRODUCER_AUTHENTICATION_FAILED.getCode()); - } - - regProcLogger.debug("validate call ended for registrationId {}", registrationId); - } - - private boolean isValidIntroducer(String introducerUIN, String introducerRID) { - return ((introducerUIN == null && introducerRID == null) || ((introducerUIN != null && introducerUIN.isEmpty()) - && (introducerRID != null && introducerRID.isEmpty()))); - } - - /** - * Validate introducer rid. - * - * @param introducerRid the introducer rid - * @param registrationId the registration id - * @param registrationStatusDto - * @return true, if successful - * @throws BaseCheckedException - */ - private boolean isValidIntroducerRid(String introducerRid, String registrationId, - InternalRegistrationStatusDto registrationStatusDto) throws BaseCheckedException { - - List internalRegistrationStatusDtoList= registrationStatusService.getAllRegistrationStatuses(introducerRid); - InternalRegistrationStatusDto introducerRegistrationStatusDto=CollectionUtils.isNotEmpty(internalRegistrationStatusDtoList) ? - internalRegistrationStatusDtoList.stream().filter(s -> RegistrationType.NEW.name().equalsIgnoreCase(s.getRegistrationType())).collect(Collectors.toList()).iterator().next() - : null; - if (introducerRegistrationStatusDto != null) { - if (introducerRegistrationStatusDto.getStatusCode().equals(RegistrationStatusCode.PROCESSING.toString())) { - - registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.ON_HOLD_INTRODUCER_PACKET)); - - registrationStatusDto.setStatusComment(StatusUtil.PACKET_ON_HOLD.getMessage()); - registrationStatusDto.setSubStatusCode(StatusUtil.PACKET_ON_HOLD.getCode()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.toString()); - regProcLogger.debug("isValidIntroducerRid call ended for registrationId {} {}", registrationId, - StatusUtil.PACKET_ON_HOLD.getMessage()); - throw new IntroducerOnHoldException(StatusUtil.PACKET_ON_HOLD.getCode(), - StatusUtil.PACKET_ON_HOLD.getMessage()); - - } else if (introducerRegistrationStatusDto.getStatusCode() - .equals(RegistrationStatusCode.REJECTED.toString()) - || introducerRegistrationStatusDto.getStatusCode() - .equals(RegistrationStatusCode.FAILED.toString())) { - - registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.OSI_FAILED_REJECTED_INTRODUCER)); - - registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); - regProcLogger.debug("isValidIntroducerRid call ended for registrationId {} {}", registrationId, - StatusUtil.CHILD_PACKET_REJECTED.getMessage()); - throw new BaseCheckedException(StatusUtil.CHILD_PACKET_REJECTED.getMessage(), - StatusUtil.CHILD_PACKET_REJECTED.getCode()); - } else { - return true; - } - - } else { - registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.ON_HOLD_INTRODUCER_PACKET)); - - registrationStatusDto.setStatusComment(StatusUtil.PACKET_IS_ON_HOLD.getMessage()); - registrationStatusDto.setSubStatusCode(StatusUtil.PACKET_IS_ON_HOLD.getCode()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.toString()); - regProcLogger.debug("isValidIntroducerRid call ended for registrationId {} {}", registrationId, - StatusUtil.PACKET_ON_HOLD.getMessage()); - throw new IntroducerOnHoldException(StatusUtil.PACKET_ON_HOLD.getCode(), - StatusUtil.PACKET_ON_HOLD.getMessage()); - } - } - - private void validateIntroducerBiometric(String registrationId, InternalRegistrationStatusDto registrationStatusDto, - String introducerUIN) - throws Exception { - BiometricRecord biometricRecord = packetManagerService.getBiometricsByMappingJsonKey(registrationId, - MappingJsonConstants.INTRODUCER_BIO, registrationStatusDto.getRegistrationType(), - ProviderStageName.INTRODUCER_VALIDATOR); - if (biometricRecord != null && biometricRecord.getSegments() != null) { - biometricRecord = filterExceptionBiometrics(biometricRecord); - if (biometricRecord != null && biometricRecord.getSegments() != null) { - validateUserBiometric(registrationId, introducerUIN, biometricRecord.getSegments(), INDIVIDUAL_TYPE_UIN, - registrationStatusDto); - } else { - registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.INTRODUCER_BIOMETRIC_ALL_EXCEPTION_IN_PACKET)); - registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); - regProcLogger.debug("validateIntroducerBiometric call ended for registrationId {} {}", registrationId, - StatusUtil.INTRODUCER_BIOMETRIC_ALL_EXCEPTION_IN_PACKET.getMessage()); - throw new BaseCheckedException(StatusUtil.INTRODUCER_BIOMETRIC_ALL_EXCEPTION_IN_PACKET.getMessage(), - StatusUtil.INTRODUCER_BIOMETRIC_ALL_EXCEPTION_IN_PACKET.getCode()); - } - - } else { - registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.INTRODUCER_BIOMETRIC_NOT_IN_PACKET)); - registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); - regProcLogger.debug("validateIntroducerBiometric call ended for registrationId {} {}", registrationId, - StatusUtil.INTRODUCER_BIOMETRIC_FILE_NAME_NOT_FOUND.getMessage()); - throw new BaseCheckedException(StatusUtil.INTRODUCER_BIOMETRIC_FILE_NAME_NOT_FOUND.getMessage(), - StatusUtil.INTRODUCER_BIOMETRIC_FILE_NAME_NOT_FOUND.getCode()); - } - } - - - /** - * Validate user. - * - * @param userId the userid - * @param registrationId the registration id - * @param list biometric data as BIR object - * @param individualType user type - * @param registrationStatusDto - * @throws Exception - * @throws - * @throws BiometricException - */ - - private void validateUserBiometric(String registrationId, String userId, List list, String individualType, - InternalRegistrationStatusDto registrationStatusDto) throws Exception { - regProcLogger.info("validateUserBiometric call started for registrationId {}", registrationId); - bioUtil.authenticateBiometrics(userId, individualType, list, registrationStatusDto,StatusUtil.INTRODUCER_AUTHENTICATION_FAILED.getCode(),StatusUtil.INTRODUCER_AUTHENTICATION_FAILED.getCode()); - regProcLogger.debug("validateUserBiometric call ended for registrationId {}", registrationId); - } - - private BiometricRecord filterExceptionBiometrics(BiometricRecord biometricRecord) { - List segments = biometricRecord.getSegments().stream().filter(bio -> { - Map othersMap = bio.getOthers().entrySet().stream() - .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); - return (othersMap == null || !othersMap.containsKey("EXCEPTION")) ? true - : !(Boolean.parseBoolean(othersMap.get("EXCEPTION"))); - }).collect(Collectors.toList()); - if (segments != null) { - segments = segments.stream().filter(bio -> !bio.getBdbInfo().getType().get(0).name() - .equalsIgnoreCase(BiometricType.EXCEPTION_PHOTO.name())).collect(Collectors.toList()); - } - BiometricRecord biorecord = new BiometricRecord(); - biorecord.setSegments(segments); - return biorecord; - } - +package io.mosip.registration.processor.stages.introducervalidator; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.commons.collections.CollectionUtils; +import org.json.JSONArray; +import org.json.JSONException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.xml.sax.SAXException; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.biometrics.constant.BiometricType; +import io.mosip.kernel.biometrics.entities.BIR; +import io.mosip.kernel.biometrics.entities.BiometricRecord; +import io.mosip.kernel.core.bioapi.exception.BiometricException; +import io.mosip.kernel.core.exception.BaseCheckedException; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.StringUtils; +import io.mosip.kernel.core.util.exception.JsonProcessingException; +import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; +import io.mosip.registration.processor.core.constant.JsonConstant; +import io.mosip.registration.processor.core.constant.MappingJsonConstants; +import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.core.constant.RegistrationType; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.IntroducerOnHoldException; +import io.mosip.registration.processor.core.exception.PacketDecryptionFailureException; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; +import io.mosip.registration.processor.core.exception.ValidationFailedException; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.packet.dto.FieldValue; +import io.mosip.registration.processor.core.status.util.StatusUtil; +import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; +import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; +import io.mosip.registration.processor.packet.storage.utils.BioSdkUtil; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.status.code.RegistrationStatusCode; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.service.RegistrationStatusService; + +@Service +public class IntroducerValidator { + + private static Logger regProcLogger = RegProcessorLogger.getLogger(IntroducerValidator.class); + + public static final String INDIVIDUAL_TYPE_UIN = "UIN"; + + @Autowired + RegistrationExceptionMapperUtil registrationExceptionMapperUtil; + + @Autowired + private PriorityBasedPacketManagerService packetManagerService; + + @Autowired + private IdRepoService idRepoService; + + @Autowired + RegistrationStatusService registrationStatusService; + + @Autowired + ObjectMapper mapper; + + + + @Autowired + private Utilities utility; + + @Autowired + private BioSdkUtil bioUtil; + + @Value("#{T(java.util.Arrays).asList('${mosip.regproc.common.before-cbeff-others-attibute.reg-client-versions:}')}") + private List regClientVersionsBeforeCbeffOthersAttritube; + + /** + * Checks if is valid introducer. + * + * @param registrationId the registration id + * @param registrationStatusDto + * @throws SAXException + * @throws ParserConfigurationException + * @throws BiometricException + * @throws io.mosip.kernel.core.exception.IOException + * @throws Exception + * @throws PacketDecryptionFailureException + * @throws RegistrationProcessorCheckedException + */ + public void validate(String registrationId, InternalRegistrationStatusDto registrationStatusDto) throws Exception { + + regProcLogger.debug("validate called for registrationId {}", registrationId); + + String introducerUIN = packetManagerService.getFieldByMappingJsonKey(registrationId, + MappingJsonConstants.INTRODUCER_UIN, registrationStatusDto.getRegistrationType(), + ProviderStageName.INTRODUCER_VALIDATOR); + String introducerRID = packetManagerService.getFieldByMappingJsonKey(registrationId, + MappingJsonConstants.INTRODUCER_RID, registrationStatusDto.getRegistrationType(), + ProviderStageName.INTRODUCER_VALIDATOR); + + if (isValidIntroducer(introducerUIN, introducerRID)) { + registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.INTRODUCER_UIN_AND_RID_NOT_IN_PACKET)); + registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.toString()); + regProcLogger.debug("validate called for registrationId {} {}", registrationId, + StatusUtil.UIN_RID_NOT_FOUND.getMessage()); + throw new BaseCheckedException(StatusUtil.UIN_RID_NOT_FOUND.getMessage(), + StatusUtil.UIN_RID_NOT_FOUND.getCode()); + } + + if ((introducerUIN == null || introducerUIN.isEmpty()) + && isValidIntroducerRid(introducerRID, registrationId, registrationStatusDto)) { + + introducerUIN = idRepoService.getUinByRid(introducerRID, utility.getGetRegProcessorDemographicIdentity()); + + if (introducerUIN == null) { + registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.INTRODUCER_UIN_NOT_AVAIALBLE)); + registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); + regProcLogger.debug("validate called for registrationId {} {}", registrationId, + StatusUtil.INTRODUCER_UIN_NOT_FOUND.getMessage()); + throw new BaseCheckedException(StatusUtil.INTRODUCER_UIN_NOT_FOUND.getMessage(), + StatusUtil.INTRODUCER_UIN_NOT_FOUND.getCode()); + } + + } + if (introducerUIN != null && !introducerUIN.isEmpty()) { + validateIntroducerBiometric(registrationId, registrationStatusDto, introducerUIN); + } else { + throw new ValidationFailedException(StatusUtil.INTRODUCER_AUTHENTICATION_FAILED.getMessage(), + StatusUtil.INTRODUCER_AUTHENTICATION_FAILED.getCode()); + } + + regProcLogger.debug("validate call ended for registrationId {}", registrationId); + } + + private boolean isValidIntroducer(String introducerUIN, String introducerRID) { + return ((introducerUIN == null && introducerRID == null) || ((introducerUIN != null && introducerUIN.isEmpty()) + && (introducerRID != null && introducerRID.isEmpty()))); + } + + /** + * Validate introducer rid. + * + * @param introducerRid the introducer rid + * @param registrationId the registration id + * @param registrationStatusDto + * @return true, if successful + * @throws BaseCheckedException + */ + private boolean isValidIntroducerRid(String introducerRid, String registrationId, + InternalRegistrationStatusDto registrationStatusDto) throws BaseCheckedException { + + List internalRegistrationStatusDtoList= registrationStatusService.getAllRegistrationStatuses(introducerRid); + InternalRegistrationStatusDto introducerRegistrationStatusDto=CollectionUtils.isNotEmpty(internalRegistrationStatusDtoList) ? + internalRegistrationStatusDtoList.stream().filter(s -> RegistrationType.NEW.name().equalsIgnoreCase(s.getRegistrationType())).collect(Collectors.toList()).iterator().next() + : null; + if (introducerRegistrationStatusDto != null) { + if (introducerRegistrationStatusDto.getStatusCode().equals(RegistrationStatusCode.PROCESSING.toString())) { + + registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.ON_HOLD_INTRODUCER_PACKET)); + + registrationStatusDto.setStatusComment(StatusUtil.PACKET_ON_HOLD.getMessage()); + registrationStatusDto.setSubStatusCode(StatusUtil.PACKET_ON_HOLD.getCode()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.toString()); + regProcLogger.debug("isValidIntroducerRid call ended for registrationId {} {}", registrationId, + StatusUtil.PACKET_ON_HOLD.getMessage()); + throw new IntroducerOnHoldException(StatusUtil.PACKET_ON_HOLD.getCode(), + StatusUtil.PACKET_ON_HOLD.getMessage()); + + } else if (introducerRegistrationStatusDto.getStatusCode() + .equals(RegistrationStatusCode.REJECTED.toString()) + || introducerRegistrationStatusDto.getStatusCode() + .equals(RegistrationStatusCode.FAILED.toString())) { + + registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.OSI_FAILED_REJECTED_INTRODUCER)); + + registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); + regProcLogger.debug("isValidIntroducerRid call ended for registrationId {} {}", registrationId, + StatusUtil.CHILD_PACKET_REJECTED.getMessage()); + throw new BaseCheckedException(StatusUtil.CHILD_PACKET_REJECTED.getMessage(), + StatusUtil.CHILD_PACKET_REJECTED.getCode()); + } else { + return true; + } + + } else { + registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.ON_HOLD_INTRODUCER_PACKET)); + + registrationStatusDto.setStatusComment(StatusUtil.PACKET_IS_ON_HOLD.getMessage()); + registrationStatusDto.setSubStatusCode(StatusUtil.PACKET_IS_ON_HOLD.getCode()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.toString()); + regProcLogger.debug("isValidIntroducerRid call ended for registrationId {} {}", registrationId, + StatusUtil.PACKET_ON_HOLD.getMessage()); + throw new IntroducerOnHoldException(StatusUtil.PACKET_ON_HOLD.getCode(), + StatusUtil.PACKET_ON_HOLD.getMessage()); + } + } + + private void validateIntroducerBiometric(String registrationId, InternalRegistrationStatusDto registrationStatusDto, + String introducerUIN) + throws Exception { + BiometricRecord biometricRecord = packetManagerService.getBiometricsByMappingJsonKey(registrationId, + MappingJsonConstants.INTRODUCER_BIO, registrationStatusDto.getRegistrationType(), + ProviderStageName.INTRODUCER_VALIDATOR); + if (biometricRecord != null && biometricRecord.getSegments() != null) { + biometricRecord = filterExceptionBiometrics(biometricRecord, registrationId, + registrationStatusDto.getRegistrationType()); + if (biometricRecord != null && biometricRecord.getSegments() != null) { + validateUserBiometric(registrationId, introducerUIN, biometricRecord.getSegments(), INDIVIDUAL_TYPE_UIN, + registrationStatusDto); + } else { + registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.INTRODUCER_BIOMETRIC_ALL_EXCEPTION_IN_PACKET)); + registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); + regProcLogger.debug("validateIntroducerBiometric call ended for registrationId {} {}", registrationId, + StatusUtil.INTRODUCER_BIOMETRIC_ALL_EXCEPTION_IN_PACKET.getMessage()); + throw new BaseCheckedException(StatusUtil.INTRODUCER_BIOMETRIC_ALL_EXCEPTION_IN_PACKET.getMessage(), + StatusUtil.INTRODUCER_BIOMETRIC_ALL_EXCEPTION_IN_PACKET.getCode()); + } + + } else { + registrationStatusDto.setLatestTransactionStatusCode(registrationExceptionMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.INTRODUCER_BIOMETRIC_NOT_IN_PACKET)); + registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); + regProcLogger.debug("validateIntroducerBiometric call ended for registrationId {} {}", registrationId, + StatusUtil.INTRODUCER_BIOMETRIC_FILE_NAME_NOT_FOUND.getMessage()); + throw new BaseCheckedException(StatusUtil.INTRODUCER_BIOMETRIC_FILE_NAME_NOT_FOUND.getMessage(), + StatusUtil.INTRODUCER_BIOMETRIC_FILE_NAME_NOT_FOUND.getCode()); + } + } + + + /** + * Validate user. + * + * @param userId the userid + * @param registrationId the registration id + * @param list biometric data as BIR object + * @param individualType user type + * @param registrationStatusDto + * @throws Exception + * @throws + * @throws BiometricException + */ + + private void validateUserBiometric(String registrationId, String userId, List list, String individualType, + InternalRegistrationStatusDto registrationStatusDto) throws Exception { + regProcLogger.info("validateUserBiometric call started for registrationId {}", registrationId); + bioUtil.authenticateBiometrics(userId, individualType, list, registrationStatusDto,StatusUtil.INTRODUCER_AUTHENTICATION_FAILED.getCode(),StatusUtil.INTRODUCER_AUTHENTICATION_FAILED.getCode()); + regProcLogger.debug("validateUserBiometric call ended for registrationId {}", registrationId); + } + + private BiometricRecord filterExceptionBiometrics(BiometricRecord biometricRecord, String id, String process) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException, + JSONException { + String version = getRegClientVersionFromMetaInfo(id, process, + packetManagerService.getMetaInfo(id, process, ProviderStageName.INTRODUCER_VALIDATOR)); + if (regClientVersionsBeforeCbeffOthersAttritube.contains(version)) { + return biometricRecord; + } + List segments = biometricRecord.getSegments().stream().filter(bio -> { + Map othersMap = bio.getOthers().entrySet().stream() + .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue())); + return (othersMap == null || !othersMap.containsKey("EXCEPTION")) ? true + : !(Boolean.parseBoolean(othersMap.get("EXCEPTION"))); + }).collect(Collectors.toList()); + if (segments != null) { + segments = segments.stream().filter(bio -> !bio.getBdbInfo().getType().get(0).name() + .equalsIgnoreCase(BiometricType.EXCEPTION_PHOTO.name())).collect(Collectors.toList()); + } + BiometricRecord biorecord = new BiometricRecord(); + biorecord.setSegments(segments); + return biorecord; + } + + private String getRegClientVersionFromMetaInfo(String id, String process, Map metaInfoMap) + throws ApisResourceAccessException, PacketManagerException, IOException, JSONException { + String metadata = metaInfoMap.get(JsonConstant.METADATA); + String version = null; + if (StringUtils.isNotEmpty(metadata)) { + JSONArray jsonArray = new JSONArray(metadata); + + for (int i = 0; i < jsonArray.length(); i++) { + if (!jsonArray.isNull(i)) { + org.json.JSONObject jsonObject = (org.json.JSONObject) jsonArray.get(i); + FieldValue fieldValue = mapper.readValue(jsonObject.toString(), FieldValue.class); + if (fieldValue.getLabel().equalsIgnoreCase(JsonConstant.REGCLIENTVERSION)) { + version = fieldValue.getValue(); + break; + } + } + } + } + return version; + } } \ No newline at end of file diff --git a/registration-processor/pre-processor/registration-processor-introducer-validator-stage/src/test/java/io/mosip/registration/processor/introducer/IntroducerValidatorTest.java b/registration-processor/pre-processor/registration-processor-introducer-validator-stage/src/test/java/io/mosip/registration/processor/introducer/IntroducerValidatorTest.java index d2f0307812f..c7216226b71 100644 --- a/registration-processor/pre-processor/registration-processor-introducer-validator-stage/src/test/java/io/mosip/registration/processor/introducer/IntroducerValidatorTest.java +++ b/registration-processor/pre-processor/registration-processor-introducer-validator-stage/src/test/java/io/mosip/registration/processor/introducer/IntroducerValidatorTest.java @@ -1,448 +1,461 @@ -package io.mosip.registration.processor.introducer; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.when; -import static org.mockito.Mockito.doNothing; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.NoSuchAlgorithmException; -import java.security.spec.InvalidKeySpecException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.commons.io.IOUtils; -import org.assertj.core.util.Lists; -import org.json.simple.JSONObject; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.springframework.core.env.Environment; -import org.xml.sax.SAXException; - -import io.mosip.kernel.biometrics.constant.BiometricType; -import io.mosip.kernel.biometrics.constant.QualityType; -import io.mosip.kernel.biometrics.entities.BDBInfo; -import io.mosip.kernel.biometrics.entities.BIR; -import io.mosip.kernel.biometrics.entities.BiometricRecord; -import io.mosip.kernel.core.bioapi.exception.BiometricException; -import io.mosip.kernel.core.exception.BaseCheckedException; -import io.mosip.registration.processor.core.auth.dto.AuthResponseDTO; -import io.mosip.registration.processor.core.auth.dto.ErrorDTO; -import io.mosip.registration.processor.core.constant.JsonConstant; -import io.mosip.registration.processor.core.constant.MappingJsonConstants; -import io.mosip.registration.processor.core.constant.PacketFiles; -import io.mosip.registration.processor.core.constant.ProviderStageName; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.AuthSystemException; -import io.mosip.registration.processor.core.exception.BioTypeException; -import io.mosip.registration.processor.core.exception.IntroducerOnHoldException; -import io.mosip.registration.processor.core.idrepo.dto.IdResponseDTO; -import io.mosip.registration.processor.core.idrepo.dto.ResponseDTO; -import io.mosip.registration.processor.core.logger.LogDescription; -import io.mosip.registration.processor.core.packet.dto.FieldValue; -import io.mosip.registration.processor.core.packet.dto.FieldValueArray; -import io.mosip.registration.processor.core.packet.dto.Identity; -import io.mosip.registration.processor.core.packet.dto.RIDResponseDto; -import io.mosip.registration.processor.core.packet.dto.RidDto; -import io.mosip.registration.processor.core.packet.dto.demographicinfo.DemographicInfoDto; -import io.mosip.registration.processor.core.packet.dto.masterdata.UserDetailsDto; -import io.mosip.registration.processor.core.packet.dto.masterdata.UserDetailsResponseDto; -import io.mosip.registration.processor.core.packet.dto.masterdata.UserResponseDto; -import io.mosip.registration.processor.core.util.JsonUtil; -import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; -import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; -import io.mosip.registration.processor.packet.storage.utils.ABISHandlerUtil; -import io.mosip.registration.processor.packet.storage.utils.BioSdkUtil; -import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; -import io.mosip.registration.processor.packet.storage.utils.Utilities; -import io.mosip.registration.processor.stages.introducervalidator.IntroducerValidator; -import io.mosip.registration.processor.status.code.RegistrationStatusCode; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.dto.TransactionDto; -import io.mosip.registration.processor.status.service.RegistrationStatusService; -import io.mosip.registration.processor.status.service.TransactionService; - -/** - * The Class IntroducerValidatorTest. - * - * @author M1022006 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({ Utilities.class, IOUtils.class }) -@PowerMockIgnore({ "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*", "javax.net.ssl.*" }) -public class IntroducerValidatorTest { - - /** The input stream. */ - @Mock - private InputStream inputStream; - - /** The registration status service. */ - @Mock - RegistrationStatusService registrationStatusService; - - @Mock - private IdRepoService idRepoService; - - /** The transcation status service. */ - @Mock - private TransactionService transcationStatusService; - - /** The auth response DTO. */ -// @Mock -// AuthResponseDTO authResponseDTO = new AuthResponseDTO(); - - - @Mock - BioSdkUtil biosdk; - - @Mock - private ABISHandlerUtil abisHandlerUtil; - - /** The env. */ - @Mock - Environment env; - - /** The data. */ - byte[] data = "1234567890".getBytes(); - - /** The registration status dto. */ - InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); - - /** The transaction dto. */ - TransactionDto transactionDto = new TransactionDto(); - - /** The supervisor validator. */ - @InjectMocks - IntroducerValidator introducerValidator; - - @Mock - private Utilities utility; - - - - /** The demographic dedupe dto list. */ - List demographicDedupeDtoList = new ArrayList<>(); - - /** The demographic info dto. */ - DemographicInfoDto demographicInfoDto = new DemographicInfoDto(); - - /** The identity. */ - private Identity identity = new Identity(); - - private JSONObject demoJson = new JSONObject(); - private UserResponseDto userResponseDto = new UserResponseDto(); - private RidDto ridDto = new RidDto(); - private ResponseDTO responseDTO1 = new ResponseDTO(); - private RIDResponseDto ridResponseDto1 = new RIDResponseDto(); - private IdResponseDTO idResponseDTO = new IdResponseDTO(); - @Mock - RegistrationExceptionMapperUtil registrationExceptionMapperUtil; - - @Mock - LogDescription description; - private ClassLoader classLoader; - - @Mock - private PriorityBasedPacketManagerService packetManagerService; - - /** - * Sets the up. - * - * @throws Exception the exception - */ - @Before - public void setUp() throws Exception { - classLoader = getClass().getClassLoader(); - - Mockito.when(utility.isUinMissingFromIdAuth(any(),any(),any())).thenReturn(false); - Mockito.when(utility.getGetRegProcessorDemographicIdentity()).thenReturn("identity"); - File file = new File(classLoader.getResource("RegistrationProcessorIdentity.json").getFile()); - InputStream inputStream = new FileInputStream(file); - String mappingJson = IOUtils.toString(inputStream); - JSONObject mappingJSONObject = JsonUtil.objectMapperReadValue(mappingJson, JSONObject.class); - Mockito.when(utility.getRegistrationProcessorMappingJson(anyString())) - .thenReturn(JsonUtil.getJSONObject(mappingJSONObject, MappingJsonConstants.IDENTITY)); - PowerMockito.mockStatic(Utilities.class); - PowerMockito.when(Utilities.class, "getJson", anyString(), anyString()).thenReturn(mappingJson); - Mockito.doNothing().when(description).setMessage(any()); - Mockito.when(registrationExceptionMapperUtil.getStatusCode(any())).thenReturn("ERROR"); - - demographicDedupeDtoList.add(demographicInfoDto); - - Mockito.when(env.getProperty("mosip.kernel.applicant.type.age.limit")).thenReturn("5"); - PowerMockito.mockStatic(IOUtils.class); - PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(data); - - // Mockito.when(authUtil.authByIdAuthentication(anyString(), any(), any())).thenReturn(authResponseDTO); - - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setApplicantType("Child"); - registrationStatusDto.setRegistrationType("New"); - - Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())).thenReturn(registrationStatusDto); - - FieldValue officerBiofileName = new FieldValue(); - officerBiofileName.setLabel(MappingJsonConstants.OFFICERBIOMETRICFILENAME); - officerBiofileName.setValue("officer_bio_CBEFF"); - - FieldValue officerPassword = new FieldValue(); - officerPassword.setLabel(JsonConstant.OFFICERPWR); - officerPassword.setValue("false"); - - FieldValue officerOtp = new FieldValue(); - officerOtp.setLabel(JsonConstant.OFFICEROTPAUTHENTICATION); - officerOtp.setValue("false"); - - FieldValue supervisorPassword = new FieldValue(); - supervisorPassword.setLabel(JsonConstant.SUPERVISORPWR); - supervisorPassword.setValue("true"); - - FieldValue supervisorId = new FieldValue(); - supervisorId.setLabel(JsonConstant.SUPERVISORID); - supervisorId.setValue("110016"); - - FieldValue supervisorOtp = new FieldValue(); - supervisorOtp.setLabel(MappingJsonConstants.SUPERVISOROTPAUTHENTICATION); - supervisorOtp.setValue("false"); - - FieldValue supervisorBiofileName = new FieldValue(); - supervisorBiofileName.setLabel(MappingJsonConstants.SUPERVISORBIOMETRICFILENAME); - supervisorBiofileName.setValue("supervisor_bio_CBEFF"); - - FieldValue creationDate = new FieldValue(); - creationDate.setLabel("creationDate"); - creationDate.setValue("2019-04-30T12:42:03.541Z"); - - identity.setOsiData((Arrays.asList(officerBiofileName, officerOtp, officerPassword, supervisorOtp, - supervisorPassword, supervisorId, supervisorBiofileName))); - identity.setMetaData((Arrays.asList(creationDate))); - List fieldValueArrayList = new ArrayList(); - FieldValueArray introducerBiometric = new FieldValueArray(); - introducerBiometric.setLabel(PacketFiles.INTRODUCERBIOMETRICSEQUENCE.name()); - List introducerBiometricValues = new ArrayList(); - introducerBiometricValues.add("introducer_bio_CBEFF"); - introducerBiometric.setValue(introducerBiometricValues); - fieldValueArrayList.add(introducerBiometric); - identity.setHashSequence(fieldValueArrayList); - - UserDetailsResponseDto userDetailsResponseDto = new UserDetailsResponseDto(); - UserDetailsDto userDetailsDto = new UserDetailsDto(); - userDetailsDto.setIsActive(true); - userDetailsResponseDto.setUserResponseDto(Arrays.asList(userDetailsDto)); - userResponseDto.setResponse(userDetailsResponseDto); - ridDto.setRid("reg4567"); - ridResponseDto1.setResponse(ridDto); - String identityJson = "{\"UIN\":\"123456\"}"; - responseDTO1.setIdentity(identityJson); - idResponseDTO.setResponse(responseDTO1); - - //File cbeffFile = new File(classLoader.getResource("cbeff.xml").getFile()); - - BIR birType3 = new BIR.BIRBuilder().build(); - BDBInfo bdbInfoType3 = new BDBInfo.BDBInfoBuilder().build(); - bdbInfoType3.setQuality(new QualityType()); - BiometricType singleType3 = BiometricType.IRIS; - List singleTypeList3 = new ArrayList<>(); - singleTypeList3.add(singleType3); - List subtype3 = new ArrayList<>(Arrays.asList("Right")); - bdbInfoType3.setSubtype(subtype3); - bdbInfoType3.setType(singleTypeList3); - birType3.setBdbInfo(bdbInfoType3); - - BIR birType4 = new BIR.BIRBuilder().build(); - BDBInfo bdbInfoType4 = new BDBInfo.BDBInfoBuilder().build(); - bdbInfoType4.setQuality(new QualityType()); - BiometricType singleType4 = BiometricType.FACE; - List singleTypeList4 = new ArrayList<>(); - singleTypeList4.add(singleType4); - List subtype4 = new ArrayList<>(); - bdbInfoType4.setSubtype(subtype4); - bdbInfoType4.setType(singleTypeList4); - birType4.setBdbInfo(bdbInfoType4); - - BiometricRecord biometricRecord = new BiometricRecord(); - biometricRecord.setSegments(Lists.newArrayList(birType3, birType4)); - when(packetManagerService.getBiometricsByMappingJsonKey(anyString(), any(), any(), any())) - .thenReturn(biometricRecord); - - when(packetManagerService.getFieldByMappingJsonKey(anyString(), anyString(), anyString(), any())) - .thenReturn("field"); - - doNothing().when(biosdk).authenticateBiometrics(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); - } - - /** - * Test introducer details null. - * - * @throws Exception the exception - */ - @Test - @Ignore - public void testIntroducerDetailsNull() throws Exception { - introducerValidator.validate("reg1234", registrationStatusDto); - } - - /** - * Test invalid iris. - * - * @throws SAXException - * @throws ParserConfigurationException - * @throws BioTypeException - * @throws BiometricException - * @throws NoSuchAlgorithmException - * @throws InvalidKeySpecException - * @throws NumberFormatException - * @throws ApisResourceAccessException the apis resource access exception - * @throws IOException Signals that an I/O exception has - * occurred. - */ - @Test(expected = BaseCheckedException.class) - public void testIntroducerRIDFailedOnHold() throws ApisResourceAccessException, IOException, Exception { - registrationStatusDto.setStatusCode("FAILED"); - List internalRegistrationStatusDtoList=new ArrayList(); - internalRegistrationStatusDtoList.add(registrationStatusDto); - - Mockito.when(registrationStatusService.getAllRegistrationStatuses(anyString())).thenReturn(internalRegistrationStatusDtoList); - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(null); - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); - introducerValidator.validate("reg1234", registrationStatusDto); - } - - @Test(expected = BaseCheckedException.class) - public void testIntroducerBiometricValidationFailed() throws ApisResourceAccessException, IOException, Exception { - - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("2832677"); - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); - when(packetManagerService.getBiometricsByMappingJsonKey(anyString(), any(), any(), any())) - .thenReturn(null); - introducerValidator.validate("reg1234", registrationStatusDto); - } - - @Test(expected = BaseCheckedException.class) - public void testIntroducerRIDUINNotFound() throws ApisResourceAccessException, IOException, Exception { - registrationStatusDto.setStatusCode("PROCESSED"); - List internalRegistrationStatusDtoList=new ArrayList(); - internalRegistrationStatusDtoList.add(registrationStatusDto); - - Mockito.when(registrationStatusService.getAllRegistrationStatuses(anyString())).thenReturn(internalRegistrationStatusDtoList); - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(null); - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); - introducerValidator.validate("reg1234", registrationStatusDto); - } - - @Test(expected = IntroducerOnHoldException.class) - public void testIntroducerRIDProcessingOnHold() - throws Exception { - registrationStatusDto.setStatusCode((RegistrationStatusCode.PROCESSING.toString())); - List internalRegistrationStatusDtoList=new ArrayList(); - internalRegistrationStatusDtoList.add(registrationStatusDto); - Mockito.when(registrationStatusService.getAllRegistrationStatuses(anyString())).thenReturn(internalRegistrationStatusDtoList); - - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(null); - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); - - introducerValidator.validate("reg1234", registrationStatusDto); - } - - @Test(expected = BaseCheckedException.class) - public void testIntroducerUINAndRIDNotPresent() throws Exception { - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(""); - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(""); - - introducerValidator.validate("reg1234", registrationStatusDto); - } - - @Test(expected = IntroducerOnHoldException.class) - @Ignore - public void testIntroducerNotInRegProc() throws Exception { - InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); - registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.toString()); - registrationStatusDto.setRegistrationType("NEW"); - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(null); - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); - - Mockito.when(registrationStatusService.getAllRegistrationStatuses(anyString())).thenReturn(null); - introducerValidator.validate("reg1234", registrationStatusDto); - } - - @Test - public void testIntroducerBioFileNotNull() throws Exception { - demoJson.put("value", "biometreics"); - - // AuthResponseDTO authResponseDTO1 = new AuthResponseDTO(); - // authResponseDTO1.setErrors(null); - io.mosip.registration.processor.core.auth.dto.ResponseDTO responseDTO = new io.mosip.registration.processor.core.auth.dto.ResponseDTO(); - responseDTO.setAuthStatus(true); - // authResponseDTO1.setResponse(responseDTO); - //Mockito.when(authUtil.authByIdAuthentication(anyString(), any(), any())).thenReturn(authResponseDTO1); - - registrationStatusDto.setStatusCode("PROCESSED"); - Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())).thenReturn(registrationStatusDto); - Mockito.when(idRepoService.getUinByRid(any(), any())).thenReturn("123456789"); - introducerValidator.validate("reg1234", registrationStatusDto); - } - - @Test - public void testIntroducerErrorTrue() throws Exception { - // Mockito.when(osiUtils.getMetaDataValue(anyString(), - // any())).thenReturn("2015/01/01"); - demoJson.put("value", "biometreics"); - introducerValidator.validate("reg1234", registrationStatusDto); - } - - @Test - public void testIntroducerAuthSystemError() throws Exception { - demoJson.put("value", "biometreics"); - introducerValidator.validate("reg1234", registrationStatusDto); - } - - @Test - public void testIntroducerAuthFalse() throws Exception { - registrationStatusDto.setStatusCode("PROCESSED"); - Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())).thenReturn(registrationStatusDto); - Mockito.when(idRepoService.getUinByRid(any(), any())).thenReturn("123456789"); - introducerValidator.validate("reg1234", registrationStatusDto); - } - - @Test(expected = BaseCheckedException.class) - public void testIntroducerUINNull() throws Exception { - InternalRegistrationStatusDto introducerRegistrationStatusDto = new InternalRegistrationStatusDto(); - introducerRegistrationStatusDto.setStatusCode((RegistrationStatusCode.PROCESSED.toString())); - Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())) - .thenReturn(introducerRegistrationStatusDto); - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(null); - when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", - ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); - Mockito.when(idRepoService.getUinByRid(any(), any())).thenReturn(null); - - introducerValidator.validate("reg1234", registrationStatusDto); - } +package io.mosip.registration.processor.introducer; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.NoSuchAlgorithmException; +import java.security.spec.InvalidKeySpecException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.commons.io.IOUtils; +import org.assertj.core.util.Lists; +import org.json.simple.JSONObject; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.core.env.Environment; +import org.springframework.test.util.ReflectionTestUtils; +import org.xml.sax.SAXException; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.biometrics.constant.BiometricType; +import io.mosip.kernel.biometrics.constant.QualityType; +import io.mosip.kernel.biometrics.entities.BDBInfo; +import io.mosip.kernel.biometrics.entities.BIR; +import io.mosip.kernel.biometrics.entities.BiometricRecord; +import io.mosip.kernel.core.bioapi.exception.BiometricException; +import io.mosip.kernel.core.exception.BaseCheckedException; +import io.mosip.registration.processor.core.constant.JsonConstant; +import io.mosip.registration.processor.core.constant.MappingJsonConstants; +import io.mosip.registration.processor.core.constant.PacketFiles; +import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.BioTypeException; +import io.mosip.registration.processor.core.exception.IntroducerOnHoldException; +import io.mosip.registration.processor.core.idrepo.dto.IdResponseDTO; +import io.mosip.registration.processor.core.idrepo.dto.ResponseDTO; +import io.mosip.registration.processor.core.logger.LogDescription; +import io.mosip.registration.processor.core.packet.dto.FieldValue; +import io.mosip.registration.processor.core.packet.dto.FieldValueArray; +import io.mosip.registration.processor.core.packet.dto.Identity; +import io.mosip.registration.processor.core.packet.dto.RIDResponseDto; +import io.mosip.registration.processor.core.packet.dto.RidDto; +import io.mosip.registration.processor.core.packet.dto.demographicinfo.DemographicInfoDto; +import io.mosip.registration.processor.core.packet.dto.masterdata.UserDetailsDto; +import io.mosip.registration.processor.core.packet.dto.masterdata.UserDetailsResponseDto; +import io.mosip.registration.processor.core.packet.dto.masterdata.UserResponseDto; +import io.mosip.registration.processor.core.util.JsonUtil; +import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; +import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; +import io.mosip.registration.processor.packet.storage.utils.ABISHandlerUtil; +import io.mosip.registration.processor.packet.storage.utils.BioSdkUtil; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.stages.introducervalidator.IntroducerValidator; +import io.mosip.registration.processor.status.code.RegistrationStatusCode; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.dto.TransactionDto; +import io.mosip.registration.processor.status.service.RegistrationStatusService; +import io.mosip.registration.processor.status.service.TransactionService; + +/** + * The Class IntroducerValidatorTest. + * + * @author M1022006 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({ Utilities.class, IOUtils.class }) +@PowerMockIgnore({ "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*", "javax.net.ssl.*" }) +public class IntroducerValidatorTest { + + /** The input stream. */ + @Mock + private InputStream inputStream; + + /** The registration status service. */ + @Mock + RegistrationStatusService registrationStatusService; + + @Mock + private IdRepoService idRepoService; + + /** The transcation status service. */ + @Mock + private TransactionService transcationStatusService; + + /** The auth response DTO. */ +// @Mock +// AuthResponseDTO authResponseDTO = new AuthResponseDTO(); + + + @Mock + BioSdkUtil biosdk; + + @Mock + private ABISHandlerUtil abisHandlerUtil; + + /** The env. */ + @Mock + Environment env; + + /** The data. */ + byte[] data = "1234567890".getBytes(); + + /** The registration status dto. */ + InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); + + /** The transaction dto. */ + TransactionDto transactionDto = new TransactionDto(); + + /** The supervisor validator. */ + @InjectMocks + IntroducerValidator introducerValidator; + + @Mock + private Utilities utility; + + + + /** The demographic dedupe dto list. */ + List demographicDedupeDtoList = new ArrayList<>(); + + /** The demographic info dto. */ + DemographicInfoDto demographicInfoDto = new DemographicInfoDto(); + + /** The identity. */ + private Identity identity = new Identity(); + + private JSONObject demoJson = new JSONObject(); + private UserResponseDto userResponseDto = new UserResponseDto(); + private RidDto ridDto = new RidDto(); + private ResponseDTO responseDTO1 = new ResponseDTO(); + private RIDResponseDto ridResponseDto1 = new RIDResponseDto(); + private IdResponseDTO idResponseDTO = new IdResponseDTO(); + @Mock + RegistrationExceptionMapperUtil registrationExceptionMapperUtil; + + @Mock + LogDescription description; + private ClassLoader classLoader; + + @Mock + private PriorityBasedPacketManagerService packetManagerService; + + @Mock + ObjectMapper mapper; + + /** + * Sets the up. + * + * @throws Exception the exception + */ + @Before + public void setUp() throws Exception { + classLoader = getClass().getClassLoader(); + + Mockito.when(utility.isUinMissingFromIdAuth(any(),any(),any())).thenReturn(false); + Mockito.when(utility.getGetRegProcessorDemographicIdentity()).thenReturn("identity"); + File file = new File(classLoader.getResource("RegistrationProcessorIdentity.json").getFile()); + InputStream inputStream = new FileInputStream(file); + String mappingJson = IOUtils.toString(inputStream); + JSONObject mappingJSONObject = JsonUtil.objectMapperReadValue(mappingJson, JSONObject.class); + Mockito.when(utility.getRegistrationProcessorMappingJson(anyString())) + .thenReturn(JsonUtil.getJSONObject(mappingJSONObject, MappingJsonConstants.IDENTITY)); + PowerMockito.mockStatic(Utilities.class); + PowerMockito.when(Utilities.class, "getJson", anyString(), anyString()).thenReturn(mappingJson); + Mockito.doNothing().when(description).setMessage(any()); + Mockito.when(registrationExceptionMapperUtil.getStatusCode(any())).thenReturn("ERROR"); + + demographicDedupeDtoList.add(demographicInfoDto); + + Mockito.when(env.getProperty("mosip.kernel.applicant.type.age.limit")).thenReturn("5"); + PowerMockito.mockStatic(IOUtils.class); + PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(data); + + // Mockito.when(authUtil.authByIdAuthentication(anyString(), any(), any())).thenReturn(authResponseDTO); + + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setApplicantType("Child"); + registrationStatusDto.setRegistrationType("New"); + + Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())).thenReturn(registrationStatusDto); + + FieldValue officerBiofileName = new FieldValue(); + officerBiofileName.setLabel(MappingJsonConstants.OFFICERBIOMETRICFILENAME); + officerBiofileName.setValue("officer_bio_CBEFF"); + + FieldValue officerPassword = new FieldValue(); + officerPassword.setLabel(JsonConstant.OFFICERPWR); + officerPassword.setValue("false"); + + FieldValue officerOtp = new FieldValue(); + officerOtp.setLabel(JsonConstant.OFFICEROTPAUTHENTICATION); + officerOtp.setValue("false"); + + FieldValue supervisorPassword = new FieldValue(); + supervisorPassword.setLabel(JsonConstant.SUPERVISORPWR); + supervisorPassword.setValue("true"); + + FieldValue supervisorId = new FieldValue(); + supervisorId.setLabel(JsonConstant.SUPERVISORID); + supervisorId.setValue("110016"); + + FieldValue supervisorOtp = new FieldValue(); + supervisorOtp.setLabel(MappingJsonConstants.SUPERVISOROTPAUTHENTICATION); + supervisorOtp.setValue("false"); + + FieldValue supervisorBiofileName = new FieldValue(); + supervisorBiofileName.setLabel(MappingJsonConstants.SUPERVISORBIOMETRICFILENAME); + supervisorBiofileName.setValue("supervisor_bio_CBEFF"); + + FieldValue creationDate = new FieldValue(); + creationDate.setLabel("creationDate"); + creationDate.setValue("2019-04-30T12:42:03.541Z"); + + identity.setOsiData((Arrays.asList(officerBiofileName, officerOtp, officerPassword, supervisorOtp, + supervisorPassword, supervisorId, supervisorBiofileName))); + identity.setMetaData((Arrays.asList(creationDate))); + List fieldValueArrayList = new ArrayList(); + FieldValueArray introducerBiometric = new FieldValueArray(); + introducerBiometric.setLabel(PacketFiles.INTRODUCERBIOMETRICSEQUENCE.name()); + List introducerBiometricValues = new ArrayList(); + introducerBiometricValues.add("introducer_bio_CBEFF"); + introducerBiometric.setValue(introducerBiometricValues); + fieldValueArrayList.add(introducerBiometric); + identity.setHashSequence(fieldValueArrayList); + + UserDetailsResponseDto userDetailsResponseDto = new UserDetailsResponseDto(); + UserDetailsDto userDetailsDto = new UserDetailsDto(); + userDetailsDto.setIsActive(true); + userDetailsResponseDto.setUserResponseDto(Arrays.asList(userDetailsDto)); + userResponseDto.setResponse(userDetailsResponseDto); + ridDto.setRid("reg4567"); + ridResponseDto1.setResponse(ridDto); + String identityJson = "{\"UIN\":\"123456\"}"; + responseDTO1.setIdentity(identityJson); + idResponseDTO.setResponse(responseDTO1); + + //File cbeffFile = new File(classLoader.getResource("cbeff.xml").getFile()); + + BIR birType3 = new BIR.BIRBuilder().build(); + BDBInfo bdbInfoType3 = new BDBInfo.BDBInfoBuilder().build(); + bdbInfoType3.setQuality(new QualityType()); + BiometricType singleType3 = BiometricType.IRIS; + List singleTypeList3 = new ArrayList<>(); + singleTypeList3.add(singleType3); + List subtype3 = new ArrayList<>(Arrays.asList("Right")); + bdbInfoType3.setSubtype(subtype3); + bdbInfoType3.setType(singleTypeList3); + birType3.setBdbInfo(bdbInfoType3); + + BIR birType4 = new BIR.BIRBuilder().build(); + BDBInfo bdbInfoType4 = new BDBInfo.BDBInfoBuilder().build(); + bdbInfoType4.setQuality(new QualityType()); + BiometricType singleType4 = BiometricType.FACE; + List singleTypeList4 = new ArrayList<>(); + singleTypeList4.add(singleType4); + List subtype4 = new ArrayList<>(); + bdbInfoType4.setSubtype(subtype4); + bdbInfoType4.setType(singleTypeList4); + birType4.setBdbInfo(bdbInfoType4); + + BiometricRecord biometricRecord = new BiometricRecord(); + biometricRecord.setSegments(Lists.newArrayList(birType3, birType4)); + when(packetManagerService.getBiometricsByMappingJsonKey(anyString(), any(), any(), any())) + .thenReturn(biometricRecord); + + when(packetManagerService.getFieldByMappingJsonKey(anyString(), anyString(), anyString(), any())) + .thenReturn("field"); + ReflectionTestUtils.setField(introducerValidator, "regClientVersionsBeforeCbeffOthersAttritube", + Arrays.asList("1.1.3")); + Map metaInfoMap = new HashMap<>(); + metaInfoMap.put(JsonConstant.METADATA, + "[{\n \"label\" : \"Registration Client Version Number\",\n \"value\" : \"1.2.0\"\n}]"); + Mockito.when(mapper.readValue(anyString(), any(Class.class))) + .thenReturn(new FieldValue("Registration Client Version Number", "1.2.0")); + Mockito.when(packetManagerService.getMetaInfo(any(), any(), any())).thenReturn(metaInfoMap); + doNothing().when(biosdk).authenticateBiometrics(Mockito.anyString(), Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); + } + + /** + * Test introducer details null. + * + * @throws Exception the exception + */ + @Test + @Ignore + public void testIntroducerDetailsNull() throws Exception { + introducerValidator.validate("reg1234", registrationStatusDto); + } + + /** + * Test invalid iris. + * + * @throws SAXException + * @throws ParserConfigurationException + * @throws BioTypeException + * @throws BiometricException + * @throws NoSuchAlgorithmException + * @throws InvalidKeySpecException + * @throws NumberFormatException + * @throws ApisResourceAccessException the apis resource access exception + * @throws IOException Signals that an I/O exception has + * occurred. + */ + @Test(expected = BaseCheckedException.class) + public void testIntroducerRIDFailedOnHold() throws ApisResourceAccessException, IOException, Exception { + registrationStatusDto.setStatusCode("FAILED"); + List internalRegistrationStatusDtoList=new ArrayList(); + internalRegistrationStatusDtoList.add(registrationStatusDto); + + Mockito.when(registrationStatusService.getAllRegistrationStatuses(anyString())).thenReturn(internalRegistrationStatusDtoList); + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(null); + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); + introducerValidator.validate("reg1234", registrationStatusDto); + } + + @Test(expected = BaseCheckedException.class) + public void testIntroducerBiometricValidationFailed() throws ApisResourceAccessException, IOException, Exception { + + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("2832677"); + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); + when(packetManagerService.getBiometricsByMappingJsonKey(anyString(), any(), any(), any())) + .thenReturn(null); + introducerValidator.validate("reg1234", registrationStatusDto); + } + + @Test(expected = BaseCheckedException.class) + public void testIntroducerRIDUINNotFound() throws ApisResourceAccessException, IOException, Exception { + registrationStatusDto.setStatusCode("PROCESSED"); + List internalRegistrationStatusDtoList=new ArrayList(); + internalRegistrationStatusDtoList.add(registrationStatusDto); + + Mockito.when(registrationStatusService.getAllRegistrationStatuses(anyString())).thenReturn(internalRegistrationStatusDtoList); + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(null); + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); + introducerValidator.validate("reg1234", registrationStatusDto); + } + + @Test(expected = IntroducerOnHoldException.class) + public void testIntroducerRIDProcessingOnHold() + throws Exception { + registrationStatusDto.setStatusCode((RegistrationStatusCode.PROCESSING.toString())); + List internalRegistrationStatusDtoList=new ArrayList(); + internalRegistrationStatusDtoList.add(registrationStatusDto); + Mockito.when(registrationStatusService.getAllRegistrationStatuses(anyString())).thenReturn(internalRegistrationStatusDtoList); + + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(null); + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); + + introducerValidator.validate("reg1234", registrationStatusDto); + } + + @Test(expected = BaseCheckedException.class) + public void testIntroducerUINAndRIDNotPresent() throws Exception { + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(""); + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(""); + + introducerValidator.validate("reg1234", registrationStatusDto); + } + + @Test(expected = IntroducerOnHoldException.class) + @Ignore + public void testIntroducerNotInRegProc() throws Exception { + InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); + registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.toString()); + registrationStatusDto.setRegistrationType("NEW"); + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(null); + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); + + Mockito.when(registrationStatusService.getAllRegistrationStatuses(anyString())).thenReturn(null); + introducerValidator.validate("reg1234", registrationStatusDto); + } + + @Test + public void testIntroducerBioFileNotNull() throws Exception { + demoJson.put("value", "biometreics"); + + // AuthResponseDTO authResponseDTO1 = new AuthResponseDTO(); + // authResponseDTO1.setErrors(null); + io.mosip.registration.processor.core.auth.dto.ResponseDTO responseDTO = new io.mosip.registration.processor.core.auth.dto.ResponseDTO(); + responseDTO.setAuthStatus(true); + // authResponseDTO1.setResponse(responseDTO); + //Mockito.when(authUtil.authByIdAuthentication(anyString(), any(), any())).thenReturn(authResponseDTO1); + + registrationStatusDto.setStatusCode("PROCESSED"); + Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())).thenReturn(registrationStatusDto); + Mockito.when(idRepoService.getUinByRid(any(), any())).thenReturn("123456789"); + introducerValidator.validate("reg1234", registrationStatusDto); + } + + @Test + public void testIntroducerErrorTrue() throws Exception { + // Mockito.when(osiUtils.getMetaDataValue(anyString(), + // any())).thenReturn("2015/01/01"); + demoJson.put("value", "biometreics"); + introducerValidator.validate("reg1234", registrationStatusDto); + } + + @Test + public void testIntroducerAuthSystemError() throws Exception { + demoJson.put("value", "biometreics"); + introducerValidator.validate("reg1234", registrationStatusDto); + } + + @Test + public void testIntroducerAuthFalse() throws Exception { + registrationStatusDto.setStatusCode("PROCESSED"); + Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())).thenReturn(registrationStatusDto); + Mockito.when(idRepoService.getUinByRid(any(), any())).thenReturn("123456789"); + introducerValidator.validate("reg1234", registrationStatusDto); + } + + @Test(expected = BaseCheckedException.class) + public void testIntroducerUINNull() throws Exception { + InternalRegistrationStatusDto introducerRegistrationStatusDto = new InternalRegistrationStatusDto(); + introducerRegistrationStatusDto.setStatusCode((RegistrationStatusCode.PROCESSED.toString())); + Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())) + .thenReturn(introducerRegistrationStatusDto); + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerUIN", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn(null); + when(packetManagerService.getFieldByMappingJsonKey("reg1234", "introducerRID", "New", + ProviderStageName.INTRODUCER_VALIDATOR)).thenReturn("field"); + Mockito.when(idRepoService.getUinByRid(any(), any())).thenReturn(null); + + introducerValidator.validate("reg1234", registrationStatusDto); + } } \ No newline at end of file