Skip to content

Commit

Permalink
MOSIP-22192_modified update verification code (#1541)
Browse files Browse the repository at this point in the history
* Release-fix

* # WARNING: head commit changed in the meantime

Merge branch '1.1.5.6' of https://github.com/mosip/registration.git into
1.1.5.6

* MOSIP-22192

Co-authored-by: M1030448 <M1030448@MT-2G2B2B3>
  • Loading branch information
JyotiPrakashNayak and M1030448 authored May 27, 2022
1 parent 3b6df88 commit 47dfd87
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.mosip.registration.processor.manual.verification.service.impl.ManualVerificationServiceImpl;
import io.mosip.registration.processor.manual.verification.stage.ManualVerificationStage;
import io.mosip.registration.processor.manual.verification.util.ManualVerificationRequestValidator;
import io.mosip.registration.processor.manual.verification.util.ManualVerificationUpdateUtility;

@Configuration
public class ManualVerificationConfigBean {
Expand All @@ -16,7 +17,10 @@ public class ManualVerificationConfigBean {
@Bean ManualVerificationService getManualVerificationService() {
return new ManualVerificationServiceImpl();
}

@Bean
ManualVerificationUpdateUtility getManualVerificationUpdateUtility() {
return new ManualVerificationUpdateUtility();
}
@Bean
public ManualVerificationStage getManualVerificationStage() {
return new ManualVerificationStage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import java.io.IOException;
import java.io.InputStream;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand All @@ -19,9 +18,6 @@
import java.util.UUID;
import java.util.stream.Collectors;

import io.mosip.registration.processor.core.constant.PolicyConstant;
import io.mosip.registration.processor.core.constant.ProviderStageName;
import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
Expand Down Expand Up @@ -61,6 +57,8 @@
import io.mosip.registration.processor.core.constant.LoggerFileConstant;
import io.mosip.registration.processor.core.constant.MappingJsonConstants;
import io.mosip.registration.processor.core.constant.PacketFiles;
import io.mosip.registration.processor.core.constant.PolicyConstant;
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.PacketManagerException;
Expand Down Expand Up @@ -102,12 +100,14 @@
import io.mosip.registration.processor.manual.verification.response.dto.ManualAdjudicationResponseDTO;
import io.mosip.registration.processor.manual.verification.service.ManualVerificationService;
import io.mosip.registration.processor.manual.verification.stage.ManualVerificationStage;
import io.mosip.registration.processor.manual.verification.util.ManualVerificationUpdateUtility;
import io.mosip.registration.processor.packet.manager.exception.FileNotFoundInDestinationException;
import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto;
import io.mosip.registration.processor.packet.storage.dto.Document;
import io.mosip.registration.processor.packet.storage.entity.ManualVerificationEntity;
import io.mosip.registration.processor.packet.storage.repository.BasePacketRepository;
import io.mosip.registration.processor.packet.storage.utils.BIRConverter;
import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService;
import io.mosip.registration.processor.packet.storage.utils.Utilities;
import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder;
import io.mosip.registration.processor.status.code.RegistrationStatusCode;
Expand Down Expand Up @@ -202,6 +202,9 @@ public class ManualVerificationServiceImpl implements ManualVerificationService

@Autowired
RegistrationExceptionMapperUtil registrationExceptionMapperUtil;

@Autowired
private ManualVerificationUpdateUtility manualVerificationUpdateUtility;

/*
* * (non-Javadoc)
Expand Down Expand Up @@ -617,14 +620,13 @@ private void pushRequestToQueue(String refId, MosipQueue queue) throws Exception
String requestId = UUID.randomUUID().toString();
mar.setRequestId(requestId);
regProcLogger.info("Request : " + JsonUtils.javaObjectToJsonString(mar));
manualVerificationUpdateUtility.updateManualVerificationEntityRID(mves, requestId);
if (messageFormat.equalsIgnoreCase(TEXT_MESSAGE))
mosipQueueManager.send(queue, JsonUtils.javaObjectToJsonString(mar), mvRequestAddress, mvRequestMessageTTL);
else
mosipQueueManager.send(queue, JsonUtils.javaObjectToJsonString(mar).getBytes(), mvRequestAddress, mvRequestMessageTTL);
regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
refId, "ManualVerificationServiceImpl::pushRequestToQueue()::entry");

updateManualVerificationEntityRID(mves, requestId);
}

private String getDataShareUrl(String id, String process) throws Exception {
Expand Down Expand Up @@ -975,24 +977,7 @@ public MessageDTO process(MessageDTO object, MosipQueue queue) {

return object;
}
/*
* Update manual verification entity once request is pushed to queue for a given
* RID
*/
private void updateManualVerificationEntityRID(List<ManualVerificationEntity> mves, String requestId) {
mves.stream().forEach(mve -> {
regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
mve.getId().getRegId(), "ManualVerificationServiceImpl::updateManualVerificationEntityRID()::entry");
mve.setStatusCode(ManualVerificationStatus.INQUEUE.name());
mve.setStatusComment("Sent to manual adjudication queue");
mve.setUpdDtimes(Timestamp.valueOf(DateUtils.getUTCCurrentDateTime()));
mve.setRequestId(requestId);
basePacketRepository.update(mve);
regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
mve.getId().getRegId(), "ManualVerificationServiceImpl::updateManualVerificationEntityRID()::exit");
});
}


/**
* Validate the response received from manual verification system.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.mosip.registration.processor.manual.verification.util;

import java.sql.Timestamp;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.kernel.core.util.DateUtils;
import io.mosip.registration.processor.core.constant.LoggerFileConstant;
import io.mosip.registration.processor.core.logger.RegProcessorLogger;
import io.mosip.registration.processor.manual.verification.dto.ManualVerificationStatus;
import io.mosip.registration.processor.packet.storage.entity.ManualVerificationEntity;
import io.mosip.registration.processor.packet.storage.repository.BasePacketRepository;

@Component
@Transactional(propagation=Propagation.REQUIRES_NEW)
public class ManualVerificationUpdateUtility {
/** The logger. */
private static Logger regProcLogger = RegProcessorLogger.getLogger(ManualVerificationUpdateUtility.class);

/** The base packet repository. */
@Autowired
private BasePacketRepository<ManualVerificationEntity, String> basePacketRepository;

/**
* Update manual verification entity once request is pushed to queue for a given
* RID
*/
public void updateManualVerificationEntityRID(List<ManualVerificationEntity> mves, String requestId) {
mves.stream().forEach(mve -> {
regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
mve.getId().getRegId(), "ManualVerificationUpdateUtility::updateManualVerificationEntityRID()::entry");
mve.setStatusCode(ManualVerificationStatus.INQUEUE.name());
mve.setStatusComment("Sent to manual adjudication queue");
mve.setUpdDtimes(Timestamp.valueOf(DateUtils.getUTCCurrentDateTime()));
mve.setRequestId(requestId);
basePacketRepository.update(mve);
regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(),
mve.getId().getRegId(), "ManualVerificationUpdateUtility::updateManualVerificationEntityRID()::exit");
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import io.mosip.registration.processor.manual.verification.response.dto.ManualAdjudicationResponseDTO;
import io.mosip.registration.processor.manual.verification.service.impl.ManualVerificationServiceImpl;
import io.mosip.registration.processor.manual.verification.stage.ManualVerificationStage;
import io.mosip.registration.processor.manual.verification.util.ManualVerificationUpdateUtility;
import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto;
import io.mosip.registration.processor.packet.storage.entity.ManualVerificationEntity;
import io.mosip.registration.processor.packet.storage.entity.ManualVerificationPKEntity;
Expand All @@ -83,6 +84,7 @@
import io.mosip.registration.processor.status.exception.TablenotAccessibleException;
import io.mosip.registration.processor.status.service.RegistrationStatusService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.util.ReflectionTestUtils;

@RunWith(PowerMockRunner.class)
Expand All @@ -107,7 +109,8 @@ public class ManualVerificationServiceTest {

@Mock
private Utilities utilities;

@Mock
private ManualVerificationUpdateUtility manualVerificationUpdateUtility;
@Mock
private PacketInfoManager<Identity, ApplicantInfoDto> packetInfoManager;

Expand Down Expand Up @@ -235,7 +238,7 @@ public void createConnection(String username, String password, String brokerUrl)
candidateList.setCount(0);
manualAdjudicationResponseDTO.setCandidateList(candidateList);
Mockito.when(basePacketRepository.getRegistrationIdbyRequestId(anyString())).thenReturn(Lists.newArrayList(registrationStatusDto.getRegistrationId()));

Mockito.doNothing().when(manualVerificationUpdateUtility).updateManualVerificationEntityRID(any(), any());
}

// @Test
Expand Down

0 comments on commit 47dfd87

Please sign in to comment.