diff --git a/matchbox-client/src/main/java/net/ihe/gazelle/matchbox/client/interlay/validation/CustomPatientValidationService.java b/matchbox-client/src/main/java/net/ihe/gazelle/matchbox/client/interlay/validation/CustomPatientValidationService.java index a74127505e9ebd9a208863d032154e8061338db9..6cd0718864f6def835878aa7b84924e004fa0f4f 100644 --- a/matchbox-client/src/main/java/net/ihe/gazelle/matchbox/client/interlay/validation/CustomPatientValidationService.java +++ b/matchbox-client/src/main/java/net/ihe/gazelle/matchbox/client/interlay/validation/CustomPatientValidationService.java @@ -57,15 +57,20 @@ public class CustomPatientValidationService implements ValidationService { OperationOutcome operationOutcome = convertStringIntoFhirResource(OperationOutcome.class, response); validationReport.setOverallResult(ValidationTestResult.PASSED); for (OperationOutcome.OperationOutcomeIssueComponent issue : operationOutcome.getIssue()) { - switch (issue.getSeverity()) { - case FATAL, ERROR, NULL -> { - validationReport.setOverallResult(ValidationTestResult.FAILED); - return; - } + if (isErrorOrFatal(issue.getSeverity())) { + validationReport.setOverallResult(ValidationTestResult.FAILED); + return; } } } + private boolean isErrorOrFatal(OperationOutcome.IssueSeverity severity) { + return switch (severity) { + case FATAL, ERROR, NULL -> true; + default -> false; + }; + } + public List<ValidationProfile> getValidationProfiles() { return new ArrayList<>(); } diff --git a/pixm-connector-service/src/main/java/net/ihe/gazelle/application/ConfigurationAdapter.java b/pixm-connector-service/src/main/java/net/ihe/gazelle/application/ConfigurationAdapter.java index 2c8ee148d2f72e2d75ff49f672ac1c3805c34c2c..4f445b268a58ce5ddf459f64899ef97a76f5e3eb 100644 --- a/pixm-connector-service/src/main/java/net/ihe/gazelle/application/ConfigurationAdapter.java +++ b/pixm-connector-service/src/main/java/net/ihe/gazelle/application/ConfigurationAdapter.java @@ -2,17 +2,10 @@ package net.ihe.gazelle.application; public class ConfigurationAdapter { - public ConfigurationAdapter() { - } - - public String getProfileIdCreateUpdateDeleteIti104() { - return System.getenv("PROFILE_ID_CREATE_UPDATE_DELETE_ITI_104"); - } - + public String getProfileIdCreateUpdateDeleteIti104() { return System.getenv("PROFILE_ID_CREATE_UPDATE_DELETE_ITI_104"); } public String getProfileIdPostIti83() { return System.getenv("PROFILE_ID_POST_ITI_83"); } - public String getProfileIdGetIti83() { return System.getenv("PROFILE_ID_GET_ITI_83"); } diff --git a/pixm-connector-service/src/main/java/net/ihe/gazelle/application/PatientRegistryFeedClient.java b/pixm-connector-service/src/main/java/net/ihe/gazelle/application/PatientRegistryFeedClient.java index 27310a606370c4c87fa9c3a136d17f41748589b8..750163955d01421a5f32dd638715f36946ab3142 100644 --- a/pixm-connector-service/src/main/java/net/ihe/gazelle/application/PatientRegistryFeedClient.java +++ b/pixm-connector-service/src/main/java/net/ihe/gazelle/application/PatientRegistryFeedClient.java @@ -3,6 +3,8 @@ package net.ihe.gazelle.application; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException; +import jakarta.inject.Named; +import jakarta.xml.ws.WebServiceException; import net.ihe.gazelle.adapter.connector.ConversionException; import net.ihe.gazelle.adapter.connector.FhirToGazelleRegistryConverter; import net.ihe.gazelle.adapter.connector.GazelleRegistryToFhirConverter; @@ -25,8 +27,6 @@ import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Patient; -import jakarta.inject.Named; -import jakarta.xml.ws.WebServiceException; import java.net.InetAddress; import java.net.MalformedURLException; import java.net.URL; @@ -42,6 +42,8 @@ public class PatientRegistryFeedClient { public static final String MANDATORY_FIELD_ARE_MISSING = "Mandatory fields are missing: family name, Date of Birth or Gender"; private static final String UUID = "PatientPIXmFeed"; private static final GazelleLogger logger = GazelleLoggerFactory.getInstance().getLogger(PatientRegistryFeedClient.class); + public static final String UUID_CANNOT_BE_NULL_OR_EMPTY = "The uuid cannot be null or empty"; + public static final String CANNOT_PROCEED_TO_DELETE = "Cannot proceed to delete"; private String serverUrl; private OperationalPreferencesService operationalPreferencesService; private PatientFeedClient client; @@ -263,10 +265,10 @@ public class PatientRegistryFeedClient { } } catch (PatientFeedException exception) { switch (exception.getCause().getMessage()) { - case "The uuid cannot be null or empty" -> - throw new InternalErrorException("The uuid cannot be null or empty", exception); - case "Cannot proceed to delete" -> - throw new InternalErrorException("Cannot proceed to delete", exception); + case UUID_CANNOT_BE_NULL_OR_EMPTY -> + throw new InternalErrorException(UUID_CANNOT_BE_NULL_OR_EMPTY, exception); + case CANNOT_PROCEED_TO_DELETE -> + throw new InternalErrorException(CANNOT_PROCEED_TO_DELETE, exception); default -> treatClientBaseErrors(exception); } } @@ -289,10 +291,10 @@ public class PatientRegistryFeedClient { } } catch (PatientFeedException exception) { switch (exception.getCause().getMessage()) { - case "The uuid cannot be null or empty" -> - throw new InternalErrorException("The uuid cannot be null or empty", exception); - case "Cannot proceed to delete" -> - throw new InternalErrorException("Cannot proceed to delete", exception); + case UUID_CANNOT_BE_NULL_OR_EMPTY -> + throw new InternalErrorException(UUID_CANNOT_BE_NULL_OR_EMPTY, exception); + case CANNOT_PROCEED_TO_DELETE -> + throw new InternalErrorException(CANNOT_PROCEED_TO_DELETE, exception); default -> treatClientBaseErrors(exception); } } diff --git a/pixm-connector-service/src/main/java/net/ihe/gazelle/business/provider/IhePatientResourceProvider.java b/pixm-connector-service/src/main/java/net/ihe/gazelle/business/provider/IhePatientResourceProvider.java index 4fb1f5f5dfb415c102bd9c623a3364375e3856bc..8ca812ce8321883ac2bc9d4be771a1d6f0f403e1 100644 --- a/pixm-connector-service/src/main/java/net/ihe/gazelle/business/provider/IhePatientResourceProvider.java +++ b/pixm-connector-service/src/main/java/net/ihe/gazelle/business/provider/IhePatientResourceProvider.java @@ -246,7 +246,7 @@ public class IhePatientResourceProvider implements IResourceProvider { } private EntityIdentifier createEntityIdentifierFromConditional(String conditional){ - String identifier = conditional.indexOf("=") > 0 ? conditional.substring(conditional.indexOf("=")+1) : null; + String identifier = conditional.contains("=") ? conditional.substring(conditional.indexOf("=")+1) : null; //clear urn:oid: if present (need to be improved so this action handled by the UI) if(identifier != null) { identifier = identifier.replace(URN_OID, ""); diff --git a/pixm-connector-service/src/test/java/net/ihe/gazelle/adapter/validation/CustomPatientValidationServiceTest.java b/pixm-connector-service/src/test/java/net/ihe/gazelle/adapter/validation/CustomPatientValidationServiceTest.java deleted file mode 100644 index b3e088c941ce57a9b76d11ff00af26a5da50ed16..0000000000000000000000000000000000000000 --- a/pixm-connector-service/src/test/java/net/ihe/gazelle/adapter/validation/CustomPatientValidationServiceTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.ihe.gazelle.adapter.validation; - -import org.junit.jupiter.api.Test; - -class CustomPatientValidationServiceTest { - - @Test - void validate() { - } - - @Test - void getValidationProfiles() { - } -} \ No newline at end of file diff --git a/pixm-connector-service/src/test/java/net/ihe/gazelle/adapter/validation/mock/CustomPatientValidationServiceMock.java b/pixm-connector-service/src/test/java/net/ihe/gazelle/adapter/validation/mock/CustomPatientValidationServiceMock.java deleted file mode 100644 index 989a2f1352b8a9e423a7a2e92688bef91ce4921b..0000000000000000000000000000000000000000 --- a/pixm-connector-service/src/test/java/net/ihe/gazelle/adapter/validation/mock/CustomPatientValidationServiceMock.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.ihe.gazelle.adapter.validation.mock; - - -import net.ihe.gazelle.matchbox.client.interlay.validation.CustomPatientValidationService; - -public class CustomPatientValidationServiceMock extends CustomPatientValidationService { - - -} diff --git a/pixm-connector-service/src/test/java/net/ihe/gazelle/application/PatientRegistrySearchClientTest.java b/pixm-connector-service/src/test/java/net/ihe/gazelle/application/PatientRegistrySearchClientTest.java index f774e3a4700d180880309cabedbcfdadf7290f5a..43be46959a6ee09e20a714618944d3f123ad0563 100644 --- a/pixm-connector-service/src/test/java/net/ihe/gazelle/application/PatientRegistrySearchClientTest.java +++ b/pixm-connector-service/src/test/java/net/ihe/gazelle/application/PatientRegistrySearchClientTest.java @@ -4,6 +4,7 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import io.qameta.allure.*; +import jakarta.xml.ws.WebServiceException; import net.ihe.gazelle.app.patientregistryapi.business.Patient; import net.ihe.gazelle.app.patientregistryapi.business.PatientSearchCriterionKey; import net.ihe.gazelle.app.patientregistryapi.business.PersonName; @@ -16,13 +17,13 @@ import net.ihe.gazelle.lib.searchmodelapi.business.exception.SearchException; import net.ihe.gazelle.lib.searchmodelapi.business.searchcriterion.SearchCriterion; import net.ihe.gazelle.lib.searchmodelapi.business.searchcriterion.StringSearchCriterion; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; -import jakarta.xml.ws.WebServiceException; import java.util.ArrayList; import java.util.List; @@ -35,7 +36,7 @@ import static org.mockito.Mockito.doAnswer; @Feature("PatientSearchClientTest") @ExtendWith(MockitoExtension.class) public class PatientRegistrySearchClientTest { -/* + private static final String TEST_UUID = "123e4567-e89b-12d3-a456-426614174000"; private static final String MALFORMED_UUID = "123e4567-e89b-12d3-a456-42661417400000000000000000000000000"; @@ -52,7 +53,8 @@ public class PatientRegistrySearchClientTest { operationalPreferencesService = Mockito.mock(OperationalPreferencesService.class); } - @Test + @Test //TODO correct this test + @Disabled @Description("Test on initialization, when a namespace exception is thrown") @Severity(SeverityLevel.CRITICAL) @Story("initialization") @@ -71,7 +73,8 @@ public class PatientRegistrySearchClientTest { () -> patientRegistrySearchClient.searchPatient(searchCriterion.getValue())); } - @Test + @Test //TODO correct this test + @Disabled @Description("Test on initialization, when a preference exception is thrown") @Severity(SeverityLevel.CRITICAL) @Story("initialization") @@ -90,7 +93,8 @@ public class PatientRegistrySearchClientTest { () -> patientRegistrySearchClient.searchPatient(searchCriterion.getValue())); } - @Test + @Test //TODO correct this test + @Disabled @Description("Test on initialization, when the url of the server is malformed") @Severity(SeverityLevel.CRITICAL) @Story("initialization") @@ -109,7 +113,8 @@ public class PatientRegistrySearchClientTest { () -> patientRegistrySearchClient.searchPatient(searchCriterion.getValue())); } - @Test + @Test //TODO correct this test + @Disabled @Description("Test on initialization, when a web service exception is thrown") @Severity(SeverityLevel.CRITICAL) @Story("initialization") @@ -309,7 +314,4 @@ public class PatientRegistrySearchClientTest { } - - - */ }