Skip to content

Commit 6c44432

Browse files
committed
#1802: cleaned up IdeGuiStateManagerTest
1 parent ac3a045 commit 6c44432

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

gui/src/test/java/com/devonfw/ide/gui/context/IdeGuiStateManagerTest.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55
import java.nio.file.Files;
66
import java.nio.file.Path;
7+
import java.util.stream.Stream;
78

89
import org.junit.jupiter.api.BeforeAll;
910
import 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
}

gui/src/test/java/com/devonfw/ide/gui/context/ProjectManagerTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import org.junit.jupiter.api.BeforeEach;
1010
import org.junit.jupiter.api.Test;
11-
import org.slf4j.Logger;
12-
import org.slf4j.LoggerFactory;
1311

1412
import com.devonfw.tools.ide.context.AbstractIdeContextTest;
1513
import com.devonfw.tools.ide.context.IdeTestContext;
@@ -19,8 +17,6 @@
1917
*/
2018
public class ProjectManagerTest extends AbstractIdeContextTest {
2119

22-
private static final Logger LOG = LoggerFactory.getLogger(ProjectManagerTest.class);
23-
2420
private static ProjectManager projectManager;
2521

2622
private static IdeTestContext context;

0 commit comments

Comments
 (0)