Search in sources :

Example 6 with DBListClass

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

the class UsedValuesListQueryBuilderTest method configure.

@Before
public void configure() throws Exception {
    this.queryManager = this.mocker.getInstance(QueryManager.class);
    this.authorization = this.mocker.getInstance(ContextualAuthorizationManager.class);
    this.documentReferenceResolver = this.mocker.getInstance(DocumentReferenceResolver.TYPE_STRING, "current");
    DocumentReference oneReference = new DocumentReference("wiki", "Page", "one");
    when(this.documentReferenceResolver.resolve("alice")).thenReturn(oneReference);
    when(this.authorization.hasAccess(Right.VIEW, oneReference)).thenReturn(false);
    DocumentReference twoReference = new DocumentReference("wiki", "Page", "two");
    when(this.documentReferenceResolver.resolve("alice")).thenReturn(twoReference);
    when(this.authorization.hasAccess(Right.VIEW, twoReference)).thenReturn(true);
    BaseClass xclass = new BaseClass();
    xclass.setDocumentReference(new DocumentReference("apps", "Blog", "BlogPostClass"));
    PropertyMetaClass metaClass = mock(PropertyMetaClass.class);
    when(metaClass.getName()).thenReturn("Blog.BlogPostClass");
    this.listClass = new DBListClass();
    this.listClass.setName("category");
    this.listClass.setObject(xclass);
    this.listClass.setxWikiClass(metaClass);
}
Also used : ContextualAuthorizationManager(org.xwiki.security.authorization.ContextualAuthorizationManager) DBListClass(com.xpn.xwiki.objects.classes.DBListClass) QueryManager(org.xwiki.query.QueryManager) BaseClass(com.xpn.xwiki.objects.classes.BaseClass) DocumentReference(org.xwiki.model.reference.DocumentReference) PropertyMetaClass(com.xpn.xwiki.objects.meta.PropertyMetaClass) Before(org.junit.Before)

Example 7 with DBListClass

use of com.xpn.xwiki.objects.classes.DBListClass 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)

Example 8 with DBListClass

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

the class PropertyConverterTest method singleToMultipleSelectOnUnsetDBList.

@Test
public void singleToMultipleSelectOnUnsetDBList() 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);
    StringProperty stringProperty = mock(StringProperty.class);
    when(stringProperty.getValue()).thenReturn(null);
    assertNull(this.mocker.getComponentUnderTest().convertProperty(stringProperty, dbListClass));
}
Also used : DBListClass(com.xpn.xwiki.objects.classes.DBListClass) StringProperty(com.xpn.xwiki.objects.StringProperty) Test(org.junit.Test)

Aggregations

DBListClass (com.xpn.xwiki.objects.classes.DBListClass)8 Test (org.junit.Test)6 StringListProperty (com.xpn.xwiki.objects.StringListProperty)3 StringProperty (com.xpn.xwiki.objects.StringProperty)3 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)1 PropertyMetaClass (com.xpn.xwiki.objects.meta.PropertyMetaClass)1 Before (org.junit.Before)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 Query (org.xwiki.query.Query)1 QueryManager (org.xwiki.query.QueryManager)1 Link (org.xwiki.rest.model.jaxb.Link)1 PropertyValues (org.xwiki.rest.model.jaxb.PropertyValues)1 ClassPropertyValuesProvider (org.xwiki.rest.resources.classes.ClassPropertyValuesProvider)1 ContextualAuthorizationManager (org.xwiki.security.authorization.ContextualAuthorizationManager)1