use of org.eclipse.reddeer.core.matcher.WithTextMatcher in project jbosstools-openshift by jbosstools.
the class EditResourcesTest method testCanEditResource.
@Test
public void testCanEditResource() {
getBuildConfig().select();
new ContextMenuItem(OpenShiftLabel.ContextMenu.EDIT).select();
try {
new TextEditor(new WithTextMatcher("*.eap-app.json"));
// pass
} catch (RedDeerException ex) {
fail("Text editor to modify build config resource has not been opened.");
}
}
use of org.eclipse.reddeer.core.matcher.WithTextMatcher in project jbosstools-openshift by jbosstools.
the class CDKTestUtils method removeAccessRedHatCredentials.
// removes access redhat com credentials used for first cdk run
public static void removeAccessRedHatCredentials(String domain, String username) {
WorkbenchPreferenceDialog dialog = new WorkbenchPreferenceDialog();
dialog.open();
// $NON-NLS-1$ //$NON-NLS-2$
dialog.select("JBoss Tools", "Credentials");
try {
new WaitUntil(new WidgetIsFound(org.eclipse.swt.custom.CLabel.class, new WithMnemonicTextMatcher("Credentials")), // $NON-NLS-1$
TimePeriod.MEDIUM);
// $NON-NLS-1$
new DefaultCLabel("Credentials");
DefaultTree tree = new DefaultTree(1);
TreeItem item = TreeViewerHandler.getInstance().getTreeItem(tree, new String[] { domain, username });
item.select();
// $NON-NLS-1$
new PushButton(new WithTextMatcher("Remove User")).click();
new WaitUntil(new JobIsRunning(), TimePeriod.MEDIUM, false);
} catch (WaitTimeoutExpiredException exc) {
// $NON-NLS-1$
log.error("JBoss Tools - Credentials preferences page has timed out");
exc.printStackTrace();
} catch (JFaceLayerException exc) {
// $NON-NLS-1$
log.error("JBoss Tools - Credentials does not contain required username to be deleted");
exc.printStackTrace();
} finally {
dialog.ok();
}
}
use of org.eclipse.reddeer.core.matcher.WithTextMatcher in project jbosstools-openshift by jbosstools.
the class BuilderImageApplicationWizardHandlingTest method testPorts.
@Test
public void testPorts() {
String defaultName = "8443-tcp";
String defaultServicePort = "8443";
String defaultPodPort = "8443";
String newName = "1234-tcp";
String newServicePort = "1234";
String newPodPort = "4321";
nextToBuildConfigurationWizardPage();
next();
next();
// Test edit of an existing pod
new DefaultTable().select(defaultName);
new PushButton(OpenShiftLabel.Button.EDIT).click();
new DefaultShell(OpenShiftLabel.Shell.SERVICE_PORTS);
new LabeledText(OpenShiftLabel.TextLabels.POD_PORT).setText(newPodPort);
new DefaultSpinner(OpenShiftLabel.TextLabels.SERVICE_PORT).setValue(Integer.valueOf(newServicePort));
new OkButton().click();
new WaitWhile(new ShellIsAvailable(OpenShiftLabel.Shell.SERVICE_PORTS));
assertTrue("There should port mapping with name " + newName + ", but there is not.", new WidgetIsFound(org.eclipse.swt.widgets.TableItem.class, new WithTextMatcher(newName)).test());
TableItem portMapping = new DefaultTable().getItem(newName);
assertTrue("Modified pod mapping has incorrect mapped ports.", portMapping.getText(1).equals(newServicePort) && portMapping.getText(2).equals(newPodPort));
// Test reset of pods
new PushButton(OpenShiftLabel.Button.RESET).click();
new DefaultShell(OpenShiftLabel.Shell.RESET_PORTS);
new YesButton().click();
new WaitWhile(new ShellIsAvailable(OpenShiftLabel.Shell.RESET_PORTS));
new WaitWhile(new JobIsRunning());
assertTrue("There should port mapping with name " + defaultName + ", but there is not.", new WidgetIsFound(org.eclipse.swt.widgets.TableItem.class, new WithTextMatcher(defaultName)).test());
portMapping = new DefaultTable().getItem(defaultName);
String resetServicePort = portMapping.getText(1);
String resetPodPort = portMapping.getText(2);
assertTrue("There should default values for port named " + defaultName + "\n" + "Service port should be " + defaultServicePort + ", but it is " + resetServicePort + " and pod port should be " + defaultPodPort + ", but it is " + resetPodPort, resetServicePort.equals(defaultServicePort) && resetPodPort.equals(defaultPodPort));
}
use of org.eclipse.reddeer.core.matcher.WithTextMatcher in project jbosstools-openshift by jbosstools.
the class ShellWithButton method lookForShellWithButton.
private static org.eclipse.swt.widgets.Shell lookForShellWithButton(final String title, final String buttonLabel) {
Matcher<String> titleMatcher = new WithTextMatcher(title);
Matcher<String> buttonMatcher = new BaseMatcher<String>() {
@Override
public boolean matches(Object obj) {
if (obj instanceof Control) {
final Control control = (Control) obj;
ReferencedComposite ref = new ReferencedComposite() {
@Override
public Control getControl() {
return control;
}
};
try {
new PushButton(ref, buttonLabel);
return true;
} catch (CoreLayerException e) {
// ok, this control doesn't contain the button
}
}
return false;
}
@Override
public void describeTo(Description description) {
description.appendText("containing button '" + buttonLabel + "'");
}
};
@SuppressWarnings("unchecked") Matcher<String> matcher = new AndMatcher(titleMatcher, buttonMatcher);
return ShellLookup.getInstance().getShell(matcher);
}
Aggregations