void () { ModifiableModuleModel moduleModel = ModuleManager.getInstance(myProject).getModifiableModel(); Module newModule = moduleModel.newModule(new File(myProject.getBasePath(), "new.iml").toPath(), EmptyModuleType.EMPTY_MODULE); FacetManager manager = FacetManager.getInstance(newModule); assertNull(manager.getFacetByType(MockFacetType.ID)); ModifiableFacetModel model = manager.createModifiableModel(); final MockFacet facet = new MockFacet(newModule, "mock"); model.addFacet(facet); assertSame(facet, assertOneElement(model.getAllFacets())); assertSame(facet, assertOneElement(model.getFacetsByType(MockFacetType.ID))); commit(model); assertSame(facet, assertOneElement(manager.getAllFacets())); assertSame(facet, assertOneElement(manager.getFacetsByType(MockFacetType.ID))); WriteAction.runAndWait(() -> moduleModel.commit()); assertSame(facet, assertOneElement(manager.getAllFacets())); assertSame(facet, assertOneElement(manager.getFacetsByType(MockFacetType.ID))); }