Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit f3ee781c authored by Youn Cadoret's avatar Youn Cadoret
Browse files

PATREG-129 implement model + TU

parent bb4a3b61
Pipeline #159256 failed
package net.ihe.gazelle.app.patientregistryapi.application;
import net.ihe.gazelle.app.patientregistryapi.business.PatientAliases;
import net.ihe.gazelle.lib.searchmodelapi.business.exception.SearchException;
import java.util.List;
/**
* Patient Cross Reference Search Service API
*/
public interface PatientCrossReferenceSearch {
List<PatientAliases> search(String key) throws SearchException;
}
package net.ihe.gazelle.app.patientregistryapi.business;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class PatientAliases {
private String uuid;
private String lastModifier;
private Date lastModifierDateTime;
private List<Patient> members = new ArrayList<>();
/**
* default constructor
*/
public PatientAliases() {
}
/**
* Constructor for the class
* @param uuid
* @param lastModifier
* @param lastModifierDateTime
*/
public PatientAliases(String uuid, String lastModifier, Date lastModifierDateTime) {
this.uuid = uuid;
this.lastModifier = lastModifier;
this.lastModifierDateTime = lastModifierDateTime;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getLastModifier() {
return lastModifier;
}
public void setLastModifier(String lastModifier) {
this.lastModifier = lastModifier;
}
public Date getLastModifierDateTime() {
return lastModifierDateTime;
}
public void setLastModifierDateTime(Date lastModifierDateTime) {
this.lastModifierDateTime = lastModifierDateTime;
}
public List<Patient> getMembers() {
return members;
}
/**
* add a patient to a members
*
* @param member the patient to add
*/
public void addMember(Patient member) {
this.members.add(member);
}
/**
* add a patient to a members
*
* @param member the patient to add
* @param index the index to insert the patient
*/
public void addMember(Patient member, int index) {
this.members.add(index, member);
}
/**
* remove a member to a list of members
*
* @param member the patient to remove
*/
public void removeMember(Patient member) {
this.members.remove(member);
}
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
PatientAliases patientAliases = (PatientAliases) o;
if (uuid != null ? !uuid.equals(patientAliases.uuid) : patientAliases.uuid != null) {
return false;
}
if (lastModifier != null ? !lastModifier.equals(patientAliases.lastModifier) : patientAliases.lastModifier != null) {
return false;
}
if (lastModifierDateTime != null ? !lastModifierDateTime.equals(patientAliases.lastModifierDateTime) : patientAliases.lastModifierDateTime != null) {
return false;
}
return members.equals(patientAliases.members);
}
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (uuid != null ? uuid.hashCode() : 0);
result = 31 * result + (lastModifier != null ? lastModifier.hashCode() : 0);
result = 31 * result + (lastModifierDateTime != null ? lastModifierDateTime.hashCode() : 0);
result = 31 * result + members.hashCode();
return result;
}
}
package net.ihe.gazelle.app.patientregistryapi.business;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
/**
* tests for Patient class
*/
class PatientAliasesTest {
/**
* test default constructor
*/
@Test
public void patientAliasesDefaultConstructorTest() {
PatientAliases patientAliases = new PatientAliases();
assertTrue(patientAliases.getMembers().isEmpty());
}
/**
* test complete constructor
*/
@Test
public void patientAliasesCompleteConstructorTest() {
String uuid = "uuid";
Date lastModifierDateTime = new Date();
String lastModifier = "toto";
PatientAliases patientAliases = new PatientAliases(uuid, lastModifier, lastModifierDateTime);
assertTrue(patientAliases.getMembers().isEmpty());
assertEquals(uuid, patientAliases.getUuid());
assertEquals(lastModifier, patientAliases.getLastModifier());
assertEquals(lastModifierDateTime, patientAliases.getLastModifierDateTime());
}
/**
* test member list add patient
*/
@Test
public void addMembersTest() {
PatientAliases patientAliases = new PatientAliases();
patientAliases.addMember(new Patient());
assertFalse(patientAliases.getMembers().isEmpty());
}
/**
* test members list remove member
*/
@Test
public void removeNameToIndexTest() {
PatientAliases patientAliases = new PatientAliases();
for(int i=0; i<5; i++) {
patientAliases.addMember(new Patient());
}
int index = 3;
Patient patientToAddAndRemove = new Patient();
patientToAddAndRemove.setUuid("uuid");
patientAliases.addMember(patientToAddAndRemove, index);
patientAliases.removeMember(patientToAddAndRemove);
assertFalse(patientAliases.getMembers().contains(patientToAddAndRemove));
}
/**
* test Members list add member
*/
@Test
public void addMemberTest() {
PatientAliases patientAliases = new PatientAliases();
patientAliases.addMember(new Patient());
assertFalse(patientAliases.getMembers().isEmpty());
}
/**
* test member list add patient to index
*/
@Test
public void addMembersToIndexTest() {
PatientAliases patientAliases = new PatientAliases();
for(int i=0; i<5; i++) {
patientAliases.addMember(new Patient());
}
int index = 3;
Patient patient = new Patient();
patientAliases.addMember(patient, index);
assertEquals(patient,patientAliases.getMembers().get(index));
}
/**
* test member list remove patient
*/
@Test
public void removePatientToIndexTest() {
PatientAliases patientAliases = new PatientAliases();
for(int i=0; i<5; i++) {
patientAliases.addMember(new Patient());
}
int index = 3;
Patient patientUUIDToAddAndRemove = new Patient();
patientUUIDToAddAndRemove.setUuid("75a59e02-cdb2-11ea-87d0-0242ac130003");
patientAliases.addMember(patientUUIDToAddAndRemove,index);
patientAliases.removeMember(patientUUIDToAddAndRemove);
assertFalse(patientAliases.getMembers().contains(patientUUIDToAddAndRemove));
}
/**
* Test patientAliases on member and Null
*/
@Test
public void equals_patientAliases_null(){
PatientAliases patientAliases = new PatientAliases();
assertFalse(patientAliases.equals(null),"PatientAliases shall not be equal to null!");
}
/**
* Test equals on same patientAliases
*/
@Test
public void equals_patientAliases_same(){
PatientAliases patientAliases = new PatientAliases();
assertTrue(patientAliases.equals(patientAliases),"Patientes shall be equal!");
}
/**
* Test equals on Patient and another class
*/
@Test
public void equals_patientAliases_other_class(){
PatientAliases patientAliases = new PatientAliases();
assertFalse(patientAliases.equals("Malade"),"Patient shall not be equal to string !");
}
/**
* Test equals on patientAliases uuid equals
*/
@Test
public void equals_patientAliases_uuid_true(){
String uuid= "uuid1";
PatientAliases patientAliases = new PatientAliases();
patientAliases.setUuid(uuid);
PatientAliases patientAliases1 = new PatientAliases();
patientAliases1.setUuid(uuid);
assertTrue(patientAliases1.equals(patientAliases1),"Patient shall be equal !");
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment