Search in sources :

Example 1 with LongProperty

use of com.xpn.xwiki.objects.LongProperty 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;
}
Also used : IntegerProperty(com.xpn.xwiki.objects.IntegerProperty) LongProperty(com.xpn.xwiki.objects.LongProperty) BaseProperty(com.xpn.xwiki.objects.BaseProperty) FloatProperty(com.xpn.xwiki.objects.FloatProperty) DoubleProperty(com.xpn.xwiki.objects.DoubleProperty)

Example 2 with LongProperty

use of com.xpn.xwiki.objects.LongProperty in project xwiki-platform by xwiki.

the class PropertyConverterTest method longToString.

@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));
}
Also used : StringClass(com.xpn.xwiki.objects.classes.StringClass) LongProperty(com.xpn.xwiki.objects.LongProperty) StringProperty(com.xpn.xwiki.objects.StringProperty) Test(org.junit.Test)

Aggregations

LongProperty (com.xpn.xwiki.objects.LongProperty)2 BaseProperty (com.xpn.xwiki.objects.BaseProperty)1 DoubleProperty (com.xpn.xwiki.objects.DoubleProperty)1 FloatProperty (com.xpn.xwiki.objects.FloatProperty)1 IntegerProperty (com.xpn.xwiki.objects.IntegerProperty)1 StringProperty (com.xpn.xwiki.objects.StringProperty)1 StringClass (com.xpn.xwiki.objects.classes.StringClass)1 Test (org.junit.Test)1