Add tests and changes for Base64Binary
This commit is contained in:
parent
9903d15ecc
commit
b5b43836eb
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Base64Binary10_30 {
|
||||
public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu3.model.Base64BinaryType();
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.Base64BinaryType();
|
||||
ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu2.model.Base64BinaryType();
|
||||
org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.Base64BinaryType();
|
||||
ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Base64Binary10_40 {
|
||||
public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType();
|
||||
org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.r4.model.Base64BinaryType();
|
||||
ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu2.model.Base64BinaryType();
|
||||
org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.Base64BinaryType();
|
||||
ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Base64Binary10_50 {
|
||||
public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType();
|
||||
org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.r5.model.Base64BinaryType();
|
||||
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu2.model.Base64BinaryType();
|
||||
org.hl7.fhir.dstu2.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.Base64BinaryType();
|
||||
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,15 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Base64Binary14_30 {
|
||||
public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2016may.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType tgt = new org.hl7.fhir.dstu3.model.Base64BinaryType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.Base64BinaryType();
|
||||
ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2016may.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2016may.model.Base64BinaryType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2016may.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.dstu2016may.model.Base64BinaryType();
|
||||
ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,15 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Base64Binary14_40 {
|
||||
public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2016may.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.r4.model.Base64BinaryType tgt = new org.hl7.fhir.r4.model.Base64BinaryType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.r4.model.Base64BinaryType();
|
||||
ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2016may.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2016may.model.Base64BinaryType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2016may.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.dstu2016may.model.Base64BinaryType();
|
||||
ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,15 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Base64Binary14_50 {
|
||||
public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu2016may.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.r5.model.Base64BinaryType tgt = new org.hl7.fhir.r5.model.Base64BinaryType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.r5.model.Base64BinaryType();
|
||||
ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2016may.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = new org.hl7.fhir.dstu2016may.model.Base64BinaryType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.dstu2016may.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu2016may.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.dstu2016may.model.Base64BinaryType();
|
||||
ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Base64Binary30_40 {
|
||||
public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType();
|
||||
org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.r4.model.Base64BinaryType();
|
||||
ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu3.model.Base64BinaryType();
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.Base64BinaryType();
|
||||
ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Base64Binary30_50 {
|
||||
public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.dstu3.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType();
|
||||
org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.r5.model.Base64BinaryType();
|
||||
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu3.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.dstu3.model.Base64BinaryType();
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.Base64BinaryType();
|
||||
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Base64Binary40_50 {
|
||||
public static org.hl7.fhir.r5.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r4.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r5.model.Base64BinaryType();
|
||||
org.hl7.fhir.r5.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.r5.model.Base64BinaryType();
|
||||
ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.r4.model.Base64BinaryType convertBase64Binary(org.hl7.fhir.r5.model.Base64BinaryType src) throws FHIRException {
|
||||
org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValue()) : new org.hl7.fhir.r4.model.Base64BinaryType();
|
||||
org.hl7.fhir.r4.model.Base64BinaryType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.Base64BinaryType(src.getValueAsString()) : new org.hl7.fhir.r4.model.Base64BinaryType();
|
||||
ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,10 @@ import java.util.stream.Stream;
|
|||
|
||||
public class VersionConvertorPrimitiveTypeTests {
|
||||
|
||||
private static String[] BASE64_BINARY_STRINGS = {
|
||||
"dGhpcyBpcyB2YWxpZCBiYXNlNjQ="
|
||||
};
|
||||
|
||||
private static String[] DEFAULT_DATE_PRECISION_STRINGS = {
|
||||
"1933", "1933-01", "1933-01-02"
|
||||
};
|
||||
|
@ -41,6 +45,44 @@ public class VersionConvertorPrimitiveTypeTests {
|
|||
|
||||
private static Stream<Arguments> getParams() {
|
||||
return Stream.of(
|
||||
//Base64Binary
|
||||
getDateTimeArgs(VersionConvertorFactory_10_30.class,
|
||||
org.hl7.fhir.dstu2.model.Base64BinaryType.class, org.hl7.fhir.dstu2.model.Type.class,
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType.class, org.hl7.fhir.dstu3.model.Type.class,
|
||||
BASE64_BINARY_STRINGS),
|
||||
getDateTimeArgs(VersionConvertorFactory_10_40.class,
|
||||
org.hl7.fhir.dstu2.model.Base64BinaryType.class, org.hl7.fhir.dstu2.model.Type.class,
|
||||
org.hl7.fhir.r4.model.Base64BinaryType.class, org.hl7.fhir.r4.model.Type.class,
|
||||
BASE64_BINARY_STRINGS),
|
||||
getDateTimeArgs(VersionConvertorFactory_10_50.class,
|
||||
org.hl7.fhir.dstu2.model.Base64BinaryType.class, org.hl7.fhir.dstu2.model.Type.class,
|
||||
org.hl7.fhir.r5.model.Base64BinaryType.class, org.hl7.fhir.r5.model.DataType.class,
|
||||
BASE64_BINARY_STRINGS),
|
||||
getDateTimeArgs(VersionConvertorFactory_14_30.class,
|
||||
org.hl7.fhir.dstu2016may.model.Base64BinaryType.class, org.hl7.fhir.dstu2016may.model.Type.class,
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType.class, org.hl7.fhir.dstu3.model.Type.class,
|
||||
BASE64_BINARY_STRINGS),
|
||||
getDateTimeArgs(VersionConvertorFactory_14_40.class,
|
||||
org.hl7.fhir.dstu2016may.model.Base64BinaryType.class, org.hl7.fhir.dstu2016may.model.Type.class,
|
||||
org.hl7.fhir.r4.model.Base64BinaryType.class, org.hl7.fhir.r4.model.Type.class,
|
||||
BASE64_BINARY_STRINGS),
|
||||
getDateTimeArgs(VersionConvertorFactory_14_50.class,
|
||||
org.hl7.fhir.dstu2016may.model.Base64BinaryType.class, org.hl7.fhir.dstu2016may.model.Type.class,
|
||||
org.hl7.fhir.r5.model.Base64BinaryType.class, org.hl7.fhir.r5.model.DataType.class,
|
||||
BASE64_BINARY_STRINGS),
|
||||
getDateTimeArgs(VersionConvertorFactory_30_40.class,
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType.class, org.hl7.fhir.dstu3.model.Type.class,
|
||||
org.hl7.fhir.r4.model.Base64BinaryType.class, org.hl7.fhir.r4.model.Type.class,
|
||||
BASE64_BINARY_STRINGS),
|
||||
getDateTimeArgs(VersionConvertorFactory_30_50.class,
|
||||
org.hl7.fhir.dstu3.model.Base64BinaryType.class, org.hl7.fhir.dstu3.model.Type.class,
|
||||
org.hl7.fhir.r5.model.Base64BinaryType.class, org.hl7.fhir.r5.model.DataType.class,
|
||||
BASE64_BINARY_STRINGS),
|
||||
getDateTimeArgs(VersionConvertorFactory_40_50.class,
|
||||
org.hl7.fhir.r4.model.Base64BinaryType.class, org.hl7.fhir.r4.model.Type.class,
|
||||
org.hl7.fhir.r5.model.Base64BinaryType.class, org.hl7.fhir.r5.model.DataType.class,
|
||||
BASE64_BINARY_STRINGS),
|
||||
|
||||
//Date
|
||||
getDateTimeArgs(VersionConvertorFactory_10_30.class,
|
||||
org.hl7.fhir.dstu2.model.DateType.class, org.hl7.fhir.dstu2.model.Type.class,
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
package org.hl7.fhir.dstu2.model;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -58,10 +58,15 @@ public class Base64BinaryType extends PrimitiveType<byte[]> {
|
|||
public Base64BinaryType(String theValue) {
|
||||
super();
|
||||
// Null values still result in non-null instance being created
|
||||
if (theValue != null) checkValidBase64(theValue);
|
||||
setValueAsString(theValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueAsString(String theValue) {
|
||||
if (theValue != null) checkValidBase64(theValue);
|
||||
super.setValueAsString(theValue);
|
||||
}
|
||||
|
||||
protected byte[] parse(String theValue) {
|
||||
if (theValue != null) {
|
||||
return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8));
|
||||
|
|
|
@ -9,11 +9,19 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||
|
||||
class Base64BinaryTypeTest {
|
||||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
String nonBase64 = "Picard was the best starship captain.";
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(nonBase64));
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to setValueAsString causes exception.")
|
||||
public void testNonBase64StringValueSet() {
|
||||
Base64BinaryType instance = new Base64BinaryType();
|
||||
assertThrows(DataFormatException.class, () -> instance.setValueAsString(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -26,13 +34,33 @@ class Base64BinaryTypeTest {
|
|||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("setValueAsString with null argument value sets instance value as null.")
|
||||
public void testNullSetValueAsString() throws DataFormatException {
|
||||
String v = null;
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(v);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNull(b64.getValue());
|
||||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValid() {
|
||||
String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
Base64BinaryType b64 = new Base64BinaryType(v);
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(v, b64.asStringValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValidSetValueAsString() {
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(VALID_BASE_64);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
}
|
|
@ -1,33 +1,33 @@
|
|||
package org.hl7.fhir.dstu2016may.model;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -59,10 +59,15 @@ public class Base64BinaryType extends PrimitiveType<byte[]> {
|
|||
public Base64BinaryType(String theValue) {
|
||||
super();
|
||||
// Null values still result in non-null instance being created
|
||||
if (theValue != null) checkValidBase64(theValue);
|
||||
setValueAsString(theValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueAsString(String theString) {
|
||||
if (theString != null) checkValidBase64(theString);
|
||||
super.setValueAsString(theString);
|
||||
}
|
||||
|
||||
protected byte[] parse(String theValue) {
|
||||
if (theValue != null) {
|
||||
return Base64.decodeBase64(theValue.getBytes(ca.uhn.fhir.rest.api.Constants.CHARSET_UTF8));
|
||||
|
|
|
@ -9,11 +9,19 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||
|
||||
class Base64BinaryTypeTest {
|
||||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
String nonBase64 = "Picard was the best starship captain.";
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(nonBase64));
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to setValueAsString causes exception.")
|
||||
public void testNonBase64StringValueSet() {
|
||||
Base64BinaryType instance = new Base64BinaryType();
|
||||
assertThrows(DataFormatException.class, () -> instance.setValueAsString(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -26,13 +34,33 @@ class Base64BinaryTypeTest {
|
|||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("setValueAsString with null argument value sets instance value as null.")
|
||||
public void testNullSetValueAsString() throws DataFormatException {
|
||||
String v = null;
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(v);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNull(b64.getValue());
|
||||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValid() {
|
||||
String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
Base64BinaryType b64 = new Base64BinaryType(v);
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(v, b64.asStringValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValidSetValueAsString() {
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(VALID_BASE_64);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
}
|
|
@ -67,7 +67,6 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
public Base64BinaryType(String theValue) {
|
||||
super();
|
||||
// Null values still result in non-null instance being created
|
||||
if (theValue != null) checkValidBase64(theValue);
|
||||
setValueAsString(theValue);
|
||||
}
|
||||
|
||||
|
@ -117,6 +116,8 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
|
||||
@Override
|
||||
public void setValueAsString(String theValue) throws IllegalArgumentException {
|
||||
// Null values still result in non-null instance being created
|
||||
if (theValue != null) checkValidBase64(theValue);
|
||||
fromStringValue(theValue);
|
||||
setValue(parse(theValue));
|
||||
}
|
||||
|
|
|
@ -9,11 +9,19 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||
|
||||
class Base64BinaryTypeTest {
|
||||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
String nonBase64 = "Picard was the best starship captain.";
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(nonBase64));
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to setValueAsString causes exception.")
|
||||
public void testNonBase64StringValueSet() {
|
||||
Base64BinaryType instance = new Base64BinaryType();
|
||||
assertThrows(DataFormatException.class, () -> instance.setValueAsString(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -26,13 +34,33 @@ class Base64BinaryTypeTest {
|
|||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("setValueAsString with null argument value sets instance value as null.")
|
||||
public void testNullSetValueAsString() throws DataFormatException {
|
||||
String v = null;
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(v);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNull(b64.getValue());
|
||||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValid() {
|
||||
String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
Base64BinaryType b64 = new Base64BinaryType(v);
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(v, b64.asStringValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValidSetValueAsString() {
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(VALID_BASE_64);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
}
|
|
@ -68,7 +68,6 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
public Base64BinaryType(String theValue) {
|
||||
super();
|
||||
// Null values still result in non-null instance being created
|
||||
if (theValue != null) checkValidBase64(theValue);
|
||||
setValueAsString(theValue);
|
||||
}
|
||||
|
||||
|
@ -118,6 +117,7 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
|
||||
@Override
|
||||
public void setValueAsString(String theValue) throws IllegalArgumentException {
|
||||
if (theValue != null) checkValidBase64(theValue);
|
||||
fromStringValue(theValue);
|
||||
setValue(parse(theValue));
|
||||
}
|
||||
|
|
|
@ -9,11 +9,19 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||
|
||||
class Base64BinaryTypeTest {
|
||||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
String nonBase64 = "Picard was the best starship captain.";
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(nonBase64));
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to setValueAsString causes exception.")
|
||||
public void testNonBase64StringValueSet() {
|
||||
Base64BinaryType instance = new Base64BinaryType();
|
||||
assertThrows(DataFormatException.class, () -> instance.setValueAsString(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -26,13 +34,33 @@ class Base64BinaryTypeTest {
|
|||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("setValueAsString with null argument value sets instance value as null.")
|
||||
public void testNullSetValueAsString() throws DataFormatException {
|
||||
String v = null;
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(v);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNull(b64.getValue());
|
||||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValid() {
|
||||
String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
Base64BinaryType b64 = new Base64BinaryType(v);
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(v, b64.asStringValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValidSetValueAsString() {
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(VALID_BASE_64);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
}
|
|
@ -67,7 +67,6 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
public Base64BinaryType(String theValue) {
|
||||
super();
|
||||
// Null values still result in non-null instance being created
|
||||
if (theValue != null) checkValidBase64(theValue);
|
||||
setValueAsString(theValue);
|
||||
}
|
||||
|
||||
|
@ -117,6 +116,7 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
|
||||
@Override
|
||||
public void setValueAsString(String theValue) throws IllegalArgumentException {
|
||||
if (theValue != null) checkValidBase64(theValue);
|
||||
fromStringValue(theValue);
|
||||
setValue(parse(theValue));
|
||||
}
|
||||
|
|
|
@ -10,11 +10,19 @@ import ca.uhn.fhir.parser.DataFormatException;
|
|||
|
||||
class Base64BinaryTypeTest {
|
||||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
String nonBase64 = "Picard was the best starship captain.";
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(nonBase64));
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to setValueAsString causes exception.")
|
||||
public void testNonBase64StringValueSet() {
|
||||
Base64BinaryType instance = new Base64BinaryType();
|
||||
assertThrows(DataFormatException.class, () -> instance.setValueAsString(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -28,13 +36,32 @@ class Base64BinaryTypeTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValid() {
|
||||
String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
Base64BinaryType b64 = new Base64BinaryType(v);
|
||||
@DisplayName("setValueAsString with null argument value sets instance value as null.")
|
||||
public void testNullSetValueAsString() throws DataFormatException {
|
||||
String v = null;
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(v);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(v, b64.asStringValue());
|
||||
Assertions.assertNull(b64.getValue());
|
||||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValid() {
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64);
|
||||
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() {
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(VALID_BASE_64);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
}
|
|
@ -67,7 +67,6 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
public Base64BinaryType(String theValue) {
|
||||
super();
|
||||
// Null values still result in non-null instance being created
|
||||
if (theValue != null) checkValidBase64(theValue);
|
||||
setValueAsString(theValue);
|
||||
}
|
||||
|
||||
|
@ -117,6 +116,7 @@ public class Base64BinaryType extends PrimitiveType<byte[]> implements IPrimitiv
|
|||
|
||||
@Override
|
||||
public void setValueAsString(String theValue) throws IllegalArgumentException {
|
||||
if (theValue != null) checkValidBase64(theValue);
|
||||
fromStringValue(theValue);
|
||||
setValue(parse(theValue));
|
||||
}
|
||||
|
|
|
@ -10,11 +10,19 @@ import ca.uhn.fhir.parser.DataFormatException;
|
|||
|
||||
class Base64BinaryTypeTest {
|
||||
|
||||
static final String NON_BASE_64 = "Picard was the best starship captain.";
|
||||
static final String VALID_BASE_64 = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to constructor causes exception.")
|
||||
public void testNonBase64String() {
|
||||
String nonBase64 = "Picard was the best starship captain.";
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(nonBase64));
|
||||
assertThrows(DataFormatException.class, () -> new Base64BinaryType(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Passing a non Base64 encoded String to setValueAsString causes exception.")
|
||||
public void testNonBase64StringValueSet() {
|
||||
Base64BinaryType instance = new Base64BinaryType();
|
||||
assertThrows(DataFormatException.class, () -> instance.setValueAsString(NON_BASE_64));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -28,13 +36,32 @@ class Base64BinaryTypeTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValid() {
|
||||
String v = "dGhpcyBpcyB2YWxpZCBiYXNlNjQ=";
|
||||
Base64BinaryType b64 = new Base64BinaryType(v);
|
||||
@DisplayName("setValueAsString with null argument value sets instance value as null.")
|
||||
public void testNullSetValueAsString() throws DataFormatException {
|
||||
String v = null;
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(v);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(v, b64.asStringValue());
|
||||
Assertions.assertNull(b64.getValue());
|
||||
Assertions.assertNull(b64.getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Valid Base64 String creates non-null instance with non-null values.")
|
||||
public void testValid() {
|
||||
Base64BinaryType b64 = new Base64BinaryType(VALID_BASE_64);
|
||||
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() {
|
||||
Base64BinaryType b64 = new Base64BinaryType();
|
||||
b64.setValueAsString(VALID_BASE_64);
|
||||
Assertions.assertNotNull(b64);
|
||||
Assertions.assertNotNull(b64.getValue());
|
||||
Assertions.assertEquals(VALID_BASE_64, b64.asStringValue());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue