mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-07-01 14:12:55 +00:00
chore: some refactoring merge ttp consent status missing and rejected into one CONSENT_MISSING_OR_REJECTED
This commit is contained in:
@ -22,10 +22,9 @@ package dev.dnpm.etl.processor.input
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
import de.ukw.ccc.bwhc.dto.*
|
import de.ukw.ccc.bwhc.dto.*
|
||||||
import dev.dnpm.etl.processor.anyValueClass
|
import dev.dnpm.etl.processor.anyValueClass
|
||||||
import dev.dnpm.etl.processor.config.AppFhirConfig
|
|
||||||
import dev.dnpm.etl.processor.config.AppSecurityConfiguration
|
import dev.dnpm.etl.processor.config.AppSecurityConfiguration
|
||||||
import dev.dnpm.etl.processor.consent.ConsentCheckedIgnored
|
import dev.dnpm.etl.processor.consent.ConsentCheckedIgnored
|
||||||
import dev.dnpm.etl.processor.consent.ConsentStatus
|
import dev.dnpm.etl.processor.consent.TtpConsentStatus
|
||||||
import dev.dnpm.etl.processor.consent.ICheckConsent
|
import dev.dnpm.etl.processor.consent.ICheckConsent
|
||||||
import dev.dnpm.etl.processor.security.TokenRepository
|
import dev.dnpm.etl.processor.security.TokenRepository
|
||||||
import dev.dnpm.etl.processor.security.UserRoleRepository
|
import dev.dnpm.etl.processor.security.UserRoleRepository
|
||||||
@ -34,7 +33,6 @@ import org.junit.jupiter.api.BeforeEach
|
|||||||
import org.junit.jupiter.api.Nested
|
import org.junit.jupiter.api.Nested
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.extension.ExtendWith
|
import org.junit.jupiter.api.extension.ExtendWith
|
||||||
import org.mockito.Mockito
|
|
||||||
import org.mockito.junit.jupiter.MockitoExtension
|
import org.mockito.junit.jupiter.MockitoExtension
|
||||||
import org.mockito.kotlin.*
|
import org.mockito.kotlin.*
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
@ -145,7 +143,7 @@ class MtbFileRestControllerTest {
|
|||||||
status { isAccepted() }
|
status { isAccepted() }
|
||||||
}
|
}
|
||||||
|
|
||||||
verify(requestProcessor, times(1)).processDeletion(anyValueClass(), eq(ConsentStatus.IGNORED))
|
verify(requestProcessor, times(1)).processDeletion(anyValueClass(), eq(TtpConsentStatus.IGNORED))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -3,7 +3,7 @@ package dev.dnpm.etl.processor.consent;
|
|||||||
public class ConsentCheckedIgnored implements ICheckConsent{
|
public class ConsentCheckedIgnored implements ICheckConsent{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConsentStatus isConsented(String personIdentifierValue) {
|
public TtpConsentStatus isConsented(String personIdentifierValue) {
|
||||||
return ConsentStatus.IGNORED;
|
return TtpConsentStatus.IGNORED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
package dev.dnpm.etl.processor.consent;
|
|
||||||
|
|
||||||
public enum ConsentStatus {
|
|
||||||
CONSENTED,
|
|
||||||
CONSENT_MISSING,
|
|
||||||
FAILED_TO_ASK,
|
|
||||||
IGNORED, CONSENT_REJECTED
|
|
||||||
}
|
|
@ -4,6 +4,7 @@ import ca.uhn.fhir.context.FhirContext;
|
|||||||
import dev.dnpm.etl.processor.config.AppFhirConfig;
|
import dev.dnpm.etl.processor.config.AppFhirConfig;
|
||||||
import dev.dnpm.etl.processor.config.GIcsConfigProperties;
|
import dev.dnpm.etl.processor.config.GIcsConfigProperties;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.hl7.fhir.r4.model.BooleanType;
|
||||||
import org.hl7.fhir.r4.model.Coding;
|
import org.hl7.fhir.r4.model.Coding;
|
||||||
import org.hl7.fhir.r4.model.Identifier;
|
import org.hl7.fhir.r4.model.Identifier;
|
||||||
import org.hl7.fhir.r4.model.Parameters;
|
import org.hl7.fhir.r4.model.Parameters;
|
||||||
@ -88,6 +89,18 @@ public class GicsConsentService implements ICheckConsent {
|
|||||||
.setSystem(configProperties.getPolicySystem())));
|
.setSystem(configProperties.getPolicySystem())));
|
||||||
result.addParameter(new ParametersParameterComponent().setName("version")
|
result.addParameter(new ParametersParameterComponent().setName("version")
|
||||||
.setValue(new StringType().setValue(configProperties.getParameterVersion())));
|
.setValue(new StringType().setValue(configProperties.getParameterVersion())));
|
||||||
|
|
||||||
|
/* add config parameter with:
|
||||||
|
* ignoreVersionNumber -> true
|
||||||
|
* unknownStateIsConsideredAsDecline -> true
|
||||||
|
*/
|
||||||
|
var config = new ParametersParameterComponent().setName("config").addPart(
|
||||||
|
new ParametersParameterComponent().setName("ignoreVersionNumber")
|
||||||
|
.setValue(new BooleanType().setValue(true))).addPart(
|
||||||
|
new ParametersParameterComponent().setName("unknownStateIsConsideredAsDecline")
|
||||||
|
.setValue(new BooleanType().setValue(true)));
|
||||||
|
result.addParameter(config);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +140,7 @@ public class GicsConsentService implements ICheckConsent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConsentStatus isConsented(String personIdentifierValue) {
|
public TtpConsentStatus isConsented(String personIdentifierValue) {
|
||||||
var parameter = GicsConsentService.getIsConsentedParam(gIcsConfigProperties,
|
var parameter = GicsConsentService.getIsConsentedParam(gIcsConfigProperties,
|
||||||
personIdentifierValue);
|
personIdentifierValue);
|
||||||
|
|
||||||
@ -136,9 +149,9 @@ public class GicsConsentService implements ICheckConsent {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConsentStatus evaluateConsentResponse(String consentStatusResponse) {
|
private TtpConsentStatus evaluateConsentResponse(String consentStatusResponse) {
|
||||||
if (consentStatusResponse == null) {
|
if (consentStatusResponse == null) {
|
||||||
return ConsentStatus.FAILED_TO_ASK;
|
return TtpConsentStatus.FAILED_TO_ASK;
|
||||||
}
|
}
|
||||||
var responseParameters = fhirContext.newJsonParser()
|
var responseParameters = fhirContext.newJsonParser()
|
||||||
.parseResource(Parameters.class, consentStatusResponse);
|
.parseResource(Parameters.class, consentStatusResponse);
|
||||||
@ -146,12 +159,12 @@ public class GicsConsentService implements ICheckConsent {
|
|||||||
var responseValue = responseParameters.getParameter("consented").getValue();
|
var responseValue = responseParameters.getParameter("consented").getValue();
|
||||||
var isConsented = responseValue.castToBoolean(responseValue);
|
var isConsented = responseValue.castToBoolean(responseValue);
|
||||||
if (!isConsented.hasValue()) {
|
if (!isConsented.hasValue()) {
|
||||||
return ConsentStatus.FAILED_TO_ASK;
|
return TtpConsentStatus.FAILED_TO_ASK;
|
||||||
}
|
}
|
||||||
if (isConsented.booleanValue()) {
|
if (isConsented.booleanValue()) {
|
||||||
return ConsentStatus.CONSENTED;
|
return TtpConsentStatus.CONSENTED;
|
||||||
} else {
|
} else {
|
||||||
return ConsentStatus.CONSENT_MISSING;
|
return TtpConsentStatus.CONSENT_MISSING_OR_REJECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,6 @@ package dev.dnpm.etl.processor.consent;
|
|||||||
|
|
||||||
public interface ICheckConsent {
|
public interface ICheckConsent {
|
||||||
|
|
||||||
ConsentStatus isConsented(String personIdentifierValue);
|
TtpConsentStatus isConsented(String personIdentifierValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package dev.dnpm.etl.processor.consent;
|
||||||
|
|
||||||
|
public enum TtpConsentStatus {
|
||||||
|
/**
|
||||||
|
* Valid consent found
|
||||||
|
*/
|
||||||
|
CONSENTED,
|
||||||
|
|
||||||
|
CONSENT_MISSING_OR_REJECTED,
|
||||||
|
/**
|
||||||
|
* Due technical problems consent status is unknown
|
||||||
|
*/
|
||||||
|
FAILED_TO_ASK,
|
||||||
|
/**
|
||||||
|
* We assume received files are consented
|
||||||
|
*/
|
||||||
|
IGNORED
|
||||||
|
}
|
@ -84,8 +84,8 @@ class AppConfiguration {
|
|||||||
|
|
||||||
@ConditionalOnProperty(value = ["app.pseudonymize.generator"], havingValue = "GPAS")
|
@ConditionalOnProperty(value = ["app.pseudonymize.generator"], havingValue = "GPAS")
|
||||||
@Bean
|
@Bean
|
||||||
fun gpasPseudonymGenerator(configProperties: GPasConfigProperties, retryTemplate: RetryTemplate, restTemplate: RestTemplate): Generator {
|
fun gpasPseudonymGenerator(configProperties: GPasConfigProperties, retryTemplate: RetryTemplate, restTemplate: RestTemplate, appFhirConfig: AppFhirConfig): Generator {
|
||||||
return GpasPseudonymGenerator(configProperties, retryTemplate, restTemplate)
|
return GpasPseudonymGenerator(configProperties, retryTemplate, restTemplate, appFhirConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConditionalOnProperty(value = ["app.pseudonymize.generator"], havingValue = "BUILDIN", matchIfMissing = true)
|
@ConditionalOnProperty(value = ["app.pseudonymize.generator"], havingValue = "BUILDIN", matchIfMissing = true)
|
||||||
|
@ -25,7 +25,7 @@ import de.ukw.ccc.bwhc.dto.MtbFile
|
|||||||
import dev.dnpm.etl.processor.CustomMediaType
|
import dev.dnpm.etl.processor.CustomMediaType
|
||||||
import dev.dnpm.etl.processor.PatientId
|
import dev.dnpm.etl.processor.PatientId
|
||||||
import dev.dnpm.etl.processor.RequestId
|
import dev.dnpm.etl.processor.RequestId
|
||||||
import dev.dnpm.etl.processor.consent.ConsentStatus
|
import dev.dnpm.etl.processor.consent.TtpConsentStatus
|
||||||
import dev.dnpm.etl.processor.services.RequestProcessor
|
import dev.dnpm.etl.processor.services.RequestProcessor
|
||||||
import org.apache.kafka.clients.consumer.ConsumerRecord
|
import org.apache.kafka.clients.consumer.ConsumerRecord
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
@ -66,7 +66,7 @@ class KafkaInputListener(
|
|||||||
} else {
|
} else {
|
||||||
RequestId("")
|
RequestId("")
|
||||||
}
|
}
|
||||||
// fixme: add consent check
|
|
||||||
if (mtbFile.consent.status == Consent.Status.ACTIVE) {
|
if (mtbFile.consent.status == Consent.Status.ACTIVE) {
|
||||||
logger.debug("Accepted MTB File for processing")
|
logger.debug("Accepted MTB File for processing")
|
||||||
if (requestId.isBlank()) {
|
if (requestId.isBlank()) {
|
||||||
@ -77,12 +77,12 @@ class KafkaInputListener(
|
|||||||
} else {
|
} else {
|
||||||
logger.debug("Accepted MTB File and process deletion")
|
logger.debug("Accepted MTB File and process deletion")
|
||||||
if (requestId.isBlank()) {
|
if (requestId.isBlank()) {
|
||||||
requestProcessor.processDeletion(patientId, ConsentStatus.IGNORED)
|
requestProcessor.processDeletion(patientId, TtpConsentStatus.IGNORED)
|
||||||
} else {
|
} else {
|
||||||
requestProcessor.processDeletion(
|
requestProcessor.processDeletion(
|
||||||
patientId,
|
patientId,
|
||||||
requestId,
|
requestId,
|
||||||
ConsentStatus.IGNORED
|
TtpConsentStatus.IGNORED
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import de.ukw.ccc.bwhc.dto.MtbFile
|
|||||||
import dev.dnpm.etl.processor.CustomMediaType
|
import dev.dnpm.etl.processor.CustomMediaType
|
||||||
import dev.dnpm.etl.processor.PatientId
|
import dev.dnpm.etl.processor.PatientId
|
||||||
import dev.dnpm.etl.processor.consent.ICheckConsent
|
import dev.dnpm.etl.processor.consent.ICheckConsent
|
||||||
import dev.dnpm.etl.processor.consent.ConsentStatus
|
import dev.dnpm.etl.processor.consent.TtpConsentStatus
|
||||||
import dev.dnpm.etl.processor.services.RequestProcessor
|
import dev.dnpm.etl.processor.services.RequestProcessor
|
||||||
import dev.pcvolkmer.mv64e.mtb.Mtb
|
import dev.pcvolkmer.mv64e.mtb.Mtb
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
@ -47,20 +47,26 @@ class MtbFileRestController(
|
|||||||
|
|
||||||
@PostMapping( consumes = [ MediaType.APPLICATION_JSON_VALUE ] )
|
@PostMapping( consumes = [ MediaType.APPLICATION_JSON_VALUE ] )
|
||||||
fun mtbFile(@RequestBody mtbFile: MtbFile): ResponseEntity<Unit> {
|
fun mtbFile(@RequestBody mtbFile: MtbFile): ResponseEntity<Unit> {
|
||||||
var consentStatus = constService.isConsented(mtbFile.patient.id)
|
var ttpConsentStatus = constService.isConsented(mtbFile.patient.id)
|
||||||
|
|
||||||
if (mtbFile.consent.status == Consent.Status.ACTIVE && (consentStatus.equals(ConsentStatus.CONSENTED) || consentStatus.equals(
|
// received status REJECTED overrides TTP value. Also in case of disabled consent service,
|
||||||
ConsentStatus.IGNORED
|
// we need to override IGNORED status
|
||||||
|
if (mtbFile.consent.status == Consent.Status.REJECTED) ttpConsentStatus =
|
||||||
|
TtpConsentStatus.CONSENT_MISSING_OR_REJECTED
|
||||||
|
|
||||||
|
val isConsentOK = mtbFile.consent.status == Consent.Status.ACTIVE && (ttpConsentStatus.equals(
|
||||||
|
TtpConsentStatus.CONSENTED
|
||||||
|
) || ttpConsentStatus.equals(
|
||||||
|
TtpConsentStatus.IGNORED
|
||||||
))
|
))
|
||||||
) {
|
if (isConsentOK) {
|
||||||
logger.debug("Accepted MTB File (bwHC V1) for processing")
|
logger.debug("Accepted MTB File (bwHC V1) for processing")
|
||||||
requestProcessor.processMtbFile(mtbFile)
|
requestProcessor.processMtbFile(mtbFile)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
logger.debug("Accepted MTB File (bwHC V1) and process deletion")
|
logger.debug("Accepted MTB File (bwHC V1) and process deletion")
|
||||||
if (mtbFile.consent.status == Consent.Status.REJECTED) consentStatus =
|
|
||||||
ConsentStatus.CONSENT_REJECTED
|
|
||||||
val patientId = PatientId(mtbFile.patient.id)
|
val patientId = PatientId(mtbFile.patient.id)
|
||||||
requestProcessor.processDeletion(patientId, consentStatus)
|
requestProcessor.processDeletion(patientId, ttpConsentStatus)
|
||||||
}
|
}
|
||||||
return ResponseEntity.accepted().build()
|
return ResponseEntity.accepted().build()
|
||||||
}
|
}
|
||||||
@ -75,7 +81,7 @@ class MtbFileRestController(
|
|||||||
@DeleteMapping(path = ["{patientId}"])
|
@DeleteMapping(path = ["{patientId}"])
|
||||||
fun deleteData(@PathVariable patientId: String): ResponseEntity<Unit> {
|
fun deleteData(@PathVariable patientId: String): ResponseEntity<Unit> {
|
||||||
logger.debug("Accepted patient ID to process deletion")
|
logger.debug("Accepted patient ID to process deletion")
|
||||||
requestProcessor.processDeletion(PatientId(patientId), ConsentStatus.IGNORED)
|
requestProcessor.processDeletion(PatientId(patientId), TtpConsentStatus.IGNORED)
|
||||||
return ResponseEntity.accepted().build()
|
return ResponseEntity.accepted().build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,5 +25,5 @@ enum class RequestStatus(val value: String) {
|
|||||||
ERROR("error"),
|
ERROR("error"),
|
||||||
UNKNOWN("unknown"),
|
UNKNOWN("unknown"),
|
||||||
DUPLICATION("duplication"),
|
DUPLICATION("duplication"),
|
||||||
CONSENTMISSING("no-consent")
|
NO_CONSENT("no-consent")
|
||||||
}
|
}
|
@ -23,7 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
|
|||||||
import de.ukw.ccc.bwhc.dto.MtbFile
|
import de.ukw.ccc.bwhc.dto.MtbFile
|
||||||
import dev.dnpm.etl.processor.*
|
import dev.dnpm.etl.processor.*
|
||||||
import dev.dnpm.etl.processor.config.AppConfigProperties
|
import dev.dnpm.etl.processor.config.AppConfigProperties
|
||||||
import dev.dnpm.etl.processor.consent.ConsentStatus
|
import dev.dnpm.etl.processor.consent.TtpConsentStatus
|
||||||
import dev.dnpm.etl.processor.monitoring.Report
|
import dev.dnpm.etl.processor.monitoring.Report
|
||||||
import dev.dnpm.etl.processor.monitoring.Request
|
import dev.dnpm.etl.processor.monitoring.Request
|
||||||
import dev.dnpm.etl.processor.monitoring.RequestStatus
|
import dev.dnpm.etl.processor.monitoring.RequestStatus
|
||||||
@ -129,19 +129,18 @@ class RequestProcessor(
|
|||||||
&& lastMtbFileRequestForPatient.fingerprint == fingerprint(pseudonymizedMtbFileRequest)
|
&& lastMtbFileRequestForPatient.fingerprint == fingerprint(pseudonymizedMtbFileRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun processDeletion(patientId: PatientId, isConsented: ConsentStatus) {
|
fun processDeletion(patientId: PatientId, isConsented: TtpConsentStatus) {
|
||||||
processDeletion(patientId, randomRequestId(), isConsented)
|
processDeletion(patientId, randomRequestId(), isConsented)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun processDeletion(patientId: PatientId, requestId: RequestId, isConsented: ConsentStatus) {
|
fun processDeletion(patientId: PatientId, requestId: RequestId, isConsented: TtpConsentStatus) {
|
||||||
try {
|
try {
|
||||||
val patientPseudonym = pseudonymizeService.patientPseudonym(patientId)
|
val patientPseudonym = pseudonymizeService.patientPseudonym(patientId)
|
||||||
|
|
||||||
val requestStatus: RequestStatus = when (isConsented) {
|
val requestStatus: RequestStatus = when (isConsented) {
|
||||||
ConsentStatus.CONSENT_MISSING -> RequestStatus.CONSENTMISSING
|
TtpConsentStatus.CONSENT_MISSING_OR_REJECTED -> RequestStatus.NO_CONSENT
|
||||||
ConsentStatus.FAILED_TO_ASK -> RequestStatus.ERROR
|
TtpConsentStatus.FAILED_TO_ASK -> RequestStatus.ERROR
|
||||||
ConsentStatus.CONSENTED, ConsentStatus.IGNORED,
|
TtpConsentStatus.CONSENTED, TtpConsentStatus.IGNORED -> RequestStatus.UNKNOWN
|
||||||
ConsentStatus.CONSENT_REJECTED -> RequestStatus.UNKNOWN
|
|
||||||
}
|
}
|
||||||
|
|
||||||
requestService.save(
|
requestService.save(
|
||||||
|
@ -70,6 +70,12 @@ class ResponseProcessor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RequestStatus.NO_CONSENT -> {
|
||||||
|
it.report = Report(
|
||||||
|
"Einwilligung Status fehlt, widerrufen oder ungeklärt."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
logger.error("Cannot process response: Unknown response!")
|
logger.error("Cannot process response: Unknown response!")
|
||||||
return@ifPresentOrElse
|
return@ifPresentOrElse
|
||||||
|
@ -23,8 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
|
|||||||
import de.ukw.ccc.bwhc.dto.Consent
|
import de.ukw.ccc.bwhc.dto.Consent
|
||||||
import de.ukw.ccc.bwhc.dto.MtbFile
|
import de.ukw.ccc.bwhc.dto.MtbFile
|
||||||
import de.ukw.ccc.bwhc.dto.Patient
|
import de.ukw.ccc.bwhc.dto.Patient
|
||||||
import dev.dnpm.etl.processor.anyValueClass
|
import dev.dnpm.etl.processor.consent.TtpConsentStatus
|
||||||
import dev.dnpm.etl.processor.consent.ConsentStatus
|
|
||||||
import dev.dnpm.etl.processor.CustomMediaType
|
import dev.dnpm.etl.processor.CustomMediaType
|
||||||
import dev.dnpm.etl.processor.services.RequestProcessor
|
import dev.dnpm.etl.processor.services.RequestProcessor
|
||||||
import org.apache.kafka.clients.consumer.ConsumerRecord
|
import org.apache.kafka.clients.consumer.ConsumerRecord
|
||||||
@ -36,10 +35,7 @@ import org.junit.jupiter.api.Test
|
|||||||
import org.junit.jupiter.api.extension.ExtendWith
|
import org.junit.jupiter.api.extension.ExtendWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.junit.jupiter.MockitoExtension
|
import org.mockito.junit.jupiter.MockitoExtension
|
||||||
import org.mockito.kotlin.any
|
import org.mockito.kotlin.*
|
||||||
import org.mockito.kotlin.eq
|
|
||||||
import org.mockito.kotlin.times
|
|
||||||
import org.mockito.kotlin.verify
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@ExtendWith(MockitoExtension::class)
|
@ExtendWith(MockitoExtension::class)
|
||||||
@ -98,7 +94,7 @@ class KafkaInputListenerTest {
|
|||||||
|
|
||||||
verify(requestProcessor, times(1)).processDeletion(
|
verify(requestProcessor, times(1)).processDeletion(
|
||||||
anyValueClass(),
|
anyValueClass(),
|
||||||
eq(ConsentStatus.IGNORED)
|
eq(TtpConsentStatus.IGNORED)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +148,8 @@ class KafkaInputListenerTest {
|
|||||||
Optional.empty()
|
Optional.empty()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
verify(requestProcessor, times(1)).processDeletion(anyValueClass(), anyValueClass(), eq(ConsentStatus.IGNORED)
|
verify(requestProcessor, times(1)).processDeletion(anyValueClass(), anyValueClass(), eq(
|
||||||
|
TtpConsentStatus.IGNORED))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -183,7 +180,8 @@ class KafkaInputListenerTest {
|
|||||||
Optional.empty()
|
Optional.empty()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
verify(requestProcessor, times(0)).processDeletion(anyValueClass(), anyValueClass(), eq(ConsentStatus.IGNORED)
|
verify(requestProcessor, times(0)).processDeletion(anyValueClass(), anyValueClass(), eq(
|
||||||
|
TtpConsentStatus.IGNORED))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,8 @@ package dev.dnpm.etl.processor.input
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
import de.ukw.ccc.bwhc.dto.*
|
import de.ukw.ccc.bwhc.dto.*
|
||||||
import dev.dnpm.etl.processor.anyValueClass
|
|
||||||
import dev.dnpm.etl.processor.consent.ConsentCheckedIgnored
|
import dev.dnpm.etl.processor.consent.ConsentCheckedIgnored
|
||||||
import dev.dnpm.etl.processor.consent.ConsentStatus
|
import dev.dnpm.etl.processor.consent.TtpConsentStatus
|
||||||
import dev.dnpm.etl.processor.CustomMediaType
|
import dev.dnpm.etl.processor.CustomMediaType
|
||||||
import dev.dnpm.etl.processor.services.RequestProcessor
|
import dev.dnpm.etl.processor.services.RequestProcessor
|
||||||
import dev.pcvolkmer.mv64e.mtb.Mtb
|
import dev.pcvolkmer.mv64e.mtb.Mtb
|
||||||
@ -81,7 +80,8 @@ class MtbFileRestControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
fun shouldProcessPostRequestWithRejectedConsent() {
|
fun shouldProcessPostRequestWithRejectedConsent() {
|
||||||
mockMvc.post("/mtbfile") {
|
mockMvc.post("/mtbfile") {
|
||||||
content = objectMapper.writeValueAsString(bwhcMtbFileContent(Consent.Status.REJECTED))
|
content =
|
||||||
|
objectMapper.writeValueAsString(bwhcMtbFileContent(Consent.Status.REJECTED))
|
||||||
contentType = MediaType.APPLICATION_JSON
|
contentType = MediaType.APPLICATION_JSON
|
||||||
}.andExpect {
|
}.andExpect {
|
||||||
status {
|
status {
|
||||||
@ -89,7 +89,10 @@ class MtbFileRestControllerTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verify(requestProcessor, times(1)).processDeletion(anyValueClass())
|
verify(requestProcessor, times(1)).processDeletion(
|
||||||
|
anyValueClass(),
|
||||||
|
org.mockito.kotlin.eq(TtpConsentStatus.CONSENT_MISSING_OR_REJECTED)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -100,7 +103,10 @@ class MtbFileRestControllerTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verify(requestProcessor, times(1)).processDeletion(anyValueClass())
|
verify(requestProcessor, times(1)).processDeletion(
|
||||||
|
anyValueClass(),
|
||||||
|
org.mockito.kotlin.eq(TtpConsentStatus.IGNORED)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +122,7 @@ class MtbFileRestControllerTest {
|
|||||||
@Mock requestProcessor: RequestProcessor
|
@Mock requestProcessor: RequestProcessor
|
||||||
) {
|
) {
|
||||||
this.requestProcessor = requestProcessor
|
this.requestProcessor = requestProcessor
|
||||||
val controller = MtbFileRestController(requestProcessor)
|
val controller = MtbFileRestController(requestProcessor, ConsentCheckedIgnored())
|
||||||
this.mockMvc = MockMvcBuilders.standaloneSetup(controller).build()
|
this.mockMvc = MockMvcBuilders.standaloneSetup(controller).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +143,8 @@ class MtbFileRestControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
fun shouldProcessPostRequestWithRejectedConsent() {
|
fun shouldProcessPostRequestWithRejectedConsent() {
|
||||||
mockMvc.post("/mtb") {
|
mockMvc.post("/mtb") {
|
||||||
content = objectMapper.writeValueAsString(bwhcMtbFileContent(Consent.Status.REJECTED))
|
content =
|
||||||
|
objectMapper.writeValueAsString(bwhcMtbFileContent(Consent.Status.REJECTED))
|
||||||
contentType = MediaType.APPLICATION_JSON
|
contentType = MediaType.APPLICATION_JSON
|
||||||
}.andExpect {
|
}.andExpect {
|
||||||
status {
|
status {
|
||||||
@ -145,7 +152,11 @@ class MtbFileRestControllerTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verify(requestProcessor, times(1)).processDeletion(anyValueClass())
|
verify(requestProcessor, times(1)).processDeletion(
|
||||||
|
anyValueClass(), org.mockito.kotlin.eq(
|
||||||
|
TtpConsentStatus.CONSENT_MISSING_OR_REJECTED
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -156,7 +167,11 @@ class MtbFileRestControllerTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verify(requestProcessor, times(1)).processDeletion(anyValueClass())
|
verify(requestProcessor, times(1)).processDeletion(
|
||||||
|
anyValueClass(), org.mockito.kotlin.eq(
|
||||||
|
TtpConsentStatus.IGNORED
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,13 +187,15 @@ class MtbFileRestControllerTest {
|
|||||||
@Mock requestProcessor: RequestProcessor
|
@Mock requestProcessor: RequestProcessor
|
||||||
) {
|
) {
|
||||||
this.requestProcessor = requestProcessor
|
this.requestProcessor = requestProcessor
|
||||||
val controller = MtbFileRestController(requestProcessor)
|
val controller = MtbFileRestController(requestProcessor, ConsentCheckedIgnored())
|
||||||
this.mockMvc = MockMvcBuilders.standaloneSetup(controller).build()
|
this.mockMvc = MockMvcBuilders.standaloneSetup(controller).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun shouldRespondPostRequest() {
|
fun shouldRespondPostRequest() {
|
||||||
val mtbFileContent = ClassPathResource("mv64e-mtb-fake-patient.json").inputStream.readAllBytes().toString(Charsets.UTF_8)
|
val mtbFileContent =
|
||||||
|
ClassPathResource("mv64e-mtb-fake-patient.json").inputStream.readAllBytes()
|
||||||
|
.toString(Charsets.UTF_8)
|
||||||
|
|
||||||
mockMvc.post("/mtb") {
|
mockMvc.post("/mtb") {
|
||||||
content = mtbFileContent
|
content = mtbFileContent
|
||||||
|
@ -25,7 +25,7 @@ import dev.dnpm.etl.processor.Fingerprint
|
|||||||
import dev.dnpm.etl.processor.PatientId
|
import dev.dnpm.etl.processor.PatientId
|
||||||
import dev.dnpm.etl.processor.PatientPseudonym
|
import dev.dnpm.etl.processor.PatientPseudonym
|
||||||
import dev.dnpm.etl.processor.config.AppConfigProperties
|
import dev.dnpm.etl.processor.config.AppConfigProperties
|
||||||
import dev.dnpm.etl.processor.consent.ConsentStatus
|
import dev.dnpm.etl.processor.consent.TtpConsentStatus
|
||||||
import dev.dnpm.etl.processor.monitoring.Request
|
import dev.dnpm.etl.processor.monitoring.Request
|
||||||
import dev.dnpm.etl.processor.monitoring.RequestStatus
|
import dev.dnpm.etl.processor.monitoring.RequestStatus
|
||||||
import dev.dnpm.etl.processor.monitoring.RequestType
|
import dev.dnpm.etl.processor.monitoring.RequestType
|
||||||
@ -344,7 +344,7 @@ class RequestProcessorTest {
|
|||||||
MtbFileSender.Response(status = RequestStatus.UNKNOWN)
|
MtbFileSender.Response(status = RequestStatus.UNKNOWN)
|
||||||
}.whenever(sender).send(any<DeleteRequest>())
|
}.whenever(sender).send(any<DeleteRequest>())
|
||||||
|
|
||||||
this.requestProcessor.processDeletion(TEST_PATIENT_ID, isConsented = ConsentStatus.IGNORED)
|
this.requestProcessor.processDeletion(TEST_PATIENT_ID, isConsented = TtpConsentStatus.IGNORED)
|
||||||
|
|
||||||
val requestCaptor = argumentCaptor<Request>()
|
val requestCaptor = argumentCaptor<Request>()
|
||||||
verify(requestService, times(1)).save(requestCaptor.capture())
|
verify(requestService, times(1)).save(requestCaptor.capture())
|
||||||
@ -362,7 +362,7 @@ class RequestProcessorTest {
|
|||||||
MtbFileSender.Response(status = RequestStatus.SUCCESS)
|
MtbFileSender.Response(status = RequestStatus.SUCCESS)
|
||||||
}.whenever(sender).send(any<DeleteRequest>())
|
}.whenever(sender).send(any<DeleteRequest>())
|
||||||
|
|
||||||
this.requestProcessor.processDeletion(TEST_PATIENT_ID, isConsented = ConsentStatus.IGNORED)
|
this.requestProcessor.processDeletion(TEST_PATIENT_ID, isConsented = TtpConsentStatus.IGNORED)
|
||||||
|
|
||||||
val eventCaptor = argumentCaptor<ResponseEvent>()
|
val eventCaptor = argumentCaptor<ResponseEvent>()
|
||||||
verify(applicationEventPublisher, times(1)).publishEvent(eventCaptor.capture())
|
verify(applicationEventPublisher, times(1)).publishEvent(eventCaptor.capture())
|
||||||
@ -380,7 +380,7 @@ class RequestProcessorTest {
|
|||||||
MtbFileSender.Response(status = RequestStatus.ERROR)
|
MtbFileSender.Response(status = RequestStatus.ERROR)
|
||||||
}.whenever(sender).send(any<DeleteRequest>())
|
}.whenever(sender).send(any<DeleteRequest>())
|
||||||
|
|
||||||
this.requestProcessor.processDeletion(TEST_PATIENT_ID, isConsented = ConsentStatus.IGNORED)
|
this.requestProcessor.processDeletion(TEST_PATIENT_ID, isConsented = TtpConsentStatus.IGNORED)
|
||||||
|
|
||||||
val eventCaptor = argumentCaptor<ResponseEvent>()
|
val eventCaptor = argumentCaptor<ResponseEvent>()
|
||||||
verify(applicationEventPublisher, times(1)).publishEvent(eventCaptor.capture())
|
verify(applicationEventPublisher, times(1)).publishEvent(eventCaptor.capture())
|
||||||
@ -392,7 +392,7 @@ class RequestProcessorTest {
|
|||||||
fun testShouldSendDeleteRequestWithPseudonymErrorAndSaveErrorRequestStatus() {
|
fun testShouldSendDeleteRequestWithPseudonymErrorAndSaveErrorRequestStatus() {
|
||||||
doThrow(RuntimeException()).whenever(pseudonymizeService).patientPseudonym(anyValueClass())
|
doThrow(RuntimeException()).whenever(pseudonymizeService).patientPseudonym(anyValueClass())
|
||||||
|
|
||||||
this.requestProcessor.processDeletion(TEST_PATIENT_ID, isConsented = ConsentStatus.IGNORED)
|
this.requestProcessor.processDeletion(TEST_PATIENT_ID, isConsented = TtpConsentStatus.IGNORED)
|
||||||
|
|
||||||
val requestCaptor = argumentCaptor<Request>()
|
val requestCaptor = argumentCaptor<Request>()
|
||||||
verify(requestService, times(1)).save(requestCaptor.capture())
|
verify(requestService, times(1)).save(requestCaptor.capture())
|
||||||
|
Reference in New Issue
Block a user