44import java .io .IOException ;
55import java .nio .file .Files ;
66import java .nio .file .Path ;
7+ import java .util .stream .Stream ;
78
89import org .junit .jupiter .api .BeforeAll ;
910import org .junit .jupiter .api .BeforeEach ;
@@ -29,8 +30,8 @@ public class IdeGuiStateManagerTest extends AbstractIdeContextTest {
2930 @ BeforeAll
3031 static void setup () throws FileNotFoundException {
3132
32- context = newContext ("testProject" , "project" );
33- LOG .warn ("root: {}" , context .getIdeRoot ());
33+ context = newContext ("testProject" , "project-0 " );
34+ LOG .debug ("root: {}" , context .getIdeRoot ());
3435
3536 guiStateManager = IdeGuiStateManager .getInstanceOverrideRootDir (context .getIdeRoot ().toString ());
3637 projectManager = guiStateManager .getProjectManager ();
@@ -96,14 +97,18 @@ void testThrowsIfNonExistentProjectSelected() {
9697 @ Test
9798 void testThrowsIfNonExistentWorkspaceSelected () throws IOException {
9899
99- Files .list (context .getIdeRoot ()).forEach ((projectPath ) -> {
100- try {
101- guiStateManager .switchContext (projectPath .getFileName ().toString (), "test" );
102- } catch (FileNotFoundException e ) {
103- assertThat (e .getMessage ()).contains ("Workspace " + projectPath .resolve ("workspaces" ).resolve ("test" ) + " does not exist!" )
104- .as ("GuiStateManager.switchContext should throw an exception, if a non-existent workspace is selected" );
105- }
106- });
100+ try (Stream <Path > stream = Files .list (context .getIdeRoot ())) {
101+ stream .forEach ((projectPath ) -> {
102+ Path fakeWorkspacePath = projectPath .resolve ("workspaces" ).resolve ("nonExistingWorkspace" );
103+
104+ try {
105+ guiStateManager .switchContext (projectPath .getFileName ().toString (), fakeWorkspacePath .getFileName ().toString ());
106+ } catch (FileNotFoundException e ) {
107+ assertThat (e .getMessage ()).contains ("Workspace " + fakeWorkspacePath + " does not exist!" )
108+ .as ("GuiStateManager.switchContext should throw an exception, if a non-existent workspace is selected" );
109+ }
110+ });
111+ }
107112 }
108113
109114}
0 commit comments