*/
private Resource buildResource(String fullpath, Iterable<Resource> children, ResourceResolver resourceResolver, ResourceProvider provider, String ... properties) {
Resource resource = Mockito.mock(Resource.class);
Mockito.when(resource.getName()).thenReturn(getName(fullpath));
Mockito.when(resource.getPath()).thenReturn(fullpath);
ResourceMetadata resourceMetadata = new ResourceMetadata();
Mockito.when(resource.getResourceMetadata()).thenReturn(resourceMetadata);
Mockito.when(resource.listChildren()).thenReturn(children.iterator());
Mockito.when(resource.getResourceResolver()).thenReturn(resourceResolver);
// register the resource with the provider
if ( provider != null ) {
Mockito.when(provider.listChildren(resource)).thenReturn(children.iterator());
if ( resourceResolver != null) {
Mockito.when(provider.getResource(Mockito.eq(resourceResolver), Mockito.eq(fullpath))).thenReturn(resource);
Mockito.when(provider.getResource(Mockito.eq(resourceResolver), Mockito.any(HttpServletRequest.class), Mockito.eq(fullpath))).thenReturn(resource);
} else {
Mockito.when(provider.getResource(Mockito.any(ResourceResolver.class), Mockito.eq(fullpath))).thenReturn(resource);
Mockito.when(provider.getResource(Mockito.any(ResourceResolver.class), Mockito.any(HttpServletRequest.class), Mockito.eq(fullpath))).thenReturn(resource);
}
}
if ( properties != null ) {
ValueMap vm = new SimpleValueMapImpl();
for ( int i=0; i < properties.length; i+=2) {
resourceMetadata.put(properties[i], properties[i+1]);
vm.put(properties[i], properties[i+1]);
}
Mockito.when(resource.getValueMap()).thenReturn(vm);
Mockito.when(resource.adaptTo(Mockito.eq(ValueMap.class))).thenReturn(vm);
} else {