### Question:
ComponentsVm { @Command public void deleteComponent() { Validate.validState(selected != null, "entity to delete must be selected"); deleteComponentDialog.confirmDeletion(selected); } ComponentsVm(final ComponentService componentService, final WindowManager windowManager,
            final SelectedEntity<Component> selectedEntity, final ComponentList componentsToBeNotified); Component getPoulpe(); boolean isPoulpeVisible(); Component getJcommune(); boolean isJcommuneVisible(); @Command void deleteComponent(); @Command void reindexComponent(); @Command void addNewPoulpe(); @Command void addNewJcommune(); @Command void configureComponent(); @Command final void backupDatabase(); void setSelected(final Component selected); static void show(final WindowManager windowManager); boolean isJcommuneAvailable(); boolean isShowReindexStartedNotification(); final void setFileDownloadService(final FileDownloadService fileDownloadService); static final String SHOW_REINDEX_START_NOTIFICATION; static final String COMPONENTS_PAGE_LOCATION; }### Answer:
@Test public void deleteComponent() throws NoSuchFieldException, IllegalAccessException { Component selected = givenSelectedComponent(); DeleteComponentDialog deleteComponentDialog = mock(DeleteComponentDialog.class); setField("deleteComponentDialog", deleteComponentDialog); componentsVm.deleteComponent(); verify(deleteComponentDialog).confirmDeletion(selected); }
@Test(expectedExceptions = IllegalStateException.class) public void deleteComponent_componentMustBeSelected() { componentsVm.deleteComponent(); }