0

I implemented a Java client for my REST API using Retrofit. The client is a simple java app and not an Android Application. How do I write unit tests for my Java client ? Following is one of my service classes.

public interface CountryService {

    /**
     * Returns country list.
     * 
     * @param sortby
     *            Optional; Sorting order of list. Pass null to ignore.
     * 
     * @return Countries object with list of countries.
     * 
     * @throws SRSRetrofitException
     */

    @GET(SRSClientConstants.SLASH + SRSClientConstants.RESOURCE_COUNTRY)
    public Countries getCountries(@Query("sortby") String sortby)
            throws SRSRetrofitException;
}
TechCrunch
  • 2,924
  • 5
  • 45
  • 79

1 Answers1

-1

With a REST Application hosted online you just need to use GET/POST and other HTTP methods to query the service. No special construct as such is required. Try sending a HTTP Request with all the valid parameters. It should work. For more on REST click here

Lalit Mehra
  • 1,183
  • 1
  • 13
  • 33
  • Question is how to unit test a client written using Retrofit for a REST API. I don't understand your answer. – TechCrunch Jun 21 '15 at 15:53
  • this might be of some help ... http://stackoverflow.com/questions/17544751/square-retrofit-server-mock-for-testing – Lalit Mehra Jun 21 '15 at 18:28