@Test @InSequence(1) public void testPostAndGet() { MultivaluedHashMap<String, String> map = new MultivaluedHashMap<>(); map.add("name", "Penny"); map.add("age", "1"); target.request().post(Entity.form(map)); map.clear(); map.add("name", "Leonard"); map.add("age", "2"); target.request().post(Entity.form(map)); map.clear(); map.add("name", "Sheldon"); map.add("age", "3"); target.request().post(Entity.form(map)); Employee[] list = target.request().get(Employee[].class); assertEquals(3, list.length); assertEquals("Penny", list[0].getName()); assertEquals(1, list[0].getAge()); assertEquals("Leonard", list[1].getName()); assertEquals(2, list[1].getAge()); assertEquals("Sheldon", list[2].getName()); assertEquals(3, list[2].getAge()); }
@GET @Produces({ "application/json", "application/xml" }) @Path("{id}") public Employee get(@PathParam("id") int id) { if (id < bean.getEmployees().size()) return bean.getEmployees().get(id); else return null; }
EmployeeResource { @GET @Produces({ "application/json", "application/xml" }) @Path("{id}") public Employee get(@PathParam("id") int id) { if (id < bean.getEmployees().size()) return bean.getEmployees().get(id); else return null; } }
EmployeeResource { @GET @Produces({ "application/json", "application/xml" }) @Path("{id}") public Employee get(@PathParam("id") int id) { if (id < bean.getEmployees().size()) return bean.getEmployees().get(id); else return null; }  }
EmployeeResource { @GET @Produces({ "application/json", "application/xml" }) @Path("{id}") public Employee get(@PathParam("id") int id) { if (id < bean.getEmployees().size()) return bean.getEmployees().get(id); else return null; }  @GET @Produces({ "application/xml", "application/json" }) Employee[] getList(); @GET @Produces({ "application/json", "application/xml" }) @Path("{id}") Employee get(@PathParam("id") int id); @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) void addToList(@FormParam("name") String name,
         @FormParam("age") int age); @PUT void putToList(@FormParam("name") String name,
         @FormParam("age") int age); @DELETE @Path("{name}") void deleteFromList(@PathParam("name") String name); }
EmployeeResource { @GET @Produces({ "application/json", "application/xml" }) @Path("{id}") public Employee get(@PathParam("id") int id) { if (id < bean.getEmployees().size()) return bean.getEmployees().get(id); else return null; }  @GET @Produces({ "application/xml", "application/json" }) Employee[] getList(); @GET @Produces({ "application/json", "application/xml" }) @Path("{id}") Employee get(@PathParam("id") int id); @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) void addToList(@FormParam("name") String name,
         @FormParam("age") int age); @PUT void putToList(@FormParam("name") String name,
         @FormParam("age") int age); @DELETE @Path("{name}") void deleteFromList(@PathParam("name") String name);  }