Skip to content
Merged
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
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.dataformat.xml.records.failing;
package com.fasterxml.jackson.dataformat.xml.records.tofix;

import org.junit.jupiter.api.Test;

Expand All @@ -9,8 +9,8 @@

import static org.junit.jupiter.api.Assertions.*;

// [dataformat-xml#734]
public class XmlRecordDeser734Test extends XmlTestUtil
// [dataformat-xml#735]
public class XmlRecordDeser735Test extends XmlTestUtil
{
record Amount(@JacksonXmlText String value,
@JacksonXmlProperty(isAttribute = true, localName = "Ccy") String currency) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.dataformat.xml.records.failing;
package com.fasterxml.jackson.dataformat.xml.records.tofix;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.fasterxml.jackson.dataformat.xml.deser;

import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

// [dataformat-xml#735]
public class XmlClassDeser735Test extends XmlTestUtil
{
public static class Amount {
@JacksonXmlText
private String value;

@JacksonXmlProperty(isAttribute = true, localName = "Ccy")
private String currency;

// Need default constructor for deserialization (failure without it)
public Amount() {

}

public Amount(String value, String currency) {
this.value = value;
this.currency = currency;
}

public String getValue() {
return value;
}

public String getCurrency() {
return currency;
}
}

private final String XML =
a2q("<Amt Ccy='EUR'>1</Amt>");

@Test
public void testDeser() throws Exception {
XmlMapper mapper = new XmlMapper();
Amount amt = mapper.readValue(XML, Amount.class);
assertEquals("1", amt.value);
assertEquals("EUR", amt.currency);
}
}