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());
}
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"));
}
Aggregations