/*******************************************************************************
* Copyright (c) 2007-2016 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v 1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributor:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.openshift.ui.bot.test.application.create;
import static org.junit.Assert.fail;
import org.jboss.reddeer.common.wait.TimePeriod;
import org.jboss.reddeer.common.wait.WaitWhile;
import org.jboss.reddeer.core.condition.JobIsRunning;
import org.jboss.reddeer.swt.exception.SWTLayerException;
import org.jboss.tools.openshift.reddeer.utils.DatastoreOS2;
import org.jboss.tools.openshift.reddeer.utils.OpenShiftLabel;
import org.jboss.tools.openshift.reddeer.utils.v2.DeleteUtils;
import org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView;
import org.jboss.tools.openshift.reddeer.view.resources.OpenShift2Application;
import org.jboss.tools.openshift.reddeer.wizard.v2.NewOpenShift2ApplicationWizard;
import org.junit.After;
import org.junit.Test;
/**
* Test capabilities of creating a new application with embedded cartridge.
*
* @author mlabuda@redhat.com
*
*/
public class ID413CreateApplicationWithEmbeddableCartridgeTest {
private String applicationName = "diy" + System.currentTimeMillis();
@Test
public void testCreateApplicationWithEmbeddableCartridge() {
OpenShiftExplorerView explorer = new OpenShiftExplorerView();
NewOpenShift2ApplicationWizard wizard = new NewOpenShift2ApplicationWizard(DatastoreOS2.USERNAME,
DatastoreOS2.SERVER, DatastoreOS2.DOMAIN);
wizard.openWizardFromExplorer();
wizard.createNewApplicationOnBasicCartridge(OpenShiftLabel.Cartridge.DIY,
applicationName, false, true, false, false, null, null, true,
null, null, null, OpenShiftLabel.EmbeddableCartridge.CRON);
wizard.postCreateSteps(true);
OpenShift2Application application = explorer.getOpenShift2Connection(DatastoreOS2.USERNAME, DatastoreOS2.SERVER).getDomain(
DatastoreOS2.DOMAIN).getApplication(applicationName);
application.select();
application.expand();
new WaitWhile(new JobIsRunning(), TimePeriod.LONG);
try {
application.getTreeItem().getItem("Cron 1.4 cron-1.4");
// PASS
} catch (SWTLayerException ex) {
fail("There is no tree item for embedded cartridge under application in OpenShift explorer view. "
+ "There is item with name \"" + application.getTreeItem().getItems().get(0).getText() + "\"");
}
}
@After
public void deleteApplication() {
new DeleteUtils(DatastoreOS2.USERNAME, DatastoreOS2.SERVER, DatastoreOS2.DOMAIN, applicationName,
applicationName).perform();
}
}