void () { myProject.getMessageBus().connect(getTestRootDisposable()).subscribe(ModuleRootListener.TOPIC, new ModuleRootListener() { @Override public void rootsChanged(@NotNull ModuleRootEvent event) { fail("rootsChanged must not be called on change of facets"); } }); final FacetManager manager = getFacetManager(); assertEquals(0, manager.getAllFacets().length); assertEquals(0, manager.getFacetsByType(MockFacetType.ID).size()); assertNull(manager.getFacetByType(MockFacetType.ID)); ModifiableFacetModel model = manager.createModifiableModel(); final MockFacet facet = createFacet(); model.addFacet(facet); assertTrue(model.isNewFacet(facet)); assertEquals(0, manager.getAllFacets().length); assertSame(facet, assertOneElement(model.getAllFacets())); assertSame(facet, assertOneElement(model.getFacetsByType(MockFacetType.ID))); assertFalse(facet.isInitialized()); commit(model); assertTrue(facet.isInitialized()); assertSame(facet, assertOneElement(manager.getAllFacets())); assertSame(facet, assertOneElement(manager.getFacetsByType(MockFacetType.ID))); model = manager.createModifiableModel(); assertFalse(model.isNewFacet(facet)); model.removeFacet(facet); assertFalse(facet.isDisposed()); assertFalse(model.isNewFacet(facet)); commit(model); assertEquals(0, manager.getAllFacets().length); assertEquals(0, manager.getFacetsByType(MockFacetType.ID).size()); assertTrue(facet.isDisposed()); }