From c1cfb7050377def97c6a5c797373f59307d40ce3 Mon Sep 17 00:00:00 2001
From: jakubs <jakubs>
Date: Fri, 7 Sep 2012 11:49:50 +0000
Subject: [PATCH] BIS-173 reorganize the sample entity validation tests.

SVN: 26551
---
 .../bo/samplelister/SampleListingQueryTest.java    |  2 +-
 .../plugin/generic/EntityValidationTest.java       | 14 +-------------
 .../sql/postgresql/119/055=sample_types.tsv        |  3 ++-
 .../sql/postgresql/119/056=samples_all.tsv         |  1 +
 .../sourceTest/sql/postgresql/119/057=scripts.tsv  |  4 ++--
 5 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/SampleListingQueryTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/SampleListingQueryTest.java
index 7e278b7a1a0..f593bf42084 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/SampleListingQueryTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/samplelister/SampleListingQueryTest.java
@@ -143,7 +143,7 @@ public class SampleListingQueryTest extends AbstractDAOTest
     @Test
     public void testSampleCount()
     {
-        assertEquals(698, query.getSampleCount(dbInstanceId)); // without deleted
+        assertEquals(699, query.getSampleCount(dbInstanceId)); // without deleted
     }
 
     @Test
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/EntityValidationTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/EntityValidationTest.java
index 6070999e45b..8702fda1f0a 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/EntityValidationTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/plugin/generic/EntityValidationTest.java
@@ -147,7 +147,6 @@ public class EntityValidationTest extends GenericSystemTestCase
     @Test
     public void testSampleUpdateTriggerValidationOfParentsChildren()
     {
-        updateTestScript("  for childRelation in entity.entityPE().getChildRelationships():\n    requestValidation(childRelation.getChildSample()) ");
         // setting the parent of this sample, forces the validation of parent (as it is aslo being
         // changed)
         // as the consequence validation of INVALID sample is forced - via the validation script of
@@ -176,24 +175,13 @@ public class EntityValidationTest extends GenericSystemTestCase
     @Test
     public void testSampleUpdateTriggerValidationOfParentsChildrenDoesNotHappen()
     {
-        updateTestScript("  pass");
-
         Sample sample = getSampleFromSpaceAndType("TEST-SPACE", "WELL", "EV-NOT_INVALID");
 
-        SampleUpdatesDTO update = createSampleUpdates(sample, "EV-PARENT");
+        SampleUpdatesDTO update = createSampleUpdates(sample, "EV-PARENT-NORMAL");
 
         etlService.updateSample(systemSessionToken, update);
     }
 
-    // this updates the script that validates the EV-PARENT sample
-    private void updateTestScript(String validationFunctionBody)
-    {
-        Script script = commonServer.getScriptInfo(systemSessionToken, new TechId(TEST_SCRIPT_ID));
-
-        script.setScript("def validate(entity, isNew):\n" + validationFunctionBody + "\n");
-        commonServer.updateScript(systemSessionToken, script);
-    }
-
     private SampleUpdatesDTO createSampleUpdates(Sample sample, String parentCode)
     {
         String[] modifiedParentCodesOrNull = new String[]
diff --git a/openbis/sourceTest/sql/postgresql/119/055=sample_types.tsv b/openbis/sourceTest/sql/postgresql/119/055=sample_types.tsv
index 072a330ba6d..5e8129f7d38 100644
--- a/openbis/sourceTest/sql/postgresql/119/055=sample_types.tsv
+++ b/openbis/sourceTest/sql/postgresql/119/055=sample_types.tsv
@@ -7,4 +7,5 @@
 7	DYNAMIC_PLATE	Dynamic Plate	1	t	1	0	2009-03-23 15:34:44.462776+01	f	S	f	f	5	f
 8	IMPOSSIBLE	Impossible to create	1	t	1	0	2009-03-23 15:34:44.462776+01	f	S	f	f	6	f
 9	IMPOSSIBLE_TO_UPDATE	Impossible to update	1	t	1	0	2009-03-23 15:34:44.462776+01	f	S	f	f	7	f
-10	TEST_VALIDATION	Update validation script before validating	1	t	1	0	2009-03-23 15:34:44.462776+01	f	S	f	f	8	f
\ No newline at end of file
+10	VALIDATE_CHILDREN	Validate children on update	1	t	1	0	2009-03-23 15:34:44.462776+01	f	S	f	f	8	f
+11	NORMAL	just the normal	1	t	1	0	2009-03-23 15:34:44.462776+01	f	S	f	f	5	f
\ No newline at end of file
diff --git a/openbis/sourceTest/sql/postgresql/119/056=samples_all.tsv b/openbis/sourceTest/sql/postgresql/119/056=samples_all.tsv
index c3460ed9c11..8853579389e 100644
--- a/openbis/sourceTest/sql/postgresql/119/056=samples_all.tsv
+++ b/openbis/sourceTest/sql/postgresql/119/056=samples_all.tsv
@@ -1027,3 +1027,4 @@
 1056	EV-INVALID	9	2009-02-09 12:09:19.327518+01	2	\N	\N	3	\N	2009-08-18 17:54:11.56+02	23	201206191219327-1056	\N
 1057	EV-NOT_INVALID	6	2009-02-09 12:09:19.327518+01	2	\N	\N	3	\N	2009-08-18 17:54:11.56+02	23	201206191219327-1057	\N
 1058	EV-PARENT	10	2009-02-09 12:09:19.327518+01	2	\N	\N	3	\N	2009-08-18 17:54:11.56+02	23	201206191219327-1058	\N
+1059	EV-PARENT-NORMAL	11	2009-02-09 12:09:19.327518+01	2	\N	\N	3	\N	2009-08-18 17:54:11.56+02	23	201206191219327-1059	\N
diff --git a/openbis/sourceTest/sql/postgresql/119/057=scripts.tsv b/openbis/sourceTest/sql/postgresql/119/057=scripts.tsv
index d388e9e3212..1ae95a485bb 100644
--- a/openbis/sourceTest/sql/postgresql/119/057=scripts.tsv
+++ b/openbis/sourceTest/sql/postgresql/119/057=scripts.tsv
@@ -5,5 +5,5 @@
 5	1	validateOK	\N	def validate(entity, isNew):\n  pass\n 	2010-10-27 15:16:48.994831+02	2	\N	ENTITY_VALIDATION
 6	1	validateFAIL	\N	def validate(entity, isNew):\n  return "This check always fail"\n 	2010-10-27 15:16:48.994831+02	2	\N	ENTITY_VALIDATION
 7	1	validateUpdateFAIL	\N	def validate(entity, isNew):\n  if (not isNew):\n    return "Cannot update this entity"\n 	2010-10-27 15:16:48.994831+02	2	\N	ENTITY_VALIDATION
-8	1	testScript	\N	def validate(entity, isNew):\n  raise "Update this script before using"\n 	2010-10-27 15:16:48.994831+02	2	\N	ENTITY_VALIDATION
-9	1	code_date	\N	"%s %s" % (entity.code(), str(currentDate().getTime()))	2010-10-27 15:16:48.994831+02	2	\N	DYNAMIC_PROPERTY
+8	1	validateChildren	\N	def validate(entity, isNew):\n  for childRelation in entity.entityPE().getChildRelationships():\n    requestValidation(childRelation.getChildSample())	2010-10-27 15:16:48.994831+02	2	\N	ENTITY_VALIDATION
+9	1	code_date	\N	"%s %s" % (entity.code(), str(currentDate().getTime()))	2010-10-27 15:16:48.994831+02	2	\N	DYNAMIC_PROPERTY
\ No newline at end of file
-- 
GitLab