@Test public void createSampleHolder() throws Exception { final SampleHolder sampleHolder = SampleHolder.builder() .label("A label") .manufacturer("A manufacturer") .model("A model") .location("New York") .cryoCapable(true) .maximumTilt(5f) .doubleTilt(false) .build(); final String json = new ObjectMapper().writeValueAsString(sampleHolder); getMockMvc().perform(post(URI).contentType(JSON_CONTENT_TYPE).content(json)).andExpect(status().isCreated()); verify(service, times(1)).createItem(sampleHolder); }
@NonNull @PostMapping @ResponseStatus(HttpStatus.CREATED) public SampleHolder createItem(@NonNull @Valid @RequestBody SampleHolder input) { return this.service.createItem(input); }
SampleHolderRestController extends BaseValidatingRestController<SampleHolder, SampleHolderService> { @NonNull @PostMapping @ResponseStatus(HttpStatus.CREATED) public SampleHolder createItem(@NonNull @Valid @RequestBody SampleHolder input) { return this.service.createItem(input); } }
SampleHolderRestController extends BaseValidatingRestController<SampleHolder, SampleHolderService> { @NonNull @PostMapping @ResponseStatus(HttpStatus.CREATED) public SampleHolder createItem(@NonNull @Valid @RequestBody SampleHolder input) { return this.service.createItem(input); } @Autowired  SampleHolderRestController(final SampleHolderService service,
                               final SampleHolderValidator validator); }
SampleHolderRestController extends BaseValidatingRestController<SampleHolder, SampleHolderService> { @NonNull @PostMapping @ResponseStatus(HttpStatus.CREATED) public SampleHolder createItem(@NonNull @Valid @RequestBody SampleHolder input) { return this.service.createItem(input); } @Autowired  SampleHolderRestController(final SampleHolderService service,
                               final SampleHolderValidator validator); @NonNull @GetMapping(value = "/findByMicroscope/{microscopeSlugOrId}") Collection<SampleHolder> findSampleHolders(@NotNull final @PathVariable("microscopeSlugOrId") String microscopeSlugOrId); @NonNull @PostMapping @ResponseStatus(HttpStatus.CREATED) SampleHolder createItem(@NonNull @Valid @RequestBody SampleHolder input); }
SampleHolderRestController extends BaseValidatingRestController<SampleHolder, SampleHolderService> { @NonNull @PostMapping @ResponseStatus(HttpStatus.CREATED) public SampleHolder createItem(@NonNull @Valid @RequestBody SampleHolder input) { return this.service.createItem(input); } @Autowired  SampleHolderRestController(final SampleHolderService service,
                               final SampleHolderValidator validator); @NonNull @GetMapping(value = "/findByMicroscope/{microscopeSlugOrId}") Collection<SampleHolder> findSampleHolders(@NotNull final @PathVariable("microscopeSlugOrId") String microscopeSlugOrId); @NonNull @PostMapping @ResponseStatus(HttpStatus.CREATED) SampleHolder createItem(@NonNull @Valid @RequestBody SampleHolder input);  }