Search in sources :

Example 1 with StringListProperty

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

the class PropertyConverterTest method multipleToSingleSelectOnEmptyDBList.

@Test
public void multipleToSingleSelectOnEmptyDBList() throws Exception {
    // The Database List property that was switched from multiple select to single select.
    DBListClass dbListClass = mock(DBListClass.class);
    when(dbListClass.isMultiSelect()).thenReturn(false);
    StringListProperty emptyListProperty = mock(StringListProperty.class);
    when(emptyListProperty.getValue()).thenReturn(Arrays.asList());
    assertNull(this.mocker.getComponentUnderTest().convertProperty(emptyListProperty, dbListClass));
}
Also used : DBListClass(com.xpn.xwiki.objects.classes.DBListClass) StringListProperty(com.xpn.xwiki.objects.StringListProperty) Test(org.junit.Test)

Example 2 with StringListProperty

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

the class PropertyConverterTest method multipleToSingleSelectOnDBList.

@Test
public void multipleToSingleSelectOnDBList() throws Exception {
    // The Database List property that was switched from multiple select to single select.
    DBListClass dbListClass = mock(DBListClass.class);
    when(dbListClass.isMultiSelect()).thenReturn(false);
    StringProperty stringProperty = mock(StringProperty.class);
    when(dbListClass.newProperty()).thenReturn(stringProperty);
    StringListProperty stringListProperty = mock(StringListProperty.class);
    when(stringListProperty.getValue()).thenReturn(Arrays.asList("one", "two"));
    assertEquals(stringProperty, this.mocker.getComponentUnderTest().convertProperty(stringListProperty, dbListClass));
    verify(stringProperty).setValue("one");
}
Also used : DBListClass(com.xpn.xwiki.objects.classes.DBListClass) StringProperty(com.xpn.xwiki.objects.StringProperty) StringListProperty(com.xpn.xwiki.objects.StringListProperty) Test(org.junit.Test)

Example 3 with StringListProperty

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

the class PropertyConverterTest method singleToMultipleSelectOnDBList.

@Test
public void singleToMultipleSelectOnDBList() throws Exception {
    // The Database List property that was switched from single select to multiple select.
    DBListClass dbListClass = mock(DBListClass.class);
    when(dbListClass.isMultiSelect()).thenReturn(true);
    StringListProperty stringListProperty = mock(StringListProperty.class);
    when(dbListClass.newProperty()).thenReturn(stringListProperty);
    StringProperty stringProperty = mock(StringProperty.class);
    when(stringProperty.getValue()).thenReturn("one");
    assertEquals(stringListProperty, this.mocker.getComponentUnderTest().convertProperty(stringProperty, dbListClass));
    verify(stringListProperty).setValue(Arrays.asList("one"));
}
Also used : DBListClass(com.xpn.xwiki.objects.classes.DBListClass) StringProperty(com.xpn.xwiki.objects.StringProperty) StringListProperty(com.xpn.xwiki.objects.StringListProperty) Test(org.junit.Test)

Aggregations

StringListProperty (com.xpn.xwiki.objects.StringListProperty)3 DBListClass (com.xpn.xwiki.objects.classes.DBListClass)3 Test (org.junit.Test)3 StringProperty (com.xpn.xwiki.objects.StringProperty)2