From ab4e2ec0fcf8ae850e94acca9bb3ec65b23936d5 Mon Sep 17 00:00:00 2001
From: buczekp <buczekp>
Date: Wed, 6 Oct 2010 14:31:31 +0000
Subject: [PATCH] test: check hidding of tabs

SVN: 18207
---
 .../client/application/ui/ActivateTab.java    |  8 +--
 .../application/ui/CheckTabNotExists.java     | 55 +++++++++++++++++++
 .../GenericExperimentViewerTest.java          | 31 ++++++++++-
 3 files changed, 88 insertions(+), 6 deletions(-)
 create mode 100644 openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CheckTabNotExists.java

diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/ActivateTab.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/ActivateTab.java
index 48ca3b1f077..8038c72d31b 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/ActivateTab.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/ActivateTab.java
@@ -24,11 +24,11 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.GWTTestU
  * 
  * @author Piotr Buczek
  */
-public final class ActivateTab extends AbstractDefaultTestCommand
+public class ActivateTab extends AbstractDefaultTestCommand
 {
-    private final String tabPanelId;
+    protected final String tabPanelId;
 
-    private final String tabItemId;
+    protected final String tabItemId;
 
     public ActivateTab(final String tabPanelId, final String tabItemId)
     {
@@ -40,7 +40,7 @@ public final class ActivateTab extends AbstractDefaultTestCommand
     // AbstractDefaultTestCommand
     //
 
-    public final void execute()
+    public void execute()
     {
         GWTTestUtil.selectTabItemWithId(tabPanelId, tabItemId);
     }
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CheckTabNotExists.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CheckTabNotExists.java
new file mode 100644
index 00000000000..52c1fabebf4
--- /dev/null
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CheckTabNotExists.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import junit.framework.AssertionFailedError;
+
+import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.AbstractDefaultTestCommand;
+
+/**
+ * A {@link AbstractDefaultTestCommand} extension that expects tab to not exist.
+ * 
+ * @author Piotr Buczek
+ */
+public final class CheckTabNotExists extends ActivateTab
+{
+    public CheckTabNotExists(final String tabPanelId, final String tabItemId)
+    {
+        super(tabPanelId, tabItemId);
+    }
+
+    //
+    // AbstractDefaultTestCommand
+    //
+
+    @Override
+    public final void execute()
+    {
+        try
+        {
+            super.execute();
+            fail("Expected AssertionFailedError because tab '" + tabItemId + "' shouldn't exist");
+        } catch (AssertionFailedError e)
+        {
+            assertTrue(
+                    "Unexpected exception message " + e.getMessage(),
+                    e.getMessage().startsWith(
+                            "No tab item with id '" + tabItemId
+                                    + "' could be found in panel with following tabs"));
+        }
+    }
+}
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentViewerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentViewerTest.java
index b491398874c..849260c5b4d 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentViewerTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentViewerTest.java
@@ -26,6 +26,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.TabContent
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DisplayTypeIDGenerator;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.IDisplayTypeIDGenerator;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.menu.TopMenu.ActionMenuKind;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.CheckTabNotExists;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.Login;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.specific.AttachmentColDefKind;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.columns.DataSetRow;
@@ -80,6 +81,12 @@ public class GenericExperimentViewerTest extends AbstractGWTTestCase
 
     private static final String EXP_X_PERM_ID = "200811050937246-1031";
 
+    private static final String EXP_TEST_1 = "EXP-TEST-1";
+
+    private static final String EXP_TEST_1_ID = "/CISD/NEMO/EXP-TEST-1";
+
+    private static final String EXP_TEST_1_PERM_ID = "200902091239077-1033";
+
     private static final String A_SIMPLE_EXPERIMENT = "A simple experiment";
 
     private static final String DOE_JOHN = "Doe, John";
@@ -88,6 +95,8 @@ public class GenericExperimentViewerTest extends AbstractGWTTestCase
 
     private static final String SIRNA_HCS = "SIRNA_HCS";
 
+    private static final String COMPOUND_HCS = "COMPOUND_HCS";
+
     private static final String NEMO = "NEMO (CISD)";
 
     private static final String EXP1 = "EXP1";
@@ -188,6 +197,23 @@ public class GenericExperimentViewerTest extends AbstractGWTTestCase
         launchTest();
     }
 
+    public final void testWebConfigurationHidingAttachmentSection()
+    {
+        prepareShowExperiment(NEMO, COMPOUND_HCS, EXP_TEST_1);
+        final CheckExperiment checkExperiment = new CheckExperiment();
+        checkExperiment.property("Experiment").asString(EXP_TEST_1_ID);
+        checkExperiment.property("PermID").matchingPattern(
+                ".*<a href=\".*permId=" + EXP_TEST_1_PERM_ID + ".*>" + EXP_TEST_1_PERM_ID
+                        + "</a>.*");
+        checkExperiment.property("Experiment Type").asCode(COMPOUND_HCS);
+        remoteConsole.prepare(checkExperiment);
+
+        remoteConsole.prepare(new CheckTabNotExists(createSectionsTabPanelId(),
+                createSectionId(DisplayTypeIDGenerator.ATTACHMENT_SECTION)));
+
+        launchTest();
+    }
+
     @DoNotRunWith(Platform.HtmlUnit)
     public final void testListOfAttachments()
     {
@@ -260,8 +286,9 @@ public class GenericExperimentViewerTest extends AbstractGWTTestCase
         final CheckTableCommand datasetTable =
                 checkExperiment.createDataSetTableCheck().expectedSize(2);
         datasetTable.expectedRow(new DataSetRow("20081105092159188-3").valid().derived());
-        datasetTable.expectedRow(new DataSetRow("20081105092158673-1").invalid().withSample(
-                "CISD:/CISD/3VCP1").withSampleType("CELL_PLATE").notDerived().withIsComplete(null));
+        datasetTable.expectedRow(new DataSetRow("20081105092158673-1").invalid()
+                .withSample("CISD:/CISD/3VCP1").withSampleType("CELL_PLATE").notDerived()
+                .withIsComplete(null));
         datasetTable.expectedColumnsNumber(25);
         final String commentColIdent = GridTestUtils.getPropertyColumnIdentifier("COMMENT", false);
         datasetTable.expectedColumnHidden(commentColIdent, true);
-- 
GitLab