eeisi_full_300 JSON roundtrip
This commit is contained in:
@@ -31,8 +31,8 @@ import org.w3c.dom.Node;
|
|||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
public class ClassCode {
|
public class ClassCode {
|
||||||
private final String listID;
|
private String listID;
|
||||||
private final String code;
|
private String code;
|
||||||
private String listVersionID;
|
private String listVersionID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,6 +58,13 @@ public class ClassCode {
|
|||||||
this(listID, code, null);
|
this(listID, code, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* bean constructor
|
||||||
|
*/
|
||||||
|
public ClassCode() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Set the version for the scheme returned by {@link #getListID()}
|
* Set the version for the scheme returned by {@link #getListID()}
|
||||||
* @param listVersionID the scheme version
|
* @param listVersionID the scheme version
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.mustangproject;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||||
import org.mustangproject.ZUGFeRD.IDesignatedProductClassification;
|
import org.mustangproject.ZUGFeRD.IDesignatedProductClassification;
|
||||||
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct;
|
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct;
|
||||||
import org.mustangproject.util.NodeMap;
|
import org.mustangproject.util.NodeMap;
|
||||||
@@ -32,6 +33,7 @@ public class Product implements IZUGFeRDExportableProduct {
|
|||||||
protected SchemedID globalId = null;
|
protected SchemedID globalId = null;
|
||||||
protected String countryOfOrigin = null;
|
protected String countryOfOrigin = null;
|
||||||
protected HashMap<String, String> attributes = new HashMap<>();
|
protected HashMap<String, String> attributes = new HashMap<>();
|
||||||
|
|
||||||
protected List<IDesignatedProductClassification> classifications = new ArrayList<>();
|
protected List<IDesignatedProductClassification> classifications = new ArrayList<>();
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@@ -365,6 +367,23 @@ public class Product implements IZUGFeRDExportableProduct {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide Jackson a hint as to use DesignatedProductClassification for the
|
||||||
|
* IDesignatedProductClassification product classifications
|
||||||
|
*
|
||||||
|
* @param classifications the new set of classifications
|
||||||
|
* @return fluent setter
|
||||||
|
*/
|
||||||
|
@JsonSetter("classifications")
|
||||||
|
public Product setClassificationsClass(DesignatedProductClassification[] classifications) {
|
||||||
|
this.classifications.clear();
|
||||||
|
if (classifications != null) {
|
||||||
|
this.classifications.addAll(Arrays.asList(classifications));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a {@link IDesignatedProductClassification} classification
|
* Add a {@link IDesignatedProductClassification} classification
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
@@ -165,6 +166,34 @@ public class DeSerializationTest extends ResourceCase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testFull300Roundtrip() {
|
||||||
|
File inputCII = getResourceAsFile("not_validating_full_invoice_based_onTest_EeISI_300_CENfullmodel.cii.xml");
|
||||||
|
|
||||||
|
Invoice i=new Invoice();
|
||||||
|
String exText=null;
|
||||||
|
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter();
|
||||||
|
zii.doIgnoreCalculationErrors();
|
||||||
|
try {
|
||||||
|
zii.fromXML(new String(Files.readAllBytes(inputCII.toPath()), StandardCharsets.UTF_8));
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
zii.extractInto(i);
|
||||||
|
String json = mapper.writeValueAsString(i);
|
||||||
|
Invoice newInvoiceFromJSON = mapper.readValue(json, Invoice.class);
|
||||||
|
|
||||||
|
assertEquals("Test_EeISI_100",i.getNumber());
|
||||||
|
assertEquals(newInvoiceFromJSON.getNumber(),i.getNumber());
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
exText=e.getMessage();
|
||||||
|
} catch (XPathExpressionException e) {
|
||||||
|
exText=e.getMessage();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
exText=e.getMessage();
|
||||||
|
}
|
||||||
|
assertNull(exText);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void testIssuerAssignedIDRoundtrip() {
|
public void testIssuerAssignedIDRoundtrip() {
|
||||||
String occurrenceFrom = "20201001";
|
String occurrenceFrom = "20201001";
|
||||||
|
|||||||
Reference in New Issue
Block a user