@Test public void deleteItem() { BasketModel basketModel = getMockedBasketModel("dummy"); basketModel.addItem("deletedItem"); BasketModel result = basketController.newBasket(basketModel); result = basketController.deleteItem(result.getId(), "deletedItem"); assert(!result.getItems().contains("deletedItem")); BasketModel storedResult = basketController.one(result.getId()); assert(!storedResult.getItems().contains("deletedItem")); }
@DeleteMapping("/baskets/{id}/add/{item}") BasketModel deleteItem(@PathVariable UUID id, @SuppressWarnings("SameParameterValue") @PathVariable String item) { BasketModel basketModel = one(id); basketModel.deleteItem(item); basketRepository.save(basketModel); return basketModel; }
BasketController { @DeleteMapping("/baskets/{id}/add/{item}") BasketModel deleteItem(@PathVariable UUID id, @SuppressWarnings("SameParameterValue") @PathVariable String item) { BasketModel basketModel = one(id); basketModel.deleteItem(item); basketRepository.save(basketModel); return basketModel; } }
BasketController { @DeleteMapping("/baskets/{id}/add/{item}") BasketModel deleteItem(@PathVariable UUID id, @SuppressWarnings("SameParameterValue") @PathVariable String item) { BasketModel basketModel = one(id); basketModel.deleteItem(item); basketRepository.save(basketModel); return basketModel; } @Autowired  BasketController(BasketRepository basketRepository); }
BasketController { @DeleteMapping("/baskets/{id}/add/{item}") BasketModel deleteItem(@PathVariable UUID id, @SuppressWarnings("SameParameterValue") @PathVariable String item) { BasketModel basketModel = one(id); basketModel.deleteItem(item); basketRepository.save(basketModel); return basketModel; } @Autowired  BasketController(BasketRepository basketRepository);  }
BasketController { @DeleteMapping("/baskets/{id}/add/{item}") BasketModel deleteItem(@PathVariable UUID id, @SuppressWarnings("SameParameterValue") @PathVariable String item) { BasketModel basketModel = one(id); basketModel.deleteItem(item); basketRepository.save(basketModel); return basketModel; } @Autowired  BasketController(BasketRepository basketRepository);   }