diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UnassignSampleFromSpaceTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UnassignSampleFromSpaceTest.java index 8a72af8918badcfe114c514919cb4dadebc056b0..e740527b97952d66238f90c9893198e53e07763f 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UnassignSampleFromSpaceTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UnassignSampleFromSpaceTest.java @@ -109,6 +109,18 @@ public class UnassignSampleFromSpaceTest extends BaseTest assertThat(parent, is(inSpace(space))); } + @Test(expectedExceptions = + { UserFailureException.class }) + public void childSampleCantBeUnassignedFromSpace() throws Exception + { + Sample parent = create(aSample().inExperiment(experiment)); + Sample child = create(aSample().withParent(parent).inExperiment(experiment)); + + perform(anUpdateOf(child).removingSpace()); + + assertThat(child, hasNoSpace()); + } + @Test public void parentSampleCanBeUnassignedFromSpace() throws Exception { diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateSampleParentsTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateSampleParentsTest.java index f327e7b998769b375e10386814724e55ddeeb342..f06dedd27351b49722f13a25d86cf63dd2201efa 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateSampleParentsTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateSampleParentsTest.java @@ -108,7 +108,6 @@ public class UpdateSampleParentsTest extends BaseTest Sample sample = create(aSample().inSpace(space)); perform(anUpdateOf(sample).toHaveParent(sample)); - } @Test(expectedExceptions = @@ -133,7 +132,7 @@ public class UpdateSampleParentsTest extends BaseTest perform(anUpdateOf(child).toHaveParent(parent)); } - @Test(groups = "broken", expectedExceptions = + @Test(expectedExceptions = { UserFailureException.class }) public void childCannotBeShared() throws Exception { diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/SampleUpdateBuilder.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/SampleUpdateBuilder.java index cd3fbf6e84da4cf1c9ccab01c36ffa0e3243f2ef..2199f58f7d7c542d1b6c183f917777ee6c42df99 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/SampleUpdateBuilder.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/SampleUpdateBuilder.java @@ -64,7 +64,7 @@ public class SampleUpdateBuilder extends UpdateBuilder<SampleUpdatesDTO> } this.version = sample.getVersion(); this.sampleIdentifier = id(sample); - this.parents = new ArrayList<Sample>(); + this.parents = null; this.container = null; } @@ -105,6 +105,10 @@ public class SampleUpdateBuilder extends UpdateBuilder<SampleUpdatesDTO> public SampleUpdateBuilder toHaveParents(Sample... samples) { + if (this.parents == null) + { + this.parents = new ArrayList<Sample>(); + } for (Sample parent : samples) { this.parents.add(parent); @@ -134,10 +138,14 @@ public class SampleUpdateBuilder extends UpdateBuilder<SampleUpdatesDTO> @Override public SampleUpdatesDTO create() { - String[] parentIdentifiers = new String[this.parents.size()]; - for (int i = 0; i < this.parents.size(); i++) + String[] parentIdentifiers = null; + if (this.parents != null) { - parentIdentifiers[i] = this.parents.get(i).getIdentifier(); + parentIdentifiers = new String[this.parents.size()]; + for (int i = 0; i < this.parents.size(); i++) + { + parentIdentifiers[i] = this.parents.get(i).getIdentifier(); + } } return new SampleUpdatesDTO(this.sampleId, new ArrayList<IEntityProperty>(), this.experimentId, new ArrayList<NewAttachment>(), this.version,