@Test
public void uploadProjectValidatorRemovedFileTHIN() 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 User uploader = new User("test_user");
  final File projectZipFile = setupTestTHIN();
  // When archiveUnthinner is called, remove a file from 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();
    randomLib.delete();
    ValidationReport r = new ValidationReport();
    r.addRemovedFiles(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");
    // Let's check to make sure that file we removed is not included in the final zip
    // the uploadProject method should have noticed that the report mentioned a file was removed
    // and re-zipped the folder. It's also possible that the zipping process removed the empty
    // lib folder, so as long as it does not exist OR is empty we'll pass this test.
    assertTrue(!libFolder.exists()
        || FileUtils.listFiles(libFolder, null, false).size() == 0);
    // 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());
}