3435363738394041424344
public static void main(String[] args) throws MalformedURLException { Client client = new Client(); try { client.postPerson(new Person(1,"John Smith",21)); client.getPerson(1); client.deletePerson(1); } catch (Exception e) { e.printStackTrace(); }
59606162636465666768
public void postPerson(Person person) throws Exception{ System.out.println("\n### PUT PERSON -> "); printPerson(person); Person result = personService.putPerson(person); System.out.println("\n### PUT PERSON RESPONSE "); printPerson(result); }
67686970717273747576
printPerson(result); } public void getPerson(int id) throws Exception{ System.out.println("\n### GET PERSON WITH ID "+id); Person result = personService.getPerson(id); System.out.println("\n### GET PERSON RESPONSE"); printPerson(result); }
75767778798081828384
printPerson(result); } public void deletePerson(int id) throws Exception{ System.out.println("\n### DELETE PERSON WITH ID "+id); Person result = personService.deletePerson(id); System.out.println("\n### DELETE PERSON RESPONSE"); printPerson(result); }
3031323334353637
public static final String ERR_PERSON_X_NOT_FOUND = "Person %s not found"; Map<Integer,Person> persons = new HashMap<Integer,Person>(); public void init(){ Person person = new Person(0,"test",100); persons.put(person.getId(), person); }
3536373839404142
Person person = new Person(0,"test",100); persons.put(person.getId(), person); } public void getPerson(@Body String id,Exchange exchange){ Person result = persons.get(Integer.parseInt(id)); checkResult(id, exchange, result); }
4546474849505152
persons.put(person.getId(), person); return person; } public void deletePerson(@Body String id,Exchange exchange){ Person result = persons.remove(Integer.parseInt(id)); checkResult(id, exchange, result); }