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 e30e540d2f02052530017f5a84c277ebd2522520..6b46cbfa04cdd77ad8df1858443043d4fe9968fd 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 @@ -38,6 +38,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewAttachment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Script; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleUpdatesDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; @@ -52,12 +53,13 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifierFa @Transactional(propagation = Propagation.NOT_SUPPORTED) public class EntityValidationTest extends GenericSystemTestCase { - // create sample of a type, that has attached script that forbids creation private static final String IMPOSSIBLE_TYPE = "IMPOSSIBLE"; private static final String IMPOSSIBLE_TO_UPDATE_TYPE = "IMPOSSIBLE_TO_UPDATE"; + private static final int TEST_SCRIPT_ID = 8; + /** * shortcut for registerNewSample(identifier, type, null) */ @@ -145,6 +147,7 @@ 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 @@ -165,6 +168,27 @@ 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"); + + 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 f1933faa232d4790a95a09888bda5780eb9e71d9..072a330ba6dfe0dd9a8cecfab8f410afb06fcf4a 100644 --- a/openbis/sourceTest/sql/postgresql/119/055=sample_types.tsv +++ b/openbis/sourceTest/sql/postgresql/119/055=sample_types.tsv @@ -7,4 +7,4 @@ 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 REQUIRE_CHILD_VALIDATION Revalidated the child 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 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 diff --git a/openbis/sourceTest/sql/postgresql/119/057=scripts.tsv b/openbis/sourceTest/sql/postgresql/119/057=scripts.tsv index 513dfcadc420ceeecb751837a6246c607b66a1d0..b4a507230680c00144072e000174341a38cef781 100644 --- a/openbis/sourceTest/sql/postgresql/119/057=scripts.tsv +++ b/openbis/sourceTest/sql/postgresql/119/057=scripts.tsv @@ -5,4 +5,4 @@ 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 validateChildren \N def validate(entity, isNew):\n for childRelation in entity.entityPE().getChildRelationships():\n requestValidation(childRelation.getChildSample()) \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