PreferencesRootScreen { public void hierarchyItemSelectedEvent(@Observes HierarchyItemSelectedEvent hierarchyItemSelectedEvent) { Map<String, String> parameters = new HashMap<>(); parameters.put("id", hierarchyItemSelectedEvent.getItemId()); parameters.put("title", view.getTranslation(hierarchyItemSelectedEvent.getPreference().bundleKey())); final HTMLElement editorContainer = view.getEditorContainer(); if (openedPreferencePlaceRequest != null) { placeManager.closePlace(openedPreferencePlaceRequest); } openedPreferencePlaceRequest = new DefaultPlaceRequest(getPreferenceFormIdentifier(hierarchyItemSelectedEvent.getPreferenceIdentifier()), parameters); placeManager.goTo(openedPreferencePlaceRequest, editorContainer); final HierarchyItemFormInitializationEvent event = new HierarchyItemFormInitializationEvent(hierarchyItemSelectedEvent.getHierarchyElement()); hierarchyItemFormInitializationEvent.fire(event); } @Inject  PreferencesRootScreen(final View view,
                                 final PlaceManager placeManager,
                                 final PreferenceFormBeansInfo preferenceFormBeansInfo,
                                 final Event<HierarchyItemFormInitializationEvent> hierarchyItemFormInitializationEvent); @OnStartup void setup(); @OnClose void onClose(); void hierarchyItemSelectedEvent(@Observes HierarchyItemSelectedEvent hierarchyItemSelectedEvent); String getPreferenceFormIdentifier(final String preferenceIdentifier); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView View getView(); static final String IDENTIFIER; }
@Test public void hierarchyItemSelectedEventWithoutPreviouslyOpenedPreference() { final HierarchyItemSelectedEvent event = mock(HierarchyItemSelectedEvent.class); doReturn(mock(BasePreferencePortable.class)).when(event).getPreference(); doReturn(mock(PreferenceHierarchyElement.class)).when(event).getHierarchyElement(); screen.hierarchyItemSelectedEvent(event); verify(placeManager, never()).closePlace(any(PlaceRequest.class)); verify(placeManager).goTo(any(PlaceRequest.class), any(HTMLElement.class)); verify(hierarchyItemFormInitializationEvent).fire(any()); }
@Test public void hierarchyItemSelectedEventWithPreviouslyOpenedPreference() { hierarchyItemSelectedEventWithoutPreviouslyOpenedPreference(); Mockito.reset(placeManager, hierarchyItemFormInitializationEvent); final HierarchyItemSelectedEvent event = mock(HierarchyItemSelectedEvent.class); doReturn(mock(BasePreferencePortable.class)).when(event).getPreference(); doReturn(mock(PreferenceHierarchyElement.class)).when(event).getHierarchyElement(); screen.hierarchyItemSelectedEvent(event); verify(placeManager).closePlace(any(PlaceRequest.class)); verify(placeManager).goTo(any(PlaceRequest.class), any(HTMLElement.class)); verify(hierarchyItemFormInitializationEvent).fire(any()); }