Handle toString for XhtmlNode when nodeType == null

This commit is contained in:
dotasek 2024-01-18 14:17:54 -05:00
parent 2156a44395
commit 8ab4340014
2 changed files with 19 additions and 0 deletions

View File

@ -626,6 +626,9 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml {
@Override @Override
public String toString() { public String toString() {
if (nodeType == null) {
return super.toString();
}
switch (nodeType) { switch (nodeType) {
case Document: case Document:
case Element: case Element:

View File

@ -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");
}
}