1212
1313package org .eclipse .ui .tests .e4 ;
1414
15+ import static org .junit .Assert .assertFalse ;
16+ import static org .junit .Assert .assertNotNull ;
17+ import static org .junit .Assert .assertNull ;
18+ import static org .junit .Assert .assertTrue ;
19+ import static org .junit .Assert .fail ;
20+
1521import java .util .Collections ;
1622import java .util .List ;
1723import java .util .Optional ;
4450import org .eclipse .ui .PartInitException ;
4551import org .eclipse .ui .internal .CloseAllHandler ;
4652import org .eclipse .ui .internal .Workbench ;
47- import org .junit .Assert ;
4853import org .junit .Before ;
4954import org .junit .Test ;
5055import org .osgi .framework .BundleContext ;
@@ -102,12 +107,12 @@ public void testCloseMixedEditorTypes() {
102107
103108 Command closeAllCommand = commandService .getCommand (CLOSE_ALL_EDITORS_COMMAND_ID );
104109 final ParameterizedCommand parameterizedCommand = ParameterizedCommand .generateCommand (closeAllCommand ,
105- Collections .EMPTY_MAP );
110+ Collections .emptyMap () );
106111
107112 // verify the close all editors handler enabledment is false (no editors are
108113 // open yet!)
109114 boolean canExecute = handlerService .canExecute (parameterizedCommand );
110- Assert . assertFalse (canExecute );
115+ assertFalse (canExecute );
111116
112117 // scenario 1: e4 part descriptor contribution
113118 MPartDescriptor partDescriptor = createDummyPartDescriptor ();
@@ -119,46 +124,46 @@ public void testCloseMixedEditorTypes() {
119124 // verify the close all handler is enabled now (since dummy editor has been
120125 // opened)
121126 canExecute = handlerService .canExecute (parameterizedCommand );
122- Assert . assertTrue (canExecute );
127+ assertTrue (canExecute );
123128
124129 // close all editors (dummy editor should close!)
125130 dummyPart = partService .findPart (DUMMY_E4_PART_ID );
126- Assert . assertNotNull (dummyPart );
131+ assertNotNull (dummyPart );
127132 handlerService .executeHandler (parameterizedCommand );
128133 dummyPart = partService .findPart (DUMMY_E4_PART_ID );
129- Assert . assertNull (dummyPart );
134+ assertNull (dummyPart );
130135
131136 // verify the close all handler is *not* enabled now (since dummy editor has
132137 // been closed)
133138 canExecute = handlerService .canExecute (parameterizedCommand );
134- Assert . assertFalse (canExecute );
139+ assertFalse (canExecute );
135140
136141 // scenario 2: open a compatibility layer editor
137142 IFileEditorInput input = new DummyFileEditorInput ();
138143 Object activeWindow = applicationContext .getActive (ISources .ACTIVE_WORKBENCH_WINDOW_NAME );
139- Assert . assertTrue ("Active workbench window not found." , activeWindow instanceof IWorkbenchWindow );
144+ assertTrue ("Active workbench window not found." , activeWindow instanceof IWorkbenchWindow );
140145 IWorkbenchWindow window = (IWorkbenchWindow ) activeWindow ;
141146 try {
142147 window .getActivePage ().openEditor (input , TEST_COMPATIBILITY_LAYER_EDITOR_ID );
143148 } catch (PartInitException e ) {
144- Assert . fail ("Test Compatibility Editor could not be opened. Further testing cannot complete." );
149+ fail ("Test Compatibility Editor could not be opened. Further testing cannot complete." );
145150 }
146151
147152 // verify the close all handler is enabled now (since a dummy compatibility
148153 // layer editor has been opened)
149154 canExecute = handlerService .canExecute (parameterizedCommand );
150- Assert . assertTrue (canExecute );
155+ assertTrue (canExecute );
151156
152157 IEditorPart compatEditor = window .getActivePage ().findEditor (input );
153- Assert . assertNotNull (compatEditor );
158+ assertNotNull (compatEditor );
154159 handlerService .executeHandler (parameterizedCommand );
155160 compatEditor = window .getActivePage ().findEditor (input );
156- Assert . assertNull (compatEditor );
161+ assertNull (compatEditor );
157162
158163 // verify the close all handler is *not* enabled now (since compatibility layer
159164 // editor has been closed)
160165 canExecute = handlerService .canExecute (parameterizedCommand );
161- Assert . assertFalse (canExecute );
166+ assertFalse (canExecute );
162167
163168 // scenario 3:
164169 // finally: re-open both the compatibility layer editor *and* the dummy e4 part
@@ -168,33 +173,33 @@ public void testCloseMixedEditorTypes() {
168173 try {
169174 window .getActivePage ().openEditor (input , TEST_COMPATIBILITY_LAYER_EDITOR_ID );
170175 } catch (PartInitException e ) {
171- Assert . fail ("Test Compatibility Editor could not be opened. Further testing cannot complete." );
176+ fail ("Test Compatibility Editor could not be opened. Further testing cannot complete." );
172177 }
173178 compatEditor = window .getActivePage ().findEditor (input );
174- Assert . assertNotNull (compatEditor );
179+ assertNotNull (compatEditor );
175180 dummyPart = partService .findPart (DUMMY_E4_PART_ID );
176- Assert . assertNotNull (dummyPart );
181+ assertNotNull (dummyPart );
177182
178183 canExecute = handlerService .canExecute (parameterizedCommand );
179- Assert . assertTrue (canExecute );
184+ assertTrue (canExecute );
180185
181186 // close all editors
182187 handlerService .executeHandler (parameterizedCommand );
183188 canExecute = handlerService .canExecute (parameterizedCommand );
184- Assert . assertFalse (canExecute );
189+ assertFalse (canExecute );
185190
186191 // verify they are all closed
187192 compatEditor = window .getActivePage ().findEditor (input );
188- Assert . assertNull (compatEditor );
193+ assertNull (compatEditor );
189194 dummyPart = partService .findPart (DUMMY_E4_PART_ID );
190- Assert . assertNull (dummyPart );
195+ assertNull (dummyPart );
191196 }
192197
193198 private MPart createAndOpenE4Part (MPartDescriptor partDescriptor ) {
194199 Optional <MPartStack > primaryPartStack = findPrimaryConfiguationAreaPartStack (application , modelService );
195200
196201 if (primaryPartStack .isEmpty ()) {
197- Assert . fail ("Test cannot proceed as the primary part stack could not be found in the application." );
202+ fail ("Test cannot proceed as the primary part stack could not be found in the application." );
198203 }
199204
200205 MPart dummyPart = partService .createPart (partDescriptor .getElementId ());
@@ -226,10 +231,10 @@ private Optional<MPartStack> findPrimaryConfiguationAreaPartStack(MApplication a
226231 if (areaCandidates .size () == 1 ) {
227232 MArea primaryArea = areaCandidates .get (0 );
228233 for (MPartSashContainerElement element : primaryArea .getChildren ()) {
229- if (element instanceof MPartStack ) {
230- return Optional .of (( MPartStack ) element );
231- } else if (element instanceof MPartSashContainer ) {
232- return (( MPartSashContainer ) element ) .getChildren ().stream ().filter (c -> c instanceof MPartStack )
234+ if (element instanceof MPartStack partStack ) {
235+ return Optional .of (partStack );
236+ } else if (element instanceof MPartSashContainer sash ) {
237+ return sash .getChildren ().stream ().filter (c -> c instanceof MPartStack )
233238 .map (c -> (MPartStack ) c ).findFirst ();
234239 }
235240 }
0 commit comments