RestAdapter restAdapter = new RestAdapter.Builder()
.setServer(API_URL)
.build();
// Create an instance of our SimpleApi interface.
SimpleApi simpleApi = restAdapter.create(SimpleApi.class);
// Call each of the methods and output the results
System.out.println("simpleApi.simpleGet()=<<" + simpleApi.simpleGet() + ">>");
System.out.println("simpleApi.simplePost()=<<" + simpleApi.simplePost() + ">>");
System.out.println("simpleApi.simpleDelete()=<<" + simpleApi.simpleDelete() + ">>");
System.out.println("simpleApi.simplePut()=<<" + simpleApi.simplePut() + ">>");
System.out.println("simpleApi.simpleHead()=<<" + simpleApi.simpleHead() + ">>");
System.out.println("simpleApi.simpleBoolean()=<<" + simpleApi.simpleBoolean() + ">>");
System.out.println("simpleApi.simpleInteger()=<<" + simpleApi.simpleInteger() + ">>");
System.out.println("simpleApi.simpleCollection()=<<" + simpleApi.simpleCollection() + ">>");
try {
ObjectMapper mapper = new ObjectMapper();
// We want to take a peek to see if all the fields are set correctly
CustomObject custom = simpleApi.simpleCustom();
System.out.println("simpleApi.simpleCustom()=<<" + custom + ">>");
System.out.println("simpleApi.simpleCustom() as JSON=<<" + mapper.writeValueAsString(custom) + ">>");
CustomChild child = simpleApi.simpleChild();
System.out.println("simpleApi.simpleChild()=<<" + child + ">>");
System.out.println("simpleApi.simpleChild() as JSON=<<" + mapper.writeValueAsString(child) + ">>");
}
catch(IOException e) {
LOG.error("Failed to convert objects to JSON", e);