@Test public void update() throws AciErrorException { when(savedSnapshotService.update(any(SavedSnapshot.class))).then(returnsFirstArg()); final SavedSnapshot updatedQuery = savedSnapshotController.update(42, savedSnapshot); verify(savedSnapshotService).update(isA(SavedSnapshot.class)); assertEquals(new Long(42L), updatedQuery.getId()); }
@RequestMapping(value = "{id}", method = RequestMethod.PUT) public SavedSnapshot update( @PathVariable("id") final long id, @RequestBody final SavedSnapshot snapshot ) throws AciErrorException { return service.update( new Builder() .setId(id) .setTitle(snapshot.getTitle()) .build() ); }
SavedSnapshotController { @RequestMapping(value = "{id}", method = RequestMethod.PUT) public SavedSnapshot update( @PathVariable("id") final long id, @RequestBody final SavedSnapshot snapshot ) throws AciErrorException { return service.update( new Builder() .setId(id) .setTitle(snapshot.getTitle()) .build() ); } }
SavedSnapshotController { @RequestMapping(value = "{id}", method = RequestMethod.PUT) public SavedSnapshot update( @PathVariable("id") final long id, @RequestBody final SavedSnapshot snapshot ) throws AciErrorException { return service.update( new Builder() .setId(id) .setTitle(snapshot.getTitle()) .build() ); } @SuppressWarnings("TypeMayBeWeakened") @Autowired  SavedSnapshotController(final SavedSearchService<SavedSnapshot, Builder> service,
                                   final ConfigService<DashboardConfig> dashboardConfigService); }
SavedSnapshotController { @RequestMapping(value = "{id}", method = RequestMethod.PUT) public SavedSnapshot update( @PathVariable("id") final long id, @RequestBody final SavedSnapshot snapshot ) throws AciErrorException { return service.update( new Builder() .setId(id) .setTitle(snapshot.getTitle()) .build() ); } @SuppressWarnings("TypeMayBeWeakened") @Autowired  SavedSnapshotController(final SavedSearchService<SavedSnapshot, Builder> service,
                                   final ConfigService<DashboardConfig> dashboardConfigService); @RequestMapping(method = RequestMethod.GET) Set<SavedSnapshot> getAll(); @RequestMapping(value = GET_SHARED, method = RequestMethod.GET) Set<SavedSnapshot> getShared(); @RequestMapping(method = RequestMethod.POST) SavedSnapshot create(
            @RequestBody final SavedQuery query
    ); @RequestMapping(value = "{id}", method = RequestMethod.PUT) SavedSnapshot update(
            @PathVariable("id") final long id,
            @RequestBody final SavedSnapshot snapshot
    ); @RequestMapping(value = "shared/{id}", method = RequestMethod.PUT) SavedSnapshot updateShared(
            @PathVariable("id") final long id,
            @RequestBody final SavedSnapshot snapshot
    ); @RequestMapping(value = "{id}", method = RequestMethod.DELETE) void delete(
            @PathVariable("id") final long id
    ); @RequestMapping(method = RequestMethod.GET, value = "/{id}") SavedSnapshot get(@PathVariable("id") final long id); }
SavedSnapshotController { @RequestMapping(value = "{id}", method = RequestMethod.PUT) public SavedSnapshot update( @PathVariable("id") final long id, @RequestBody final SavedSnapshot snapshot ) throws AciErrorException { return service.update( new Builder() .setId(id) .setTitle(snapshot.getTitle()) .build() ); } @SuppressWarnings("TypeMayBeWeakened") @Autowired  SavedSnapshotController(final SavedSearchService<SavedSnapshot, Builder> service,
                                   final ConfigService<DashboardConfig> dashboardConfigService); @RequestMapping(method = RequestMethod.GET) Set<SavedSnapshot> getAll(); @RequestMapping(value = GET_SHARED, method = RequestMethod.GET) Set<SavedSnapshot> getShared(); @RequestMapping(method = RequestMethod.POST) SavedSnapshot create(
            @RequestBody final SavedQuery query
    ); @RequestMapping(value = "{id}", method = RequestMethod.PUT) SavedSnapshot update(
            @PathVariable("id") final long id,
            @RequestBody final SavedSnapshot snapshot
    ); @RequestMapping(value = "shared/{id}", method = RequestMethod.PUT) SavedSnapshot updateShared(
            @PathVariable("id") final long id,
            @RequestBody final SavedSnapshot snapshot
    ); @RequestMapping(value = "{id}", method = RequestMethod.DELETE) void delete(
            @PathVariable("id") final long id
    ); @RequestMapping(method = RequestMethod.GET, value = "/{id}") SavedSnapshot get(@PathVariable("id") final long id);  }