Related to issue #724 - Added more unit tests
This commit is contained in:
parent
5650238421
commit
8f06cf7322
|
@ -1,6 +1,9 @@
|
|||
package ca.uhn.fhir.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.hl7.fhir.dstu2016may.model.BackboneElement;
|
||||
import org.hl7.fhir.dstu2016may.model.Patient.PatientCommunicationComponent;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -16,6 +19,8 @@ public class BackboneElementDstu2_1Test {
|
|||
|
||||
PatientCommunicationComponent copiedPcc = pcc1.copy();
|
||||
String copiedPccID = copiedPcc.getIdElement().getIdPart();
|
||||
|
||||
assertTrue(copiedPcc instanceof BackboneElement); // Just making sure this assumption still holds up, otherwise this test isn't very useful
|
||||
assertEquals("1001", copiedPccID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,30 @@
|
|||
package ca.uhn.fhir.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.hl7.fhir.dstu2016may.model.DomainResource;
|
||||
import org.hl7.fhir.dstu2016may.model.Narrative;
|
||||
import org.hl7.fhir.dstu2016may.model.Patient;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DomainResourceDstu2_1Test {
|
||||
/**
|
||||
* Ensuring that IDs of subtypes of DomainResource get copied when
|
||||
* the {@link org.hl7.fhir.dstu2016may.model.DomainResource#copy()} method is called
|
||||
* Ensuring that Ensuring that fields defined in {@link org.hl7.fhir.dstu2016may.model.DomainResource} and {@link org.hl7.fhir.dstu2016may.model.Resource}
|
||||
* get copied when the {@link org.hl7.fhir.dstu2016may.model.DomainResource#copy()} method is called
|
||||
*/
|
||||
@Test
|
||||
public void testPatientIdCopy() {
|
||||
public void testPatientCopy() {
|
||||
Patient p1 = new Patient();
|
||||
p1.setId("1001");
|
||||
p1.setText(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL));
|
||||
|
||||
Patient copiedPatient = p1.copy();
|
||||
String copiedPatientID = copiedPatient.getIdElement().getIdPart();
|
||||
Narrative.NarrativeStatus copiedPatientTextStatus = copiedPatient.getText().getStatus();
|
||||
|
||||
assertTrue(copiedPatient instanceof DomainResource); // Just making sure this assumption still holds up, otherwise this test isn't very useful
|
||||
assertEquals("1001", copiedPatientID);
|
||||
assertEquals(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL).getStatus(), copiedPatientTextStatus);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.hl7.fhir.dstu3.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -10,12 +12,14 @@ public class BackboneElementDstu3Test {
|
|||
* the {@link BackboneElement#copy()} method is called
|
||||
*/
|
||||
@Test
|
||||
public void testPatientCommunicationComponentIdCopy() {
|
||||
public void testPatientCommunicationComponentCopy() {
|
||||
PatientCommunicationComponent pcc1 = new PatientCommunicationComponent();
|
||||
pcc1.setId("1001");
|
||||
|
||||
PatientCommunicationComponent copiedPcc = pcc1.copy();
|
||||
String copiedPccID = copiedPcc.getId();
|
||||
assertEquals("1001", copiedPccID);
|
||||
|
||||
assertTrue(copiedPcc instanceof BackboneElement); // Just making sure this assumption still holds up, otherwise this test isn't very useful
|
||||
assertEquals("1001", copiedPccID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
package org.hl7.fhir.dstu3.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class DomainResourceDstu3Test {
|
||||
/**
|
||||
* Ensuring that IDs of subtypes of DomainResource get copied when
|
||||
* the {@link DomainResource#copy()} method is called
|
||||
* Ensuring that fields defined in {@link DomainResource} and {@link Resource}
|
||||
* get copied when the {@link DomainResource#copy()} method is called
|
||||
*/
|
||||
@Test
|
||||
public void testPatientIdCopy() {
|
||||
public void testPatientCopy() {
|
||||
Patient p1 = new Patient();
|
||||
p1.setId("1001");
|
||||
p1.setText(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL));
|
||||
|
||||
Patient copiedPatient = p1.copy();
|
||||
String copiedPatientID = copiedPatient.getIdElement().getIdPart();
|
||||
Narrative.NarrativeStatus copiedPatientTextStatus = copiedPatient.getText().getStatus();
|
||||
|
||||
assertTrue(copiedPatient instanceof DomainResource); // Just making sure this assumption still holds up, otherwise this test isn't very useful
|
||||
assertEquals("1001", copiedPatientID);
|
||||
assertEquals(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL).getStatus(), copiedPatientTextStatus);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package org.hl7.fhir.dstu3.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MetadataResourceDstu3Test {
|
||||
/**
|
||||
* Ensuring that fields defined in {@link MetadataResource}, {@link DomainResource}, and {@link Resource}
|
||||
* get copied when the {@link MetadataResource#copy()} method is called
|
||||
*/
|
||||
@Test
|
||||
public void testCodeSystemCopy() {
|
||||
CodeSystem codeSystem1 = new CodeSystem();
|
||||
codeSystem1.setId("1001");
|
||||
codeSystem1.setName("Name123");
|
||||
codeSystem1.setText(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL));
|
||||
|
||||
CodeSystem copiedCodeSystem = codeSystem1.copy();
|
||||
String copiedCodeSystemID = copiedCodeSystem.getId();
|
||||
String copiedCodeSystemName = copiedCodeSystem.getName();
|
||||
Narrative.NarrativeStatus copiedCodeSystemTextStatus = copiedCodeSystem.getText().getStatus();
|
||||
|
||||
assertTrue(copiedCodeSystem instanceof MetadataResource); // Just making sure this assumption still holds up, otherwise this test isn't very useful
|
||||
assertEquals("1001", copiedCodeSystemID);
|
||||
assertEquals("Name123", copiedCodeSystemName);
|
||||
assertEquals(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL).getStatus(), copiedCodeSystemTextStatus);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package ca.uhn.fhir.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.hl7.fhir.instance.model.BackboneElement;
|
||||
import org.hl7.fhir.instance.model.Patient.PatientCommunicationComponent;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -16,6 +19,8 @@ public class BackboneElementHL7_Dstu2Test {
|
|||
|
||||
PatientCommunicationComponent copiedPcc = pcc1.copy();
|
||||
String copiedPccID = copiedPcc.getIdElement().getIdPart();
|
||||
|
||||
assertTrue(copiedPcc instanceof BackboneElement); // Just making sure this assumption still holds up, otherwise this test isn't very useful
|
||||
assertEquals("1001", copiedPccID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,30 @@
|
|||
package ca.uhn.fhir.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.hl7.fhir.instance.model.Patient;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DomainResourceHL7_Dstu2Test {
|
||||
/**
|
||||
* Ensuring that IDs of subtypes of DomainResource get copied when
|
||||
* the {@link org.hl7.fhir.instance.model.DomainResource#copy()} method is called
|
||||
*/
|
||||
@Test
|
||||
public void testPatientIdCopy() {
|
||||
Patient p1 = new Patient();
|
||||
p1.setId("1001");
|
||||
|
||||
Patient copiedPatient = p1.copy();
|
||||
String copiedPatientID = copiedPatient.getIdElement().getIdPart();
|
||||
assertEquals("1001", copiedPatientID);
|
||||
}
|
||||
}
|
||||
package ca.uhn.fhir.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.hl7.fhir.instance.model.DomainResource;
|
||||
import org.hl7.fhir.instance.model.Narrative;
|
||||
import org.hl7.fhir.instance.model.Patient;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DomainResourceHL7_Dstu2Test {
|
||||
/**
|
||||
* Ensuring that fields defined in {@link org.hl7.fhir.instance.model.DomainResource} and {@link org.hl7.fhir.instance.model.Resource}
|
||||
* the {@link org.hl7.fhir.instance.model.DomainResource#copy()} method is called
|
||||
*/
|
||||
@Test
|
||||
public void testPatientCopy() {
|
||||
Patient p1 = new Patient();
|
||||
p1.setId("1001");
|
||||
p1.setText(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL));
|
||||
|
||||
Patient copiedPatient = p1.copy();
|
||||
String copiedPatientID = copiedPatient.getIdElement().getIdPart();
|
||||
Narrative.NarrativeStatus copiedPatientTextStatus = copiedPatient.getText().getStatus();
|
||||
|
||||
assertTrue(copiedPatient instanceof DomainResource); // Just making sure this assumption still holds up, otherwise this test isn't very useful
|
||||
assertEquals("1001", copiedPatientID);
|
||||
assertEquals(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL).getStatus(), copiedPatientTextStatus);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.hl7.fhir.r4.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -10,12 +12,14 @@ public class BackboneElementR4Test {
|
|||
* the {@link BackboneElement#copy()} method is called
|
||||
*/
|
||||
@Test
|
||||
public void testPatientCommunicationComponentIdCopy() {
|
||||
public void testPatientCommunicationComponentCopy() {
|
||||
PatientCommunicationComponent pcc1 = new PatientCommunicationComponent();
|
||||
pcc1.setId("1001");
|
||||
|
||||
PatientCommunicationComponent copiedPcc = pcc1.copy();
|
||||
String copiedPccID = copiedPcc.getId();
|
||||
|
||||
assertTrue(copiedPcc instanceof BackboneElement); // Just making sure this assumption still holds up, otherwise this test isn't very useful
|
||||
assertEquals("1001", copiedPccID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,26 @@
|
|||
package org.hl7.fhir.r4.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DomainResourceR4Test {
|
||||
/**
|
||||
* Ensuring that IDs of subtypes of DomainResource get copied when
|
||||
* the {@link DomainResource#copy()} method is called
|
||||
* Ensuring that fields defined in {@link DomainResource} and {@link Resource}
|
||||
* get copied when the {@link DomainResource#copy()} method is called
|
||||
*/
|
||||
@Test
|
||||
public void testPatientIdCopy() {
|
||||
public void testPatientCopy() {
|
||||
Patient p1 = new Patient();
|
||||
p1.setId("1001");
|
||||
p1.setText(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL));
|
||||
|
||||
Patient copiedPatient = p1.copy();
|
||||
String copiedPatientID = copiedPatient.getIdElement().getIdPart();
|
||||
Narrative.NarrativeStatus copiedPatientTextStatus = copiedPatient.getText().getStatus();
|
||||
|
||||
assertTrue(copiedPatient instanceof DomainResource); // Just making sure this assumption still holds up, otherwise this test isn't very useful
|
||||
assertEquals("1001", copiedPatientID);
|
||||
assertEquals(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL).getStatus(), copiedPatientTextStatus);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package org.hl7.fhir.r4.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MetadataResourceR4Test {
|
||||
/**
|
||||
* Ensuring that fields defined in {@link MetadataResource}, {@link DomainResource}, and {@link Resource}
|
||||
* get copied when the {@link MetadataResource#copy()} method is called
|
||||
*/
|
||||
@Test
|
||||
public void testCodeSystemCopy() {
|
||||
CodeSystem codeSystem1 = new CodeSystem();
|
||||
codeSystem1.setId("1001");
|
||||
codeSystem1.setName("Name123");
|
||||
codeSystem1.setText(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL));
|
||||
|
||||
CodeSystem copiedCodeSystem = codeSystem1.copy();
|
||||
String copiedCodeSystemID = copiedCodeSystem.getId();
|
||||
String copiedCodeSystemName = copiedCodeSystem.getName();
|
||||
Narrative.NarrativeStatus copiedCodeSystemTextStatus = copiedCodeSystem.getText().getStatus();
|
||||
|
||||
assertTrue(copiedCodeSystem instanceof MetadataResource); // Just making sure this assumption still holds up, otherwise this test isn't very useful
|
||||
assertEquals("1001", copiedCodeSystemID);
|
||||
assertEquals("Name123", copiedCodeSystemName);
|
||||
assertEquals(new Narrative().setStatus(Narrative.NarrativeStatus.ADDITIONAL).getStatus(), copiedCodeSystemTextStatus);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue