I'm trying to practice TDD and have an exercise to do. There is an existing service deployed somewhere in internet having public RESTful api. Each request to this api requires some data preparation like valid request string construction, some encryption, some body message formatting etc. I'd like to write generic client for this service using TDD.

I know it is not as simple as e.g. StringCalculator kata, and requires a bit different approach.

I don't know how to start with that. I'd like to test it without using real service, so there is kind of fake impl required. Is it better to write some fake implementation, deploy it on localhost and call it from my tests? Or maybe mock a class responsible for sending http request?

I'd like my client usage to be as below:

public class ServiceClientTest {
   @Test
   public void testSendStoreRequest() {
        ServiceClient client = new ServiceClient("app_key", "private_key")
        ClientResponse response = client.sendStoreRequest(StorageType.NORMAL,     "string_to_store");
       assertEquals("200", response.getStatus());
   } 
}

Can you point me any direction on how to start with this? Should I start bottom-up and writing all the components (for request string creation, for encryption etc) and then use them all in ServiceClient, or should I start from ServiceClient test and implementation with top-down and mocking?

Edit
Report