@RestMethod(method = HttpMethod.POST, template = "", requestFormat = "application/json") public TestTeamPojo addTeam(@RequestBody TestTeamPojo newTeam) { if (teams.contains(newTeam)) throw new DuplicateKeyConstraintException( String.format("There is already a team in the collection with key %s", newTeam.getKey())); teams.add(newTeam); lastMethodCalled = "addTeam"; lastHttpMethodCalled = "POST"; return newTeam; }
@RestMethod(method = HttpMethod.PUT, template = "", requestFormat = "application/json") public TestTeamPojo updateTeam(@RequestBody TestTeamPojo teamToUpdate) { if (!teams.contains(teamToUpdate)) throw new UnrecongizedKeyException( String.format("No team with key %s is in the collection.", teamToUpdate.getKey())); teams.remove(teamToUpdate); teams.add(teamToUpdate); lastMethodCalled = "updateTeam"; lastHttpMethodCalled = "PUT"; return teamToUpdate; }