### Question:
FileServiceImpl implements FileService { @Override public Entity updateReportFileName(final Entity entity, final String dateFieldName, final String name) { String currentFiles = entity.getStringField("fileName"); if (currentFiles == null) { currentFiles = ""; } if (!currentFiles.isEmpty()) { currentFiles += ","; } entity.setField("fileName", currentFiles + getReportFullPath(name, (Date) entity.getField(dateFieldName))); return entity.getDataDefinition().save(entity); } FileServiceImpl(); static FileService getInstance(); @Value("${reportPath}") void setUploadDirectory(final String uploadDirectory); @Override String getName(final String path); @Override String getLastModificationDate(final String path); @Override String getUrl(final String path); @Override String getPathFromUrl(final String url); @Override InputStream getInputStream(final String path); @Override String upload(final MultipartFile multipartFile); @Override File createExportFile(final String filename); @Override File createReportFile(final String fileName); File getFileFromFilenameWithRandomDirectory(final String filename); @Override Entity updateReportFileName(final Entity entity, final String dateFieldName, final String name); @Override Entity updateReportFileName(final Entity entity, final String dateFieldName, final String name, final String... args); @Override File compressToZipFile(List<File> documents, boolean removeCompressed); @Override String getContentType(final String path); @Override void remove(final String path);  }### Answer:
@Test public void shouldAddANewReportFilenameIfThereAreNoneYet() { String filename = "newFileName.abc"; given(translationService.translate(Mockito.eq(filename), Mockito.any(Locale.class))).willReturn(filename); given(entity.getStringField("fileName")).willReturn(""); fileService.updateReportFileName(entity, "date", filename); verify(entity).setField("fileName", "/0/newFileName.abc_1970_01_01_01_20_34"); }
@Test public void shouldStackThatNewReportFilenameToTheCurrentFilenamesAndSeparateThemWithCommas() { String filename = "newFileName.abc"; given(translationService.translate(Mockito.eq(filename), Mockito.any(Locale.class))).willReturn(filename); given(entity.getStringField("fileName")).willReturn("oldFilename"); fileService.updateReportFileName(entity, "date", filename); verify(entity).setField("fileName", "oldFilename,/0/newFileName.abc_1970_01_01_01_20_34"); }