@Test
public void uploadProjectValidatorModifiedFileTHIN() throws Exception {

  // NOTE!! This test assumes that the thin archive project folder structure defined in
  // ThinArchiveTestUtils.makeSampleThinProjectDirAB() is not modified. If it is modified,
  // this test will have to be updated.
  final String writtenModifiedString = "HELLOEVERYONE";
  final User uploader = new User("test_user");
  final File projectZipFile = setupTestTHIN();
  // When archiveUnthinner is called, modify a file in the folder
  doAnswer((Answer<Map<String, ValidationReport>>) invocation -> {
    File libFolder = new File((File) invocation.getArguments()[1], "lib");
    File randomLib = FileUtils.listFiles(libFolder, null, false).iterator().next();
    FileUtils.writeStringToFile(randomLib, writtenModifiedString);
    ValidationReport r = new ValidationReport();
    r.addModifiedFiles(new HashSet(Arrays.asList(randomLib)));
    Map<String, ValidationReport> resultingReports = new HashMap();
    resultingReports.put("somevalidator", r);
    return resultingReports;
  }).when(this.archiveUnthinner).validateThinProject(any(), any(), any(), any());
  // When uploadProject is called, make sure it has the correctly modified zip being passed in and that
  // the startup-dependencies.json file being passed still exists (it wasn't cleaned up too early).
  doAnswer(invocation -> {
    File zipFileBeingUploaded = (File) invocation.getArguments()[2];
    File unzippedFinalProjFolder = TEMP_DIR.newFolder("finalproj");
    Utils.unzip(new ZipFile(zipFileBeingUploaded), unzippedFinalProjFolder);
    File libFolder = new File(unzippedFinalProjFolder, "lib");
    File randomLib = FileUtils.listFiles(libFolder, null, false).iterator().next();
    // Let's check to make sure that file we modified is modified in the final zip
    assertEquals(writtenModifiedString, FileUtils.readFileToString(randomLib));
    // Make sure startup-dependencies.json file still exists
    assertTrue(((File) invocation.getArguments()[3]).exists());
    return null;
  }).when(this.projectStorageManager)
      .uploadProject(any(Project.class), anyInt(), any(File.class), any(File.class),
          any(User.class), anyString());
  this.project.setVersion(this.VERSION);
  this.azkabanProjectLoader
      .uploadProject(this.project, projectZipFile, "zip", uploader, null,
          IPv6);
  // Verify that the archiveUnthinner was called
  verify(this.archiveUnthinner).validateThinProject(any(), any(), any(), any());
}