[ARVADOS] updated: 1.1.2-187-gc2a0759

Git user git at public.curoverse.com
Tue Jan 23 04:50:34 EST 2018


Summary of changes:
 sdk/R/R/Arvados.R                            | 246 ++----------
 sdk/R/R/Collection.R                         |  14 +-
 sdk/R/R/RESTService.R                        | 222 +++++++++--
 sdk/R/tests/testthat/fakes/FakeHttpParser.R  |   8 +
 sdk/R/tests/testthat/fakes/FakeRESTService.R |  54 +++
 sdk/R/tests/testthat/test-Arvados.R          | 559 +++------------------------
 sdk/R/tests/testthat/test-ArvadosFile.R      |  63 +--
 sdk/R/tests/testthat/test-Collection.R       |  90 ++---
 sdk/R/tests/testthat/test-RESTService.R      | 549 ++++++++++++++++++--------
 sdk/R/tests/testthat/test-Subcollection.R    |  41 +-
 10 files changed, 792 insertions(+), 1054 deletions(-)

       via  c2a07597440e4db06481d2532adc317331df441b (commit)
      from  1499d395e3d2ef62334e349f7bc4ae2cfd0418aa (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit c2a07597440e4db06481d2532adc317331df441b
Author: Fuad Muhic <fmuhic at capeannenterprises.com>
Date:   Tue Jan 23 10:45:28 2018 +0100

    Factored out HttpRequest and HttpParser classes from Arvados class to
    RESTService class
    
    Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic at capeannenterprises.com>

diff --git a/sdk/R/R/Arvados.R b/sdk/R/R/Arvados.R
index 582a7ab..cb36e49 100644
--- a/sdk/R/R/Arvados.R
+++ b/sdk/R/R/Arvados.R
@@ -1,6 +1,6 @@
+source("./R/RESTService.R")
 source("./R/HttpRequest.R")
 source("./R/HttpParser.R")
-source("./R/RESTService.R")
 
 #' Arvados SDK Object
 #'
@@ -16,97 +16,47 @@ Arvados <- R6::R6Class(
 
     public = list(
 
-        initialize = function(auth_token = NULL, host_name = NULL)
+        initialize = function(authToken = NULL, hostName = NULL)
         {
-            if(!is.null(host_name))
-               Sys.setenv(ARVADOS_API_HOST = host_name)
+            if(!is.null(hostName))
+               Sys.setenv(ARVADOS_API_HOST = hostName)
 
-            if(!is.null(auth_token))
-                Sys.setenv(ARVADOS_API_TOKEN = auth_token)
+            if(!is.null(authToken))
+                Sys.setenv(ARVADOS_API_TOKEN = authToken)
 
-            host_name  <- Sys.getenv("ARVADOS_API_HOST");
+            hostName  <- Sys.getenv("ARVADOS_API_HOST");
             token <- Sys.getenv("ARVADOS_API_TOKEN");
 
-            if(host_name == "" | token == "")
+            if(hostName == "" | token == "")
                 stop(paste0("Please provide host name and authentification token",
                             " or set ARVADOS_API_HOST and ARVADOS_API_TOKEN",
                             " environment variables."))
 
-            version <- "v1"
-            host  <- paste0("https://", host_name, "/arvados/", version, "/")
-
-            private$http       <- HttpRequest$new()
-            private$httpParser <- HttpParser$new()
-            private$REST       <- RESTService$new(self)
-            private$token      <- token
-            private$host       <- host
-            private$rawHost    <- host_name
+            private$REST  <- RESTService$new(token, hostName, NULL,
+                                             HttpRequest$new(), HttpParser$new())
+            private$token <- private$REST$token
+            private$host  <- private$REST$hostName
         },
 
-        getToken    = function() private$token,
-        getHostName = function() private$host,
-
-        getHttpClient = function() private$http,
-        setHttpClient = function(newClient) private$http <- newClient,
-
-        getHttpParser = function() private$httpParser,
-        setHttpParser = function(newParser) private$httpParser <- newParser,
-
-        getRESTService = function() private$REST,
-        setRESTService = function(newRESTService) private$REST <- newRESTService,
-
-        getWebDavHostName = function()
-        {
-            if(is.null(private$webDavHostName))
-            {
-                discoveryDocumentURL <- paste0("https://", private$rawHost,
-                                               "/discovery/v1/apis/arvados/v1/rest")
-
-                headers <- list(Authorization = paste("OAuth2", private$token))
-
-                serverResponse <- private$http$GET(discoveryDocumentURL, headers)
-
-                discoveryDocument <- private$httpParser$parseJSONResponse(serverResponse)
-                private$webDavHostName <- discoveryDocument$keepWebServiceUrl
-
-                if(is.null(private$webDavHostName))
-                    stop("Unable to find WebDAV server.")
-            }
-
-            private$webDavHostName
-        },
+        getToken          = function() private$REST$token,
+        getHostName       = function() private$REST$hostName,
+        getWebDavHostName = function() private$REST$getWebDavHostName(),
+        getRESTService    = function() private$REST,
+        setRESTService    = function(newRESTService) private$REST <- newRESTService,
 
         getCollection = function(uuid)
         {
-            collectionURL <- paste0(private$host, "collections/", uuid)
-            headers <- list(Authorization = paste("OAuth2", private$token))
-
-            serverResponse <- private$http$GET(collectionURL, headers)
-
-            collection <- private$httpParser$parseJSONResponse(serverResponse)
-
-            if(!is.null(collection$errors))
-                stop(collection$errors)
-
+            collection <- private$REST$getResource("collections", uuid)
             collection
         },
 
         listCollections = function(filters = NULL, limit = 100, offset = 0)
         {
-            collectionURL <- paste0(private$host, "collections")
-            headers <- list(Authorization = paste("OAuth2", private$token))
-
             if(!is.null(filters))
                 names(filters) <- c("collection")
 
-            serverResponse <- private$http$GET(collectionURL, headers, filters,
-                                               limit, offset)
-
-            collections <- private$httpParser$parseJSONResponse(serverResponse)
-
-            if(!is.null(collections$errors))
-                stop(collections$errors)
-
+            collections <- private$REST$listResources("collections", filters,
+                                                      limit, offset)
             collections
         },
 
@@ -116,145 +66,74 @@ Arvados <- R6::R6Class(
                 names(filters) <- c("collection")
 
             collectionURL <- paste0(private$host, "collections")
-            private$fetchAllItems(collectionURL, filters)
+            allCollection <- private$REST$fetchAllItems(collectionURL, filters)
+            allCollection
         },
 
         deleteCollection = function(uuid)
         {
-            collectionURL <- paste0(private$host, "collections/", uuid)
-            headers <- list("Authorization" = paste("OAuth2", private$token),
-                            "Content-Type"  = "application/json")
-
-            serverResponse <- private$http$DELETE(collectionURL, headers)
-
-            collection <- private$httpParser$parseJSONResponse(serverResponse)
-
-            if(!is.null(collection$errors))
-                stop(collection$errors)
-
-            collection
+            removedCollection <- private$REST$deleteResource("collections", uuid)
+            removedCollection
         },
 
         updateCollection = function(uuid, newContent)
         {
-            collectionURL <- paste0(private$host, "collections/", uuid)
-            headers <- list("Authorization" = paste("OAuth2", private$token),
-                            "Content-Type"  = "application/json")
-
             body <- list(list())
             #test if this is needed
             names(body) <- c("collection")
             body$collection <- newContent
 
-            body <- jsonlite::toJSON(body, auto_unbox = T)
-
-            serverResponse <- private$http$PUT(collectionURL, headers, body)
-
-            collection <- private$httpParser$parseJSONResponse(serverResponse)
-
-            if(!is.null(collection$errors))
-                stop(collection$errors)
-
-            collection
+            updatedCollection <- private$REST$updateResource("collections",
+                                                             uuid, body)
+            updatedCollection
         },
 
         createCollection = function(content)
         {
-            collectionURL <- paste0(private$host, "collections")
-            headers <- list("Authorization" = paste("OAuth2", private$token),
-                            "Content-Type"  = "application/json")
-
             body <- list(list())
             names(body) <- c("collection")
             body$collection <- content
 
-            body <- jsonlite::toJSON(body, auto_unbox = T)
-
-            serverResponse <- private$http$POST(collectionURL, headers, body)
-
-            collection <- private$httpParser$parseJSONResponse(serverResponse)
-
-            if(!is.null(collection$errors))
-                stop(collection$errors)
-
-            collection
+            newCollection <- private$REST$createResource("collections", body)
+            newCollection
         },
 
         getProject = function(uuid)
         {
-            projectURL <- paste0(private$host, "groups/", uuid)
-            headers <- list(Authorization = paste("OAuth2", private$token))
-
-            serverResponse <- private$http$GET(projectURL, headers)
-
-            project <- private$httpParser$parseJSONResponse(serverResponse)
-
-            if(!is.null(project$errors))
-                stop(project$errors)
-
+            project <- private$REST$getResource("groups", uuid)
             project
         },
 
         createProject = function(content)
         {
-            projectURL <- paste0(private$host, "groups")
-            headers <- list("Authorization" = paste("OAuth2", private$token),
-                            "Content-Type"  = "application/json")
-
             body <- list(list())
             names(body) <- c("group")
             body$group <- c("group_class" = "project", content)
-            body <- jsonlite::toJSON(body, auto_unbox = T)
-
-            serverResponse <- private$http$POST(projectURL, headers, body)
 
-            project <- private$httpParser$parseJSONResponse(serverResponse)
-
-            if(!is.null(project$errors))
-                stop(project$errors)
-
-            project
+            newProject <- private$REST$createResource("groups", body)
+            newProject
         },
 
         updateProject = function(uuid, newContent)
         {
-            projectURL <- paste0(private$host, "groups/", uuid)
-            headers <- list("Authorization" = paste("OAuth2", private$token),
-                            "Content-Type"  = "application/json")
-
             body <- list(list())
             names(body) <- c("group")
             body$group <- newContent
-            body <- jsonlite::toJSON(body, auto_unbox = T)
 
-            serverResponse <- private$http$PUT(projectURL, headers, body)
-
-            project <- private$httpParser$parseJSONResponse(serverResponse)
-
-            if(!is.null(project$errors))
-                stop(project$errors)
-
-            project
+            updatedProject <- private$REST$updateResource("groups",
+                                                          uuid, body)
+            updatedProject
         },
 
         listProjects = function(filters = NULL, limit = 100, offset = 0)
         {
-            projectURL <- paste0(private$host, "groups")
-            headers <- list(Authorization = paste("OAuth2", private$token))
-
             if(!is.null(filters))
                 names(filters) <- c("groups")
 
             filters[[length(filters) + 1]] <- list("group_class", "=", "project")
 
-            serverResponse <- private$http$GET(projectURL, headers, filters,
-                                               limit, offset)
-
-            projects <- private$httpParser$parseJSONResponse(serverResponse)
-
-            if(!is.null(projects$errors))
-                stop(projects$errors)
-
+            projects <- private$REST$listResources("groups", filters,
+                                                   limit, offset)
             projects
         },
 
@@ -267,23 +146,14 @@ Arvados <- R6::R6Class(
 
             projectURL <- paste0(private$host, "groups")
 
-            private$fetchAllItems(projectURL, filters)
+            result <- private$REST$fetchAllItems(projectURL, filters)
+            result
         },
 
         deleteProject = function(uuid)
         {
-            projectURL <- paste0(private$host, "groups/", uuid)
-            headers <- list("Authorization" = paste("OAuth2", private$token),
-                            "Content-Type"  = "application/json")
-
-            serverResponse <- private$http$DELETE(projectURL, headers)
-
-            project <- private$httpParser$parseJSONResponse(serverResponse)
-
-            if(!is.null(project$errors))
-                stop(project$errors)
-
-            project
+            removedProject <- private$REST$deleteResource("groups", uuid)
+            removedProject
         }
     ),
 
@@ -291,39 +161,7 @@ Arvados <- R6::R6Class(
 
         token          = NULL,
         host           = NULL,
-        rawHost        = NULL,
-        webDavHostName = NULL,
-        http           = NULL,
-        httpParser     = NULL,
-        REST           = NULL,
-
-        fetchAllItems = function(resourceURL, filters)
-        {
-            headers <- list(Authorization = paste("OAuth2", private$token))
-
-            offset <- 0
-            itemsAvailable <- .Machine$integer.max
-            items <- c()
-            while(length(items) < itemsAvailable)
-            {
-                serverResponse <- private$http$GET(url          = resourceURL,
-                                                   headers      = headers,
-                                                   queryFilters = filters,
-                                                   limit        = NULL,
-                                                   offset       = offset)
-
-                parsedResponse <- private$httpParser$parseJSONResponse(serverResponse)
-
-                if(!is.null(parsedResponse$errors))
-                    stop(parsedResponse$errors)
-
-                items          <- c(items, parsedResponse$items)
-                offset         <- length(items)
-                itemsAvailable <- parsedResponse$items_available
-            }
-
-            items
-        }
+        REST           = NULL
     ),
 
     cloneable = FALSE
diff --git a/sdk/R/R/Collection.R b/sdk/R/R/Collection.R
index eb82617..203aaff 100644
--- a/sdk/R/R/Collection.R
+++ b/sdk/R/R/Collection.R
@@ -1,7 +1,5 @@
 source("./R/Subcollection.R")
 source("./R/ArvadosFile.R")
-source("./R/HttpRequest.R")
-source("./R/HttpParser.R")
 source("./R/RESTService.R")
 source("./R/util.R")
 
@@ -23,12 +21,9 @@ Collection <- R6::R6Class(
         initialize = function(api, uuid)
         {
             self$api <- api
-            private$http <- api$getHttpClient()
-            private$httpParser <- api$getHttpParser()
             private$REST <- api$getRESTService()
 
             self$uuid <- uuid
-            collection <- self$api$getCollection(uuid)
 
             private$fileContent <- private$REST$getCollectionContent(uuid)
             private$tree <- CollectionTree$new(private$fileContent, self)
@@ -76,7 +71,7 @@ Collection <- R6::R6Class(
             }
             else
             {
-                relativePath <- trimFromEnd(relativePath, "/") 
+                relativePath  <- trimFromEnd(relativePath, "/") 
                 subcollection <- self$get(relativePath)
             }
 
@@ -160,11 +155,8 @@ Collection <- R6::R6Class(
 
     private = list(
 
-        http       = NULL,
-        httpParser = NULL,
-        REST       = NULL,
-        tree       = NULL,
-
+        REST        = NULL,
+        tree        = NULL,
         fileContent = NULL,
 
         generateTree = function(content)
diff --git a/sdk/R/R/RESTService.R b/sdk/R/R/RESTService.R
index 6ffd34b..c4790ae 100644
--- a/sdk/R/R/RESTService.R
+++ b/sdk/R/R/RESTService.R
@@ -4,11 +4,155 @@ RESTService <- R6::R6Class(
 
     public = list(
 
-        initialize = function(api)
+        hostName       = NULL,
+        token          = NULL,
+        http           = NULL,
+        httpParser     = NULL,
+
+        initialize = function(token, hostName, webDavHostName = NULL,  http, httpParser)
+        {
+            version <- "v1"
+
+            self$token       <- token
+            self$hostName    <- paste0("https://", hostName,
+                                       "/arvados/", version, "/")
+            self$http        <- http
+            self$httpParser  <- httpParser
+
+            private$rawHostName    <- hostName
+            private$webDavHostName <- webDavHostName
+        },
+
+        getWebDavHostName = function()
+        {
+            if(is.null(private$webDavHostName))
+            {
+                discoveryDocumentURL <- paste0("https://", private$rawHostName,
+                                               "/discovery/v1/apis/arvados/v1/rest")
+
+                headers <- list(Authorization = paste("OAuth2", self$token))
+
+                serverResponse <- self$http$GET(discoveryDocumentURL, headers)
+
+                discoveryDocument <- self$httpParser$parseJSONResponse(serverResponse)
+                private$webDavHostName <- discoveryDocument$keepWebServiceUrl
+
+                if(is.null(private$webDavHostName))
+                    stop("Unable to find WebDAV server.")
+            }
+
+            private$webDavHostName
+        },
+
+        getResource = function(resource, uuid)
         {
-            private$api <- api
-            private$http <- api$getHttpClient()
-            private$httpParser <- api$getHttpParser()
+            resourceURL <- paste0(self$hostName, resource, "/", uuid)
+            headers <- list(Authorization = paste("OAuth2", self$token))
+
+            serverResponse <- self$http$GET(resourceURL, headers)
+
+            resource <- self$httpParser$parseJSONResponse(serverResponse)
+
+            if(!is.null(resource$errors))
+                stop(resource$errors)
+
+            resource
+        },
+
+        listResources = function(resource, filters = NULL, limit = 100, offset = 0)
+        {
+            resourceURL <- paste0(self$hostName, resource)
+            headers <- list(Authorization = paste("OAuth2", self$token))
+
+            serverResponse <- self$http$GET(resourceURL, headers, filters,
+                                            limit, offset)
+
+            resources <- self$httpParser$parseJSONResponse(serverResponse)
+
+            if(!is.null(resources$errors))
+                stop(resources$errors)
+
+            resources
+        },
+
+        fetchAllItems = function(resourceURL, filters)
+        {
+            headers <- list(Authorization = paste("OAuth2", self$token))
+
+            offset <- 0
+            itemsAvailable <- .Machine$integer.max
+            items <- c()
+            while(length(items) < itemsAvailable)
+            {
+                serverResponse <- self$http$GET(url          = resourceURL,
+                                                headers      = headers,
+                                                queryFilters = filters,
+                                                limit        = NULL,
+                                                offset       = offset)
+
+                parsedResponse <- self$httpParser$parseJSONResponse(serverResponse)
+
+                if(!is.null(parsedResponse$errors))
+                    stop(parsedResponse$errors)
+
+                items          <- c(items, parsedResponse$items)
+                offset         <- length(items)
+                itemsAvailable <- parsedResponse$items_available
+            }
+
+            items
+        },
+
+        deleteResource = function(resource, uuid)
+        {
+            collectionURL <- paste0(self$hostName, resource, "/", uuid)
+            headers <- list("Authorization" = paste("OAuth2", self$token),
+                            "Content-Type"  = "application/json")
+
+            serverResponse <- self$http$DELETE(collectionURL, headers)
+
+            removedResource <- self$httpParser$parseJSONResponse(serverResponse)
+
+            if(!is.null(removedResource$errors))
+                stop(removedResource$errors)
+
+            removedResource
+        },
+
+        updateResource = function(resource, uuid, newContent)
+        {
+            resourceURL <- paste0(self$hostName, resource, "/", uuid)
+            headers <- list("Authorization" = paste("OAuth2", self$token),
+                            "Content-Type"  = "application/json")
+
+            newContent <- jsonlite::toJSON(newContent, auto_unbox = T)
+
+            serverResponse <- self$http$PUT(resourceURL, headers, newContent)
+
+            updatedResource <- self$httpParser$parseJSONResponse(serverResponse)
+
+            if(!is.null(updatedResource$errors))
+                stop(updatedResource$errors)
+
+            updatedResource
+        },
+
+        createResource = function(resource, content)
+        {
+            resourceURL <- paste0(self$hostName, resource)
+            headers <- list("Authorization" = paste("OAuth2", self$token),
+                            "Content-Type"  = "application/json")
+
+            content <- jsonlite::toJSON(content, auto_unbox = T)
+
+            serverResponse <- self$http$POST(resourceURL, headers, content)
+
+            newResource <- self$httpParser$parseJSONResponse(serverResponse)
+
+            if(!is.null(newResource$errors))
+                stop(newResource$errors)
+
+            newResource
         },
 
         create = function(files, uuid)
@@ -21,11 +165,11 @@ RESTService <- R6::R6Class(
 
         delete = function(relativePath, uuid)
         {
-            fileURL <- paste0(private$api$getWebDavHostName(), "c=",
+            fileURL <- paste0(self$getWebDavHostName(), "c=",
                               uuid, "/", relativePath);
-            headers <- list(Authorization = paste("OAuth2", private$api$getToken())) 
+            headers <- list(Authorization = paste("OAuth2", self$token)) 
 
-            serverResponse <- private$http$DELETE(fileURL, headers)
+            serverResponse <- self$http$DELETE(fileURL, headers)
 
             if(serverResponse$status_code < 200 || serverResponse$status_code >= 300)
                 stop(paste("Server code:", serverResponse$status_code))
@@ -35,14 +179,14 @@ RESTService <- R6::R6Class(
 
         move = function(from, to, uuid)
         {
-            collectionURL <- paste0(private$api$getWebDavHostName(), "c=", uuid, "/")
+            collectionURL <- paste0(self$getWebDavHostName(), "c=", uuid, "/")
             fromURL <- paste0(collectionURL, from)
             toURL <- paste0(collectionURL, to)
 
-            headers <- list("Authorization" = paste("OAuth2", private$api$getToken()),
+            headers <- list("Authorization" = paste("OAuth2", self$token),
                            "Destination" = toURL)
 
-            serverResponse <- private$http$MOVE(fromURL, headers)
+            serverResponse <- self$http$MOVE(fromURL, headers)
 
             if(serverResponse$status_code < 200 || serverResponse$status_code >= 300)
                 stop(paste("Server code:", serverResponse$status_code))
@@ -52,42 +196,47 @@ RESTService <- R6::R6Class(
 
         getCollectionContent = function(uuid)
         {
-            collectionURL <- URLencode(paste0(private$api$getWebDavHostName(),
+            collectionURL <- URLencode(paste0(self$getWebDavHostName(),
                                               "c=", uuid))
 
-            headers <- list("Authorization" = paste("OAuth2", private$api$getToken()))
+            headers <- list("Authorization" = paste("OAuth2", self$token))
 
-            response <- private$http$PROPFIND(collectionURL, headers)
+            response <- self$http$PROPFIND(collectionURL, headers)
 
             if(all(response == ""))
                 stop("Response is empty, request may be misconfigured")
 
-            private$httpParser$getFileNamesFromResponse(response, collectionURL)
+            if(response$status_code < 200 || response$status_code >= 300)
+                stop(paste("Server code:", response$status_code))
+
+            self$httpParser$getFileNamesFromResponse(response, collectionURL)
         },
 
         getResourceSize = function(relativePath, uuid)
         {
-            collectionURL <- URLencode(paste0(private$api$getWebDavHostName(),
+            collectionURL <- URLencode(paste0(self$getWebDavHostName(),
                                               "c=", uuid))
 
             subcollectionURL <- paste0(collectionURL, "/", relativePath);
 
-            headers <- list("Authorization" = paste("OAuth2",
-                                                   private$api$getToken()))
+            headers <- list("Authorization" = paste("OAuth2", self$token))
 
-            response <- private$http$PROPFIND(subcollectionURL, headers)
+            response <- self$http$PROPFIND(subcollectionURL, headers)
 
             if(all(response == ""))
                 stop("Response is empty, request may be misconfigured")
 
-            sizes <- private$httpParser$getFileSizesFromResponse(response,
-                                                             collectionURL)
+            if(response$status_code < 200 || response$status_code >= 300)
+                stop(paste("Server code:", response$status_code))
+
+            sizes <- self$httpParser$getFileSizesFromResponse(response,
+                                                              collectionURL)
             as.numeric(sizes)
         },
 
         read = function(relativePath, uuid, contentType = "raw", offset = 0, length = 0)
         {
-            fileURL <- paste0(private$api$getWebDavHostName(),
+            fileURL <- paste0(self$getWebDavHostName(),
                              "c=", uuid, "/", relativePath);
 
             range <- paste0("bytes=", offset, "-")
@@ -97,57 +246,56 @@ RESTService <- R6::R6Class(
 
             if(offset == 0 && length == 0)
             {
-                headers <- list(Authorization = paste("OAuth2", private$api$getToken()))
+                headers <- list(Authorization = paste("OAuth2", self$token))
             }
             else
             {
-                headers <- list(Authorization = paste("OAuth2", private$api$getToken()),
+                headers <- list(Authorization = paste("OAuth2", self$token),
                                 Range = range)
             }
 
-            if(!(contentType %in% private$httpParser$validContentTypes))
+            if(!(contentType %in% self$httpParser$validContentTypes))
                 stop("Invalid contentType. Please use text or raw.")
 
-            serverResponse <- private$http$GET(fileURL, headers)
+            serverResponse <- self$http$GET(fileURL, headers)
 
             if(serverResponse$status_code < 200 || serverResponse$status_code >= 300)
                 stop(paste("Server code:", serverResponse$status_code))
 
-            private$httpParser$parseResponse(serverResponse, contentType)
+            self$httpParser$parseResponse(serverResponse, contentType)
         },
 
         write = function(relativePath, uuid, content, contentType)
         {
-            fileURL <- paste0(private$api$getWebDavHostName(),
+            fileURL <- paste0(self$getWebDavHostName(),
                              "c=", uuid, "/", relativePath);
-            headers <- list(Authorization = paste("OAuth2", private$api$getToken()),
+            headers <- list(Authorization = paste("OAuth2", self$token),
                             "Content-Type" = contentType)
             body <- content
 
-            serverResponse <- private$http$PUT(fileURL, headers, body)
+            serverResponse <- self$http$PUT(fileURL, headers, body)
 
             if(serverResponse$status_code < 200 || serverResponse$status_code >= 300)
                 stop(paste("Server code:", serverResponse$status_code))
 
-            private$httpParser$parseResponse(serverResponse, "text")
+            self$httpParser$parseResponse(serverResponse, "text")
         }
     ),
 
     private = list(
 
-        api        = NULL,
-        http       = NULL,
-        httpParser = NULL,
+        webDavHostName = NULL,
+        rawHostName    = NULL,
 
         createNewFile = function(relativePath, uuid, contentType)
         {
-            fileURL <- paste0(private$api$getWebDavHostName(), "c=",
-                              uuid, "/", relativePath);
-            headers <- list(Authorization = paste("OAuth2", private$api$getToken()), 
+            fileURL <- paste0(self$getWebDavHostName(), "c=",
+                              uuid, "/", relativePath)
+            headers <- list(Authorization = paste("OAuth2", self$token), 
                             "Content-Type" = contentType)
             body <- NULL
 
-            serverResponse <- private$http$PUT(fileURL, headers, body)
+            serverResponse <- self$http$PUT(fileURL, headers, body)
 
             if(serverResponse$status_code < 200 || serverResponse$status_code >= 300)
                 stop(paste("Server code:", serverResponse$status_code))
diff --git a/sdk/R/tests/testthat/fakes/FakeHttpParser.R b/sdk/R/tests/testthat/fakes/FakeHttpParser.R
index bd46b49..865234d 100644
--- a/sdk/R/tests/testthat/fakes/FakeHttpParser.R
+++ b/sdk/R/tests/testthat/fakes/FakeHttpParser.R
@@ -36,12 +36,20 @@ FakeHttpParser <- R6::R6Class(
         getFileNamesFromResponse = function(serverResponse, uri)
         {
             self$parserCallCount <- self$parserCallCount + 1
+
+            if(!is.null(serverResponse$content))
+                return(serverResponse$content)
+
             serverResponse
         },
 
         getFileSizesFromResponse = function(serverResponse, uri)    
         {
             self$parserCallCount <- self$parserCallCount + 1
+
+            if(!is.null(serverResponse$content))
+                return(serverResponse$content)
+
             serverResponse
         }
     )
diff --git a/sdk/R/tests/testthat/fakes/FakeRESTService.R b/sdk/R/tests/testthat/fakes/FakeRESTService.R
index bda1b0e..c71a3ef 100644
--- a/sdk/R/tests/testthat/fakes/FakeRESTService.R
+++ b/sdk/R/tests/testthat/fakes/FakeRESTService.R
@@ -4,6 +4,13 @@ FakeRESTService <- R6::R6Class(
 
     public = list(
 
+        getResourceCallCount    = NULL,
+        createResourceCallCount = NULL,
+        listResourcesCallCount  = NULL,
+        deleteResourceCallCount = NULL,
+        updateResourceCallCount = NULL,
+        fetchAllItemsCallCount  = NULL,
+
         createCallCount               = NULL,
         deleteCallCount               = NULL,
         moveCallCount                 = NULL,
@@ -18,6 +25,13 @@ FakeRESTService <- R6::R6Class(
 
         initialize = function(collectionContent = NULL, returnContent = NULL)
         {
+            self$getResourceCallCount    <- 0
+            self$createResourceCallCount <- 0
+            self$listResourcesCallCount  <- 0
+            self$deleteResourceCallCount <- 0
+            self$updateResourceCallCount <- 0
+            self$fetchAllItemsCallCount  <- 0
+
             self$createCallCount               <- 0
             self$deleteCallCount               <- 0
             self$moveCallCount                 <- 0
@@ -30,6 +44,46 @@ FakeRESTService <- R6::R6Class(
             self$returnContent <- returnContent
         },
 
+        getWebDavHostName = function()
+        {
+        },
+
+        getResource = function(resource, uuid)
+        {
+            self$getResourceCallCount <- self$getResourceCallCount + 1
+            self$returnContent
+        },
+
+        listResources = function(resource, filters = NULL, limit = 100, offset = 0)
+        {
+            self$listResourcesCallCount <- self$listResourcesCallCount + 1
+            self$returnContent
+        },
+
+        fetchAllItems = function(resourceURL, filters)
+        {
+            self$fetchAllItemsCallCount <- self$fetchAllItemsCallCount + 1
+            self$returnContent
+        },
+
+        deleteResource = function(resource, uuid)
+        {
+            self$deleteResourceCallCount <- self$deleteResourceCallCount + 1
+            self$returnContent
+        },
+
+        updateResource = function(resource, uuid, newContent)
+        {
+            self$updateResourceCallCount <- self$updateResourceCallCount + 1
+            self$returnContent
+        },
+
+        createResource = function(resource, content)
+        {
+            self$createResourceCallCount <- self$createResourceCallCount + 1
+            self$returnContent
+        },
+
         create = function(files, uuid)
         {
             self$createCallCount <- self$createCallCount + 1
diff --git a/sdk/R/tests/testthat/test-Arvados.R b/sdk/R/tests/testthat/test-Arvados.R
index ef82b3d..8ebad95 100644
--- a/sdk/R/tests/testthat/test-Arvados.R
+++ b/sdk/R/tests/testthat/test-Arvados.R
@@ -1,7 +1,6 @@
 context("Arvados API")
 
-source("fakes/FakeHttpRequest.R")
-source("fakes/FakeHttpParser.R")
+source("fakes/FakeRESTService.R")
 
 test_that("Constructor will use environment variables if no parameters are passed to it", {
 
@@ -45,586 +44,144 @@ test_that("Constructor raises exception if fields and environment variables are
                                     " environment variables.")))
 }) 
 
-test_that("getWebDavHostName calls REST service properly", {
-
-    hostName <- "hostName"
-    token    <- "token"
-    arv      <- Arvados$new(token, hostName)
-
-    serverResponse <- list(keepWebServiceUrl = "https://myWebDavServer.com")
-    expectedURL    <- paste0("https://", hostName,
-                             "/discovery/v1/apis/arvados/v1/rest")
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
-
-    webDAVHostName <- arv$getWebDavHostName()
-
-    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
-    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
-    expect_that(httpRequest$numberOfGETRequests, equals(1))
-}) 
-
-test_that("getWebDavHostName returns webDAV host name properly", {
-
-    arv <- Arvados$new("token", "hostName")
-
-    serverResponse <- list(keepWebServiceUrl = "https://myWebDavServer.com")
-
-    httpRequest <- FakeHttpRequest$new(expectedURL = NULL, serverResponse)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
-
-    expect_that("https://myWebDavServer.com", equals(arv$getWebDavHostName())) 
-}) 
-
-test_that("getCollection calls REST service properly", {
+test_that("getCollection delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
-
-    serverResponse <- NULL
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
     collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    expectedURL    <- paste0(arv$getHostName(), "collections/", collectionUUID)
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
 
     arv$getCollection(collectionUUID)
 
-    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
-    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
-    expect_that(httpRequest$numberOfGETRequests, equals(1))
+    expect_that(fakeREST$getResourceCallCount, equals(1))
 }) 
 
-test_that("getCollection parses server response", {
+test_that("listCollection delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
-
-    httpParser <- FakeHttpParser$new()
-    arv$setHttpParser(httpParser)
-    arv$setHttpClient(FakeHttpRequest$new())
-
-    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    arv$getCollection(collectionUUID)
-
-    expect_that(httpParser$parserCallCount, equals(1))
-}) 
-
-test_that("getCollection raises exception if response contains errors field", {
-
-    arv <- Arvados$new("token", "hostName")
-    
-    serverResponse <- list(errors = 404)
-    arv$setHttpClient(FakeHttpRequest$new(NULL, serverResponse))
-    arv$setHttpParser(FakeHttpParser$new())
-
-    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    
-    expect_that(arv$getCollection(collectionUUID), 
-                throws_error(404))
-}) 
-
-test_that("listCollections calls REST service properly", {
-
-    arv <- Arvados$new("token", "hostName")
-
-    serverResponse <- NULL
-    expectedURL    <- paste0(arv$getHostName(), "collections")
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
 
     arv$listCollections()
 
-    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
-    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
-    expect_that(httpRequest$numberOfGETRequests, equals(1))
+    expect_that(fakeREST$listResourcesCallCount, equals(1))
 }) 
 
-test_that("listCollections parses server response", {
+test_that("listAllCollection delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
 
-    httpParser <- FakeHttpParser$new()
-    arv$setHttpParser(httpParser)
-    arv$setHttpClient(FakeHttpRequest$new())
+    arv$listAllCollections()
 
-    arv$listCollections()
-
-    expect_that(httpParser$parserCallCount, equals(1))
-}) 
-
-test_that("listCollections raises exception if response contains errors field", {
-
-    arv <- Arvados$new("token", "hostName")
-    
-    serverResponse <- list(errors = 404)
-    expectedURL <- NULL
-    arv$setHttpClient(FakeHttpRequest$new(expectedURL, serverResponse))
-    arv$setHttpParser(FakeHttpParser$new())
-
-    expect_that(arv$listCollections(), 
-                throws_error(404))
-}) 
-
-test_that("listAllCollections always returns all collections from server", {
-
-    arv <- Arvados$new("token", "hostName")
-    
-    expectedURL <- NULL
-    serverResponse <- list(items_available = 8,
-                           items = list("collection1",
-                                        "collection2",
-                                        "collection3",
-                                        "collection4",
-                                        "collection5",
-                                        "collection6",
-                                        "collection7",
-                                        "collection8"))
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
-    httpParser  <- FakeHttpParser$new()
-
-    httpRequest$serverMaxElementsPerRequest <- 3
-
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(httpParser)
-
-    result <- arv$listAllCollections()
-
-    expect_that(length(result), equals(8))
-    expect_that(httpRequest$numberOfGETRequests, equals(3))
-    expect_that(httpParser$parserCallCount, equals(3))
+    expect_that(fakeREST$fetchAllItemsCallCount, equals(1))
 }) 
 
-test_that("deleteCollection calls REST service properly", {
+test_that("deleteCollection delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
-
-    serverResponse <- NULL
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
     collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    expectedURL    <- paste0(arv$getHostName(), "collections/", collectionUUID)
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
-
-    arv$deleteCollection(collectionUUID)
-
-    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
-    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
-    expect_that(httpRequest$numberOfDELETERequests, equals(1))
-}) 
 
-test_that("deleteCollection parses server response", {
-
-    arv <- Arvados$new("token", "hostName")
-
-    httpParser <- FakeHttpParser$new()
-    arv$setHttpParser(httpParser)
-    arv$setHttpClient(FakeHttpRequest$new())
-
-    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
     arv$deleteCollection(collectionUUID)
 
-    expect_that(httpParser$parserCallCount, equals(1))
+    expect_that(fakeREST$deleteResourceCallCount, equals(1))
 }) 
 
-test_that("deleteCollection raises exception if response contains errors field", {
+test_that("updateCollection delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
-    
-    serverResponse <- list(errors = 404)
-    arv$setHttpClient(FakeHttpRequest$new(NULL, serverResponse))
-    arv$setHttpParser(FakeHttpParser$new())
-
-    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    
-    expect_that(arv$deleteCollection(collectionUUID), 
-                throws_error(404))
-}) 
-
-test_that("updateCollection calls REST service properly", {
-
-    arv <- Arvados$new("token", "hostName")
-
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
     newCollectionContent <- list(newName = "Brand new shiny name")
     collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    expectedURL    <- paste0(arv$getHostName(), "collections/", collectionUUID)
-    serverResponse <- NULL
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
 
     arv$updateCollection(collectionUUID, newCollectionContent)
 
-    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
-    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
-    expect_that(httpRequest$JSONEncodedBodyIsProvided, is_true())
-    expect_that(httpRequest$numberOfPUTRequests, equals(1))
-}) 
-
-test_that("updateCollection parses server response", {
-
-    arv <- Arvados$new("token", "hostName")
-
-    httpParser <- FakeHttpParser$new()
-    arv$setHttpParser(httpParser)
-    arv$setHttpClient(FakeHttpRequest$new())
-
-    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    newCollectionContent <- list(newName = "Brand new shiny name")
-
-    arv$updateCollection(collectionUUID, newCollectionContent)
-
-    expect_that(httpParser$parserCallCount, equals(1))
-}) 
-
-test_that("updateCollection raises exception if response contains errors field", {
-
-    arv <- Arvados$new("token", "hostName")
-    
-    expectedURL <- NULL
-    serverResponse <- list(errors = 404)
-    arv$setHttpClient(FakeHttpRequest$new(expectedURL, serverResponse))
-    arv$setHttpParser(FakeHttpParser$new())
-
-    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    newCollectionContent <- list(newName = "Brand new shiny name")
-    
-    expect_that(arv$updateCollection(collectionUUID, newCollectionContent), 
-                throws_error(404))
-}) 
-
-test_that("createCollection calls REST service properly", {
-
-    arv <- Arvados$new("token", "hostName")
-
-    collectionContent <- list(name = "My favorite collection")
-    expectedURL    <- paste0(arv$getHostName(), "collections")
-    serverResponse <- NULL
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
-
-    arv$createCollection(collectionContent)
-
-    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
-    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
-    expect_that(httpRequest$JSONEncodedBodyIsProvided, is_true())
-    expect_that(httpRequest$numberOfPOSTRequests, equals(1))
+    expect_that(fakeREST$updateResourceCallCount, equals(1))
 }) 
 
-test_that("createCollection parses server response", {
+test_that("createCollection delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
-
-    httpParser <- FakeHttpParser$new()
-    arv$setHttpParser(httpParser)
-    arv$setHttpClient(FakeHttpRequest$new())
-
-    collectionContent <- list(name = "My favorite collection")
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
+    collectionContent <- list(newName = "Brand new shiny name")
 
     arv$createCollection(collectionContent)
 
-    expect_that(httpParser$parserCallCount, equals(1))
+    expect_that(fakeREST$createResourceCallCount, equals(1))
 }) 
 
-test_that("createCollection raises exception if response contains errors field", {
+test_that("getProject delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
-    
-    expectedURL <- NULL
-    serverResponse <- list(errors = 404)
-    arv$setHttpClient(FakeHttpRequest$new(expectedURL, serverResponse))
-    arv$setHttpParser(FakeHttpParser$new())
-
-    collectionContent <- list(name = "My favorite collection")
-    
-    expect_that(arv$createCollection(collectionContent), 
-                throws_error(404))
-}) 
-
-test_that("getProject calls REST service properly", {
-
-    arv <- Arvados$new("token", "hostName")
-
-    serverResponse <- NULL
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
     projectUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    expectedURL    <- paste0(arv$getHostName(), "groups/", projectUUID)
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
 
-    arv$getProject(projectUUID)
+    arv$getCollection(projectUUID)
 
-    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
-    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
-    expect_that(httpRequest$numberOfGETRequests, equals(1))
+    expect_that(fakeREST$getResourceCallCount, equals(1))
 }) 
 
-test_that("getProject parses server response", {
+test_that("listProjects delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
 
-    httpParser <- FakeHttpParser$new()
-    arv$setHttpParser(httpParser)
-    arv$setHttpClient(FakeHttpRequest$new())
-
-    projectUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    arv$getProject(projectUUID)
-
-    expect_that(httpParser$parserCallCount, equals(1))
-}) 
-
-test_that("getProject raises exception if response contains errors field", {
-
-    arv <- Arvados$new("token", "hostName")
-    
-    serverResponse <- list(errors = 404)
-    arv$setHttpClient(FakeHttpRequest$new(NULL, serverResponse))
-    arv$setHttpParser(FakeHttpParser$new())
-
-    projectUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    
-    expect_that(arv$getProject(projectUUID), 
-                throws_error(404))
-}) 
-
-test_that("createProject calls REST service properly", {
-
-    arv <- Arvados$new("token", "hostName")
-
-    projectContent <- list(name = "My favorite project")
-    expectedURL    <- paste0(arv$getHostName(), "groups")
-    serverResponse <- NULL
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
-
-    arv$createProject(projectContent)
-
-    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
-    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
-    expect_that(httpRequest$JSONEncodedBodyIsProvided, is_true())
-    expect_that(httpRequest$numberOfPOSTRequests, equals(1))
-}) 
-
-test_that("createProject parses server response", {
-
-    arv <- Arvados$new("token", "hostName")
-
-    httpParser <- FakeHttpParser$new()
-    arv$setHttpParser(httpParser)
-    arv$setHttpClient(FakeHttpRequest$new())
-
-    projectContent <- list(name = "My favorite project")
-
-    arv$createProject(projectContent)
-
-    expect_that(httpParser$parserCallCount, equals(1))
-}) 
-
-test_that("createProject raises exception if response contains errors field", {
+    arv$listCollections()
 
-    arv <- Arvados$new("token", "hostName")
-    
-    expectedURL <- NULL
-    serverResponse <- list(errors = 404)
-    arv$setHttpClient(FakeHttpRequest$new(expectedURL, serverResponse))
-    arv$setHttpParser(FakeHttpParser$new())
-
-    projectContent <- list(name = "My favorite project")
-    
-    expect_that(arv$createProject(projectContent), 
-                throws_error(404))
+    expect_that(fakeREST$listResourcesCallCount, equals(1))
 }) 
 
-test_that("updateProject calls REST service properly", {
+test_that("listAllProjects delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
 
-    newProjectContent <- list(newName = "Brand new shiny name")
-    projectUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    expectedURL    <- paste0(arv$getHostName(), "groups/", projectUUID)
-    serverResponse <- NULL
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
+    arv$listAllProjects()
 
-    arv$updateProject(projectUUID, newProjectContent)
-
-    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
-    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
-    expect_that(httpRequest$JSONEncodedBodyIsProvided, is_true())
-    expect_that(httpRequest$numberOfPUTRequests, equals(1))
+    expect_that(fakeREST$fetchAllItemsCallCount, equals(1))
 }) 
 
-test_that("updateProject parses server response", {
+test_that("deleteProject delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
-
-    httpParser <- FakeHttpParser$new()
-    arv$setHttpParser(httpParser)
-    arv$setHttpClient(FakeHttpRequest$new())
-
-    newProjectContent <- list(newName = "Brand new shiny name")
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
     projectUUID <- "aaaaa-j7d0g-ccccccccccccccc"
 
-    arv$updateProject(projectUUID, newProjectContent)
+    arv$deleteCollection(projectUUID)
 
-    expect_that(httpParser$parserCallCount, equals(1))
+    expect_that(fakeREST$deleteResourceCallCount, equals(1))
 }) 
 
-test_that("updateProject raises exception if response contains errors field", {
+test_that("updateProject delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
-    
-    expectedURL <- NULL
-    serverResponse <- list(errors = 404)
-    arv$setHttpClient(FakeHttpRequest$new(expectedURL, serverResponse))
-    arv$setHttpParser(FakeHttpParser$new())
-
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
     newProjectContent <- list(newName = "Brand new shiny name")
     projectUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    
-    expect_that(arv$updateProject(projectUUID, newProjectContent), 
-                throws_error(404))
-}) 
-
-test_that("listProjects calls REST service properly", {
-
-    arv <- Arvados$new("token", "hostName")
-
-    serverResponse <- NULL
-    expectedURL    <- paste0(arv$getHostName(), "groups")
-    expectedFilters <- list(list("name" = "My project"), 
-                            list("group_class", "=", "project"))
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse, expectedFilters)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
 
-    arv$listProjects(list(list("name" = "My project")))
+    arv$updateCollection(projectUUID, newProjectContent)
 
-    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
-    expect_that(httpRequest$queryFiltersAreCorrect, is_true())
-    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
-    expect_that(httpRequest$numberOfGETRequests, equals(1))
+    expect_that(fakeREST$updateResourceCallCount, equals(1))
 }) 
 
-test_that("listProjects parses server response", {
+test_that("createProject delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
+    fakeREST <- FakeRESTService$new()
+    arv$setRESTService(fakeREST)
+    projectContent <- list(newName = "Brand new shiny name")
 
-    httpParser <- FakeHttpParser$new()
-    arv$setHttpParser(httpParser)
-    arv$setHttpClient(FakeHttpRequest$new())
-
-    arv$listProjects()
-
-    expect_that(httpParser$parserCallCount, equals(1))
-}) 
-
-test_that("listProjects raises exception if response contains errors field", {
-
-    arv <- Arvados$new("token", "hostName")
-    
-    serverResponse <- list(errors = 404)
-    expectedURL <- NULL
-    arv$setHttpClient(FakeHttpRequest$new(expectedURL, serverResponse))
-    arv$setHttpParser(FakeHttpParser$new())
-
-    expect_that(arv$listProjects(), 
-                throws_error(404))
-}) 
-
-test_that("listAllProjects always returns all projects from server", {
-
-    arv <- Arvados$new("token", "hostName")
-    
-    expectedURL <- NULL
-    serverResponse <- list(items_available = 8,
-                           items = list("project1",
-                                        "project2",
-                                        "project3",
-                                        "project4",
-                                        "project5",
-                                        "project6",
-                                        "project7",
-                                        "project8"))
-
-    expectedFilters <- list(list("name" = "My project"), 
-                            list("group_class", "=", "project"))
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse, expectedFilters)
-    httpParser  <- FakeHttpParser$new()
-
-    httpRequest$serverMaxElementsPerRequest <- 3
-
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(httpParser)
-
-    result <- arv$listAllProjects(list(list("name" = "My project")))
-
-    expect_that(length(result), equals(8))
-    expect_that(httpRequest$queryFiltersAreCorrect, is_true())
-    expect_that(httpRequest$numberOfGETRequests, equals(3))
-    expect_that(httpParser$parserCallCount, equals(3))
-}) 
+    arv$createCollection(projectContent)
 
-test_that("deleteProject calls REST service properly", {
-
-    arv <- Arvados$new("token", "hostName")
-
-    serverResponse <- NULL
-    projectUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    expectedURL    <- paste0(arv$getHostName(), "groups/", projectUUID)
-
-    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
-    arv$setHttpClient(httpRequest)
-    arv$setHttpParser(FakeHttpParser$new())
-
-    arv$deleteProject(projectUUID)
-
-    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
-    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
-    expect_that(httpRequest$numberOfDELETERequests, equals(1))
-}) 
-
-test_that("deleteProject parses server response", {
-
-    arv <- Arvados$new("token", "hostName")
-
-    httpParser <- FakeHttpParser$new()
-    arv$setHttpParser(httpParser)
-    arv$setHttpClient(FakeHttpRequest$new())
-
-    projectUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    arv$deleteProject(projectUUID)
-
-    expect_that(httpParser$parserCallCount, equals(1))
-}) 
-
-test_that("deleteCollection raises exception if response contains errors field", {
-
-    arv <- Arvados$new("token", "hostName")
-    
-    serverResponse <- list(errors = 404)
-    expectedURL <- NULL
-    arv$setHttpClient(FakeHttpRequest$new(expectedURL, serverResponse))
-    arv$setHttpParser(FakeHttpParser$new())
-
-    projectUUID <- "aaaaa-j7d0g-ccccccccccccccc"
-    
-    expect_that(arv$deleteProject(projectUUID), 
-                throws_error(404))
+    expect_that(fakeREST$createResourceCallCount, equals(1))
 }) 
diff --git a/sdk/R/tests/testthat/test-ArvadosFile.R b/sdk/R/tests/testthat/test-ArvadosFile.R
index fbf7acb..4897056 100644
--- a/sdk/R/tests/testthat/test-ArvadosFile.R
+++ b/sdk/R/tests/testthat/test-ArvadosFile.R
@@ -36,14 +36,11 @@ test_that(paste("getSizeInBytes returns zero if arvadosFile",
 test_that(paste("getSizeInBytes delegates size calculation",
                 "to REST service class"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal", "animal/fish")
     returnSize <- 100
-
     fakeREST <- FakeRESTService$new(collectionContent, returnSize)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
@@ -75,13 +72,11 @@ test_that("read raises exception if file doesn't belong to a collection", {
 
 test_that("read raises exception offset or length is negative number", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
 
     collectionContent <- c("animal", "animal/fish")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
@@ -96,14 +91,11 @@ test_that("read raises exception offset or length is negative number", {
 
 test_that("read delegates reading operation to REST service class", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal", "animal/fish")
     readContent <- "my file"
-
     fakeREST <- FakeRESTService$new(collectionContent, readContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
@@ -117,14 +109,11 @@ test_that("read delegates reading operation to REST service class", {
 test_that(paste("connect returns textConnection opened",
                 "in read mode when 'r' is passed as argument"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal", "animal/fish")
     readContent <- "file content"
-
     fakeREST <- FakeRESTService$new(collectionContent, readContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
@@ -137,13 +126,11 @@ test_that(paste("connect returns textConnection opened",
 test_that(paste("connect returns textConnection opened",
                 "in write mode when 'w' is passed as argument"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
 
     collectionContent <- c("animal", "animal/fish")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
@@ -161,13 +148,11 @@ test_that(paste("connect returns textConnection opened",
 
 test_that("flush sends data stored in a connection to a REST server", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
 
     collectionContent <- c("animal", "animal/fish")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
@@ -191,13 +176,11 @@ test_that("write raises exception if file doesn't belong to a collection", {
 
 test_that("write delegates writing operation to REST service class", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
 
     collectionContent <- c("animal", "animal/fish")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
@@ -219,17 +202,15 @@ test_that(paste("move raises exception if arvados file",
 test_that(paste("move raises exception if newLocationInCollection",
                 "parameter is invalid"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
 
     collectionContent <- c("animal",
                            "animal/fish",
                            "animal/dog",
                            "animal/fish/shark",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
 
     collection <- Collection$new(api, "myUUID")
@@ -241,17 +222,15 @@ test_that(paste("move raises exception if newLocationInCollection",
 
 test_that("move raises exception if new location contains content with the same name", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
 
     collectionContent <- c("animal",
                            "animal/fish",
                            "animal/dog",
                            "animal/fish/shark",
                            "dog")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     dog <- collection$get("animal/dog")
@@ -263,17 +242,15 @@ test_that("move raises exception if new location contains content with the same
 
 test_that("move moves arvados file inside collection tree", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
 
     collectionContent <- c("animal",
                            "animal/fish",
                            "animal/dog",
                            "animal/fish/shark",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     dog <- collection$get("animal/dog")
diff --git a/sdk/R/tests/testthat/test-Collection.R b/sdk/R/tests/testthat/test-Collection.R
index 1249483..af03748 100644
--- a/sdk/R/tests/testthat/test-Collection.R
+++ b/sdk/R/tests/testthat/test-Collection.R
@@ -5,15 +5,13 @@ context("Collection")
 test_that(paste("constructor creates file tree from text content",
                 "retreived form REST service"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
 
     collectionContent <- c("animal",
                            "animal/fish",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -26,15 +24,12 @@ test_that(paste("constructor creates file tree from text content",
 test_that(paste("add raises exception if passed argumet is not",
                 "ArvadosFile or Subcollection"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -47,15 +42,12 @@ test_that(paste("add raises exception if passed argumet is not",
 
 test_that("add raises exception if relative path is not valid", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -69,15 +61,12 @@ test_that("add raises exception if relative path is not valid", {
 test_that(paste("add adds ArvadosFile or Subcollection",
                 "to local tree structure and remote REST service"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -93,15 +82,12 @@ test_that(paste("add adds ArvadosFile or Subcollection",
 
 test_that("create raises exception if passed argumet is not character vector", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -112,15 +98,12 @@ test_that("create raises exception if passed argumet is not character vector", {
 
 test_that("create raises exception if relative path is not valid", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -134,15 +117,12 @@ test_that("create raises exception if relative path is not valid", {
 test_that(paste("create adds files specified by fileNames",
                 "to local tree structure and remote REST service"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -161,15 +141,12 @@ test_that(paste("create adds files specified by fileNames",
 
 test_that("remove raises exception if passed argumet is not character vector", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -181,17 +158,14 @@ test_that("remove raises exception if passed argumet is not character vector", {
 test_that(paste("remove removes files specified by paths",
                 "from local tree structure and from remote REST service"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "animal/dog",
                            "animal/cat",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -210,15 +184,12 @@ test_that(paste("remove removes files specified by paths",
 test_that(paste("move moves content to a new location inside file tree",
                 "and on REST service"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/dog",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -234,15 +205,12 @@ test_that(paste("move moves content to a new location inside file tree",
 
 test_that("move raises exception if new location is not valid", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -253,15 +221,12 @@ test_that("move raises exception if new location is not valid", {
 
 test_that("getFileListing returns collection content received from REST service", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
@@ -276,15 +241,12 @@ test_that("getFileListing returns collection content received from REST service"
 
 test_that("get returns arvados file or subcollection from internal tree structure", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
 
diff --git a/sdk/R/tests/testthat/test-RESTService.R b/sdk/R/tests/testthat/test-RESTService.R
index 5d0eac2..abc34d9 100644
--- a/sdk/R/tests/testthat/test-RESTService.R
+++ b/sdk/R/tests/testthat/test-RESTService.R
@@ -1,22 +1,288 @@
 source("fakes/FakeArvados.R")
+source("fakes/FakeHttpRequest.R")
+source("fakes/FakeHttpParser.R")
 
 context("REST service")
 
+test_that("getWebDavHostName calls REST service properly", {
+
+    expectedURL <- "https://host/discovery/v1/apis/arvados/v1/rest"
+    serverResponse <- list(keepWebServiceUrl = "https://myWebDavServer.com")
+    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
+
+    REST <- RESTService$new("token", "host", NULL,
+                            httpRequest, FakeHttpParser$new())
+
+    REST$getWebDavHostName()
+
+    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
+    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
+    expect_that(httpRequest$numberOfGETRequests, equals(1))
+}) 
+
+test_that("getWebDavHostName returns webDAV host name properly", {
+
+    serverResponse <- list(keepWebServiceUrl = "https://myWebDavServer.com")
+    httpRequest <- FakeHttpRequest$new(expectedURL = NULL, serverResponse)
+
+    REST <- RESTService$new("token", "host", NULL,
+                            httpRequest, FakeHttpParser$new())
+
+    expect_that("https://myWebDavServer.com", equals(REST$getWebDavHostName())) 
+}) 
+
+test_that("getResource calls REST service properly", {
+
+    serverResponse <- NULL
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL    <- paste0("https://host/arvados/v1/collections/", resourceUUID)
+
+    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
+
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            httpRequest, FakeHttpParser$new())
+
+    REST$getResource("collections", resourceUUID)
+
+    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
+    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
+    expect_that(httpRequest$numberOfGETRequests, equals(1))
+}) 
+
+test_that("getResource parses server response", {
+
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    httpParser <- FakeHttpParser$new()
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            FakeHttpRequest$new(), httpParser)
+
+    REST$getResource("collections", resourceUUID)
+
+    expect_that(httpParser$parserCallCount, equals(1))
+}) 
+
+test_that("getResource raises exception if response contains errors field", {
+
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    serverResponse <- list(errors = 404)
+
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            FakeHttpRequest$new(NULL, serverResponse),
+                            FakeHttpParser$new())
+    
+    expect_that(REST$getResource("collections", resourceUUID), throws_error(404))
+}) 
+
+test_that("listResources calls REST service properly", {
+
+    serverResponse <- NULL
+    expectedURL    <- paste0("https://host/arvados/v1/collections")
+    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
+
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            httpRequest, FakeHttpParser$new())
+
+    REST$listResources("collections")
+
+    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
+    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
+    expect_that(httpRequest$numberOfGETRequests, equals(1))
+}) 
+
+test_that("listResources parses server response", {
+
+    httpParser <- FakeHttpParser$new()
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            FakeHttpRequest$new(), httpParser)
+
+    REST$listResources("collections")
+
+    expect_that(httpParser$parserCallCount, equals(1))
+}) 
+
+test_that("listResources raises exception if response contains errors field", {
+
+    serverResponse <- list(errors = 404)
+
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            FakeHttpRequest$new(NULL, serverResponse),
+                            FakeHttpParser$new())
+    
+    expect_that(REST$listResources("collections"), throws_error(404))
+}) 
+
+test_that("fetchAllItems always returns all resource items from server", {
+
+    expectedURL <- NULL
+    serverResponse <- list(items_available = 8,
+                           items = list("collection1",
+                                        "collection2",
+                                        "collection3",
+                                        "collection4",
+                                        "collection5",
+                                        "collection6",
+                                        "collection7",
+                                        "collection8"))
+
+    httpParser <- FakeHttpParser$new()
+    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
+    httpRequest$serverMaxElementsPerRequest <- 3
+
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            httpRequest, httpParser)
+
+    result <- REST$fetchAllItems(NULL, NULL)
+
+    expect_that(length(result), equals(8))
+    expect_that(httpRequest$numberOfGETRequests, equals(3))
+    expect_that(httpParser$parserCallCount, equals(3))
+}) 
+
+test_that("deleteResource calls REST service properly", {
+
+    serverResponse <- NULL
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL    <- paste0("https://host/arvados/v1/collections/", resourceUUID)
+
+    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
+
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            httpRequest, FakeHttpParser$new())
+
+    REST$deleteResource("collections", resourceUUID)
+
+    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
+    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
+    expect_that(httpRequest$numberOfDELETERequests, equals(1))
+}) 
+
+test_that("deleteCollection parses server response", {
+
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    httpParser <- FakeHttpParser$new()
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            FakeHttpRequest$new(), httpParser)
+
+    REST$deleteResource("collections", resourceUUID)
+
+    expect_that(httpParser$parserCallCount, equals(1))
+}) 
+
+test_that("deleteCollection raises exception if response contains errors field", {
+
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    serverResponse <- list(errors = 404)
+
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            FakeHttpRequest$new(NULL, serverResponse),
+                            FakeHttpParser$new())
+    
+    expect_that(REST$deleteResource("collections", resourceUUID), throws_error(404))
+}) 
+
+test_that("updateResource calls REST service properly", {
+
+    serverResponse <- NULL
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL    <- paste0("https://host/arvados/v1/collections/", resourceUUID)
+    newResourceContent <- list(newName = "Brand new shiny name")
+
+    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
+
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            httpRequest, FakeHttpParser$new())
+
+    REST$updateResource("collections", resourceUUID, newResourceContent)
+
+    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
+    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
+    expect_that(httpRequest$JSONEncodedBodyIsProvided, is_true())
+    expect_that(httpRequest$numberOfPUTRequests, equals(1))
+}) 
+
+test_that("updateResource parses server response", {
+
+    newResourceContent <- list(newName = "Brand new shiny name")
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    httpParser <- FakeHttpParser$new()
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            FakeHttpRequest$new(), httpParser)
+
+    REST$updateResource("collections", resourceUUID, newResourceContent)
+
+    expect_that(httpParser$parserCallCount, equals(1))
+}) 
+
+test_that("updateResource raises exception if response contains errors field", {
+
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    serverResponse <- list(errors = 404)
+    newResourceContent <- list(newName = "Brand new shiny name")
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            FakeHttpRequest$new(NULL, serverResponse),
+                            FakeHttpParser$new())
+    
+    expect_that(REST$updateResource("collections", resourceUUID, newResourceContent),
+                throws_error(404))
+}) 
+
+test_that("createResource calls REST service properly", {
+
+    resourceContent <- list(name = "My favorite collection")
+    serverResponse <- NULL
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL <- "https://host/arvados/v1/collections"
+    newResourceContent <- list(newName = "Brand new shiny name")
+
+    httpRequest <- FakeHttpRequest$new(expectedURL, serverResponse)
+
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            httpRequest, FakeHttpParser$new())
+
+    REST$createResource("collections", resourceContent)
+
+    expect_that(httpRequest$URLIsProperlyConfigured, is_true())
+    expect_that(httpRequest$requestHeaderContainsAuthorizationField, is_true())
+    expect_that(httpRequest$JSONEncodedBodyIsProvided, is_true())
+    expect_that(httpRequest$numberOfPOSTRequests, equals(1))
+}) 
+
+test_that("createResource parses server response", {
+
+    resourceContent <- list(newName = "Brand new shiny name")
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    httpParser <- FakeHttpParser$new()
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            FakeHttpRequest$new(), httpParser)
+
+    REST$createResource("collections", resourceContent)
+
+    expect_that(httpParser$parserCallCount, equals(1))
+}) 
+
+test_that("createResource raises exception if response contains errors field", {
+
+    resourceUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    serverResponse <- list(errors = 404)
+    resourceContent <- list(newName = "Brand new shiny name")
+    REST <- RESTService$new("token", "host", "webDavHost",
+                            FakeHttpRequest$new(NULL, serverResponse),
+                            FakeHttpParser$new())
+    
+    expect_that(REST$createResource("collections", resourceContent),
+                throws_error(404))
+}) 
+
 test_that("create calls REST service properly", {
 
-    expectedURL <- "https://webdavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL <- "https://webDavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
     fakeHttp <- FakeHttpRequest$new(expectedURL)
     fakeHttpParser <- FakeHttpParser$new()
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           fakeHttpParser)
-
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, fakeHttpParser)
 
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     REST$create("file", uuid)
 
     expect_that(fakeHttp$URLIsProperlyConfigured, is_true())
@@ -26,18 +292,13 @@ test_that("create calls REST service properly", {
 
 test_that("create raises exception if server response code is not between 200 and 300", {
 
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     response <- list()
     response$status_code <- 404
     fakeHttp <- FakeHttpRequest$new(serverResponse = response)
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           FakeHttpParser$new())
-
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, HttpParser$new())
 
     expect_that(REST$create("file", uuid),
                 throws_error("Server code: 404"))
@@ -45,19 +306,14 @@ test_that("create raises exception if server response code is not between 200 an
 
 test_that("delete calls REST service properly", {
 
-    expectedURL <- "https://webdavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL <- "https://webDavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
     fakeHttp <- FakeHttpRequest$new(expectedURL)
     fakeHttpParser <- FakeHttpParser$new()
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           fakeHttpParser)
-
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, fakeHttpParser)
 
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     REST$delete("file", uuid)
 
     expect_that(fakeHttp$URLIsProperlyConfigured, is_true())
@@ -67,18 +323,13 @@ test_that("delete calls REST service properly", {
 
 test_that("delete raises exception if server response code is not between 200 and 300", {
 
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     response <- list()
     response$status_code <- 404
     fakeHttp <- FakeHttpRequest$new(serverResponse = response)
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           FakeHttpParser$new())
-
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, HttpParser$new())
 
     expect_that(REST$delete("file", uuid),
                 throws_error("Server code: 404"))
@@ -86,19 +337,14 @@ test_that("delete raises exception if server response code is not between 200 an
 
 test_that("move calls REST service properly", {
 
-    expectedURL <- "https://webdavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL <- "https://webDavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
     fakeHttp <- FakeHttpRequest$new(expectedURL)
     fakeHttpParser <- FakeHttpParser$new()
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           fakeHttpParser)
-
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, fakeHttpParser)
 
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     REST$move("file", "newDestination/file", uuid)
 
     expect_that(fakeHttp$URLIsProperlyConfigured, is_true())
@@ -109,18 +355,13 @@ test_that("move calls REST service properly", {
 
 test_that("move raises exception if server response code is not between 200 and 300", {
 
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     response <- list()
     response$status_code <- 404
     fakeHttp <- FakeHttpRequest$new(serverResponse = response)
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           FakeHttpParser$new())
-
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, HttpParser$new())
 
     expect_that(REST$move("file", "newDestination/file", uuid),
                 throws_error("Server code: 404"))
@@ -128,21 +369,17 @@ test_that("move raises exception if server response code is not between 200 and
 
 test_that("getCollectionContent retreives correct content from WebDAV server", {
 
-    expectedURL <- "https://webdavHost/c=aaaaa-j7d0g-ccccccccccccccc"
-    returnContent <- c("animal", "animal/dog", "ball")
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL <- "https://webDavHost/c=aaaaa-j7d0g-ccccccccccccccc"
+    returnContent <- list()
+    returnContent$status_code <- 200
+    returnContent$content <- c("animal", "animal/dog", "ball")
 
     fakeHttp <- FakeHttpRequest$new(expectedURL, returnContent)
-    fakeHttpParser <- FakeHttpParser$new()
-
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           fakeHttpParser)
 
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, FakeHttpParser$new())
 
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     returnResult <- REST$getCollectionContent(uuid)
     returnedContentMatchExpected <- all.equal(returnResult,
                                               c("animal", "animal/dog", "ball"))
@@ -153,17 +390,12 @@ test_that("getCollectionContent retreives correct content from WebDAV server", {
 
 test_that("getCollectionContent raises exception if server returns empty response", {
 
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     response <- ""
     fakeHttp <- FakeHttpRequest$new(serverResponse = response)
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           FakeHttpParser$new())
-
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, FakeHttpParser$new())
 
     expect_that(REST$getCollectionContent(uuid),
                 throws_error("Response is empty, request may be misconfigured"))
@@ -171,42 +403,60 @@ test_that("getCollectionContent raises exception if server returns empty respons
 
 test_that("getCollectionContent parses server response", {
 
-    fakeHttp <- FakeHttpRequest$new()
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     fakeHttpParser <- FakeHttpParser$new()
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            FakeHttpRequest$new(), fakeHttpParser)
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           fakeHttpParser)
+    REST$getCollectionContent(uuid)
+
+    expect_that(fakeHttpParser$parserCallCount, equals(1))
+}) 
 
-    REST <- RESTService$new(arv)
+test_that("getCollectionContent raises exception if server returns empty response", {
 
     uuid <- "aaaaa-j7d0g-ccccccccccccccc"
-    REST$getCollectionContent(uuid)
+    response <- ""
+    fakeHttp <- FakeHttpRequest$new(serverResponse = response)
 
-    expect_that(fakeHttpParser$parserCallCount, equals(1))
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, FakeHttpParser$new())
+
+    expect_that(REST$getCollectionContent(uuid),
+                throws_error("Response is empty, request may be misconfigured"))
 }) 
 
-test_that("getResourceSize calls REST service properly", {
+test_that(paste("getCollectionContent raises exception if server",
+                "response code is not between 200 and 300"), {
 
-    expectedURL <- "https://webdavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
-    expectedContent <- c("6", "2", "931", "12003")
-    fakeHttp <- FakeHttpRequest$new(expectedURL, expectedContent)
-    fakeHttpParser <- FakeHttpParser$new()
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
+    response <- list()
+    response$status_code <- 404
+    fakeHttp <- FakeHttpRequest$new(serverResponse = response)
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           fakeHttpParser)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, HttpParser$new())
 
-    REST <- RESTService$new(arv)
+    expect_that(REST$getCollectionContent(uuid),
+                throws_error("Server code: 404"))
+}) 
+
+
+test_that("getResourceSize calls REST service properly", {
 
     uuid <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL <- "https://webDavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
+    response <- list()
+    response$status_code <- 200
+    response$content <- c(6, 2, 931, 12003)
+    fakeHttp <- FakeHttpRequest$new(expectedURL, response)
+
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, FakeHttpParser$new())
+
     returnResult <- REST$getResourceSize("file", uuid)
     returnedContentMatchExpected <- all.equal(returnResult,
-                                              as.numeric(expectedContent))
+                                              c(6, 2, 931, 12003))
 
     expect_that(fakeHttp$URLIsProperlyConfigured, is_true())
     expect_that(fakeHttp$requestHeaderContainsAuthorizationField, is_true())
@@ -215,36 +465,39 @@ test_that("getResourceSize calls REST service properly", {
 
 test_that("getResourceSize raises exception if server returns empty response", {
 
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     response <- ""
     fakeHttp <- FakeHttpRequest$new(serverResponse = response)
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           FakeHttpParser$new())
-
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, FakeHttpParser$new())
 
     expect_that(REST$getResourceSize("file", uuid),
                 throws_error("Response is empty, request may be misconfigured"))
 }) 
 
-test_that("getResourceSize parses server response", {
+test_that(paste("getResourceSize raises exception if server",
+                "response code is not between 200 and 300"), {
 
-    fakeHttp <- FakeHttpRequest$new()
-    fakeHttpParser <- FakeHttpParser$new()
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
+    response <- list()
+    response$status_code <- 404
+    fakeHttp <- FakeHttpRequest$new(serverResponse = response)
+
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, HttpParser$new())
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           fakeHttpParser)
+    expect_that(REST$getResourceSize("file", uuid),
+                throws_error("Server code: 404"))
+}) 
 
-    REST <- RESTService$new(arv)
+test_that("getResourceSize parses server response", {
 
     uuid <- "aaaaa-j7d0g-ccccccccccccccc"
+    fakeHttpParser <- FakeHttpParser$new()
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            FakeHttpRequest$new(), fakeHttpParser)
+
     REST$getResourceSize("file", uuid)
 
     expect_that(fakeHttpParser$parserCallCount, equals(1))
@@ -252,23 +505,17 @@ test_that("getResourceSize parses server response", {
 
 test_that("read calls REST service properly", {
 
-    expectedURL <- "https://webdavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL <- "https://webDavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
     serverResponse <- list()
     serverResponse$status_code <- 200
     serverResponse$content <- "file content"
 
     fakeHttp <- FakeHttpRequest$new(expectedURL, serverResponse)
-    fakeHttpParser <- FakeHttpParser$new()
-
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           fakeHttpParser)
 
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, FakeHttpParser$new())
 
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     returnResult <- REST$read("file", uuid, "text", 1024, 512)
 
     expect_that(fakeHttp$URLIsProperlyConfigured, is_true())
@@ -279,18 +526,13 @@ test_that("read calls REST service properly", {
 
 test_that("read raises exception if server response code is not between 200 and 300", {
 
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     response <- list()
     response$status_code <- 404
     fakeHttp <- FakeHttpRequest$new(serverResponse = response)
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           FakeHttpParser$new())
-
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, HttpParser$new())
 
     expect_that(REST$read("file", uuid),
                 throws_error("Server code: 404"))
@@ -298,16 +540,11 @@ test_that("read raises exception if server response code is not between 200 and
 
 test_that("read raises exception if contentType is not valid", {
 
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     fakeHttp <- FakeHttpRequest$new()
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           FakeHttpParser$new())
-
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, HttpParser$new())
 
     expect_that(REST$read("file", uuid, "some invalid content type"),
                 throws_error("Invalid contentType. Please use text or raw."))
@@ -315,39 +552,26 @@ test_that("read raises exception if contentType is not valid", {
 
 test_that("read parses server response", {
 
-    fakeHttp <- FakeHttpRequest$new()
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     fakeHttpParser <- FakeHttpParser$new()
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            FakeHttpRequest$new(), fakeHttpParser)
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           fakeHttpParser)
-
-    REST <- RESTService$new(arv)
-
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
-    REST$getCollectionContent(uuid)
+    REST$read("file", uuid, "text", 1024, 512)
 
     expect_that(fakeHttpParser$parserCallCount, equals(1))
 }) 
 
 test_that("write calls REST service properly", {
 
-    expectedURL <- "https://webdavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
+    fileContent <- "new file content" 
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
+    expectedURL <- "https://webDavHost/c=aaaaa-j7d0g-ccccccccccccccc/file"
     fakeHttp <- FakeHttpRequest$new(expectedURL)
-    fakeHttpParser <- FakeHttpParser$new()
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           fakeHttpParser)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, FakeHttpParser$new())
 
-    REST <- RESTService$new(arv)
-
-    fileContent <- "new file content" 
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
     REST$write("file", uuid, fileContent, "text/html")
 
     expect_that(fakeHttp$URLIsProperlyConfigured, is_true())
@@ -358,19 +582,14 @@ test_that("write calls REST service properly", {
 
 test_that("write raises exception if server response code is not between 200 and 300", {
 
+    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
+    fileContent <- "new file content" 
     response <- list()
     response$status_code <- 404
     fakeHttp <- FakeHttpRequest$new(serverResponse = response)
 
-    arv <- FakeArvados$new("token",
-                           "https://host/",
-                           "https://webdavHost/",
-                           fakeHttp,
-                           FakeHttpParser$new())
-
-    uuid <- "aaaaa-j7d0g-ccccccccccccccc"
-    fileContent <- "new file content" 
-    REST <- RESTService$new(arv)
+    REST <- RESTService$new("token", "https://host/", "https://webDavHost/",
+                            fakeHttp, HttpParser$new())
 
     expect_that(REST$write("file", uuid, fileContent, "text/html"),
                 throws_error("Server code: 404"))
diff --git a/sdk/R/tests/testthat/test-Subcollection.R b/sdk/R/tests/testthat/test-Subcollection.R
index 3572044..401b086 100644
--- a/sdk/R/tests/testthat/test-Subcollection.R
+++ b/sdk/R/tests/testthat/test-Subcollection.R
@@ -103,12 +103,10 @@ test_that(paste("add raises exception if passed argument is",
 test_that(paste("add post content to a REST service", 
                 "if subcollection belongs to a collection"), {
     
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal", "animal/fish")
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
 
     collection <- Collection$new(api, "myUUID")
@@ -156,13 +154,10 @@ test_that("remove raises exception if passed argument is not character vector",
 test_that(paste("remove removes content from REST service", 
                 "if subcollection belongs to a collection"), {
     
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal", "animal/fish", "animal/dog")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     animal <- collection$get("animal")
@@ -265,17 +260,14 @@ test_that(paste("move raises exception if subcollection",
 
 test_that("move raises exception if new location contains content with the same name", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "animal/dog",
                            "animal/fish/shark",
                            "fish")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
@@ -288,17 +280,14 @@ test_that("move raises exception if new location contains content with the same
 test_that(paste("move raises exception if newLocationInCollection",
                 "parameter is invalid"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "animal/dog",
                            "animal/fish/shark",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
 
     collection <- Collection$new(api, "myUUID")
@@ -310,17 +299,14 @@ test_that(paste("move raises exception if newLocationInCollection",
 
 test_that("move moves subcollection inside collection tree", {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal",
                            "animal/fish",
                            "animal/dog",
                            "animal/fish/shark",
                            "ball")
-
     fakeREST <- FakeRESTService$new(collectionContent)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
@@ -344,14 +330,11 @@ test_that(paste("getSizeInBytes returns zero if subcollection",
 test_that(paste("getSizeInBytes delegates size calculation",
                 "to REST service class"), {
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setHttpClient(FakeHttpRequest$new())
-    api$setHttpParser(FakeHttpParser$new())
-
     collectionContent <- c("animal", "animal/fish")
     returnSize <- 100
-
     fakeREST <- FakeRESTService$new(collectionContent, returnSize)
+
+    api <- Arvados$new("myToken", "myHostName")
     api$setRESTService(fakeREST)
     collection <- Collection$new(api, "myUUID")
     animal <- collection$get("animal")

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list