SaveAndRenameServiceImpl implements SupportsSaveAndRename<T, M> { @Override public Path saveAndRename(final Path path, final String newFileName, final M metadata, final T content, final String comment) { final Path savedPath = save(path, content, metadata, comment); final Path renamedPath = rename(savedPath, newFileName, comment); return renamedPath; }  void init(final SupportsSaveAndRename<T, M> updateService); @Override Path rename(final Path path,
                       final String newFileName,
                       final String comment); @Override Path save(final Path path,
                     final T content,
                     final M metadata,
                     final String comment); @Override Path saveAndRename(final Path path,
                              final String newFileName,
                              final M metadata,
                              final T content,
                              final String comment);  }
@Test public void testSaveAndRename() throws Exception { final Path path = mock(Path.class); final String newFileName = "newFileName"; final DefaultMetadata metadata = mock(DefaultMetadata.class); final String content = "content"; final String comment = "comment"; doReturn(path).when(service).save(path, content, metadata, comment); service.saveAndRename(path, newFileName, metadata, content, comment); verify(service).save(path, content, metadata, comment); verify(service).rename(path, newFileName, comment); }