/** * {@inheritDoc} */ @Override protected AbstractPropertyUpdate<Float> createPropertyUpdate(Float updateValue) { return new PercentagePropertyUpdate(this, updateValue); }
@Test public void floatPropertyUpdateXmlSaveLoad() throws PropertyValidationException, JAXBException { float value = new Random().nextInt(100); if (1 == value) { // make sure we don't update with same value value++; } PercentageProperty floatProperty = new PercentageProperty("name", "description", "logical-name", Float.valueOf(1), false, false); AbstractPropertyUpdate<Float> floatPropertyUpdate = floatProperty.createAndValidatePropertyUpdate(Float.valueOf(value)); JAXBContext context = JAXBContext.newInstance(PercentagePropertyUpdate.class); Marshaller marshaller = context.createMarshaller(); Unmarshaller unmarshaller = context.createUnmarshaller(); marshaller.marshal(floatPropertyUpdate, f); Object object = unmarshaller.unmarshal(f); assertThat(object, is(instanceOf(PercentagePropertyUpdate.class))); PercentagePropertyUpdate unmarsalled = (PercentagePropertyUpdate) object; assertThat(floatProperty.canUpdate(unmarsalled), is(true)); floatProperty.setValue(unmarsalled.getUpdateValue()); assertThat(floatProperty.getValue().floatValue(), is(value)); }