Merge pull request #1547 from hapifhir/do-20240118-fix-null-ex-on-xhtml-tostring
Handle toString for XhtmlNode when nodeType == null
This commit is contained in:
commit
8a3f1037b3
|
@ -626,6 +626,9 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (nodeType == null) {
|
||||
return super.toString();
|
||||
}
|
||||
switch (nodeType) {
|
||||
case Document:
|
||||
case Element:
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package org.hl7.fhir.utilities.xhtml;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class XhtmlTests {
|
||||
|
||||
@Test
|
||||
public void testToStringOnNullType()
|
||||
{
|
||||
XhtmlNode node = new XhtmlNode(null, "Blah");
|
||||
String actual = node.toString();
|
||||
assertTrue(actual.startsWith("org.hl7.fhir.utilities.xhtml.XhtmlNode@"), "toString() should return java the toString default method for objects, which starts with the full class name");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue