public void testResourceBundleManagerUpdatesProperlyWhileDirRemoval() {
    myFixture.addFileToProject("qwe/asd/p.properties", "");
    final PsiFile file = myFixture.addFileToProject("qwe/asd/p_en.properties", "");
    final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file);
    assertNotNull(propertiesFile);
    final ResourceBundleManager resourceBundleManager =
        ResourceBundleManager.getInstance(getProject());
    resourceBundleManager.dissociateResourceBundle(propertiesFile.getResourceBundle());

    final PropertiesFile propFile1 =
        PropertiesImplUtil.getPropertiesFile(
            myFixture.addFileToProject("qwe1/asd1/p.properties", ""));
    final PropertiesFile propFile2 =
        PropertiesImplUtil.getPropertiesFile(
            myFixture.addFileToProject("qwe1/asd1/p_abc.properties", ""));
    assertNotNull(propFile1);
    assertNotNull(propFile2);
    resourceBundleManager.combineToResourceBundle(
        ContainerUtil.newArrayList(propFile1, propFile2), "p");

    final PsiFile someFile = myFixture.addFileToProject("to_remove/asd.txt", "");
    final PsiDirectory toRemove = someFile.getParent();
    assertNotNull(toRemove);
    ApplicationManager.getApplication().runWriteAction(toRemove::delete);

    final ResourceBundleManagerState state = resourceBundleManager.getState();
    assertNotNull(state);
    assertSize(1, state.getCustomResourceBundles());
    assertSize(2, state.getDissociatedFiles());

    final PsiDirectory directory = propertiesFile.getParent().getParent();
    assertNotNull(directory);
    ApplicationManager.getApplication().runWriteAction(directory::delete);

    assertSize(1, state.getCustomResourceBundles());
    assertSize(0, state.getDissociatedFiles());

    final PsiDirectory directory1 = propFile1.getParent().getParent();
    assertNotNull(directory1);
    ApplicationManager.getApplication().runWriteAction(directory1::delete);

    assertSize(0, state.getCustomResourceBundles());
    assertSize(0, state.getDissociatedFiles());
  }
  public void testResourceBundleManagerUpdatesProperlyWhileDirMove() {
    final PropertiesFile propFile1 =
        PropertiesImplUtil.getPropertiesFile(myFixture.addFileToProject("qwe/p.properties", ""));
    final PropertiesFile propFile2 =
        PropertiesImplUtil.getPropertiesFile(
            myFixture.addFileToProject("qwe/p_abc.properties", ""));
    assertNotNull(propFile1);
    assertNotNull(propFile2);
    myFixture.addFileToProject("qwe/q.properties", "");
    final PropertiesFile propertiesFile =
        PropertiesImplUtil.getPropertiesFile(myFixture.addFileToProject("qwe/q_fr.properties", ""));
    assertNotNull(propertiesFile);
    assertSize(2, propertiesFile.getResourceBundle().getPropertiesFiles());

    final ResourceBundleManager resourceBundleManager =
        ResourceBundleManager.getInstance(getProject());
    resourceBundleManager.combineToResourceBundle(
        ContainerUtil.newArrayList(propFile1, propFile2), "p");
    resourceBundleManager.dissociateResourceBundle(propertiesFile.getResourceBundle());
    assertSize(1, propertiesFile.getResourceBundle().getPropertiesFiles());
    assertSize(2, propFile2.getResourceBundle().getPropertiesFiles());

    final PsiDirectory toMove = myFixture.addFileToProject("asd/temp.txt", "").getParent();
    assertNotNull(toMove);
    ApplicationManager.getApplication()
        .runWriteAction(
            () -> MoveFilesOrDirectoriesUtil.doMoveDirectory(propFile1.getParent(), toMove));

    final PsiDirectory movedDir = toMove.findSubdirectory("qwe");
    assertNotNull(movedDir);

    final PropertiesFile newPropFile1 =
        PropertiesImplUtil.getPropertiesFile(movedDir.findFile("p.properties"));
    assertNotNull(newPropFile1);
    assertSize(2, newPropFile1.getResourceBundle().getPropertiesFiles());

    final PropertiesFile newPropertiesFile =
        PropertiesImplUtil.getPropertiesFile(movedDir.findFile("q_fr.properties"));
    assertNotNull(newPropertiesFile);
    assertSize(1, newPropertiesFile.getResourceBundle().getPropertiesFiles());
  }