Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 02f619f8 authored by pm's avatar pm
Browse files

fixed UTs

parent d58c86c4
No related branches found
No related tags found
2 merge requests!5Release/2.0.0,!4Pixm
......@@ -32,6 +32,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import net.ihe.gazelle.adapter.connector.BundleToPatientRegistryConverter;
import net.ihe.gazelle.adapter.connector.BusinessToFhirConverter;
import net.ihe.gazelle.adapter.connector.ConversionException;
import net.ihe.gazelle.app.patientregistryapi.application.PatientFeedException;
import net.ihe.gazelle.app.patientregistryapi.application.SearchCrossReferenceException;
import net.ihe.gazelle.app.patientregistryapi.business.EntityIdentifier;
import net.ihe.gazelle.application.PatientRegistryFeedClient;
......
......@@ -4,10 +4,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Matchers.anyObject;
import java.net.MalformedURLException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import javax.xml.ws.WebServiceException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
......@@ -29,6 +32,7 @@ import net.ihe.gazelle.app.patientregistryapi.business.PersonName;
import net.ihe.gazelle.app.patientregistryfeedclient.adapter.PatientFeedClient;
import net.ihe.gazelle.app.patientregistryfeedclient.adapter.PatientFeedProcessResponseException;
import net.ihe.gazelle.framework.preferencesmodelapi.application.NamespaceException;
import net.ihe.gazelle.framework.preferencesmodelapi.application.OperationalPreferencesService;
import net.ihe.gazelle.framework.preferencesmodelapi.application.PreferenceException;
@Feature("PatientFeedClient")
......@@ -40,25 +44,81 @@ public class PatientFeedClientTest {
@Mock
static private PatientFeedClient patientFeedClientMock;
@Mock
static private OperationalPreferencesService operationalPreferencesService;
@Mock
private PatientRegistryFeedClient patientRegistryFeedClient;
@BeforeAll
static void initialize() {
patientFeedClientMock = Mockito.mock(PatientFeedClient.class);
operationalPreferencesService = Mockito.mock(OperationalPreferencesService.class);
}
@Test
@Description("Test on initialization, when a namespace exception is thrown")
@Severity(SeverityLevel.CRITICAL)
@Story("initialization")
void TestInitializeNameSpaceException() throws PreferenceException, NamespaceException {
patientRegistryFeedClient = new PatientRegistryFeedClient(operationalPreferencesService);
Mockito.doThrow(NamespaceException.class).when(operationalPreferencesService).getStringValue("java:/app/gazelle/pixm-connector" +
"/operational" +
"-preferences", "patientregistry.url");
Patient patient = new Patient();
assertThrows(PatientFeedException.class,
() -> patientRegistryFeedClient.createPatient(patient));
}
@Test
@Description("Test on initialization, when a preference exception is thrown")
@Severity(SeverityLevel.CRITICAL)
@Story("initialization")
void TestInitializePreferenceException() throws PreferenceException, NamespaceException {
Mockito.doThrow(PreferenceException.class).when(operationalPreferencesService).getStringValue("java:/app/gazelle/pixm-connector" +
"/operational" +
"-preferences", "patientregistry.url");
patientRegistryFeedClient = new PatientRegistryFeedClient(operationalPreferencesService);
Patient patient = new Patient();
assertThrows(PatientFeedException.class,
() -> patientRegistryFeedClient.createPatient(patient));
}
@Test
@Description("Test on initialization, when the url of the server is malformed")
@Severity(SeverityLevel.CRITICAL)
@Story("initialization")
void TestInitializeMalformedURLException() throws PreferenceException, NamespaceException {
Mockito.doThrow(MalformedURLException.class).when(operationalPreferencesService).getStringValue("java:/app/gazelle/pixm-connector" +
"/operational" +
"-preferences", "patientregistry.url");
patientRegistryFeedClient = new PatientRegistryFeedClient(operationalPreferencesService);
Patient patient = new Patient();
assertThrows(PatientFeedException.class,
() -> patientRegistryFeedClient.createPatient(patient));
}
/*@Test
@Description("Test on initialization with DAOs")
@Severity(SeverityLevel.MINOR)
@Test
@Description("Test on initialization, when a web service exception is thrown")
@Severity(SeverityLevel.CRITICAL)
@Story("initialization")
void TestInitialization() throws PreferenceException, NamespaceException, PatientFeedException {
void TestInitializeWebServiceException() throws PreferenceException, NamespaceException {
Mockito.doThrow(WebServiceException.class).when(operationalPreferencesService).getStringValue("java:/app/gazelle/pixm-connector" +
"/operational" +
"-preferences", "patientregistry.url");
patientRegistryFeedClient = new PatientRegistryFeedClient(operationalPreferencesService);
PatientDAOImpl patientDAO = new PatientDAOImpl();
DomainDAOImpl domainDAO;
PatientCrossReferenceDAOImpl patientCrossReferenceDAO;
IdentifierDAOImpl identifierDAO;
Patient patient = new Patient();
}*/
assertThrows(PatientFeedException.class,
() -> patientRegistryFeedClient.createPatient(patient));
}
@Test
@Description("Test on create, nominal case")
......
......@@ -26,7 +26,6 @@ import io.qameta.allure.Feature;
import io.qameta.allure.Severity;
import io.qameta.allure.SeverityLevel;
import io.qameta.allure.Story;
import net.ihe.gazelle.adapter.connector.BusinessToFhirConverter;
import net.ihe.gazelle.app.patientregistryapi.business.Patient;
import net.ihe.gazelle.app.patientregistryapi.business.PatientSearchCriterionKey;
import net.ihe.gazelle.app.patientregistryapi.business.PersonName;
......@@ -44,8 +43,6 @@ import net.ihe.gazelle.lib.searchmodelapi.business.searchcriterion.StringSearchC
@RunWith(MockitoJUnitRunner.class)
public class PatientRegistrySearchClientTest {
static private BusinessToFhirConverter businessToFhirConverter;
private static final String TEST_UUID = "123e4567-e89b-12d3-a456-426614174000";
private static final String MALFORMED_UUID = "123e4567-e89b-12d3-a456-42661417400000000000000000000000000";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment