diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/sample/VerifySampleExperimentExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/sample/VerifySampleExperimentExecutor.java index 5dcccd19af6870dc237bb8a7d1b58e5c0d3c7b78..0816a1be088b49ac4d9e6946c4d185b64c68ed02 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/sample/VerifySampleExperimentExecutor.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/asapi/v3/executor/sample/VerifySampleExperimentExecutor.java @@ -78,7 +78,7 @@ public class VerifySampleExperimentExecutor implements IVerifySampleExperimentEx if (hasDatasets && sample.getSpace() == null) { - throw UserFailureException.fromTemplate("Cannot detach the sample '%s' from the space " + throw UserFailureException.fromTemplate("Cannot detach the sample %s from the space " + "because there are already datasets attached to the sample.", EntityUtils.render(sample)); } diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateSampleTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateSampleTest.java index 80aac39c4ba4d04187a7ac2362f25da9f3ee38dd..ace8542abf8e631aee2aef919be78fcb750e1421 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateSampleTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/UpdateSampleTest.java @@ -318,8 +318,8 @@ public class UpdateSampleTest extends AbstractSampleTest { v3api.updateSamples(sessionToken, Arrays.asList(update)); } - }, "Cannot detach the sample '/CISD/CP-TEST-1' from the space because there are already datasets attached to the sample", - patternContains("verifying (1/1)", toDblQuotes("'identifier' : '/CISD/CP-TEST-1'"))); + }, "Cannot detach the sample /CP-TEST-1 (perm id: 200902091219327-1025) from the space because there are already datasets attached to the sample", + patternContains("verifying (1/1)", toDblQuotes("'identifier' : '/CP-TEST-1'"))); } @Test @@ -435,7 +435,7 @@ public class UpdateSampleTest extends AbstractSampleTest { v3api.updateSamples(sessionToken, Arrays.asList(update)); } - }, "Sample space must be the same as experiment space. Sample: /CISD/SAMPLE, Experiment: /TEST-SPACE/TEST-PROJECT/EXP-SPACE-TEST", + }, "Experiment: /TEST-SPACE/TEST-PROJECT/EXP-SPACE-TEST (perm id: 201206190940555-1032)", patternContains("verifying (1/1)", toDblQuotes("'identifier' : '/CISD/SAMPLE'"))); } @@ -461,7 +461,7 @@ public class UpdateSampleTest extends AbstractSampleTest { v3api.updateSamples(sessionToken, Arrays.asList(update)); } - }, "Shared samples cannot be attached to experiments. Sample: /SAMPLE, Experiment: /TEST-SPACE/TEST-PROJECT/EXP-SPACE-TEST", + }, "Experiment: /TEST-SPACE/TEST-PROJECT/EXP-SPACE-TEST (perm id: 201206190940555-1032)", patternContains("verifying (1/1)", toDblQuotes("'identifier' : '/SAMPLE'"))); } @@ -744,7 +744,7 @@ public class UpdateSampleTest extends AbstractSampleTest { v3api.updateSamples(sessionToken, Arrays.asList(update)); } - }, "'/CISD/A01:CL1' cannot be it's own container", patternContains("verifying (1/1)", toDblQuotes("'identifier' : '/CISD/A01:CL1'"))); + }, "/CISD/A01:CL1 (perm id: 200811050919915-8) cannot be it's own container", patternContains("verifying (1/1)", toDblQuotes("'identifier' : '/CISD/A01:CL1'"))); } @Test @@ -920,7 +920,8 @@ public class UpdateSampleTest extends AbstractSampleTest { v3api.updateSamples(sessionToken, Arrays.asList(update)); } - }, "'/CISD/CL1:A01' cannot be it's own container", patternContains("verifying (1/1)", toDblQuotes("'identifier' : '/CISD/CL1:A01'"))); + }, "/CISD/CL1:A01 (perm id: 200811050919915-9) cannot be it's own container", + patternContains("verifying (1/1)", toDblQuotes("'identifier' : '/CISD/CL1:A01'"))); } @Test diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractAssignmentSampleToExperimentTestCase.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractAssignmentSampleToExperimentTestCase.java index 5bcdcb88973951b8221ed7d67c657138f8e8601e..b599020bdfda21ff60ae66bc584326bf13318aee 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractAssignmentSampleToExperimentTestCase.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractAssignmentSampleToExperimentTestCase.java @@ -403,10 +403,11 @@ public abstract class AbstractAssignmentSampleToExperimentTestCase extends BaseT fail("UserFailureException expected"); } catch (UserFailureException ex) { - assertEquals("Operation cannot be performed, because the sample " - + entityGraphManager.getSample(g.s(1)).getIdentifier() - + " has the following datasets which need an experiment: [" - + entityGraphManager.getDataSet(g.ds(2)).getCode() + "]", getErrorMessage(ex)); + String errorMessage = getErrorMessage(ex); + AssertionUtil.assertContains("Operation cannot be performed, because the sample " + + entityGraphManager.getSample(g.s(1)).getIdentifier(), errorMessage); + AssertionUtil.assertContains(" has the following datasets which need an experiment: [" + + entityGraphManager.getDataSet(g.ds(2)).getCode() + "]", errorMessage); } } @@ -494,12 +495,21 @@ public abstract class AbstractAssignmentSampleToExperimentTestCase extends BaseT fail("UserFailureException expected"); } catch (UserFailureException ex) { - String expected1 = "Samples with following codes do not exist in the space 'S2': '[" - + entityGraphManager.getSample(g.s(1)).getCode() + "]'."; - String expected2 = - "Sample space must be the same as experiment space. Sample: " + entityGraphManager.getSample(g.s(1)).getIdentifier() - + ", Experiment: " + entityGraphManager.getExperimentIdentifierOrNull(g.e(1)); - AssertionUtil.assertCollectionContains(Arrays.asList(expected1, expected2), getErrorMessage(ex)); + String errorMessage = getErrorMessage(ex); + if (errorMessage.startsWith("Samples")) + { + AssertionUtil.assertContains("Samples with following codes do not exist in the space 'S2': '[" + + entityGraphManager.getSample(g.s(1)).getCode(), errorMessage); + } else if (errorMessage.startsWith("Sample space")) + { + AssertionUtil.assertContains("Sample space must be the same as experiment space. Sample: " + + entityGraphManager.getSample(g.s(1)).getIdentifier(), errorMessage); + String experimentIdentifier = entityGraphManager.getExperimentIdentifierOrNull(g.e(1)); + AssertionUtil.assertContains("Experiment: " + experimentIdentifier, errorMessage); + } else + { + fail("Starts neither with 'Samples' nor with 'Sample space': " + errorMessage); + } } } @@ -632,12 +642,21 @@ public abstract class AbstractAssignmentSampleToExperimentTestCase extends BaseT fail("UserFailureException expected"); } catch (UserFailureException ex) { - String expected1 = "Samples with following codes do not exist in the space 'S1': '[" - + entityGraphManager.getSample(g.s(1)).getCode() + "]'."; - String expected2 = - "Shared samples cannot be attached to experiments. Sample: " + entityGraphManager.getSample(g.s(1)).getIdentifier() - + ", Experiment: " + entityGraphManager.getExperimentIdentifierOrNull(g.e(1)); - AssertionUtil.assertCollectionContains(Arrays.asList(expected1, expected2), getErrorMessage(ex)); + String errorMessage = getErrorMessage(ex); + if (errorMessage.startsWith("Samples")) + { + AssertionUtil.assertContains("Samples with following codes do not exist in the space 'S1': '[" + + entityGraphManager.getSample(g.s(1)).getCode(), errorMessage); + } else if (errorMessage.startsWith("Shared samples")) + { + AssertionUtil.assertContains("Shared samples cannot be attached to experiments. Sample: " + + entityGraphManager.getSample(g.s(1)).getIdentifier(), errorMessage); + String experimentIdentifier = entityGraphManager.getExperimentIdentifierOrNull(g.e(1)); + AssertionUtil.assertContains("Experiment: " + experimentIdentifier, errorMessage); + } else + { + fail("Starts neither with 'Samples' nor with 'Shared samples': " + errorMessage); + } } }