use of com.xpn.xwiki.objects.classes.DBListClass in project xwiki-platform by xwiki.
the class ClassPropertyValuesResourceImplTest method getClassPropertyValues.
@Test
public void getClassPropertyValues() throws Exception {
when(this.authorization.hasAccess(Right.VIEW, this.propertyReference)).thenReturn(true);
when(this.xclass.get("status")).thenReturn(new DBListClass());
PropertyValues values = new PropertyValues();
ClassPropertyValuesProvider propertyValuesProvider = this.mocker.getInstance(ClassPropertyValuesProvider.class);
when(propertyValuesProvider.getValues(this.propertyReference, 6, "one", "two")).thenReturn(values);
assertSame(values, this.resource.getClassPropertyValues("wiki", "Path.To.Class", "status", 6, Arrays.asList("one", "two")));
assertEquals(1, values.getLinks().size());
Link propertyLink = values.getLinks().get(0);
assertEquals("/xwiki/rest/wikis/wiki/classes/Path.To.Class/properties/status", propertyLink.getHref());
assertEquals(Relations.PROPERTY, propertyLink.getRel());
}
use of com.xpn.xwiki.objects.classes.DBListClass in project xwiki-platform by xwiki.
the class WatchListClassDocumentInitializer method addWatchedElementField.
/**
* @param xclass the class to add to
* @param name the name of the property to add
* @param prettyName the pretty name of the property to add
*/
private void addWatchedElementField(BaseClass xclass, String name, String prettyName) {
xclass.addDBListField(name, prettyName, 80, true, null);
// Set the input display type in order to easily debug from the object editor.
DBListClass justAddedProperty = (DBListClass) xclass.get(name);
justAddedProperty.setDisplayType(ListClass.DISPLAYTYPE_INPUT);
}
use of com.xpn.xwiki.objects.classes.DBListClass 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));
}
use of com.xpn.xwiki.objects.classes.DBListClass 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");
}
use of com.xpn.xwiki.objects.classes.DBListClass in project xwiki-platform by xwiki.
the class DefaultDBListQueryBuilderTest method build.
@Test
public void build() throws Exception {
DBListClass dbListClass = new DBListClass();
DefaultParameterizedType dbListQueryBuilderType = new DefaultParameterizedType(null, QueryBuilder.class, DBListClass.class);
QueryBuilder<DBListClass> explicitlyAllowedValuesQueryBuilder = this.mocker.getInstance(dbListQueryBuilderType, "explicitlyAllowedValues");
QueryBuilder<DBListClass> implicitlyAllowedValuesQueryBuilder = this.mocker.getInstance(dbListQueryBuilderType, "implicitlyAllowedValues");
Query explicitlyAllowedValuesQuery = mock(Query.class, "explicit");
when(explicitlyAllowedValuesQueryBuilder.build(dbListClass)).thenReturn(explicitlyAllowedValuesQuery);
Query implicitlyAllowedValuesQuery = mock(Query.class, "implicit");
when(implicitlyAllowedValuesQueryBuilder.build(dbListClass)).thenReturn(implicitlyAllowedValuesQuery);
assertSame(implicitlyAllowedValuesQuery, this.mocker.getComponentUnderTest().build(dbListClass));
dbListClass.setSql("test");
assertSame(explicitlyAllowedValuesQuery, this.mocker.getComponentUnderTest().build(dbListClass));
}
Aggregations