From 19d4bca1511a95c9a54a81bc81a735604d1625fa Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Wed, 3 Dec 2008 12:50:36 +0000 Subject: [PATCH] LMS-656 Refactoring: Extract Method to GWTTestUtil. Add possiblity to set parent and container of a sample SVN: 9192 --- .../web/client/testframework/GWTTestUtil.java | 15 +++++++++++ .../sample/FillSampleRegistrationForm.java | 25 +++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/testframework/GWTTestUtil.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/testframework/GWTTestUtil.java index eed900e2a9e..844b806eb68 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/testframework/GWTTestUtil.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/testframework/GWTTestUtil.java @@ -101,6 +101,21 @@ public final class GWTTestUtil widget instanceof Button); ((Button) widget).fireEvent(Events.Select); } + + + /** + * Sets the value of the {@link TextField} with specified id. + * + * @param valueOrNull If <code>null</code> the text field value will not be changed. + * @throws AssertionError if no widget found for <code>id</code> or isn't a text field. + */ + public static void setTextFieldValue(final String id, final String valueOrNull) + { + if (valueOrNull != null) + { + getTextFieldWithID(id).setValue(valueOrNull); + } + } /** * Gets the {@link TextField} with specified id. diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/FillSampleRegistrationForm.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/FillSampleRegistrationForm.java index edced55c58a..d58def3cf48 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/FillSampleRegistrationForm.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/FillSampleRegistrationForm.java @@ -17,7 +17,6 @@ package ch.systemsx.cisd.openbis.plugin.generic.client.web.client.application.sample; import com.extjs.gxt.ui.client.widget.form.CheckBox; -import com.extjs.gxt.ui.client.widget.form.TextField; import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.ModelDataPropertyNames; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.GroupSelectionWidget; @@ -39,6 +38,10 @@ public final class FillSampleRegistrationForm extends AbstractDefaultTestCommand private final boolean includeShared; + private String parent; + + private String container; + public FillSampleRegistrationForm(final boolean includeShared, final String groupNameOrNull, final String code) { @@ -47,7 +50,19 @@ public final class FillSampleRegistrationForm extends AbstractDefaultTestCommand this.code = code; addCallbackClass(GroupSelectionWidget.ListGroupsCallback.class); } + + public FillSampleRegistrationForm parent(String parentFieldValue) + { + this.parent = parentFieldValue; + return this; + } + public FillSampleRegistrationForm container(String containerFieldValue) + { + this.container = containerFieldValue; + return this; + } + // // AbstractDefaultTestCommand // @@ -55,10 +70,7 @@ public final class FillSampleRegistrationForm extends AbstractDefaultTestCommand @SuppressWarnings("unchecked") public final void execute() { - final TextField<String> codeField = - (TextField<String>) GWTTestUtil - .getWidgetWithID(GenericSampleRegistrationForm.CODE_FIELD_ID); - codeField.setValue(code); + GWTTestUtil.setTextFieldValue(GenericSampleRegistrationForm.CODE_FIELD_ID, code); final CheckBox includeSharedCheckbox = (CheckBox) GWTTestUtil @@ -71,6 +83,9 @@ public final class FillSampleRegistrationForm extends AbstractDefaultTestCommand (GroupSelectionWidget) GWTTestUtil.getWidgetWithID(GroupSelectionWidget.ID); GWTUtils.setSelectedItem(groupSelector, ModelDataPropertyNames.CODE, groupNameOrNull); } + + GWTTestUtil.setTextFieldValue(GenericSampleRegistrationForm.PARENT_GENERATOR_FIELD_ID, parent); + GWTTestUtil.setTextFieldValue(GenericSampleRegistrationForm.PARENT_CONTAINER_FIELD_ID, container); GWTTestUtil.clickButtonWithID(GenericSampleRegistrationForm.SAVE_BUTTON_ID); } -- GitLab