SavedSnapshotController { @RequestMapping(method = RequestMethod.POST) public SavedSnapshot create( @RequestBody final SavedQuery query ) throws AciErrorException { return service.create(service.build(query)); } @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);  }
@Test public void create() throws Exception { when(savedSnapshotService.build(any())).thenReturn(new SavedSnapshot()); savedSnapshotController.create(savedQuery); verify(savedSnapshotService).build(savedQuery); verify(savedSnapshotService).create(any(SavedSnapshot.class)); }