Rework ConvertToProjectWithPomFileTest test for checking conversion folders to maven multimodule project (#11427)
Rework ConvertToProjectWithPomFileTest test for checking conversion folders to maven multimodule project6.19.x
parent
6049168cdb
commit
4d05e9cab0
|
|
@ -293,6 +293,8 @@ public class TestProjectServiceClient {
|
|||
return requestFactory
|
||||
.fromUrl(workspaceAgentApiEndpointUrlProvider.get(workspaceId) + "project/" + projectName)
|
||||
.useGetMethod()
|
||||
.setAuthorizationHeader(
|
||||
BEARER_TOKEN_PREFIX + machineServiceClient.getMachineApiToken(workspaceId))
|
||||
.request()
|
||||
.asDto(ProjectConfigDto.class);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ public class ProjectTemplates {
|
|||
public static final String CONSOLE_JAVA_SIMPLE = "console_java_simple.json";
|
||||
public static final String GO = "go.json";
|
||||
public static final String DOT_NET = "dotNet.json";
|
||||
public static final String PROJECT_OF_UNDEFINED_TYPE = "undefined.json";
|
||||
|
||||
private ProjectTemplates() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2018 Red Hat, Inc.
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.selenium.miscellaneous;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Project.PROJECT;
|
||||
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Project.UPDATE_PROJECT_CONFIGURATION;
|
||||
import static org.eclipse.che.selenium.core.constant.TestProjectExplorerContextMenuConstants.ContextMenuFirstLevelItems.CONVERT_TO_PROJECT;
|
||||
import static org.eclipse.che.selenium.core.project.ProjectTemplates.PROJECT_OF_UNDEFINED_TYPE;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Paths;
|
||||
import org.eclipse.che.commons.lang.NameGenerator;
|
||||
import org.eclipse.che.selenium.core.SeleniumWebDriver;
|
||||
import org.eclipse.che.selenium.core.action.ActionsFactory;
|
||||
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
|
||||
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
|
||||
import org.eclipse.che.selenium.pageobject.AskForValueDialog;
|
||||
import org.eclipse.che.selenium.pageobject.CodenvyEditor;
|
||||
import org.eclipse.che.selenium.pageobject.Ide;
|
||||
import org.eclipse.che.selenium.pageobject.InformationDialog;
|
||||
import org.eclipse.che.selenium.pageobject.Loader;
|
||||
import org.eclipse.che.selenium.pageobject.Menu;
|
||||
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
|
||||
import org.eclipse.che.selenium.pageobject.Wizard;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/** @author Aleksandr Shmaraev, Musienko Maxim */
|
||||
public class ConvertToMavenProjectTest {
|
||||
private static final String PROJECT_NAME = NameGenerator.generate("project", 4);
|
||||
private static final String WEB_APP_MODULE = "my-webapp";
|
||||
private static final String NONE_MAVEN_PROJECT = NameGenerator.generate("noneMavenProject", 4);
|
||||
private static final String PARENT_ARTIFACT_SECTION =
|
||||
"<parent>\n"
|
||||
+ "<groupId>org.eclipse.che.examples</groupId>\n"
|
||||
+ "<artifactId>qa-multimodule</artifactId>\n"
|
||||
+ " <version>1.0-SNAPSHOT</version>\n"
|
||||
+ "</parent>\n";
|
||||
private static final String CONVERT_PATH = format("%s/%s", PROJECT_NAME, WEB_APP_MODULE);
|
||||
@Inject private TestWorkspace workspace;
|
||||
@Inject private Ide ide;
|
||||
@Inject private ProjectExplorer projectExplorer;
|
||||
@Inject private CodenvyEditor editor;
|
||||
@Inject private Menu menu;
|
||||
@Inject private Loader loader;
|
||||
@Inject private Wizard wizard;
|
||||
@Inject private AskForValueDialog askForValueDialog;
|
||||
@Inject private InformationDialog informationDialog;
|
||||
@Inject private ActionsFactory actionsFactory;
|
||||
@Inject private TestProjectServiceClient testProjectServiceClient;
|
||||
@Inject private SeleniumWebDriver seleniumWebDriver;
|
||||
private String workspaceId;
|
||||
|
||||
@BeforeClass
|
||||
public void setUp() throws Exception {
|
||||
workspaceId = workspace.getId();
|
||||
URL mavenMultimodule = getClass().getResource("/projects/java-multimodule");
|
||||
URL noneMavenProject = getClass().getResource("/projects/console-cpp-simple");
|
||||
testProjectServiceClient.importProject(
|
||||
workspaceId, Paths.get(mavenMultimodule.toURI()), PROJECT_NAME, PROJECT_OF_UNDEFINED_TYPE);
|
||||
testProjectServiceClient.importProject(
|
||||
workspaceId,
|
||||
Paths.get(noneMavenProject.toURI()),
|
||||
NONE_MAVEN_PROJECT,
|
||||
PROJECT_OF_UNDEFINED_TYPE);
|
||||
|
||||
ide.open(workspace);
|
||||
ide.waitOpenedWorkspaceIsReadyToUse();
|
||||
projectExplorer.quickRevealToItemWithJavaScript(format("%s/%s", PROJECT_NAME, WEB_APP_MODULE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldConvertToMavenMultimoduleProject() throws Exception {
|
||||
convertPredefinedFolderToMavenProjectWithContextMenu(CONVERT_PATH);
|
||||
testProjectServiceClient.checkProjectType(workspaceId, CONVERT_PATH, "maven");
|
||||
addParentArticatSectionIntoPomFile();
|
||||
menu.runCommand(PROJECT, UPDATE_PROJECT_CONFIGURATION);
|
||||
convertToMavenByWizard("/", PROJECT_NAME);
|
||||
testProjectServiceClient.checkProjectType(workspaceId, CONVERT_PATH, "maven");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotConvertToMavenProject() {
|
||||
projectExplorer.waitAndSelectItem(NONE_MAVEN_PROJECT);
|
||||
menu.runCommand(PROJECT, UPDATE_PROJECT_CONFIGURATION);
|
||||
wizard.waitOpenProjectConfigForm();
|
||||
wizard.waitTextParentDirectoryName("/");
|
||||
wizard.waitTextProjectNameInput(NONE_MAVEN_PROJECT);
|
||||
wizard.selectSample(Wizard.TypeProject.MAVEN);
|
||||
informationDialog.acceptInformDialogWithText("pom.xml does not exist.");
|
||||
wizard.closeWithIcon();
|
||||
}
|
||||
|
||||
private void convertPredefinedFolderToMavenProjectWithContextMenu(String converPath) {
|
||||
projectExplorer.waitAndSelectItem(converPath);
|
||||
projectExplorer.openContextMenuByPathSelectedItem(converPath);
|
||||
projectExplorer.clickOnItemInContextMenu(CONVERT_TO_PROJECT);
|
||||
convertToMavenByWizard("/" + PROJECT_NAME, WEB_APP_MODULE);
|
||||
}
|
||||
|
||||
private void convertToMavenByWizard(String pathToDirectory, String convertedFolder) {
|
||||
wizard.waitOpenProjectConfigForm();
|
||||
wizard.waitTextParentDirectoryName(pathToDirectory);
|
||||
wizard.waitTextProjectNameInput(convertedFolder);
|
||||
wizard.selectSample(Wizard.TypeProject.MAVEN);
|
||||
loader.waitOnClosed();
|
||||
wizard.clickSaveButton();
|
||||
wizard.waitCloseProjectConfigForm();
|
||||
}
|
||||
|
||||
private void addParentArticatSectionIntoPomFile() {
|
||||
projectExplorer.openItemByPath(CONVERT_PATH + "/pom.xml");
|
||||
editor.goToPosition(23, 3);
|
||||
editor.typeTextIntoEditor(PARENT_ARTIFACT_SECTION);
|
||||
projectExplorer.waitAndSelectItem(PROJECT_NAME);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2018 Red Hat, Inc.
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.selenium.miscellaneous;
|
||||
|
||||
import static org.eclipse.che.selenium.core.constant.TestProjectExplorerContextMenuConstants.ContextMenuFirstLevelItems.CONVERT_TO_PROJECT;
|
||||
import static org.eclipse.che.selenium.core.constant.TestProjectExplorerContextMenuConstants.ContextMenuFirstLevelItems.NEW;
|
||||
import static org.eclipse.che.selenium.core.constant.TestProjectExplorerContextMenuConstants.SubMenuNew.XML_FILE;
|
||||
import static org.eclipse.che.selenium.core.project.ProjectTemplates.MAVEN_SPRING;
|
||||
import static org.eclipse.che.selenium.pageobject.ProjectExplorer.FolderTypes.SIMPLE_FOLDER;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Paths;
|
||||
import org.eclipse.che.commons.lang.NameGenerator;
|
||||
import org.eclipse.che.selenium.core.SeleniumWebDriver;
|
||||
import org.eclipse.che.selenium.core.action.ActionsFactory;
|
||||
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
|
||||
import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants;
|
||||
import org.eclipse.che.selenium.core.constant.TestProjectExplorerContextMenuConstants.ContextMenuItems;
|
||||
import org.eclipse.che.selenium.core.utils.WaitUtils;
|
||||
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
|
||||
import org.eclipse.che.selenium.pageobject.AskForValueDialog;
|
||||
import org.eclipse.che.selenium.pageobject.CodenvyEditor;
|
||||
import org.eclipse.che.selenium.pageobject.Ide;
|
||||
import org.eclipse.che.selenium.pageobject.InformationDialog;
|
||||
import org.eclipse.che.selenium.pageobject.Loader;
|
||||
import org.eclipse.che.selenium.pageobject.Menu;
|
||||
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
|
||||
import org.eclipse.che.selenium.pageobject.Wizard;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/** @author Aleksandr Shmaraev */
|
||||
public class ConvertToProjectWithPomFileTest {
|
||||
private static final String PROJECT_NAME = NameGenerator.generate("project", 4);
|
||||
private static final String NEW_FOLDER_NAME = "new-folder";
|
||||
private static final String NEW_MODULE_NAME = "new-module";
|
||||
private static final String PATH_TO_POM_FILE = PROJECT_NAME + "/" + NEW_MODULE_NAME;
|
||||
private static final String EXPECTED_TEXT =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
+ "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
|
||||
+ "xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
|
||||
+ "<modelVersion>4.0.0</modelVersion>\n"
|
||||
+ "<groupId>groupId</groupId>\n"
|
||||
+ "<artifactId>new-module</artifactId>\n"
|
||||
+ "<packaging>jar</packaging>\n"
|
||||
+ "<version>1.0-SNAPSHOT</version>\n"
|
||||
+ "<name>new-module</name>\n"
|
||||
+ "</project>";
|
||||
|
||||
@Inject private TestWorkspace workspace;
|
||||
@Inject private Ide ide;
|
||||
@Inject private ProjectExplorer projectExplorer;
|
||||
@Inject private CodenvyEditor editor;
|
||||
@Inject private Menu menu;
|
||||
@Inject private Loader loader;
|
||||
@Inject private Wizard wizard;
|
||||
@Inject private AskForValueDialog askForValueDialog;
|
||||
@Inject private InformationDialog informationDialog;
|
||||
@Inject private ActionsFactory actionsFactory;
|
||||
@Inject private TestProjectServiceClient testProjectServiceClient;
|
||||
@Inject private SeleniumWebDriver seleniumWebDriver;
|
||||
|
||||
@BeforeClass
|
||||
public void setUp() throws Exception {
|
||||
URL resource = getClass().getResource("/projects/guess-project");
|
||||
testProjectServiceClient.importProject(
|
||||
workspace.getId(), Paths.get(resource.toURI()), PROJECT_NAME, MAVEN_SPRING);
|
||||
ide.open(workspace);
|
||||
|
||||
ide.waitOpenedWorkspaceIsReadyToUse();
|
||||
projectExplorer.waitAndSelectItem(PROJECT_NAME);
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void expandProject() {
|
||||
projectExplorer.quickCollapseJavaScript();
|
||||
projectExplorer.quickExpandWithJavaScript();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkConvertToProjectWithPomFile() throws Exception {
|
||||
|
||||
// create a folder and check message if the path is wrong
|
||||
createNewFolder(PROJECT_NAME, NEW_FOLDER_NAME);
|
||||
projectExplorer.waitAndSelectItemByName(NEW_FOLDER_NAME);
|
||||
projectExplorer.openContextMenuByPathSelectedItem(PROJECT_NAME + "/" + NEW_FOLDER_NAME);
|
||||
projectExplorer.clickOnItemInContextMenu(CONVERT_TO_PROJECT);
|
||||
wizard.waitOpenProjectConfigForm();
|
||||
wizard.waitTextParentDirectoryName("/" + PROJECT_NAME);
|
||||
wizard.waitTextProjectNameInput(NEW_FOLDER_NAME);
|
||||
wizard.selectSample(Wizard.TypeProject.MAVEN);
|
||||
informationDialog.acceptInformDialogWithText("pom.xml does not exist.");
|
||||
wizard.selectSample(Wizard.TypeProject.BLANK);
|
||||
loader.waitOnClosed();
|
||||
wizard.clickSaveButton();
|
||||
wizard.waitCloseProjectConfigForm();
|
||||
|
||||
// create a folder with pom file
|
||||
createNewFolder(PROJECT_NAME, NEW_MODULE_NAME);
|
||||
createNewFile("pom", PATH_TO_POM_FILE, XML_FILE);
|
||||
editor.waitActive();
|
||||
editor.waitTabIsPresent("pom.xml");
|
||||
editor.selectTabByName("pom.xml");
|
||||
editor.deleteAllContent();
|
||||
actionsFactory.createAction(seleniumWebDriver).sendKeys(EXPECTED_TEXT).perform();
|
||||
editor.waitTextIntoEditor(EXPECTED_TEXT);
|
||||
|
||||
// this timeout is needed for waiting that the Editor tab name of 'pom.xml' file is changed
|
||||
WaitUtils.sleepQuietly(5);
|
||||
editor.waitTabIsPresent("pom.xml");
|
||||
projectExplorer.waitDefinedTypeOfFolder(PATH_TO_POM_FILE, SIMPLE_FOLDER);
|
||||
|
||||
editor.closeAllTabs();
|
||||
seleniumWebDriver.navigate().refresh();
|
||||
projectExplorer.waitProjectExplorer();
|
||||
projectExplorer.waitDefinedTypeOfFolder(PATH_TO_POM_FILE, SIMPLE_FOLDER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkEditorTabNameAfterChangingArtifactID() {
|
||||
projectExplorer.openItemByPath(PROJECT_NAME + "/pom.xml");
|
||||
editor.waitActive();
|
||||
editor.waitTabIsPresent("qa-spring-sample");
|
||||
editor.goToCursorPositionVisible(19, 17);
|
||||
editor.typeTextIntoEditor("new-");
|
||||
|
||||
// this timeout is needed for waiting that the Editor tab name of 'pom.xml' file is changed
|
||||
WaitUtils.sleepQuietly(5);
|
||||
editor.waitTabIsPresent("new-qa-spring-sample");
|
||||
|
||||
seleniumWebDriver.navigate().refresh();
|
||||
ide.waitOpenedWorkspaceIsReadyToUse();
|
||||
projectExplorer.waitItem(PROJECT_NAME + "/pom.xml");
|
||||
editor.waitTabIsPresent("new-qa-spring-sample");
|
||||
|
||||
editor.closeAllTabsByContextMenu();
|
||||
}
|
||||
|
||||
private void createNewFolder(String path, String folderName) {
|
||||
projectExplorer.waitAndSelectItem(path);
|
||||
menu.runCommand(
|
||||
TestMenuCommandsConstants.Project.PROJECT,
|
||||
TestMenuCommandsConstants.Project.New.NEW,
|
||||
TestMenuCommandsConstants.Project.New.FOLDER);
|
||||
askForValueDialog.waitFormToOpen();
|
||||
askForValueDialog.typeAndWaitText(folderName);
|
||||
askForValueDialog.clickOkBtn();
|
||||
askForValueDialog.waitFormToClose();
|
||||
projectExplorer.waitVisibilityByName(folderName);
|
||||
loader.waitOnClosed();
|
||||
}
|
||||
|
||||
private void createNewFile(String name, String pathToFile, ContextMenuItems type) {
|
||||
projectExplorer.waitAndSelectItem(pathToFile);
|
||||
projectExplorer.openContextMenuByPathSelectedItem(pathToFile);
|
||||
projectExplorer.clickOnItemInContextMenu(NEW);
|
||||
projectExplorer.clickOnItemInContextMenu(type);
|
||||
askForValueDialog.waitFormToOpen();
|
||||
askForValueDialog.typeAndWaitText(name);
|
||||
askForValueDialog.clickOkBtn();
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.eclipse.che.examples</groupId>
|
||||
<artifactId>qa-multimodule</artifactId>
|
||||
<artifactId>qa-webapp</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>qa-spring-sample</name>
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2012-2018 Red Hat, Inc.
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int integer1; // Declare a variable named integer1 of the type integer
|
||||
int integer2; // Declare a variable named integer2 of the type integer
|
||||
int sum; // Declare a variable named sum of the type integer
|
||||
int multiplyVal;
|
||||
|
||||
integer1 = 55; // Assign value to variable integer1
|
||||
integer2 = 66; // Assign value to variable integer1
|
||||
multiplyVal = 0;
|
||||
sum = integer1 + integer2; // Compute the sum
|
||||
multiplyVal = multiply(integer1, integer2);
|
||||
// Print the result
|
||||
printf("The sum of %d and %d is %d.\n", integer1, integer2, sum);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int multiply(int a, int b){
|
||||
return a*b;
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@
|
|||
<class name="org.eclipse.che.selenium.miscellaneous.CheckMacrosFeatureTest"/>
|
||||
<class name="org.eclipse.che.selenium.miscellaneous.CheckRestoringWorkspaceAfterStoppingWsAgentProcessTest"/>
|
||||
<class name="org.eclipse.che.selenium.miscellaneous.ConvertToProjectFromConfigurationTest"/>
|
||||
<class name="org.eclipse.che.selenium.miscellaneous.ConvertToProjectWithPomFileTest"/>
|
||||
<class name="org.eclipse.che.selenium.miscellaneous.ConvertToMavenProjectTest"/>
|
||||
<class name="org.eclipse.che.selenium.miscellaneous.DialogAboutTest"/>
|
||||
<class name="org.eclipse.che.selenium.miscellaneous.FileStructureBaseOperationTest"/>
|
||||
<class name="org.eclipse.che.selenium.miscellaneous.FileStructureByKeyboardTest"/>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name":"replaced_name",
|
||||
"contentRoot":null,
|
||||
|
||||
"visibility":"public",
|
||||
"mixinTypes":[
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue