/*
 * Copyright (c) 2012-2018 Red Hat, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
package org.eclipse.che.selenium.workspaces;

import static org.eclipse.che.selenium.core.constant.TestStacksConstants.JAVA;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOADER_TIMEOUT_SEC;

import com.google.inject.Inject;
import org.eclipse.che.commons.lang.NameGenerator;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.user.TestUser;
import org.eclipse.che.selenium.pageobject.Loader;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.dashboard.CreateWorkspace;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.eclipse.che.selenium.pageobject.dashboard.NavigationBar;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces;
import org.eclipse.che.selenium.pageobject.machineperspective.MachineTerminal;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;

/** @author Andrey Chizhikov */
public class CreateWorkspaceOnDashboardTest {
  private static final String WORKSPACE = NameGenerator.generate("WsDashboard", 4);

  @Inject private NavigationBar navigationBar;
  @Inject private CreateWorkspace createWorkspace;
  @Inject private TestUser defaultTestUser;
  @Inject private ProjectExplorer projectExplorer;
  @Inject private Loader loader;
  @Inject private MachineTerminal terminal;
  @Inject private Dashboard dashboard;
  @Inject private WorkspaceDetails workspaceDetails;
  @Inject private SeleniumWebDriver seleniumWebDriver;
  @Inject private TestWorkspaceServiceClient workspaceServiceClient;
  @Inject private Workspaces workspaces;

  @AfterClass
  public void tearDown() throws Exception {
    workspaceServiceClient.delete(WORKSPACE, defaultTestUser.getName());
  }

  @Test
  public void createWorkspaceOnDashboardTest() {
    dashboard.open();
    dashboard.waitDashboardToolbarTitle();
    dashboard.selectWorkspacesItemOnDashboard();
    dashboard.waitToolbarTitleName("Workspaces");

    workspaces.clickOnNewWorkspaceBtn();

    createWorkspace.waitToolbar();
    createWorkspace.typeWorkspaceName(WORKSPACE);
    createWorkspace.selectStack(JAVA.getId());
    createWorkspace.setMachineRAM("dev-machine", 2.0);
    createWorkspace.clickOnCreateButtonAndOpenInIDE();

    seleniumWebDriver.switchFromDashboardIframeToIde();

    projectExplorer.waitProjectExplorer();
    terminal.waitTerminalTab(LOADER_TIMEOUT_SEC);
  }
}

@@ -559,30 +559,40 @@
 nstants.
-LOADER_TIMEOUT
+EXPECTED_MESS_IN_CONSOLE
 _SEC;%0A%0Ai
@@ -858,59 +858,8 @@
 er;%0A
-import org.eclipse.che.selenium.pageobject.Loader;%0A
 impo
@@ -1052,158 +1052,8 @@
 rd;%0A
-import org.eclipse.che.selenium.pageobject.dashboard.NavigationBar;%0Aimport org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails;%0A
 impo
@@ -1449,55 +1449,8 @@
 );%0A%0A
-  @Inject private NavigationBar navigationBar;%0A
   @I
@@ -1595,41 +1595,8 @@
 er;%0A
-  @Inject private Loader loader;%0A
   @I
@@ -1678,61 +1678,8 @@
 rd;%0A
-  @Inject private WorkspaceDetails workspaceDetails;%0A
   @I
@@ -2616,22 +2616,32 @@
 Tab(
-LOADER_TIMEOUT
+EXPECTED_MESS_IN_CONSOLE
 _SEC

change timeout in the CreateWorkspaceOnDashboardTest selenium test (#8403)