Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework ConvertToProjectWithPomFileTest test for checking conversion folders to maven multimodule project #11427

Merged
merged 8 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ private ProjectConfig getProject(String workspaceId, String projectName) throws
return requestFactory
.fromUrl(workspaceAgentApiEndpointUrlProvider.get(workspaceId) + "project/" + projectName)
.useGetMethod()
.setAuthorizationHeader(machineServiceClient.getMachineApiToken(workspaceId))
Copy link
Contributor

@dmytro-ndp dmytro-ndp Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be added prefix BEARER_TOKEN_PREFIX + as well?

.request()
.asDto(ProjectConfigDto.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 UNDEFINED_PROJECT = "undefined.json";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO next name would better reflect template proposal: PROJECT_OF_UNDEFINED_TYPE


private ProjectTemplates() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* 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.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, the common import is a bad practice. Please import relations directly.

import static org.eclipse.che.selenium.core.constant.TestProjectExplorerContextMenuConstants.ContextMenuFirstLevelItems.CONVERT_TO_PROJECT;
import static org.eclipse.che.selenium.core.project.ProjectTemplates.UNDEFINED_PROJECT;

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.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 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the author name correct?

public class CheckConvertingToMavenProjectTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test name could be simplified slightly: 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_INFORMATION =
Copy link
Contributor

@dmytro-ndp dmytro-ndp Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to use more specific name 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";
@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add empty line to improve readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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, UNDEFINED_PROJECT);
testProjectServiceClient.importProject(
workspaceId, Paths.get(noneMavenProject.toURI()), NONE_MAVEN_PROJECT, UNDEFINED_PROJECT);

ide.open(workspace);
ide.waitOpenedWorkspaceIsReadyToUse();
projectExplorer.quickRevealToItemWithJavaScript(format("%s/%s", PROJECT_NAME, WEB_APP_MODULE));
}

@Test
public void shouldConvertToMavenMultimoduleProject() throws Exception {
convertPredefinedFolderToMavenProjectWithContextMenu(
format("%s/%s", PROJECT_NAME, WEB_APP_MODULE));
testProjectServiceClient.checkProjectType(
workspaceId, format("%s/%s", PROJECT_NAME, WEB_APP_MODULE), "maven");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about move all these items to the upper of the test and declare them as constants.

final String convertPath = format("%s/%s", PROJECT_NAME, WEB_APP_MODULE);

addParentConfigurationToPredefinedFolder();
menu.runCommand(
TestMenuCommandsConstants.Project.PROJECT,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static import?

TestMenuCommandsConstants.Project.UPDATE_PROJECT_CONFIGURATION);
convertToMavenByhWizard("/", PROJECT_NAME);
testProjectServiceClient.checkProjectType(
workspaceId, format("%s/%s", PROJECT_NAME, WEB_APP_MODULE), "maven");
}

@Test
public void shouldNotConvertToMavenProject() {
projectExplorer.waitAndSelectItem(NONE_MAVEN_PROJECT);
menu.runCommand(
TestMenuCommandsConstants.Project.PROJECT,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static import?

TestMenuCommandsConstants.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);
convertToMavenByhWizard("/" + PROJECT_NAME, WEB_APP_MODULE);
}

private void convertToMavenByhWizard(String pathToDirectory, String convertedFolder) {
Copy link
Contributor

@dmytro-ndp dmytro-ndp Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo convertToMavenByhWizard
Also, this method could be useful for other tests, and would be better moved into the Wizard page object.

wizard.waitOpenProjectConfigForm();
wizard.waitTextParentDirectoryName(pathToDirectory);
wizard.waitTextProjectNameInput(convertedFolder);
wizard.selectSample(Wizard.TypeProject.MAVEN);
loader.waitOnClosed();
wizard.clickSaveButton();
wizard.waitCloseProjectConfigForm();
}

private void addParentConfigurationToPredefinedFolder() throws Exception {
projectExplorer.openItemByPath(format("%s/%s/pom.xml", PROJECT_NAME, WEB_APP_MODULE));
editor.goToPosition(23, 3);
editor.typeTextIntoEditor(PARENT_INFORMATION);
projectExplorer.waitAndSelectItem(PROJECT_NAME);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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.CheckConvertingToMavenProjectTest"/>
<class name="org.eclipse.che.selenium.miscellaneous.DialogAboutTest"/>
<class name="org.eclipse.che.selenium.miscellaneous.FileStructureBaseOperationTest"/>
<class name="org.eclipse.che.selenium.miscellaneous.FileStructureByKeyboardTest"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name":"replaced_name",
"contentRoot":null,

"visibility":"public",
"mixinTypes":[
]
}