Merge pull request #786 from hapifhir/dotasek-base64binary-40_50-output-stream
Fix Base64BinaryType instantiation
This commit is contained in:
commit
c9d379cf18
|
@ -0,0 +1,91 @@
|
|||
package org.hl7.fhir.convertors.conv40_50;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class AuditEvent40_50Test {
|
||||
|
||||
public static final String THE_BASE_64_BINARY_STRING = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
public static final byte[] THE_BASE_64_BINARY_BYTE_ARRAY = Base64.decodeBase64(THE_BASE_64_BINARY_STRING.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8));
|
||||
|
||||
public static final String INVALID_BASE_64_BINARY_STRING = "Picard was the best starship captain";
|
||||
public static final byte[] INVALID_BASE_64_BINARY_BYTE_ARRAY = Base64.decodeBase64(INVALID_BASE_64_BINARY_STRING.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8));
|
||||
|
||||
|
||||
@Test
|
||||
@DisplayName("Test r5 -> r4 AuditEvent conversion.")
|
||||
public void testR5_R4() throws IOException {
|
||||
InputStream r5_input = this.getClass().getResourceAsStream("/auditevent_50_with_base64binary.xml");
|
||||
|
||||
org.hl7.fhir.r5.model.AuditEvent r5_actual = (org.hl7.fhir.r5.model.AuditEvent) new org.hl7.fhir.r5.formats.XmlParser().parse(r5_input);
|
||||
org.hl7.fhir.r4.model.Resource r4_conv = VersionConvertorFactory_40_50.convertResource(r5_actual);
|
||||
|
||||
org.hl7.fhir.r4.formats.XmlParser r4_parser = new org.hl7.fhir.r4.formats.XmlParser();
|
||||
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
r4_parser.compose(stream, r4_conv);
|
||||
|
||||
org.hl7.fhir.r4.model.Resource r4_streamed = (org.hl7.fhir.r4.model.AuditEvent) new org.hl7.fhir.r4.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray()));
|
||||
|
||||
assertArrayEquals(((org.hl7.fhir.r4.model.AuditEvent)r4_conv).getEntity().get(0).getQuery(), THE_BASE_64_BINARY_BYTE_ARRAY);
|
||||
assertArrayEquals(((org.hl7.fhir.r4.model.AuditEvent)r4_streamed).getEntity().get(0).getQuery(), THE_BASE_64_BINARY_BYTE_ARRAY);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test r5 -> r4 AuditEvent conversion.")
|
||||
public void testR4_R5() throws IOException {
|
||||
InputStream r4_input = this.getClass().getResourceAsStream("/auditevent_40_with_base64binary.xml");
|
||||
|
||||
org.hl7.fhir.r4.model.AuditEvent r4_actual = (org.hl7.fhir.r4.model.AuditEvent) new org.hl7.fhir.r4.formats.XmlParser().parse(r4_input);
|
||||
org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_40_50.convertResource(r4_actual);
|
||||
|
||||
org.hl7.fhir.r5.formats.XmlParser r5_parser = new org.hl7.fhir.r5.formats.XmlParser();
|
||||
|
||||
ByteArrayOutputStream stream
|
||||
= new ByteArrayOutputStream();
|
||||
|
||||
r5_parser.compose(stream, r5_conv);
|
||||
|
||||
org.hl7.fhir.r5.model.Resource r5_streamed = (org.hl7.fhir.r5.model.AuditEvent) new org.hl7.fhir.r5.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray()));
|
||||
|
||||
assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQuery(), THE_BASE_64_BINARY_BYTE_ARRAY);
|
||||
assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_streamed).getEntity().get(0).getQuery(), THE_BASE_64_BINARY_BYTE_ARRAY);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test r5 -> r4 AuditEvent conversion with invalid Base64Binary.")
|
||||
public void testR4_R5BadBase64Binary() throws IOException {
|
||||
InputStream r4_input = this.getClass().getResourceAsStream("/auditevent_40_with_invalid_base64binary.xml");
|
||||
|
||||
org.hl7.fhir.r4.model.AuditEvent r4_actual = (org.hl7.fhir.r4.model.AuditEvent) new org.hl7.fhir.r4.formats.XmlParser().parse(r4_input);
|
||||
|
||||
org.hl7.fhir.r5.model.Resource r5_conv = VersionConvertorFactory_40_50.convertResource(r4_actual);
|
||||
|
||||
org.hl7.fhir.r5.formats.XmlParser r5_parser = new org.hl7.fhir.r5.formats.XmlParser();
|
||||
|
||||
ByteArrayOutputStream stream
|
||||
= new ByteArrayOutputStream();
|
||||
|
||||
r5_parser.compose(stream, r5_conv);
|
||||
|
||||
org.hl7.fhir.r5.model.Resource r5_streamed = (org.hl7.fhir.r5.model.AuditEvent) new org.hl7.fhir.r5.formats.XmlParser().parse(new ByteArrayInputStream(stream.toByteArray()));
|
||||
|
||||
System.out.println(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQueryElement().getValueAsString());
|
||||
|
||||
//FIXME we should not be even getting this far.
|
||||
assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_conv).getEntity().get(0).getQuery(), INVALID_BASE_64_BINARY_BYTE_ARRAY);
|
||||
assertArrayEquals(((org.hl7.fhir.r5.model.AuditEvent)r5_streamed).getEntity().get(0).getQuery(), INVALID_BASE_64_BINARY_BYTE_ARRAY);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<AuditEvent xmlns="http://hl7.org/fhir">
|
||||
<id value="example"/>
|
||||
<text>
|
||||
<status value="generated"/>
|
||||
<div xmlns="http://www.w3.org/1999/xhtml">Application Start for under service login "Grahame" (id: Grahame's Test HL7Connect)</div>
|
||||
</text>
|
||||
|
||||
<type>
|
||||
<system value="http://dicom.nema.org/resources/ontology/DCM"/>
|
||||
<code value="110100"/>
|
||||
<display value="Application Activity"/>
|
||||
</type>
|
||||
<subtype>
|
||||
<system value="http://dicom.nema.org/resources/ontology/DCM"/>
|
||||
<code value="110120"/>
|
||||
<display value="Application Start"/>
|
||||
</subtype>
|
||||
<action value="E"/>
|
||||
<recorded value="2012-10-25T22:04:27+11:00"/>
|
||||
<outcome value="0"/>
|
||||
<agent>
|
||||
<type> <coding> <system value="http://terminology.hl7.org/CodeSystem/extra-security-role-type"/> <code value="humanuser"/> <display value="human user"/> </coding> </type>
|
||||
|
||||
<role>
|
||||
<text value="Service User (Logon)"/>
|
||||
</role>
|
||||
<who>
|
||||
<identifier>
|
||||
<value value="Grahame"/>
|
||||
</identifier>
|
||||
</who>
|
||||
|
||||
<requestor value="false"/>
|
||||
<network>
|
||||
<address value="127.0.0.1"/>
|
||||
<type value="2"/>
|
||||
</network>
|
||||
</agent>
|
||||
<agent> <!-- Source active participant, the software making the . AlternativeUserId - Process ID
|
||||
-->
|
||||
<type> <coding> <system value="http://dicom.nema.org/resources/ontology/DCM"/> <code value="110153"/> <display value="Source Role ID"/> </coding> </type>
|
||||
<who>
|
||||
<identifier>
|
||||
<system value="urn:oid:2.16.840.1.113883.4.2"/>
|
||||
<value value="2.16.840.1.113883.4.2"/>
|
||||
</identifier>
|
||||
</who>
|
||||
<altId value="6580"/>
|
||||
<requestor value="false"/>
|
||||
<network> <address value="Workstation1.ehr.familyclinic.com"/> <type value="1"/> </network>
|
||||
</agent>
|
||||
<source>
|
||||
<site value="Development"/>
|
||||
<observer>
|
||||
<display value="Grahame's Laptop"/>
|
||||
</observer>
|
||||
<type>
|
||||
<system value="http://dicom.nema.org/resources/ontology/DCM"/>
|
||||
<code value="110122"/>
|
||||
<display value="Login"/>
|
||||
</type>
|
||||
</source>
|
||||
<entity>
|
||||
<what> <identifier>
|
||||
<type>
|
||||
<coding>
|
||||
<system value="http://terminology.hl7.org/CodeSystem/v2-0203"/>
|
||||
<code value="SNO"/>
|
||||
</coding>
|
||||
<text value="Dell Serial Number"/>
|
||||
</type>
|
||||
<value value="ABCDEF"/>
|
||||
</identifier>
|
||||
</what>
|
||||
<type>
|
||||
<system value="http://terminology.hl7.org/CodeSystem/audit-entity-type"/>
|
||||
<code value="4"/>
|
||||
<display value="Other"/>
|
||||
</type>
|
||||
<role>
|
||||
<system value="http://terminology.hl7.org/CodeSystem/object-role"/>
|
||||
<code value="4"/>
|
||||
<display value="Domain Resource"/>
|
||||
</role>
|
||||
<lifecycle>
|
||||
<system value="http://terminology.hl7.org/CodeSystem/dicom-audit-lifecycle"/>
|
||||
<code value="6"/>
|
||||
<display value="Access / Use"/>
|
||||
</lifecycle>
|
||||
<name value="Grahame's Laptop"/>
|
||||
<query value="dGhpcyBpcyB2YWxpZCBiYXNlNjQ="/>
|
||||
</entity>
|
||||
</AuditEvent>
|
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<AuditEvent xmlns="http://hl7.org/fhir">
|
||||
<id value="example"/>
|
||||
<text>
|
||||
<status value="generated"/>
|
||||
<div xmlns="http://www.w3.org/1999/xhtml">Application Start for under service login "Grahame" (id: Grahame's Test HL7Connect)</div>
|
||||
</text>
|
||||
|
||||
<type>
|
||||
<system value="http://dicom.nema.org/resources/ontology/DCM"/>
|
||||
<code value="110100"/>
|
||||
<display value="Application Activity"/>
|
||||
</type>
|
||||
<subtype>
|
||||
<system value="http://dicom.nema.org/resources/ontology/DCM"/>
|
||||
<code value="110120"/>
|
||||
<display value="Application Start"/>
|
||||
</subtype>
|
||||
<action value="E"/>
|
||||
<recorded value="2012-10-25T22:04:27+11:00"/>
|
||||
<outcome value="0"/>
|
||||
<agent>
|
||||
<type> <coding> <system value="http://terminology.hl7.org/CodeSystem/extra-security-role-type"/> <code value="humanuser"/> <display value="human user"/> </coding> </type>
|
||||
|
||||
<role>
|
||||
<text value="Service User (Logon)"/>
|
||||
</role>
|
||||
<who>
|
||||
<identifier>
|
||||
<value value="Grahame"/>
|
||||
</identifier>
|
||||
</who>
|
||||
|
||||
<requestor value="false"/>
|
||||
<network>
|
||||
<address value="127.0.0.1"/>
|
||||
<type value="2"/>
|
||||
</network>
|
||||
</agent>
|
||||
<agent> <!-- Source active participant, the software making the . AlternativeUserId - Process ID
|
||||
-->
|
||||
<type> <coding> <system value="http://dicom.nema.org/resources/ontology/DCM"/> <code value="110153"/> <display value="Source Role ID"/> </coding> </type>
|
||||
<who>
|
||||
<identifier>
|
||||
<system value="urn:oid:2.16.840.1.113883.4.2"/>
|
||||
<value value="2.16.840.1.113883.4.2"/>
|
||||
</identifier>
|
||||
</who>
|
||||
<altId value="6580"/>
|
||||
<requestor value="false"/>
|
||||
<network> <address value="Workstation1.ehr.familyclinic.com"/> <type value="1"/> </network>
|
||||
</agent>
|
||||
<source>
|
||||
<site value="Development"/>
|
||||
<observer>
|
||||
<display value="Grahame's Laptop"/>
|
||||
</observer>
|
||||
<type>
|
||||
<system value="http://dicom.nema.org/resources/ontology/DCM"/>
|
||||
<code value="110122"/>
|
||||
<display value="Login"/>
|
||||
</type>
|
||||
</source>
|
||||
<entity>
|
||||
<what> <identifier>
|
||||
<type>
|
||||
<coding>
|
||||
<system value="http://terminology.hl7.org/CodeSystem/v2-0203"/>
|
||||
<code value="SNO"/>
|
||||
</coding>
|
||||
<text value="Dell Serial Number"/>
|
||||
</type>
|
||||
<value value="ABCDEF"/>
|
||||
</identifier>
|
||||
</what>
|
||||
<type>
|
||||
<system value="http://terminology.hl7.org/CodeSystem/audit-entity-type"/>
|
||||
<code value="4"/>
|
||||
<display value="Other"/>
|
||||
</type>
|
||||
<role>
|
||||
<system value="http://terminology.hl7.org/CodeSystem/object-role"/>
|
||||
<code value="4"/>
|
||||
<display value="Domain Resource"/>
|
||||
</role>
|
||||
<lifecycle>
|
||||
<system value="http://terminology.hl7.org/CodeSystem/dicom-audit-lifecycle"/>
|
||||
<code value="6"/>
|
||||
<display value="Access / Use"/>
|
||||
</lifecycle>
|
||||
<name value="Grahame's Laptop"/>
|
||||
<query value="Picard was the best starship captain"/>
|
||||
</entity>
|
||||
</AuditEvent>
|
|
@ -0,0 +1,100 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<AuditEvent xmlns="http://hl7.org/fhir">
|
||||
<id value="example"/>
|
||||
<text>
|
||||
<status value="generated"/>
|
||||
<div xmlns="http://www.w3.org/1999/xhtml">Application Start for under service login "Grahame" (id: Grahame's Test HL7Connect)</div>
|
||||
</text>
|
||||
<category>
|
||||
<coding>
|
||||
<system value="http://dicom.nema.org/resources/ontology/DCM"/>
|
||||
<code value="110100"/>
|
||||
<display value="Application Activity"/>
|
||||
</coding>
|
||||
</category>
|
||||
<code>
|
||||
<coding>
|
||||
<system value="http://dicom.nema.org/resources/ontology/DCM"/>
|
||||
<code value="110120"/>
|
||||
<display value="Application Start"/>
|
||||
</coding>
|
||||
</code>
|
||||
<action value="E"/>
|
||||
<recorded value="2012-10-25T22:04:27+11:00"/>
|
||||
<outcome>
|
||||
<code>
|
||||
<system value="http://terminology.hl7.org/CodeSystem/audit-event-outcome"/>
|
||||
<code value="0"/>
|
||||
<display value="Success"/>
|
||||
</code>
|
||||
</outcome>
|
||||
<agent>
|
||||
<role>
|
||||
<text value="Service User (Logon)"/>
|
||||
</role>
|
||||
<who>
|
||||
<identifier>
|
||||
<value value="Grahame"/>
|
||||
</identifier>
|
||||
</who>
|
||||
<requestor value="false"/>
|
||||
|
||||
</agent>
|
||||
<agent>
|
||||
<!-- Source active participant, the software making the . AlternativeUserId - Process ID
|
||||
-->
|
||||
<extension url="http://hl7.org/fhir/StructureDefinition/auditevent-AlternativeUserID">
|
||||
<valueIdentifier>
|
||||
<type>
|
||||
<text value="process ID"/>
|
||||
</type>
|
||||
<value value="6580"/>
|
||||
</valueIdentifier>
|
||||
</extension>
|
||||
<who>
|
||||
<identifier>
|
||||
<system value="urn:oid:2.16.840.1.113883.4.2"/>
|
||||
<value value="2.16.840.1.113883.4.2"/>
|
||||
</identifier>
|
||||
</who>
|
||||
<requestor value="false"/>
|
||||
<networkString value="Workstation1.ehr.familyclinic.com"/>
|
||||
|
||||
</agent>
|
||||
<source>
|
||||
<observer>
|
||||
<display value="Grahame's Laptop"/>
|
||||
</observer>
|
||||
<type>
|
||||
<coding>
|
||||
<system value="http://dicom.nema.org/resources/ontology/DCM"/>
|
||||
<code value="110122"/>
|
||||
<display value="Login"/>
|
||||
</coding>
|
||||
</type>
|
||||
</source>
|
||||
<entity>
|
||||
<what>
|
||||
<identifier>
|
||||
<type>
|
||||
<coding>
|
||||
<system value="http://terminology.hl7.org/CodeSystem/v2-0203"/>
|
||||
<code value="SNO"/>
|
||||
</coding>
|
||||
<text value="Dell Serial Number"/>
|
||||
</type>
|
||||
<value value="ABCDEF"/>
|
||||
</identifier>
|
||||
</what>
|
||||
|
||||
<role>
|
||||
<coding>
|
||||
<system value="http://terminology.hl7.org/CodeSystem/object-role"/>
|
||||
<code value="4"/>
|
||||
<display value="Domain Resource"/>
|
||||
</coding>
|
||||
</role>
|
||||
<query value="dGhpcyBpcyB2YWxpZCBiYXNlNjQ="/>
|
||||
</entity>
|
||||
</AuditEvent>
|
|
@ -1,6 +1,7 @@
|
|||
package org.hl7.fhir.dstu2.model;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -11,6 +12,8 @@ class Base64BinaryTypeTest {
|
|||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
static final byte[] VALID_BASE_64_BYTES = Base64.decodeBase64(VALID_BASE_64.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8));
|
||||
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
|
@ -45,6 +48,15 @@ class Base64BinaryTypeTest {
|
|||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null bytes.")
|
||||
public void testValidBytes() {
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64_BYTES);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValid() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.hl7.fhir.dstu2016may.model;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -11,6 +12,8 @@ class Base64BinaryTypeTest {
|
|||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
static final byte[] VALID_BASE_64_BYTES = Base64.decodeBase64(VALID_BASE_64.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8));
|
||||
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
|
@ -45,6 +48,15 @@ class Base64BinaryTypeTest {
|
|||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null bytes.")
|
||||
public void testValidBytes() {
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64_BYTES);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValid() {
|
||||
|
|
|
@ -130,7 +130,7 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
@Override
|
||||
public Base64BinaryType setValue(byte[] theValue) throws IllegalArgumentException {
|
||||
myValue = theValue;
|
||||
return this;
|
||||
return (Base64BinaryType) super.setValue(theValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.hl7.fhir.dstu3.model;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -11,6 +12,8 @@ class Base64BinaryTypeTest {
|
|||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
static final byte[] VALID_BASE_64_BYTES = Base64.decodeBase64(VALID_BASE_64.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8));
|
||||
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
|
@ -54,6 +57,15 @@ class Base64BinaryTypeTest {
|
|||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null bytes.")
|
||||
public void testValidBytes() {
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64_BYTES);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValidSetValueAsString() {
|
||||
|
|
|
@ -130,7 +130,7 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
@Override
|
||||
public Base64BinaryType setValue(byte[] theValue) throws IllegalArgumentException {
|
||||
myValue = theValue;
|
||||
return this;
|
||||
return (Base64BinaryType) super.setValue(theValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.hl7.fhir.r4.model;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -11,6 +12,8 @@ class Base64BinaryTypeTest {
|
|||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
static final byte[] VALID_BASE_64_BYTES = Base64.decodeBase64(VALID_BASE_64.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8));
|
||||
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
|
@ -54,6 +57,15 @@ class Base64BinaryTypeTest {
|
|||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null bytes.")
|
||||
public void testValidBytes() {
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64_BYTES);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValidSetValueAsString() {
|
||||
|
|
|
@ -129,7 +129,7 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
@Override
|
||||
public Base64BinaryType setValue(byte[] theValue) throws IllegalArgumentException {
|
||||
myValue = theValue;
|
||||
return this;
|
||||
return (Base64BinaryType) super.setValue(theValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.hl7.fhir.r4b.model;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -12,6 +13,8 @@ class Base64BinaryTypeTest {
|
|||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
static final byte[] VALID_BASE_64_BYTES = Base64.decodeBase64(VALID_BASE_64.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8));
|
||||
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
|
@ -55,6 +58,15 @@ class Base64BinaryTypeTest {
|
|||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null bytes.")
|
||||
public void testValidBytes() {
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64_BYTES);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValidSetValueAsString() {
|
||||
|
|
|
@ -129,7 +129,7 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
@Override
|
||||
public Base64BinaryType setValue(byte[] theValue) throws IllegalArgumentException {
|
||||
myValue = theValue;
|
||||
return this;
|
||||
return (Base64BinaryType) super.setValue(theValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,16 +2,20 @@ package org.hl7.fhir.r5.model;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
class Base64BinaryTypeTest {
|
||||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
static final byte[] VALID_BASE_64_BYTES = Base64.decodeBase64(VALID_BASE_64.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8));
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
|
@ -55,6 +59,15 @@ class Base64BinaryTypeTest {
|
|||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null bytes.")
|
||||
public void testValidBytes() {
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64_BYTES);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValidSetValueAsString() {
|
||||
|
|
Loading…
Reference in New Issue