DataSetExplorer implements IsWidget { void onDataSetDefRemovedEvent(@Observes DataSetDefRemovedEvent event) { checkNotNull("event", event); final DataSetDef def = event.getDataSetDef(); if (def != null && def.isPublic()) { show(); } } @Inject  DataSetExplorer(final Instance<DataSetPanel> panelInstances,
                           final DataSetClientServices clientServices,
                           final View view); @PostConstruct void init(); @Override Widget asWidget(); void show();  }
@Test public void testOnDataSetDefRemovedEvent() { final DataSetDef removedDataSetDef = mock(DataSetDef.class); when(removedDataSetDef.getUUID()).thenReturn("removed"); when(removedDataSetDef.getName()).thenReturn("removedDef"); when(removedDataSetDef.isPublic()).thenReturn(true); when(removedDataSetDef.getProvider()).thenReturn(DataSetProviderType.SQL); final DataSetDefRemovedEvent event = mock(DataSetDefRemovedEvent.class); when(event.getDataSetDef()).thenReturn(removedDataSetDef); presenter.onDataSetDefRemovedEvent(event); assertEquals(1, presenter.panels.size()); assertEquals(dataSetPanel, presenter.panels.get(0)); verify(view, times(1)).clear(); verify(view, times(1)).addPanel(any(DataSetPanel.View.class)); verify(dataSetPanel, times(1)).show(dataSetDef, "dataSetsExplorerPanelGroup"); }