From 60cea84c4fba52b34a3da4f72c8829ee648621cf Mon Sep 17 00:00:00 2001
From: pkupczyk <pkupczyk>
Date: Sun, 23 Jul 2017 17:28:39 +0000
Subject: [PATCH] SSDM-5416 : Project Authorization - sample predicates and
 validators - more tests

SVN: 38570
---
 .../authorization/common/DeletionUtil.java    |  73 ++++++++++++
 ...onTechIdCollectionPredicateSystemTest.java |   3 +-
 ...tionPredicateWithExperimentSystemTest.java |   7 +-
 ...llectionPredicateWithSampleSystemTest.java |  30 +----
 .../RevertDeletionPredicateSystemTest.java    |  92 +++++++++++++++
 ...tionPredicateWithExperimentSystemTest.java |  36 ++++++
 ...DeletionPredicateWithSampleSystemTest.java | 106 ++++++++++++++++++
 .../V3DeletionIdPredicateSystemTest.java      |  86 ++++++++++++++
 ...onIdPredicateWithExperimentSystemTest.java |  39 +++++++
 ...letionIdPredicateWithSampleSystemTest.java | 103 +++++++++++++++++
 .../DeletionTechIdCollectionPredicate.java    |   2 +-
 .../predicate/RevertDeletionPredicate.java    |   2 +-
 .../DeletionPredicateTestService.java         |  17 +++
 13 files changed, 562 insertions(+), 34 deletions(-)
 create mode 100644 datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/common/DeletionUtil.java
 create mode 100644 datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateSystemTest.java
 create mode 100644 datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithExperimentSystemTest.java
 create mode 100644 datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithSampleSystemTest.java
 create mode 100644 datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateSystemTest.java
 create mode 100644 datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithExperimentSystemTest.java
 create mode 100644 datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithSampleSystemTest.java

diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/common/DeletionUtil.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/common/DeletionUtil.java
new file mode 100644
index 00000000000..9bc5910b2d7
--- /dev/null
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/common/DeletionUtil.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2017 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.datastoreserver.systemtests.authorization.common;
+
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.CommonAuthorizationSystemTest;
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.CommonAuthorizationSystemTest.SampleKind;
+import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Deletion;
+import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE;
+
+/**
+ * @author pkupczyk
+ */
+public class DeletionUtil
+{
+
+    public static TechId createNonexistentObject(Object param)
+    {
+        return new TechId(-1);
+    }
+
+    public static TechId createObjectWithExperiment(CommonAuthorizationSystemTest test, SpacePE spacePE, ProjectPE projectPE, Object param)
+    {
+        ExperimentPE experiment = test.getExperimentEmpty(spacePE, projectPE);
+        Deletion deletion = test.getCommonService().trashExperiment(experiment);
+        return new TechId(deletion.getId());
+    }
+
+    public static TechId createObjectWithSample(CommonAuthorizationSystemTest test, SpacePE spacePE, ProjectPE projectPE, Object param)
+    {
+        SamplePE sample;
+
+        switch ((SampleKind) param)
+        {
+            case SHARED_READ:
+            case SHARED_READ_WRITE:
+                if (test.getSpace1().equals(spacePE))
+                {
+                    sample = test.getSharedSample1();
+                } else if (test.getSpace2().equals(spacePE))
+                {
+                    sample = test.getSharedSample2();
+                } else
+                {
+                    throw new RuntimeException();
+                }
+                break;
+            default:
+                sample = test.getSample(spacePE, projectPE, (SampleKind) param);
+        }
+
+        Deletion deletion = test.getCommonService().trashSample(sample);
+        return new TechId(deletion.getId());
+    }
+
+}
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateSystemTest.java
index 835f58cf945..3827984b91c 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateSystemTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateSystemTest.java
@@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predi
 import java.util.List;
 
 import ch.systemsx.cisd.common.exceptions.UserFailureException;
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil;
 import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTest;
 import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
 import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider;
@@ -40,7 +41,7 @@ public abstract class DeletionTechIdCollectionPredicateSystemTest extends Common
     @Override
     protected TechId createNonexistentObject(Object param)
     {
-        return new TechId(-1);
+        return DeletionUtil.createNonexistentObject(param);
     }
 
     @Override
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithExperimentSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithExperimentSystemTest.java
index 996fc1c6ddc..b6c5a9fe164 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithExperimentSystemTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithExperimentSystemTest.java
@@ -16,9 +16,8 @@
 
 package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.deletion;
 
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil;
 import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
-import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Deletion;
-import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE;
 
@@ -31,9 +30,7 @@ public class DeletionTechIdCollectionPredicateWithExperimentSystemTest extends D
     @Override
     protected TechId createObject(SpacePE spacePE, ProjectPE projectPE, Object param)
     {
-        ExperimentPE experiment = getExperimentEmpty(spacePE, projectPE);
-        Deletion deletion = getCommonService().trashExperiment(experiment);
-        return new TechId(deletion.getId());
+        return DeletionUtil.createObjectWithExperiment(this, spacePE, projectPE, param);
     }
 
 }
\ No newline at end of file
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithSampleSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithSampleSystemTest.java
index b6a5f146727..cac5eb53661 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithSampleSystemTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/DeletionTechIdCollectionPredicateWithSampleSystemTest.java
@@ -19,13 +19,12 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predi
 import java.util.List;
 
 import ch.systemsx.cisd.common.exceptions.UserFailureException;
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil;
 import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonSamplePredicateSystemTest;
 import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
-import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Deletion;
 import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider;
 import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
-import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE;
 import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.deletion.DeletionPredicateTestService;
 
@@ -44,40 +43,19 @@ public class DeletionTechIdCollectionPredicateWithSampleSystemTest extends Commo
     @Override
     protected SampleKind getSharedSampleKind()
     {
-        return SampleKind.SHARED_READ;
+        return SampleKind.SHARED_READ_WRITE;
     }
 
     @Override
     protected TechId createNonexistentObject(Object param)
     {
-        return new TechId(-1);
+        return DeletionUtil.createNonexistentObject(param);
     }
 
     @Override
     protected TechId createObject(SpacePE spacePE, ProjectPE projectPE, Object param)
     {
-        SamplePE sample;
-
-        switch ((SampleKind) param)
-        {
-            case SHARED_READ:
-                if (getSpace1().equals(spacePE))
-                {
-                    sample = getSharedSample1();
-                } else if (getSpace2().equals(spacePE))
-                {
-                    sample = getSharedSample2();
-                } else
-                {
-                    throw new RuntimeException();
-                }
-                break;
-            default:
-                sample = getSample(spacePE, projectPE, (SampleKind) param);
-        }
-
-        Deletion deletion = getCommonService().trashSample(sample);
-        return new TechId(deletion.getId());
+        return DeletionUtil.createObjectWithSample(this, spacePE, projectPE, param);
     }
 
     @Override
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateSystemTest.java
new file mode 100644
index 00000000000..4bce8d0d2e6
--- /dev/null
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateSystemTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2017 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.datastoreserver.systemtests.authorization.predicate.deletion;
+
+import java.util.List;
+
+import ch.systemsx.cisd.common.exceptions.UserFailureException;
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil;
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTest;
+import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
+import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider;
+import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
+import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.deletion.DeletionPredicateTestService;
+
+/**
+ * @author pkupczyk
+ */
+public abstract class RevertDeletionPredicateSystemTest extends CommonPredicateSystemTest<TechId>
+{
+
+    @Override
+    protected boolean isCollectionPredicate()
+    {
+        return true;
+    }
+
+    @Override
+    protected TechId createNonexistentObject(Object param)
+    {
+        return DeletionUtil.createNonexistentObject(param);
+    }
+
+    @Override
+    protected void evaluateObjects(IAuthSessionProvider sessionProvider, List<TechId> objects, Object param)
+    {
+        try
+        {
+            getBean(DeletionPredicateTestService.class).testRevertDeletionPredicate(sessionProvider, objects);
+        } finally
+        {
+            if (objects != null)
+            {
+                for (TechId object : objects)
+                {
+                    if (object != null)
+                    {
+                        getCommonService().untrash(object.getId());
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    protected void assertWithNull(PersonPE person, Throwable t, Object param)
+    {
+        assertException(t, NullPointerException.class, null);
+    }
+
+    @Override
+    protected void assertWithNullForInstanceUser(PersonPE person, Throwable t, Object param)
+    {
+        assertNoException(t);
+    }
+
+    @Override
+    protected void assertWithNullCollection(PersonPE person, Throwable t, Object param)
+    {
+        assertException(t, UserFailureException.class, "No revert deletion technical id specified.");
+    }
+
+    @Override
+    protected void assertWithNonexistentObject(PersonPE person, Throwable t, Object param)
+    {
+        assertNoException(t);
+    }
+
+}
\ No newline at end of file
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithExperimentSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithExperimentSystemTest.java
new file mode 100644
index 00000000000..0f7dd79ef70
--- /dev/null
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithExperimentSystemTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017 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.datastoreserver.systemtests.authorization.predicate.deletion;
+
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil;
+import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
+import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE;
+
+/**
+ * @author pkupczyk
+ */
+public class RevertDeletionPredicateWithExperimentSystemTest extends RevertDeletionPredicateSystemTest
+{
+
+    @Override
+    protected TechId createObject(SpacePE spacePE, ProjectPE projectPE, Object param)
+    {
+        return DeletionUtil.createObjectWithExperiment(this, spacePE, projectPE, param);
+    }
+
+}
\ No newline at end of file
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithSampleSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithSampleSystemTest.java
new file mode 100644
index 00000000000..7ee0a3c7939
--- /dev/null
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/RevertDeletionPredicateWithSampleSystemTest.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2017 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.datastoreserver.systemtests.authorization.predicate.deletion;
+
+import java.util.List;
+
+import ch.systemsx.cisd.common.exceptions.UserFailureException;
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil;
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonSamplePredicateSystemTest;
+import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
+import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider;
+import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE;
+import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.deletion.DeletionPredicateTestService;
+
+/**
+ * @author pkupczyk
+ */
+public class RevertDeletionPredicateWithSampleSystemTest extends CommonSamplePredicateSystemTest<TechId>
+{
+
+    @Override
+    protected boolean isCollectionPredicate()
+    {
+        return true;
+    }
+
+    @Override
+    protected SampleKind getSharedSampleKind()
+    {
+        return SampleKind.SHARED_READ_WRITE;
+    }
+
+    @Override
+    protected TechId createNonexistentObject(Object param)
+    {
+        return DeletionUtil.createNonexistentObject(param);
+    }
+
+    @Override
+    protected TechId createObject(SpacePE spacePE, ProjectPE projectPE, Object param)
+    {
+        return DeletionUtil.createObjectWithSample(this, spacePE, projectPE, param);
+    }
+
+    @Override
+    protected void evaluateObjects(IAuthSessionProvider sessionProvider, List<TechId> objects, Object param)
+    {
+        try
+        {
+            getBean(DeletionPredicateTestService.class).testRevertDeletionPredicate(sessionProvider, objects);
+        } finally
+        {
+            if (objects != null)
+            {
+                for (TechId object : objects)
+                {
+                    if (object != null)
+                    {
+                        getCommonService().untrash(object.getId());
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    protected void assertWithNull(PersonPE person, Throwable t, Object param)
+    {
+        assertException(t, NullPointerException.class, null);
+    }
+
+    @Override
+    protected void assertWithNullForInstanceUser(PersonPE person, Throwable t, Object param)
+    {
+        assertNoException(t);
+    }
+
+    @Override
+    protected void assertWithNullCollection(PersonPE person, Throwable t, Object param)
+    {
+        assertException(t, UserFailureException.class, "No revert deletion technical id specified.");
+    }
+
+    @Override
+    protected void assertWithNonexistentObject(PersonPE person, Throwable t, Object param)
+    {
+        assertNoException(t);
+    }
+
+}
\ No newline at end of file
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateSystemTest.java
new file mode 100644
index 00000000000..7b524803cb5
--- /dev/null
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateSystemTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2017 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.datastoreserver.systemtests.authorization.predicate.deletion;
+
+import java.util.List;
+
+import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.DeletionTechId;
+import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.IDeletionId;
+import ch.systemsx.cisd.common.exceptions.UserFailureException;
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonPredicateSystemTest;
+import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider;
+import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
+import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.deletion.DeletionPredicateTestService;
+
+/**
+ * @author pkupczyk
+ */
+public abstract class V3DeletionIdPredicateSystemTest extends CommonPredicateSystemTest<IDeletionId>
+{
+
+    @Override
+    protected boolean isCollectionPredicate()
+    {
+        return true;
+    }
+
+    @Override
+    protected IDeletionId createNonexistentObject(Object param)
+    {
+        return new DeletionTechId(-1L);
+    }
+
+    @Override
+    protected void evaluateObjects(IAuthSessionProvider sessionProvider, List<IDeletionId> objects, Object param)
+    {
+        try
+        {
+            getBean(DeletionPredicateTestService.class).testV3DeletionIdPredicate(sessionProvider, objects);
+        } finally
+        {
+            if (objects != null)
+            {
+                for (IDeletionId object : objects)
+                {
+                    if (object != null)
+                    {
+                        getCommonService().untrash(((DeletionTechId) object).getTechId());
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    protected void assertWithNull(PersonPE person, Throwable t, Object param)
+    {
+        assertException(t, NullPointerException.class, null);
+    }
+
+    @Override
+    protected void assertWithNullCollection(PersonPE person, Throwable t, Object param)
+    {
+        assertException(t, UserFailureException.class, "No v3 deletion id object specified.");
+    }
+
+    @Override
+    protected void assertWithNonexistentObject(PersonPE person, Throwable t, Object param)
+    {
+        assertNoException(t);
+    }
+
+}
\ No newline at end of file
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithExperimentSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithExperimentSystemTest.java
new file mode 100644
index 00000000000..52886205292
--- /dev/null
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithExperimentSystemTest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2017 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.datastoreserver.systemtests.authorization.predicate.deletion;
+
+import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.DeletionTechId;
+import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.IDeletionId;
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil;
+import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
+import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE;
+
+/**
+ * @author pkupczyk
+ */
+public class V3DeletionIdPredicateWithExperimentSystemTest extends V3DeletionIdPredicateSystemTest
+{
+
+    @Override
+    protected IDeletionId createObject(SpacePE spacePE, ProjectPE projectPE, Object param)
+    {
+        TechId techId = DeletionUtil.createObjectWithExperiment(this, spacePE, projectPE, param);
+        return new DeletionTechId(techId.getId());
+    }
+
+}
\ No newline at end of file
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithSampleSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithSampleSystemTest.java
new file mode 100644
index 00000000000..e637507b835
--- /dev/null
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/authorization/predicate/deletion/V3DeletionIdPredicateWithSampleSystemTest.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2017 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.datastoreserver.systemtests.authorization.predicate.deletion;
+
+import java.util.List;
+
+import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.DeletionTechId;
+import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.IDeletionId;
+import ch.systemsx.cisd.common.exceptions.UserFailureException;
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.common.DeletionUtil;
+import ch.systemsx.cisd.openbis.datastoreserver.systemtests.authorization.predicate.CommonSamplePredicateSystemTest;
+import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
+import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider;
+import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE;
+import ch.systemsx.cisd.openbis.systemtest.authorization.predicate.deletion.DeletionPredicateTestService;
+
+/**
+ * @author pkupczyk
+ */
+public class V3DeletionIdPredicateWithSampleSystemTest extends CommonSamplePredicateSystemTest<IDeletionId>
+{
+
+    @Override
+    protected boolean isCollectionPredicate()
+    {
+        return true;
+    }
+
+    @Override
+    protected SampleKind getSharedSampleKind()
+    {
+        return SampleKind.SHARED_READ_WRITE;
+    }
+
+    @Override
+    protected IDeletionId createNonexistentObject(Object param)
+    {
+        return new DeletionTechId(-1L);
+    }
+
+    @Override
+    protected IDeletionId createObject(SpacePE spacePE, ProjectPE projectPE, Object param)
+    {
+        TechId techId = DeletionUtil.createObjectWithSample(this, spacePE, projectPE, param);
+        return new DeletionTechId(techId.getId());
+    }
+
+    @Override
+    protected void evaluateObjects(IAuthSessionProvider sessionProvider, List<IDeletionId> objects, Object param)
+    {
+        try
+        {
+            getBean(DeletionPredicateTestService.class).testV3DeletionIdPredicate(sessionProvider, objects);
+        } finally
+        {
+            if (objects != null)
+            {
+                for (IDeletionId object : objects)
+                {
+                    if (object != null)
+                    {
+                        getCommonService().untrash(((DeletionTechId) object).getTechId());
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    protected void assertWithNull(PersonPE person, Throwable t, Object param)
+    {
+        assertException(t, NullPointerException.class, null);
+    }
+
+    @Override
+    protected void assertWithNullCollection(PersonPE person, Throwable t, Object param)
+    {
+        assertException(t, UserFailureException.class, "No v3 deletion id object specified.");
+    }
+
+    @Override
+    protected void assertWithNonexistentObject(PersonPE person, Throwable t, Object param)
+    {
+        assertNoException(t);
+    }
+
+}
\ No newline at end of file
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DeletionTechIdCollectionPredicate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DeletionTechIdCollectionPredicate.java
index aa83ed7b3d2..aee89b20df1 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DeletionTechIdCollectionPredicate.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DeletionTechIdCollectionPredicate.java
@@ -43,7 +43,7 @@ public class DeletionTechIdCollectionPredicate extends AbstractSpacePredicate<Li
     public DeletionTechIdCollectionPredicate()
     {
         this.experimentAccessPECollectionPredicate = new ExperimentAccessPECollectionPredicate();
-        this.sampleAccessPECollectionPredicate = new SampleAccessPECollectionPredicate();
+        this.sampleAccessPECollectionPredicate = new SampleAccessPECollectionPredicate(false);
     }
 
     @Override
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/RevertDeletionPredicate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/RevertDeletionPredicate.java
index 5cb787fea80..9e0034066cb 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/RevertDeletionPredicate.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/RevertDeletionPredicate.java
@@ -97,7 +97,7 @@ public class RevertDeletionPredicate extends AbstractPredicate<List<TechId>>
         final Set<RoleAssignmentPE> roleAssignments = person.getAllPersonRoles();
         for (final RoleAssignmentPE roleAssignment : roleAssignments)
         {
-            if (roleAssignment.getSpace() == null && roleAssignment.getRole().equals(RoleCode.ADMIN))
+            if (roleAssignment.getSpace() == null && roleAssignment.getProject() == null && roleAssignment.getRole().equals(RoleCode.ADMIN))
             {
                 return true;
             }
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/authorization/predicate/deletion/DeletionPredicateTestService.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/authorization/predicate/deletion/DeletionPredicateTestService.java
index 5bbcf766ef3..6cdd80f8601 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/authorization/predicate/deletion/DeletionPredicateTestService.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/authorization/predicate/deletion/DeletionPredicateTestService.java
@@ -21,9 +21,12 @@ import java.util.List;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
+import ch.ethz.sis.openbis.generic.asapi.v3.dto.deletion.id.IDeletionId;
 import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.AuthorizationGuard;
 import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.RolesAllowed;
 import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.DeletionTechIdCollectionPredicate;
+import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.RevertDeletionPredicate;
+import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.V3DeletionIdPredicate;
 import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.RoleWithHierarchy;
 import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSessionProvider;
@@ -42,4 +45,18 @@ public class DeletionPredicateTestService
     {
     }
 
+    @Transactional
+    @RolesAllowed(value = { RoleWithHierarchy.PROJECT_OBSERVER })
+    public void testRevertDeletionPredicate(IAuthSessionProvider sessionProvider,
+            @AuthorizationGuard(guardClass = RevertDeletionPredicate.class) List<TechId> deletionTechIds)
+    {
+    }
+
+    @Transactional
+    @RolesAllowed(value = { RoleWithHierarchy.PROJECT_OBSERVER })
+    public void testV3DeletionIdPredicate(IAuthSessionProvider sessionProvider,
+            @AuthorizationGuard(guardClass = V3DeletionIdPredicate.class) List<IDeletionId> deletionIds)
+    {
+    }
+
 }
-- 
GitLab