Skip to content

Commit ba4bc07

Browse files
devonfw#103 fixed tests
added missing answers to IdeTestContext
1 parent 3834ce8 commit ba4bc07

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

cli/src/test/java/com/devonfw/tools/ide/context/AbstractIdeContextTest.java

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
package com.devonfw.tools.ide.context;
22

3+
import java.nio.file.Files;
4+
import java.nio.file.Path;
5+
import java.util.List;
6+
7+
import org.assertj.core.api.Assertions;
8+
import org.assertj.core.api.Condition;
9+
import org.assertj.core.api.ListAssert;
10+
311
import com.devonfw.tools.ide.io.FileAccess;
412
import com.devonfw.tools.ide.io.FileAccessImpl;
513
import com.devonfw.tools.ide.io.FileCopyMode;
614
import com.devonfw.tools.ide.io.IdeProgressBarTestImpl;
715
import com.devonfw.tools.ide.log.IdeLogLevel;
816
import com.devonfw.tools.ide.log.IdeTestLogger;
917
import com.devonfw.tools.ide.repo.ToolRepositoryMock;
10-
import org.assertj.core.api.Assertions;
11-
import org.assertj.core.api.Condition;
12-
import org.assertj.core.api.ListAssert;
13-
14-
import java.nio.file.Files;
15-
import java.nio.file.Path;
16-
import java.util.List;
1718

1819
/**
1920
* Abstract base class for tests that need mocked instances of {@link IdeContext}.
@@ -37,7 +38,7 @@ public abstract class AbstractIdeContextTest extends Assertions {
3738

3839
/**
3940
* @param testProject the (folder)name of the project test case, in this folder a 'project' folder represents the test
40-
* project in {@link #TEST_PROJECTS}. E.g. "basic".
41+
* project in {@link #TEST_PROJECTS}. E.g. "basic".
4142
* @return the {@link IdeTestContext} pointing to that project.
4243
*/
4344
protected IdeTestContext newContext(String testProject) {
@@ -47,7 +48,7 @@ protected IdeTestContext newContext(String testProject) {
4748

4849
/**
4950
* @param testProject the (folder)name of the project test case, in this folder a 'project' folder represents the test
50-
* project in {@link #TEST_PROJECTS}. E.g. "basic".
51+
* project in {@link #TEST_PROJECTS}. E.g. "basic".
5152
* @param projectPath the relative path inside the test project where to create the context.
5253
* @return the {@link IdeTestContext} pointing to that project.
5354
*/
@@ -58,15 +59,16 @@ protected static IdeTestContext newContext(String testProject, String projectPat
5859

5960
/**
6061
* @param testProject the (folder)name of the project test case, in this folder a 'project' folder represents the test
61-
* project in {@link #TEST_PROJECTS}. E.g. "basic".
62+
* project in {@link #TEST_PROJECTS}. E.g. "basic".
6263
* @param projectPath the relative path inside the test project where to create the context.
6364
* @param copyForMutation - {@code true} to create a copy of the project that can be modified by the test,
64-
* {@code false} otherwise (only to save resources if you are 100% sure that your test never modifies anything in that
65-
* project.)
65+
* {@code false} otherwise (only to save resources if you are 100% sure that your test never modifies anything
66+
* in that project.)
6667
* @param answers the answers to use for the {@link IdeTestContext}.
6768
* @return the {@link IdeTestContext} pointing to that project.
6869
*/
69-
protected static IdeTestContext newContext(String testProject, String projectPath, boolean copyForMutation) {
70+
protected static IdeTestContext newContext(String testProject, String projectPath, boolean copyForMutation,
71+
String... answers) {
7072

7173
Path ideRoot = TEST_PROJECTS.resolve(testProject);
7274
if (copyForMutation) {
@@ -87,7 +89,7 @@ protected static IdeTestContext newContext(String testProject, String projectPat
8789
if (Files.isDirectory(repositoryFolder)) {
8890
toolRepository = new ToolRepositoryMock(repositoryFolder);
8991
}
90-
IdeTestContext context = new IdeTestContext(ideHome, toolRepository);
92+
IdeTestContext context = new IdeTestContext(ideHome, toolRepository, answers);
9193
if (toolRepository != null) {
9294
toolRepository.setContext(context);
9395
}

cli/src/test/java/com/devonfw/tools/ide/tool/ToolCommandletTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public void testSecurityRiskInteractionCurrentVersionIsSafe() {
314314
*/
315315
private IdeContext getContextForSecurityJsonTests(Class<? extends ToolCommandlet> dummyTool, String... answers) {
316316

317-
String path = "workspaces/foo-test/my-git-repo";
317+
String path = "project/workspaces/foo-test/my-git-repo";
318318
// if I don't pass answers here I get: End of answers reached!
319319
IdeContext context = newContext("basic", path, true, answers);
320320
ToolCommandlet toolCommandlet = context.getCommandletManager().getCommandlet(dummyTool);

cli/src/test/java/com/devonfw/tools/ide/url/model/UrlSecurityJsonFileTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class UrlSecurityJsonFileTest extends AbstractIdeContextTest {
2424
public void testUrlJsonSecurityFileLoad() {
2525

2626
// arrange
27-
String path = "workspaces/foo-test/my-git-repo";
27+
String path = "project/workspaces/foo-test/my-git-repo";
2828
UrlSecurityWarning warning1 = new UrlSecurityWarning();
2929
warning1.setVersionRange(VersionRange.of("[3.0.6,3.2.1)"));
3030
warning1.setSeverity(BigDecimal.valueOf(5.8));
@@ -54,7 +54,7 @@ public void testUrlJsonSecurityFileLoad() {
5454
public void testUrlJsonSecurityFileAddAndSave() {
5555

5656
// arrange
57-
String path = "workspaces/foo-test/my-git-repo";
57+
String path = "project/workspaces/foo-test/my-git-repo";
5858
IdeContext context = newContext("basic", path, true);
5959
UrlSecurityJsonFile securityFile = context.getUrls().getEdition("mvn", "mvn").getSecurityJsonFile();
6060
Path securityFilePath = securityFile.getPath();
@@ -82,7 +82,7 @@ public void testUrlJsonSecurityFileAddAndSave() {
8282
public void testUrlSecurityJsonFileContains() {
8383

8484
// arrange
85-
String path = "workspaces/foo-test/my-git-repo";
85+
String path = "project/workspaces/foo-test/my-git-repo";
8686
IdeContext context = newContext("basic", path, true);
8787
UrlSecurityJsonFile securityFile = context.getUrls().getEdition("mvn", "mvn").getSecurityJsonFile();
8888

@@ -99,7 +99,7 @@ public void testUrlSecurityJsonFileContains() {
9999
public void testUrlSecurityJsonFileContainsIgnoreWarningsThatAffectAllVersions() {
100100

101101
// arrange
102-
String path = "workspaces/foo-test/my-git-repo";
102+
String path = "project/workspaces/foo-test/my-git-repo";
103103
IdeContext context = newContext("basic", path, true);
104104
UrlEdition edition = context.getUrls().getEdition("mvn", "mvn");
105105
UrlSecurityJsonFile securityFile = edition.getSecurityJsonFile();
@@ -114,7 +114,7 @@ public void testUrlSecurityJsonFileContainsIgnoreWarningsThatAffectAllVersions()
114114
public void testGetMatchingSecurityWarnings() {
115115

116116
// arrange
117-
String path = "workspaces/foo-test/my-git-repo";
117+
String path = "project/workspaces/foo-test/my-git-repo";
118118
IdeContext context = newContext("basic", path, true);
119119
UrlEdition edition = context.getUrls().getEdition("mvn", "mvn");
120120
UrlSecurityJsonFile securityFile = edition.getSecurityJsonFile();

0 commit comments

Comments
 (0)