diff --git a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateExperimentTest.java b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateExperimentTest.java index aed6a6ed9198c887e02ec93ca66eb861bab3ca7c..fdc684d1b6bd3389fa3711315438fbc847e1d9dc 100644 --- a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateExperimentTest.java +++ b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateExperimentTest.java @@ -267,6 +267,35 @@ public class CreateExperimentTest extends AbstractExperimentTest }, typeId); } + @Test + public void testCreateWithImmutableData() + { + final String sessionToken = v3api.login(TEST_USER, PASSWORD); + + final ExperimentCreation creation = new ExperimentCreation(); + creation.setCode("TEST_EXPERIMENT1"); + creation.setTypeId(new EntityTypePermId("SIRNA_HCS")); + creation.setProjectId(new ProjectIdentifier("/TESTGROUP/TESTPROJ")); + creation.setProperty("DESCRIPTION", "a description"); + creation.setImmutableData(true); + + ExperimentFetchOptions fetchOptions = new ExperimentFetchOptions(); + fetchOptions.withTags(); + + List<ExperimentPermId> permIds = v3api.createExperiments(sessionToken, Arrays.asList(creation)); + Map<IExperimentId, Experiment> map = v3api.getExperiments(sessionToken, permIds, fetchOptions); + List<Experiment> experiments = new ArrayList<Experiment>(map.values()); + + assertEquals(experiments.size(), 1); + + Experiment experiment = experiments.get(0); + + assertEquals(experiment.getIdentifier().getIdentifier(), "/TESTGROUP/TESTPROJ/TEST_EXPERIMENT1"); + assertEquals(experiment.isImmutableData(), true); + assertEquals(experiment.isFrozen(), false); + assertEquals(experiment.getProperty("DESCRIPTION"), "a description"); + } + @Test public void testCreateWithTagExisting() { diff --git a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateSampleTest.java b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateSampleTest.java index a271155d6e110850df89afeb6705380cfb9eb1f9..b232335ed00ba9fbe29718836bd34b7d31e33f4a 100644 --- a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateSampleTest.java +++ b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/CreateSampleTest.java @@ -1217,6 +1217,38 @@ public class CreateSampleTest extends AbstractSampleTest patternContains("setting relation sample-components (1/1)", toDblQuotes("'identifier' : '/TEST-SPACE/HAS_NONEXISTENT_COMPONENT'"))); } + @Test + public void testCreateWithImmutableData() + { + String systemPropertyName = "$PLATE_GEOMETRY"; + String systemPropertyValue = "384_WELLS_16X24"; + + + String sessionToken = v3api.login(TEST_USER, PASSWORD); + + + SampleCreation samp1 = new SampleCreation(); + samp1.setCode("SAMPLE_WITH_SYS_PROPERTY"); + samp1.setTypeId(new EntityTypePermId("MASTER_PLATE")); + samp1.setSpaceId(new SpacePermId("CISD")); + samp1.setProperty(systemPropertyName, systemPropertyValue); + samp1.setImmutableData(true); + + List<SamplePermId> sampleIds = v3api.createSamples(sessionToken, + Arrays.asList(samp1)); + + SampleFetchOptions fetchOptions = new SampleFetchOptions(); + fetchOptions.withProperties(); + + Map<ISampleId, Sample> map = v3api.getSamples(sessionToken, sampleIds, fetchOptions); + List<Sample> samples = new ArrayList<Sample>(map.values()); + + Sample foundSample = samples.get(0); + assertEquals(foundSample.getProperty(systemPropertyName), systemPropertyValue); + assertEquals(foundSample.isImmutableData(), true); + assertEquals(foundSample.isFrozen(), false); + } + @Test public void testCreateWithSystemProperty() { diff --git a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateExperimentTest.java b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateExperimentTest.java index a3b707013a2b6163bd820fcc8aa1fdf1a08f99bf..d3e87b6d5e91055ac2a895024153bfede3ebe690 100644 --- a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateExperimentTest.java +++ b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateExperimentTest.java @@ -779,6 +779,31 @@ public class UpdateExperimentTest extends AbstractExperimentTest } } + @Test + public void testMakeDataImmutable() + { + // Given + String sessionToken = v3api.login(TEST_USER, PASSWORD); + ExperimentIdentifier expId1 = new ExperimentIdentifier("/CISD/NEMO/EXP10"); + ExperimentUpdate update1 = new ExperimentUpdate(); + update1.setExperimentId(expId1); + update1.makeDataImmutable(); + + // When + v3api.updateExperiments(sessionToken, Arrays.asList(update1)); + + // Then + Map<IExperimentId, Experiment> experiments = + v3api.getExperiments(sessionToken, Arrays.asList(expId1), + new ExperimentFetchOptions()); + Experiment experiment1 = experiments.get(expId1); + assertEquals(experiment1.getIdentifier().getIdentifier(), expId1.getIdentifier()); + assertEquals(experiment1.isFrozen(), false); + assertEquals(experiment1.isImmutableData(), true); + assertEquals(experiment1.isFrozenForDataSets(), false); + assertEquals(experiment1.isFrozenForSamples(), false); + } + @Test public void testFreezeForSamples() { @@ -803,6 +828,7 @@ public class UpdateExperimentTest extends AbstractExperimentTest Experiment experiment1 = experiments.get(expId1); assertEquals(experiment1.getIdentifier().getIdentifier(), expId1.getIdentifier()); assertEquals(experiment1.isFrozen(), true); + assertEquals(experiment1.isImmutableData(), true); assertEquals(experiment1.isFrozenForDataSets(), false); assertEquals(experiment1.isFrozenForSamples(), false); assertFreezingEvent(TEST_USER, experiment1.getIdentifier().getIdentifier(), @@ -810,6 +836,7 @@ public class UpdateExperimentTest extends AbstractExperimentTest Experiment experiment2 = experiments.get(expId2); assertEquals(experiment2.getIdentifier().getIdentifier(), expId2.getIdentifier()); assertEquals(experiment2.isFrozen(), true); + assertEquals(experiment2.isImmutableData(), true); assertEquals(experiment2.isFrozenForDataSets(), false); assertEquals(experiment2.isFrozenForSamples(), true); assertFreezingEvent(TEST_USER, experiment2.getIdentifier().getIdentifier(), @@ -841,6 +868,7 @@ public class UpdateExperimentTest extends AbstractExperimentTest Experiment experiment1 = experiments.get(expId1); assertEquals(experiment1.getIdentifier().getIdentifier(), expId1.getIdentifier()); assertEquals(experiment1.isFrozen(), true); + assertEquals(experiment1.isImmutableData(), true); assertEquals(experiment1.isFrozenForDataSets(), false); assertEquals(experiment1.isFrozenForSamples(), false); assertFreezingEvent(TEST_USER, experiment1.getIdentifier().getIdentifier(), @@ -848,6 +876,7 @@ public class UpdateExperimentTest extends AbstractExperimentTest Experiment experiment2 = experiments.get(expId2); assertEquals(experiment2.getIdentifier().getIdentifier(), expId2.getIdentifier()); assertEquals(experiment2.isFrozen(), true); + assertEquals(experiment2.isImmutableData(), true); assertEquals(experiment2.isFrozenForDataSets(), true); assertEquals(experiment2.isFrozenForSamples(), false); assertFreezingEvent(TEST_USER, experiment2.getIdentifier().getIdentifier(), diff --git a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateSampleTest.java b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateSampleTest.java index f12af7410ebf471dbe64e663825c7f351ff26994..486a53a75e284ee1ee7f00ddbbe4485843c74ee5 100644 --- a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateSampleTest.java +++ b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateSampleTest.java @@ -2118,6 +2118,33 @@ public class UpdateSampleTest extends AbstractSampleTest "update-samples SAMPLE_UPDATES('[SampleUpdate[sampleId=/CISD/NEMO/CP-TEST-1], SampleUpdate[sampleId=201206191219327-1055]]')"); } + @Test + public void testmakeDataImmutable() + { + // Given + String sessionToken = v3api.login(TEST_USER, PASSWORD); + SampleIdentifier sampleId1 = new SampleIdentifier("/CISD/MP002-1:B11"); + SampleUpdate update1 = new SampleUpdate(); + update1.setSampleId(sampleId1); + update1.makeDataImmutable(); + + // When + v3api.updateSamples(sessionToken, Arrays.asList(update1)); + + // Then + Map<ISampleId, Sample> samples = v3api.getSamples(sessionToken, + Arrays.asList(sampleId1), new SampleFetchOptions()); + Sample sample1 = samples.get(sampleId1); + assertEquals(sample1.getIdentifier().getIdentifier(), sampleId1.getIdentifier()); + assertEquals(sample1.isFrozen(), false); + assertEquals(sample1.isImmutableData(), true); + assertEquals(sample1.isFrozenForComponents(), false); + assertEquals(sample1.isFrozenForChildren(), false); + assertEquals(sample1.isFrozenForParents(), false); + assertEquals(sample1.isFrozenForDataSets(), false); + + } + @Test public void testFreeze() { @@ -2153,6 +2180,7 @@ public class UpdateSampleTest extends AbstractSampleTest Sample sample1 = samples.get(sampleId1); assertEquals(sample1.getIdentifier().getIdentifier(), sampleId1.getIdentifier()); assertEquals(sample1.isFrozen(), true); + assertEquals(sample1.isImmutableData(), true); assertEquals(sample1.isFrozenForComponents(), false); assertEquals(sample1.isFrozenForChildren(), false); assertEquals(sample1.isFrozenForParents(), false); @@ -2162,6 +2190,7 @@ public class UpdateSampleTest extends AbstractSampleTest Sample sample2 = samples.get(sampleId2); assertEquals(sample2.getIdentifier().getIdentifier(), sampleId2.getIdentifier()); assertEquals(sample2.isFrozen(), true); + assertEquals(sample2.isImmutableData(), true); assertEquals(sample2.isFrozenForComponents(), true); assertEquals(sample2.isFrozenForChildren(), false); assertEquals(sample2.isFrozenForParents(), false); @@ -2171,6 +2200,7 @@ public class UpdateSampleTest extends AbstractSampleTest Sample sample3 = samples.get(sampleId3); assertEquals(sample3.getIdentifier().getIdentifier(), sampleId3.getIdentifier()); assertEquals(sample3.isFrozen(), true); + assertEquals(sample3.isImmutableData(), true); assertEquals(sample3.isFrozenForComponents(), false); assertEquals(sample3.isFrozenForChildren(), true); assertEquals(sample3.isFrozenForParents(), false); @@ -2180,6 +2210,7 @@ public class UpdateSampleTest extends AbstractSampleTest Sample sample4 = samples.get(sampleId4); assertEquals(sample4.getIdentifier().getIdentifier(), sampleId4.getIdentifier()); assertEquals(sample4.isFrozen(), true); + assertEquals(sample4.isImmutableData(), true); assertEquals(sample4.isFrozenForComponents(), false); assertEquals(sample4.isFrozenForChildren(), false); assertEquals(sample4.isFrozenForParents(), true); @@ -2189,6 +2220,7 @@ public class UpdateSampleTest extends AbstractSampleTest Sample sample5 = samples.get(sampleId5); assertEquals(sample5.getIdentifier().getIdentifier(), sampleId5.getIdentifier()); assertEquals(sample5.isFrozen(), true); + assertEquals(sample5.isImmutableData(), true); assertEquals(sample5.isFrozenForComponents(), false); assertEquals(sample5.isFrozenForChildren(), false); assertEquals(sample5.isFrozenForParents(), false);