Add some tests
This commit is contained in:
parent
2cfa08f179
commit
d3c8962ae6
|
@ -1,11 +1,14 @@
|
||||||
package ca.uhn.fhir.model.dstu2;
|
package ca.uhn.fhir.model.dstu2;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||||
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -72,6 +75,21 @@ public class ModelDstu2Test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInstantPrecision() {
|
||||||
|
new InstantDt("2019-01-01T00:00:00Z");
|
||||||
|
new InstantDt("2019-01-01T00:00:00.0Z");
|
||||||
|
new InstantDt("2019-01-01T00:00:00.000Z");
|
||||||
|
try {
|
||||||
|
new InstantDt("2019-01-01T00:00Z");
|
||||||
|
fail();
|
||||||
|
} catch (DataFormatException e) {
|
||||||
|
// good
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See #354
|
* See #354
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,25 +1,14 @@
|
||||||
package ca.uhn.fhir.model;
|
package ca.uhn.fhir.model;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hl7.fhir.dstu3.model.Appointment;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
import org.hl7.fhir.dstu3.model.Claim;
|
import org.hl7.fhir.dstu3.model.*;
|
||||||
import org.hl7.fhir.dstu3.model.Claim.CareTeamComponent;
|
import org.hl7.fhir.dstu3.model.Claim.CareTeamComponent;
|
||||||
import org.hl7.fhir.dstu3.model.CodeableConcept;
|
|
||||||
import org.hl7.fhir.dstu3.model.Element;
|
|
||||||
import org.hl7.fhir.dstu3.model.Enumerations;
|
|
||||||
import org.hl7.fhir.dstu3.model.HumanName;
|
|
||||||
import org.hl7.fhir.dstu3.model.Identifier;
|
|
||||||
import org.hl7.fhir.dstu3.model.Patient;
|
|
||||||
import org.hl7.fhir.dstu3.model.Practitioner;
|
|
||||||
import org.hl7.fhir.dstu3.model.Practitioner.PractitionerQualificationComponent;
|
import org.hl7.fhir.dstu3.model.Practitioner.PractitionerQualificationComponent;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseElement;
|
import org.hl7.fhir.instance.model.api.IBaseElement;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
@ -31,6 +20,8 @@ import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.util.FhirTerser;
|
import ca.uhn.fhir.util.FhirTerser;
|
||||||
import ca.uhn.fhir.util.TestUtil;
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class ModelDstu3Test {
|
public class ModelDstu3Test {
|
||||||
|
|
||||||
private static FhirContext ourCtx = FhirContext.forDstu3();
|
private static FhirContext ourCtx = FhirContext.forDstu3();
|
||||||
|
@ -153,4 +144,18 @@ public class ModelDstu3Test {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInstantPrecision() {
|
||||||
|
new InstantType("2019-01-01T00:00:00Z");
|
||||||
|
new InstantType("2019-01-01T00:00:00.0Z");
|
||||||
|
new InstantType("2019-01-01T00:00:00.000Z");
|
||||||
|
try {
|
||||||
|
new InstantType("2019-01-01T00:00Z");
|
||||||
|
fail();
|
||||||
|
} catch (DataFormatException e) {
|
||||||
|
// good
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import ca.uhn.fhir.context.FhirContext;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class ModelR4Test {
|
public class ModelR4Test {
|
||||||
|
|
||||||
|
@ -15,5 +16,18 @@ public class ModelR4Test {
|
||||||
assertEquals("base64Binary", ourCtx.getElementDefinition("base64Binary").getName());
|
assertEquals("base64Binary", ourCtx.getElementDefinition("base64Binary").getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInstantPrecision() {
|
||||||
|
new InstantType("2019-01-01T00:00:00Z");
|
||||||
|
new InstantType("2019-01-01T00:00:00.0Z");
|
||||||
|
new InstantType("2019-01-01T00:00:00.000Z");
|
||||||
|
try {
|
||||||
|
new InstantType("2019-01-01T00:00Z");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// good
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package org.hl7.fhir.r5.model;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
public class ModelR5Test {
|
||||||
|
|
||||||
|
private static FhirContext ourCtx = FhirContext.forR5();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testbase64BinaryName() {
|
||||||
|
assertEquals("base64Binary", ourCtx.getElementDefinition("base64binary").getName());
|
||||||
|
assertEquals("base64Binary", ourCtx.getElementDefinition("base64Binary").getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInstantPrecision() {
|
||||||
|
new InstantType("2019-01-01T00:00:00Z");
|
||||||
|
new InstantType("2019-01-01T00:00:00.0Z");
|
||||||
|
new InstantType("2019-01-01T00:00:00.000Z");
|
||||||
|
try {
|
||||||
|
new InstantType("2019-01-01T00:00Z");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// good
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue