Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ private ExtensionElement extensionElement(Node node) {
}

private boolean isSimpleElementNode(Node node) {
return node.getChildNodes().getLength() == 1
&& isTextualNode(node.getFirstChild());
return (node.getChildNodes().getLength() == 1
&& isTextualNode(node.getFirstChild()))
|| node.getChildNodes().getLength() == 0;
}

private boolean isTextualNode(Node node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ public void unmarshal_single_simple_element() throws Exception {
.build());
}

@Test
public void unmarshal_single_simple_void_element() throws Exception {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On peut aussi ajouter un test d'un élément sans attribut ?

String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<root xmlns=\"http://www.w3.org/2005/Atom\">\n" +
" <any:element xmlns:any=\"http://foo.bar.net/-/any/\"/>\n" +
"</root>";

ExtensionElement result = unmarshalElement(xml);

assertThat(result).isEqualTo(ExtensionElements.simpleElement("element", "")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cela doit être un structured element, et ce qu'on marshall c'est aussi un structured (contient un attribut). Voir les autres échanges sur la PR

.withNamespace(ANY_NAMESPACE)
.addAttribute(XMLNS_ATTRIBUTE)
.addAttribute(Attribute.builder("any", "http://foo.bar.net/-/any/")
.withNamespace(XMLNS_NAMESPACE)
.build())
.build());
}

@Test
public void unmarshal_structured_element_with_single_child() throws Exception {
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
Expand Down