Search in sources :

Example 1 with ClassPropertyValuesProvider

use of org.xwiki.rest.resources.classes.ClassPropertyValuesProvider 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());
}
Also used : DBListClass(com.xpn.xwiki.objects.classes.DBListClass) ClassPropertyValuesProvider(org.xwiki.rest.resources.classes.ClassPropertyValuesProvider) PropertyValues(org.xwiki.rest.model.jaxb.PropertyValues) Link(org.xwiki.rest.model.jaxb.Link) Test(org.junit.Test)

Example 2 with ClassPropertyValuesProvider

use of org.xwiki.rest.resources.classes.ClassPropertyValuesProvider in project xwiki-platform by xwiki.

the class DefaultClassPropertyValuesProviderTest method getValues.

@Test
public void getValues() throws Exception {
    ClassPropertyReference propertyReference = new ClassPropertyReference("category", this.classReference);
    ClassPropertyValuesProvider dbListValuesProvider = mock(ClassPropertyValuesProvider.class);
    ComponentManager contextComponentManager = this.mocker.getInstance(ComponentManager.class, "context");
    PropertyValues values = new PropertyValues();
    when(contextComponentManager.getInstance(ClassPropertyValuesProvider.class, "DBList")).thenReturn(dbListValuesProvider);
    when(dbListValuesProvider.getValues(propertyReference, 13, "one", "two")).thenReturn(values);
    assertSame(values, this.mocker.getComponentUnderTest().getValues(propertyReference, 13, "one", "two"));
}
Also used : ClassPropertyValuesProvider(org.xwiki.rest.resources.classes.ClassPropertyValuesProvider) PropertyValues(org.xwiki.rest.model.jaxb.PropertyValues) ComponentManager(org.xwiki.component.manager.ComponentManager) ClassPropertyReference(org.xwiki.model.reference.ClassPropertyReference) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 PropertyValues (org.xwiki.rest.model.jaxb.PropertyValues)2 ClassPropertyValuesProvider (org.xwiki.rest.resources.classes.ClassPropertyValuesProvider)2 DBListClass (com.xpn.xwiki.objects.classes.DBListClass)1 ComponentManager (org.xwiki.component.manager.ComponentManager)1 ClassPropertyReference (org.xwiki.model.reference.ClassPropertyReference)1 Link (org.xwiki.rest.model.jaxb.Link)1