|
11 | 11 |
|
12 | 12 | package com.ibm.microclimate.test; |
13 | 13 |
|
| 14 | +import java.io.IOException; |
14 | 15 | import java.net.URI; |
15 | 16 | import java.net.URL; |
16 | 17 | import java.util.HashSet; |
| 18 | +import java.util.List; |
17 | 19 | import java.util.Set; |
18 | 20 |
|
19 | 21 | import org.eclipse.core.resources.IMarker; |
|
31 | 33 | import org.eclipse.ui.console.IConsoleManager; |
32 | 34 | import org.eclipse.ui.console.TextConsole; |
33 | 35 | import org.eclipse.ui.ide.IDE; |
| 36 | +import org.json.JSONException; |
34 | 37 |
|
35 | 38 | import com.ibm.microclimate.core.internal.HttpUtil; |
36 | 39 | import com.ibm.microclimate.core.internal.MCEclipseApplication; |
|
39 | 42 | import com.ibm.microclimate.core.internal.connection.MicroclimateConnection; |
40 | 43 | import com.ibm.microclimate.core.internal.connection.MicroclimateConnectionManager; |
41 | 44 | import com.ibm.microclimate.core.internal.console.MicroclimateConsoleFactory; |
| 45 | +import com.ibm.microclimate.core.internal.console.ProjectTemplateInfo; |
42 | 46 | import com.ibm.microclimate.core.internal.constants.AppState; |
43 | 47 | import com.ibm.microclimate.core.internal.constants.MCConstants; |
44 | 48 | import com.ibm.microclimate.core.internal.constants.ProjectType; |
@@ -76,7 +80,7 @@ public void doSetup() throws Exception { |
76 | 80 | MicroclimateConnectionManager.add(connection); |
77 | 81 |
|
78 | 82 | // Create a new microprofile project |
79 | | - connection.requestProjectCreate(projectType, projectName); |
| 83 | + createProject(projectType, projectName); |
80 | 84 |
|
81 | 85 | // Wait for the project to be created |
82 | 86 | assertTrue("The application " + projectName + " should be created", MicroclimateUtil.waitForProject(connection, projectName, 300, 5)); |
@@ -238,5 +242,34 @@ public static Boolean setWorkspaceAutoBuild(boolean enabled) { |
238 | 242 | } |
239 | 243 | return null; |
240 | 244 | } |
| 245 | + |
| 246 | + protected void createProject(ProjectType type, String name) throws IOException, JSONException { |
| 247 | + if (connection.checkVersion(1905, "2019_M5_E")) { |
| 248 | + ProjectTemplateInfo templateInfo = null; |
| 249 | + List<ProjectTemplateInfo> templates = connection.requestProjectTemplates(); |
| 250 | + for (ProjectTemplateInfo template : templates) { |
| 251 | + if (type.language.equals(template.getLanguage())) { |
| 252 | + if (type.isLanguage(ProjectType.LANGUAGE_JAVA)) { |
| 253 | + String extension = template.getExtension(); |
| 254 | + if (type.isType(ProjectType.TYPE_LIBERTY) && extension.toLowerCase().contains("microprofile")) { |
| 255 | + templateInfo = template; |
| 256 | + break; |
| 257 | + } |
| 258 | + if (type.isType(ProjectType.TYPE_SPRING) && extension.toLowerCase().contains("spring")) { |
| 259 | + templateInfo = template; |
| 260 | + break; |
| 261 | + } |
| 262 | + } else { |
| 263 | + templateInfo = template; |
| 264 | + break; |
| 265 | + } |
| 266 | + } |
| 267 | + } |
| 268 | + assertNotNull("No template found that matches the project type: " + projectType, templateInfo); |
| 269 | + connection.requestProjectCreate(templateInfo, name); |
| 270 | + } else { |
| 271 | + connection.requestProjectCreate(projectType, projectName); |
| 272 | + } |
| 273 | + } |
241 | 274 |
|
242 | 275 | } |
0 commit comments