### Question:
AbstractMultiInstanceResource extends AbstractResource { String getNewInstanceFileName(String masterFileName, int size, String langCode) { String baseName = FilenameUtils.getBaseName(masterFileName); String extension = FilenameUtils.getExtension(masterFileName); String suffix = ""; if (size >= 0) { suffix += "_d" + size; } if (langCode != null) { suffix += "_" + langCode; } return this.createFileName( super.getMultiFileUniqueBaseName(baseName, suffix, extension), extension ); } AbstractMultiInstanceResource(); @Override void deleteResourceInstances(); @Override boolean isMultiInstance(); @Override String getXML(); @Deprecated abstract String getInstanceFileName(String masterFileName, int size, String langCode); abstract ResourceInstance getInstance(int size, String langCode); Map<String, ResourceInstance> getInstances();  }### Answer:
@Test public void firstFileReturnsCorrectName() { String newFileName = resource.getNewInstanceFileName("myFile.jpg", 0, null); assertEquals("myFile_d0.jpg", newFileName); }
@Test public void thirdFileReturnsCorrectName() { String newFileName = resource.getNewInstanceFileName("myFile.jpg", 2, null); assertEquals("myFile_d2.jpg", newFileName); }
@Test public void fileRepeatedReturnsCorrectName() { resource.setFileExistsCountdown(2); String newFileName = resource.getNewInstanceFileName("myFile.jpg", 0, null); assertEquals("myFile_2_d0.jpg", newFileName); }
@Test public void fourthFileWithTenRepeatedReturnsCorrectName() { resource.setFileExistsCountdown(10); String tenthName = resource.getNewInstanceFileName("myFile.jpg", 4, null); assertEquals("myFile_10_d4.jpg", tenthName); }
@Test public void secondFileWithFourRepeatedAndItalianReturnsCorrectName() { resource.setFileExistsCountdown(4); String tenthName = resource.getNewInstanceFileName("myFile.jpg", 2, "it"); assertEquals("myFile_4_d2_it.jpg", tenthName); }