use of com.xpn.xwiki.objects.DoubleProperty in project xwiki-platform by xwiki.
the class PropertyConverterTest method doubleToInteger.
/**
* @see XWIKI-8649: Error when changing the number type of a field from an application
*/
@Test
public void doubleToInteger() throws Exception {
// The number property whose type has changed from Double to Integer.
NumberClass numberClass = mock(NumberClass.class);
IntegerProperty integerProperty = mock(IntegerProperty.class);
when(numberClass.newProperty()).thenReturn(integerProperty);
when(numberClass.getNumberType()).thenReturn("integer");
DoubleProperty doubleProperty = mock(DoubleProperty.class);
when(doubleProperty.getValue()).thenReturn(3.5);
assertEquals(integerProperty, this.mocker.getComponentUnderTest().convertProperty(doubleProperty, numberClass));
verify(integerProperty).setValue(3);
}
use of com.xpn.xwiki.objects.DoubleProperty in project xwiki-platform by xwiki.
the class PropertyConverterTest method unsetDoubleToInteger.
@Test
public void unsetDoubleToInteger() throws Exception {
NumberClass numberClass = mock(NumberClass.class);
DoubleProperty unsetDoubleProperty = mock(DoubleProperty.class, "unset");
assertNull(this.mocker.getComponentUnderTest().convertProperty(unsetDoubleProperty, numberClass));
}
use of com.xpn.xwiki.objects.DoubleProperty in project xwiki-platform by xwiki.
the class NumberClass method newProperty.
@Override
public BaseProperty newProperty() {
String ntype = getNumberType();
BaseProperty property;
if (ntype.equals("integer")) {
property = new IntegerProperty();
} else if (ntype.equals("float")) {
property = new FloatProperty();
} else if (ntype.equals("double")) {
property = new DoubleProperty();
} else {
property = new LongProperty();
}
property.setName(getName());
return property;
}
Aggregations