@Test public void longToString() throws Exception { LongProperty longProperty = new LongProperty(); longProperty.setValue(Long.MAX_VALUE); StringClass stringClass = mock(StringClass.class); when(stringClass.newProperty()).thenReturn(new StringProperty()); StringProperty stringProperty = new StringProperty(); when(stringClass.fromString(longProperty.toText())).thenReturn(stringProperty); assertEquals(stringProperty, this.mocker.getComponentUnderTest().convertProperty(longProperty, stringClass)); }
public BaseProperty<?> convertProperty(BaseProperty<?> storedProperty, PropertyClass modifiedPropertyClass) { Object newValue = convertPropertyValue(storedProperty.getValue(), modifiedPropertyClass); BaseProperty<?> newProperty = null; if (newValue != null) { newProperty = modifiedPropertyClass.newProperty(); try { newProperty.setValue(newValue); } catch (Exception e) { newProperty = modifiedPropertyClass.fromString(storedProperty.toText()); } if (newProperty != null) { newProperty.setId(storedProperty.getId()); newProperty.setName(storedProperty.getName()); } else { this.logger.warn("Incompatible data migration when changing field [{}] of class [{}]", modifiedPropertyClass.getName(), modifiedPropertyClass.getClassName()); } } else { } return newProperty; }
PropertyConverter { public BaseProperty<?> convertProperty(BaseProperty<?> storedProperty, PropertyClass modifiedPropertyClass) { Object newValue = convertPropertyValue(storedProperty.getValue(), modifiedPropertyClass); BaseProperty<?> newProperty = null; if (newValue != null) { newProperty = modifiedPropertyClass.newProperty(); try { newProperty.setValue(newValue); } catch (Exception e) { newProperty = modifiedPropertyClass.fromString(storedProperty.toText()); } if (newProperty != null) { newProperty.setId(storedProperty.getId()); newProperty.setName(storedProperty.getName()); } else { this.logger.warn("Incompatible data migration when changing field [{}] of class [{}]", modifiedPropertyClass.getName(), modifiedPropertyClass.getClassName()); } } else { } return newProperty; } }
PropertyConverter { public BaseProperty<?> convertProperty(BaseProperty<?> storedProperty, PropertyClass modifiedPropertyClass) { Object newValue = convertPropertyValue(storedProperty.getValue(), modifiedPropertyClass); BaseProperty<?> newProperty = null; if (newValue != null) { newProperty = modifiedPropertyClass.newProperty(); try { newProperty.setValue(newValue); } catch (Exception e) { newProperty = modifiedPropertyClass.fromString(storedProperty.toText()); } if (newProperty != null) { newProperty.setId(storedProperty.getId()); newProperty.setName(storedProperty.getName()); } else { this.logger.warn("Incompatible data migration when changing field [{}] of class [{}]", modifiedPropertyClass.getName(), modifiedPropertyClass.getClassName()); } } else { } return newProperty; }  }
PropertyConverter { public BaseProperty<?> convertProperty(BaseProperty<?> storedProperty, PropertyClass modifiedPropertyClass) { Object newValue = convertPropertyValue(storedProperty.getValue(), modifiedPropertyClass); BaseProperty<?> newProperty = null; if (newValue != null) { newProperty = modifiedPropertyClass.newProperty(); try { newProperty.setValue(newValue); } catch (Exception e) { newProperty = modifiedPropertyClass.fromString(storedProperty.toText()); } if (newProperty != null) { newProperty.setId(storedProperty.getId()); newProperty.setName(storedProperty.getName()); } else { this.logger.warn("Incompatible data migration when changing field [{}] of class [{}]", modifiedPropertyClass.getName(), modifiedPropertyClass.getClassName()); } } else { } return newProperty; }  BaseProperty<?> convertProperty(BaseProperty<?> storedProperty, PropertyClass modifiedPropertyClass); }
PropertyConverter { public BaseProperty<?> convertProperty(BaseProperty<?> storedProperty, PropertyClass modifiedPropertyClass) { Object newValue = convertPropertyValue(storedProperty.getValue(), modifiedPropertyClass); BaseProperty<?> newProperty = null; if (newValue != null) { newProperty = modifiedPropertyClass.newProperty(); try { newProperty.setValue(newValue); } catch (Exception e) { newProperty = modifiedPropertyClass.fromString(storedProperty.toText()); } if (newProperty != null) { newProperty.setId(storedProperty.getId()); newProperty.setName(storedProperty.getName()); } else { this.logger.warn("Incompatible data migration when changing field [{}] of class [{}]", modifiedPropertyClass.getName(), modifiedPropertyClass.getClassName()); } } else { } return newProperty; }  BaseProperty<?> convertProperty(BaseProperty<?> storedProperty, PropertyClass modifiedPropertyClass);  }