@Test public void givenProjekt_whenAddingAndRetrieving_thenTheyMatch() { Projekt projekt = createSampleProjekt(); Long projektId = addProject(projekt); Projekt responseProjekt = getProject(projektId); Assertions.assertThat(responseProjekt). usingRecursiveComparison() .ignoringFields("id") .isEqualTo(projekt); }
@RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody Long addProject(@RequestBody @Valid Projekt projekt) { LOG.info("POST called on /projects resource"); projektRepository.save(projekt); LOG.info("Projekt successfully saved into DB with id " + projekt.getId()); return projekt.getId(); }
ProjekteController { @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody Long addProject(@RequestBody @Valid Projekt projekt) { LOG.info("POST called on /projects resource"); projektRepository.save(projekt); LOG.info("Projekt successfully saved into DB with id " + projekt.getId()); return projekt.getId(); } }
ProjekteController { @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody Long addProject(@RequestBody @Valid Projekt projekt) { LOG.info("POST called on /projects resource"); projektRepository.save(projekt); LOG.info("Projekt successfully saved into DB with id " + projekt.getId()); return projekt.getId(); }  }
ProjekteController { @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody Long addProject(@RequestBody @Valid Projekt projekt) { LOG.info("POST called on /projects resource"); projektRepository.save(projekt); LOG.info("Projekt successfully saved into DB with id " + projekt.getId()); return projekt.getId(); }  @RequestMapping(method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<Projekt> getProjects(); @GetMapping(path = "/{id}") @ResponseBody Projekt getProjectById(@PathVariable("id") Long id); @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) @ResponseBody Long addProject(@RequestBody @Valid Projekt projekt); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody Projekt updateProject(@RequestBody @Valid Projekt projekt); @RequestMapping(path = "/{id}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) void deleteProject(@PathVariable("id") Long id); @GetMapping(path = "/{projektId}/users") @ResponseBody List<Teilnehmer> getRegisteredUsersOfProject(@PathVariable("projektId") Long projektId); @GetMapping(path = "/{projektId}/cancelledusers") @ResponseBody List<Teilnehmer> getCancelledUsersOfProject(@PathVariable("projektId") Long projektId); @RequestMapping(path = "/{projektId}/users/{teilnehmerId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) void assignUserToProject(@PathVariable("projektId") Long projektId, @PathVariable("teilnehmerId") Long teilnehmerId); @RequestMapping(path = "/{projektId}/users/{teilnehmerId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) void unassignUserFromProject(@PathVariable("projektId") Long projektId, @PathVariable("teilnehmerId") Long teilnehmerId); }
ProjekteController { @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody Long addProject(@RequestBody @Valid Projekt projekt) { LOG.info("POST called on /projects resource"); projektRepository.save(projekt); LOG.info("Projekt successfully saved into DB with id " + projekt.getId()); return projekt.getId(); }  @RequestMapping(method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody List<Projekt> getProjects(); @GetMapping(path = "/{id}") @ResponseBody Projekt getProjectById(@PathVariable("id") Long id); @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) @ResponseBody Long addProject(@RequestBody @Valid Projekt projekt); @RequestMapping(method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) @ResponseBody Projekt updateProject(@RequestBody @Valid Projekt projekt); @RequestMapping(path = "/{id}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) void deleteProject(@PathVariable("id") Long id); @GetMapping(path = "/{projektId}/users") @ResponseBody List<Teilnehmer> getRegisteredUsersOfProject(@PathVariable("projektId") Long projektId); @GetMapping(path = "/{projektId}/cancelledusers") @ResponseBody List<Teilnehmer> getCancelledUsersOfProject(@PathVariable("projektId") Long projektId); @RequestMapping(path = "/{projektId}/users/{teilnehmerId}", method = RequestMethod.PUT) @ResponseStatus(HttpStatus.OK) void assignUserToProject(@PathVariable("projektId") Long projektId, @PathVariable("teilnehmerId") Long teilnehmerId); @RequestMapping(path = "/{projektId}/users/{teilnehmerId}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) void unassignUserFromProject(@PathVariable("projektId") Long projektId, @PathVariable("teilnehmerId") Long teilnehmerId);  }