XmlEstimationSpec extends ec.demetra.xml.modelling.XmlEstimationSpec { public void setUBP(Double value) { if (value != null && value == EstimateSpec.DEF_UBP) { ubp = null; } else { ubp = value; } }  Double getPrecision(); void setPrecision(Double value); boolean isEML(); void setEML(Boolean value); Double getUBP(); void setUBP(Double value); static final InPlaceXmlUnmarshaller<XmlEstimationSpec, EstimateSpec> UNMARSHALLER; static final IXmlMarshaller<XmlEstimationSpec, EstimateSpec> MARSHALLER; }
@Test @Ignore public void testMarshal() throws FileNotFoundException, JAXBException, IOException, Exception { TramoSpecification spec = TramoSpecification.TRfull; EstimateSpec espec = spec.getEstimate().clone(); espec.setUbp(1); TsPeriodSelector sel = new TsPeriodSelector(); sel.last(120); espec.setSpan(sel); XmlEstimationSpec xspec = XmlEstimationSpec.MARSHALLER.marshal(espec); JAXBContext jaxb = JAXBContext.newInstance(xspec.getClass()); FileOutputStream ostream = new FileOutputStream(FILE); try (OutputStreamWriter writer = new OutputStreamWriter(ostream, StandardCharsets.UTF_8)) { Marshaller marshaller = jaxb.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(xspec, writer); writer.flush(); } XmlEstimationSpec rslt; FileInputStream istream = new FileInputStream(FILE); try (InputStreamReader reader = new InputStreamReader(istream, StandardCharsets.UTF_8)) { Unmarshaller unmarshaller = jaxb.createUnmarshaller(); rslt = (XmlEstimationSpec) unmarshaller.unmarshal(reader); EstimateSpec nspec = new EstimateSpec(); XmlEstimationSpec.UNMARSHALLER.unmarshal(rslt, nspec); assertTrue(nspec.equals(espec)); } }
@Test @Ignore public void testValidation() throws FileNotFoundException, JAXBException, IOException, SAXException, Exception { TramoSpecification spec = TramoSpecification.TRfull; EstimateSpec espec = spec.getEstimate().clone(); espec.setUbp(1); TsPeriodSelector sel = new TsPeriodSelector(); sel.last(120); espec.setSpan(sel); XmlEstimationSpec xspec = XmlEstimationSpec.MARSHALLER.marshal(espec); JAXBContext jaxb = JAXBContext.newInstance(xspec.getClass()); JAXBSource source = new JAXBSource(jaxb, xspec); Validator validator = Schemas.TramoSeats.newValidator(); validator.validate(source); }