From 2aa38a89e4a86a44cdf5bb7ecda425786d8319a9 Mon Sep 17 00:00:00 2001
From: izabel <izabel>
Date: Thu, 18 Dec 2008 11:11:10 +0000
Subject: [PATCH] [LMS-661] prepare system test

SVN: 9437
---
 .../web/client/ICommonClientService.java      |   2 +-
 .../web/client/ICommonClientServiceAsync.java |   2 +-
 .../PropertyTypeAssignmentForm.java           |  44 ++---
 .../web/server/CommonClientService.java       |   4 +-
 .../openbis/generic/server/CommonServer.java  |   4 +-
 .../generic/server/CommonServerLogger.java    |   3 +-
 .../openbis/generic/shared/ICommonServer.java |   2 +-
 .../cisd/openbis/generic/SystemTestSuite.java |   2 +
 .../EntityTypePropertyTypeAssignmentTest.java |  66 +++++++
 .../FillPropertyTypeAssignmentForm.java       | 175 ++++++++++++++++++
 .../shared/ICommonServer.java.expected        |   2 +-
 11 files changed, 270 insertions(+), 36 deletions(-)
 create mode 100644 openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/EntityTypePropertyTypeAssignmentTest.java
 create mode 100644 openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/FillPropertyTypeAssignmentForm.java

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java
index d4b01433528..0aa5b6b82cc 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java
@@ -179,7 +179,7 @@ public interface ICommonClientService extends IClientService
     /**
      * Assigns property type to entity type.
      */
-    public void assignPropertyType(EntityKind entityKind, String propertyTypeCode,
+    public String assignPropertyType(EntityKind entityKind, String propertyTypeCode,
             String entityTypeCode, boolean isMandatory, String defaultValue)
             throws UserFailureException;
 
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java
index 29cc79d0623..bd0f6fe4cfe 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java
@@ -147,7 +147,7 @@ public interface ICommonClientServiceAsync extends IClientServiceAsync
     /** @see ICommonClientService#assignPropertyType(EntityKind, String, String, boolean, String) */
     public void assignPropertyType(EntityKind entityKind, String propertyTypeCode,
             String entityTypeCode, boolean isMandatory, String defaultValue,
-            AsyncCallback<Void> process);
+            AsyncCallback<String> process);
 
     /** @see ICommonClientService#registerPropertyType(PropertyType) */
     public void registerPropertyType(final PropertyType propertyType,
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeAssignmentForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeAssignmentForm.java
index 5f69c4cab82..21a87845131 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeAssignmentForm.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/PropertyTypeAssignmentForm.java
@@ -63,13 +63,13 @@ public final class PropertyTypeAssignmentForm extends LayoutContainer
 
     public static final String ID_PREFIX = GenericConstants.ID_PREFIX + PREFIX;
 
-    private static final String PROPERTY_TYPE_ID_SUFFIX = "property_type";
+    public static final String PROPERTY_TYPE_ID_SUFFIX = "property_type";
 
-    private static final String SAMPLE_TYPE_ID_SUFFIX = ID_PREFIX + "sample_type";
+    public static final String SAMPLE_TYPE_ID_SUFFIX = ID_PREFIX + "sample_type";
 
-    private static final String EXPERIMENT_TYPE_ID_SUFFIX = ID_PREFIX + "experiment_type";
+    public static final String EXPERIMENT_TYPE_ID_SUFFIX = ID_PREFIX + "experiment_type";
 
-    private static final String MANDATORY_CHECKBOX_ID_SUFFIX = "mandatory_checkbox";
+    public static final String MANDATORY_CHECKBOX_ID_SUFFIX = "mandatory_checkbox";
 
     public static final String SAVE_BUTTON_ID_SUFFIX = "save-button";
 
@@ -127,13 +127,14 @@ public final class PropertyTypeAssignmentForm extends LayoutContainer
             propertyTypeSelectionWidget.setAllowBlank(false);
             propertyTypeSelectionWidget
                     .setLabelSeparator(GenericConstants.MANDATORY_LABEL_SEPARATOR);
-            propertyTypeSelectionWidget.addListener(Events.Change, new Listener<BaseEvent>()
-                {
-                    public void handleEvent(BaseEvent be)
-                    {
-                        updateDefaultField();
-                    }
-                });
+            propertyTypeSelectionWidget.addListener(Events.SelectionChange,
+                    new Listener<BaseEvent>()
+                        {
+                            public void handleEvent(BaseEvent be)
+                            {
+                                updateDefaultField();
+                            }
+                        });
         }
         return propertyTypeSelectionWidget;
     }
@@ -272,28 +273,17 @@ public final class PropertyTypeAssignmentForm extends LayoutContainer
         }
     }
 
-    public final class AssignPropertyTypeCallback extends AbstractAsyncCallback<Void>
+    public final class AssignPropertyTypeCallback extends AbstractAsyncCallback<String>
     {
         AssignPropertyTypeCallback(final IViewContext<?> viewContext)
         {
-            super(viewContext, new InfoBoxCallbackListener<Void>(infoBox));
-        }
-
-        private final String createSuccessfullAssignmentInfo(String propertyTypeCode, String eKind,
-                String entityTypeCode)
-        {
-            return "Property type <b>" + propertyTypeCode + "</b> successfully assigned to "
-                    + eKind.toLowerCase() + " <b>" + entityTypeCode + "</b>.";
+            super(viewContext, new InfoBoxCallbackListener<String>(infoBox));
         }
 
         @Override
-        protected final void process(final Void result)
+        protected final void process(final String result)
         {
-            final String message =
-                    createSuccessfullAssignmentInfo(propertyTypeSelectionWidget
-                            .tryGetSelectedPropertyTypeCode(), entityKind.name() + " type",
-                            getSelectedEntityCode());
-            infoBox.displayInfo(message);
+            infoBox.displayInfo(result);
             resetForm();
         }
     }
@@ -307,7 +297,7 @@ public final class PropertyTypeAssignmentForm extends LayoutContainer
             Field<?> field =
                     PropertyFieldFactory.createField(propertyType, false, viewContext
                             .getMessage(Dict.DEFAULT_VALUE), createId(DEFAULT_VALUE_ID_PART
-                            + propertyType.getCode()));
+                            + propertyType.isInternalNamespace() + propertyType.getSimpleCode()));
             defaultValueField = field;
             defaultValueField.show();
             formPanel.add(defaultValueField);
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java
index c35f6a55f48..5b5d3a78496 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java
@@ -558,14 +558,14 @@ public final class CommonClientService extends AbstractClientService implements
         }
     }
 
-    public void assignPropertyType(EntityKind entityKind, String propertyTypeCode,
+    public String assignPropertyType(EntityKind entityKind, String propertyTypeCode,
             String entityTypeCode, boolean isMandatory, String defaultValue)
             throws ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException
     {
         try
         {
             final String sessionToken = getSessionToken();
-            commonServer.assignPropertyType(sessionToken, DtoConverters
+            return commonServer.assignPropertyType(sessionToken, DtoConverters
                     .convertEntityKind(entityKind), propertyTypeCode, entityTypeCode, isMandatory,
                     defaultValue);
         } catch (final UserFailureException e)
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java
index 262a437ea46..4f6f0ae106b 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java
@@ -393,13 +393,13 @@ public final class CommonServer extends AbstractServer<ICommonServer> implements
         return vocabularies;
     }
 
-    public void assignPropertyType(String sessionToken, EntityKind entityKind,
+    public String assignPropertyType(String sessionToken, EntityKind entityKind,
             String propertyTypeCode, String entityTypeCode, boolean isMandatory, String defaultValue)
     {
         assert sessionToken != null : "Unspecified session token";
 
         getSessionManager().getSession(sessionToken);
-        throw new UserFailureException("Not implemented");
+        return "Warning: feature not implemented";
 
     }
 
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServerLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServerLogger.java
index f2a78cea663..5a9abd73890 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServerLogger.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServerLogger.java
@@ -225,13 +225,14 @@ final class CommonServerLogger extends AbstractServerLogger implements ICommonSe
         return null;
     }
 
-    public void assignPropertyType(String sessionToken, EntityKind entityKind,
+    public String assignPropertyType(String sessionToken, EntityKind entityKind,
             String propertyTypeCode, String entityTypeCode, boolean isMandatory, String defaultValue)
     {
         String entityTypeFormat = entityKind.name() + "_TYPE(%S)";
         logTracking(sessionToken, "assign_property_type", " PROPERTY_TYPE(%S) " + entityTypeFormat
                 + " MANDATORY(%S) DEFAULT(%S)", propertyTypeCode, entityTypeCode, isMandatory,
                 defaultValue);
+        return null;
     }
 
     public final void registerPropertyType(final String sessionToken,
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java
index a55c2f441d8..76ab713c8dd 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java
@@ -242,7 +242,7 @@ public interface ICommonServer extends IServer
      */
     @Transactional
     @RolesAllowed(RoleSet.INSTANCE_ADMIN)
-    public void assignPropertyType(String sessionToken, EntityKind entityKind,
+    public String assignPropertyType(String sessionToken, EntityKind entityKind,
             String propertyTypeCode, String entityTypeCode, boolean isMandatory, String defaultValue);
 
 }
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/SystemTestSuite.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/SystemTestSuite.java
index 7757a107076..8f15db6c6d2 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/SystemTestSuite.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/SystemTestSuite.java
@@ -23,6 +23,7 @@ import com.google.gwt.junit.tools.GWTTestSuite;
 
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.AuthenticationTest;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.AuthorizationManagementConsolTest;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.EntityTypePropertyTypeAssignmentTest;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ExperimentBrowserTest;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.PropertyTypeAssignmentBrowserTest;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.PropertyTypeBrowserTest;
@@ -50,6 +51,7 @@ public class SystemTestSuite extends GWTTestSuite
         testSuite.addTestSuite(GenericExperimentViewerTest.class);
         testSuite.addTestSuite(PropertyTypeBrowserTest.class);
         testSuite.addTestSuite(PropertyTypeAssignmentBrowserTest.class);
+        testSuite.addTestSuite(EntityTypePropertyTypeAssignmentTest.class);
         return testSuite;
     }
 }
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/EntityTypePropertyTypeAssignmentTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/EntityTypePropertyTypeAssignmentTest.java
new file mode 100644
index 00000000000..1a8717c0355
--- /dev/null
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/EntityTypePropertyTypeAssignmentTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2008 ETH Zuerich, CISD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.systemsx.cisd.openbis.generic.client.web.client.application;
+
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.CategoriesBuilder;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.ModelDataPropertyNames;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.Login;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.OpenTab;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.property_type.CheckPropertyTypeAssignmentTable;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.property_type.FillPropertyTypeAssignmentForm;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.property_type.PropertyTypeAssignmentForm;
+import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.AbstractGWTTestCase;
+import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.Row;
+
+/**
+ * A {@link AbstractGWTTestCase} extension to test Entity Property Type Assignment.
+ * 
+ * @author Izabela Adamczyk
+ */
+public class EntityTypePropertyTypeAssignmentTest extends AbstractGWTTestCase
+{
+
+    private static final String EXPERIMENT = "EXPERIMENT";
+    private static final String SIRNA_HCS = "SIRNA_HCS";
+    private static final String USER_DESCRIPTION = "USER.DESCRIPTION";
+
+    private final void prepareListingAfterAssignment(String propertyTypeCode,
+            String entityTypeCode, String entityKindName)
+    {
+        remoteConsole.prepare(new OpenTab(CategoriesBuilder.CATEGORIES.PROPERTY_TYPES,
+                CategoriesBuilder.MENU_ELEMENTS.LIST_ASSIGNMENTS,
+                PropertyTypeAssignmentForm.AssignPropertyTypeCallback.class));
+        CheckPropertyTypeAssignmentTable table = new CheckPropertyTypeAssignmentTable();
+        table.expectedRow(new Row().withCell(ModelDataPropertyNames.PROPERTY_TYPE_CODE,
+                propertyTypeCode).withCell(ModelDataPropertyNames.ENTITY_TYPE_CODE, entityTypeCode)
+                .withCell(ModelDataPropertyNames.ENTITY_KIND, entityKindName));
+        remoteConsole.prepare(table.expectedSize(24));
+    }
+
+    public final void testAssignmenExperimentPropertyType()
+    {
+        // TODO 2008-12-17, IA: Finish after server side of entity property assignment is ready
+        remoteConsole.prepare(new Login("test", "a"));
+        remoteConsole.prepare(new OpenTab(CategoriesBuilder.CATEGORIES.PROPERTY_TYPES,
+                CategoriesBuilder.MENU_ELEMENTS.ASSIGN_ETPT));
+        remoteConsole.prepare(new FillPropertyTypeAssignmentForm(false, USER_DESCRIPTION,
+                SIRNA_HCS, null, EXPERIMENT));
+        prepareListingAfterAssignment(USER_DESCRIPTION, SIRNA_HCS, EXPERIMENT);
+        remoteConsole.finish(20000);
+        client.onModuleLoad();
+    }
+}
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/FillPropertyTypeAssignmentForm.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/FillPropertyTypeAssignmentForm.java
new file mode 100644
index 00000000000..9498bc966ac
--- /dev/null
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/FillPropertyTypeAssignmentForm.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2008 ETH Zuerich, CISD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.property_type;
+
+import com.extjs.gxt.ui.client.widget.form.CheckBox;
+import com.extjs.gxt.ui.client.widget.form.ComboBox;
+import com.extjs.gxt.ui.client.widget.form.Field;
+import com.google.gwt.user.client.ui.Widget;
+
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.ExperimentTypeModel;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.ModelDataPropertyNames;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.SampleTypeModel;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.experiment.ExperimentTypeSelectionWidget;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.sample.SampleTypeSelectionWidget;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.GWTUtils;
+import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.AbstractDefaultTestCommand;
+import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.GWTTestUtil;
+
+/**
+ * A {@link AbstractDefaultTestCommand} extension for property type assignment.
+ * 
+ * @author Izabela Adamczyk
+ */
+public final class FillPropertyTypeAssignmentForm extends AbstractDefaultTestCommand
+{
+    private static final String USER_PROPERTY_PREFIX = "USER.";
+
+    private final String entityTypeCode;
+
+    private final String propertyTypeCode;
+
+    private final boolean isMandatory;
+
+    private String defaultValue;
+
+    private String entityKindName;
+
+    private String widgetId;
+
+    public FillPropertyTypeAssignmentForm(final boolean isMandatory, final String propertyTypeCode,
+            final String entityTypeCode, String defaultValue, String entityKindName)
+    {
+        this.isMandatory = isMandatory;
+        this.propertyTypeCode = propertyTypeCode;
+        this.entityTypeCode = entityTypeCode;
+        this.defaultValue = defaultValue;
+        this.entityKindName = entityKindName;
+        widgetId = PropertyTypeAssignmentForm.ID_PREFIX + entityKindName;
+        addCallbackClass(PropertyTypeSelectionWidget.ListPropertyTypesCallback.class);
+        addEntityTypeCallback();
+    }
+
+    private void addEntityTypeCallback()
+    {
+        if (entityKindName.equals("EXPERIMENT"))
+        {
+            addCallbackClass(ExperimentTypeSelectionWidget.ListExperimentTypesCallback.class);
+        } else if (entityKindName.equals("SAMPLE"))
+        {
+            addCallbackClass(SampleTypeSelectionWidget.ListSampleTypesCallback.class);
+        } else
+        {
+            throw new IllegalArgumentException();
+        }
+
+    }
+
+    @SuppressWarnings("unchecked")
+    public final void execute()
+    {
+
+        final PropertyTypeSelectionWidget propertyTypeSelector = choosePropertyType();
+        setDefaultValue(propertyTypeSelector.tryGetSelectedPropertyTypeCode());
+        chooseEntityType();
+        chooseIfMandatory();
+        clickSaveButton();
+    }
+
+    private PropertyTypeSelectionWidget choosePropertyType()
+    {
+        final PropertyTypeSelectionWidget propertyTypeSelector =
+                (PropertyTypeSelectionWidget) GWTTestUtil
+                        .getWidgetWithID(PropertyTypeSelectionWidget.ID + widgetId
+                                + PropertyTypeAssignmentForm.PROPERTY_TYPE_ID_SUFFIX);
+        GWTUtils.setSelectedItem(propertyTypeSelector, ModelDataPropertyNames.CODE,
+                propertyTypeCode);
+        return propertyTypeSelector;
+    }
+
+    private void setDefaultValue(final String selectedPropertyTypeCode)
+    {
+        final Widget widget =
+                GWTTestUtil.getWidgetWithID(widgetId
+                        + PropertyTypeAssignmentForm.DEFAULT_VALUE_ID_PART
+                        + isInternalNamespace(selectedPropertyTypeCode)
+                        + getSimpleCode(selectedPropertyTypeCode));
+        assertTrue(widget instanceof Field);
+        if (defaultValue != null)
+        {
+            ((Field<?>) widget).setRawValue(defaultValue);
+        }
+    }
+
+    private void chooseIfMandatory()
+    {
+        final CheckBox mandatoryCheckbox =
+                (CheckBox) GWTTestUtil.getWidgetWithID(widgetId
+                        + PropertyTypeAssignmentForm.MANDATORY_CHECKBOX_ID_SUFFIX);
+        mandatoryCheckbox.setValue(isMandatory);
+    }
+
+    private void chooseEntityType()
+    {
+        if (entityKindName.equals("EXPERIMENT"))
+        {
+            final ComboBox<ExperimentTypeModel> experimentTypeSelector =
+                    (ExperimentTypeSelectionWidget) GWTTestUtil
+                            .getWidgetWithID(ExperimentTypeSelectionWidget.ID
+                                    + PropertyTypeAssignmentForm.EXPERIMENT_TYPE_ID_SUFFIX);
+            GWTUtils.setSelectedItem(experimentTypeSelector, ModelDataPropertyNames.CODE,
+                    entityTypeCode);
+            assertEquals(((ExperimentTypeSelectionWidget) experimentTypeSelector)
+                    .tryGetSelectedExperimentType().getCode(), entityTypeCode);
+        } else if (entityKindName.equals("SAMPLE"))
+        {
+            final ComboBox<SampleTypeModel> sampleTypeSelector =
+                    (SampleTypeSelectionWidget) GWTTestUtil
+                            .getWidgetWithID(SampleTypeSelectionWidget.ID
+                                    + PropertyTypeAssignmentForm.SAMPLE_TYPE_ID_SUFFIX);
+            GWTUtils.setSelectedItem(sampleTypeSelector, ModelDataPropertyNames.CODE,
+                    entityTypeCode);
+            assertEquals(((SampleTypeSelectionWidget) sampleTypeSelector)
+                    .tryGetSelectedSampleType().getCode(), entityTypeCode);
+        } else
+        {
+            throw new IllegalArgumentException();
+        }
+    }
+
+    private void clickSaveButton()
+    {
+        GWTTestUtil.clickButtonWithID(widgetId + PropertyTypeAssignmentForm.SAVE_BUTTON_ID_SUFFIX);
+    }
+
+    private String getSimpleCode(String code)
+    {
+        if (isInternalNamespace(code))
+        {
+            return code;
+        } else
+        {
+            return code.substring(USER_PROPERTY_PREFIX.length());
+        }
+    }
+
+    private boolean isInternalNamespace(String code)
+    {
+        return code.startsWith(USER_PROPERTY_PREFIX) == false;
+    }
+
+}
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java.expected b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java.expected
index 9112214b4a1..122ff780a7d 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java.expected
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/ICommonServer.java.expected
@@ -136,7 +136,7 @@ public interface ICommonServer extends IServer
     
     @Transactional
     @RolesAllowed(RoleSet.INSTANCE_ADMIN)
-    public void assignPropertyType(String sessionToken, EntityKind entityKind,
+    public String assignPropertyType(String sessionToken, EntityKind entityKind,
             String propertyTypeCode, String entityTypeCode, boolean isMandatory, String defaultValue);
             
 }
-- 
GitLab