diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignDataSetToExperimentTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignDataSetToExperimentTest.java index c8515ceba783b48fbe0bbf16a2dbe21b9318068e..02c9c6adce2ea722fbbd197ca3a23aa813530248 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignDataSetToExperimentTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignDataSetToExperimentTest.java @@ -21,7 +21,6 @@ import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.not; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.or; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.rule; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import org.testng.annotations.BeforeClass; @@ -62,7 +61,7 @@ public class AssignDataSetToExperimentTest extends BaseTest perform(anUpdateOf(dataset).toExperiment(destinationExperiment)); - assertThat(serverSays(dataset), is(inExperiment(destinationExperiment))); + assertThat(dataset, is(inExperiment(destinationExperiment))); } @Test @@ -73,7 +72,7 @@ public class AssignDataSetToExperimentTest extends BaseTest perform(anUpdateOf(dataset).toExperiment(destinationExperiment)); - assertThat(serverSays(dataset), is(inExperiment(destinationExperiment))); + assertThat(dataset, is(inExperiment(destinationExperiment))); } @Test @@ -85,7 +84,7 @@ public class AssignDataSetToExperimentTest extends BaseTest perform(anUpdateOf(dataset).toExperiment(destinationExperiment)); - assertThat(serverSays(dataset).getSample(), is(nullValue())); + assertThat(dataset, hasNoSample()); } @Test @@ -96,7 +95,7 @@ public class AssignDataSetToExperimentTest extends BaseTest perform(anUpdateOf(child).toExperiment(destinationExperiment)); - assertThat(serverSays(child), is(inExperiment(destinationExperiment))); + assertThat(child, is(inExperiment(destinationExperiment))); } @Test @@ -108,7 +107,7 @@ public class AssignDataSetToExperimentTest extends BaseTest perform(anUpdateOf(child).toExperiment(destinationExperiment)); - assertThat(serverSays(parent), is(inExperiment(sourceExperiment))); + assertThat(parent, is(inExperiment(sourceExperiment))); } @Test @@ -119,7 +118,7 @@ public class AssignDataSetToExperimentTest extends BaseTest perform(anUpdateOf(parent).toExperiment(destinationExperiment)); - assertThat(serverSays(parent), is(inExperiment(destinationExperiment))); + assertThat(parent, is(inExperiment(destinationExperiment))); } @Test @@ -131,7 +130,7 @@ public class AssignDataSetToExperimentTest extends BaseTest perform(anUpdateOf(parent).toExperiment(destinationExperiment)); - assertThat(serverSays(child), is(inExperiment(sourceExperiment))); + assertThat(child, is(inExperiment(sourceExperiment))); } @Test @@ -142,7 +141,7 @@ public class AssignDataSetToExperimentTest extends BaseTest perform(anUpdateOf(component).toExperiment(destinationExperiment)); - assertThat(serverSays(component), is(inExperiment(destinationExperiment))); + assertThat(component, is(inExperiment(destinationExperiment))); } @Test @@ -155,7 +154,7 @@ public class AssignDataSetToExperimentTest extends BaseTest perform(anUpdateOf(component).toExperiment(destinationExperiment)); - assertThat(serverSays(container), is(inExperiment(sourceExperiment))); + assertThat(container, is(inExperiment(sourceExperiment))); } @Test @@ -167,7 +166,7 @@ public class AssignDataSetToExperimentTest extends BaseTest perform(anUpdateOf(container).toExperiment(destinationExperiment)); - assertThat(serverSays(container), is(inExperiment(destinationExperiment))); + assertThat(container, is(inExperiment(destinationExperiment))); } @Test @@ -180,7 +179,7 @@ public class AssignDataSetToExperimentTest extends BaseTest perform(anUpdateOf(container).toExperiment(destinationExperiment)); - assertThat(serverSays(component), is(inExperiment(sourceExperiment))); + assertThat(component, is(inExperiment(sourceExperiment))); } Space unrelatedAdmin; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignDataSetToSampleTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignDataSetToSampleTest.java index 1c31a63c05d80069b46d5056e0e4e406f6fff37c..c8d58c4cff2ccf981fe5f7019cb65c9ffc2e35ba 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignDataSetToSampleTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignDataSetToSampleTest.java @@ -65,7 +65,7 @@ public class AssignDataSetToSampleTest extends BaseTest perform(anUpdateOf(dataset).toSample(destinationSample)); - assertThat(serverSays(dataset), is(inSample(destinationSample))); + assertThat(dataset, is(inSample(destinationSample))); } @Test @@ -75,7 +75,7 @@ public class AssignDataSetToSampleTest extends BaseTest perform(anUpdateOf(dataset).toSample(destinationSample)); - assertThat(serverSays(dataset), is(inExperiment(destinationExperiment))); + assertThat(dataset, is(inExperiment(destinationExperiment))); } @Test @@ -85,7 +85,7 @@ public class AssignDataSetToSampleTest extends BaseTest perform(anUpdateOf(dataset).toSample(destinationSample)); - assertThat(serverSays(dataset), is(inSample(destinationSample))); + assertThat(dataset, is(inSample(destinationSample))); } @Test(expectedExceptions = @@ -116,7 +116,7 @@ public class AssignDataSetToSampleTest extends BaseTest perform(anUpdateOf(child).toSample(destinationSample)); - assertThat(serverSays(child), is(inSample(destinationSample))); + assertThat(child, is(inSample(destinationSample))); } @Test @@ -128,7 +128,7 @@ public class AssignDataSetToSampleTest extends BaseTest perform(anUpdateOf(child).toSample(destinationSample)); - assertThat(serverSays(parent), is(inSample(sourceSample))); + assertThat(parent, is(inSample(sourceSample))); } @Test @@ -139,7 +139,7 @@ public class AssignDataSetToSampleTest extends BaseTest perform(anUpdateOf(parent).toSample(destinationSample)); - assertThat(serverSays(parent), is(inSample(destinationSample))); + assertThat(parent, is(inSample(destinationSample))); } @Test @@ -151,7 +151,7 @@ public class AssignDataSetToSampleTest extends BaseTest perform(anUpdateOf(parent).toSample(destinationSample)); - assertThat(serverSays(child), is(inSample(sourceSample))); + assertThat(child, is(inSample(sourceSample))); } @Test @@ -162,7 +162,7 @@ public class AssignDataSetToSampleTest extends BaseTest perform(anUpdateOf(component).toSample(destinationSample)); - assertThat(serverSays(component), is(inSample(destinationSample))); + assertThat(component, is(inSample(destinationSample))); } @Test @@ -174,7 +174,7 @@ public class AssignDataSetToSampleTest extends BaseTest perform(anUpdateOf(component).toSample(destinationSample)); - assertThat(serverSays(container), is(inSample(sourceSample))); + assertThat(container, is(inSample(sourceSample))); } @Test @@ -185,7 +185,7 @@ public class AssignDataSetToSampleTest extends BaseTest perform(anUpdateOf(container).toSample(destinationSample)); - assertThat(serverSays(container), is(inSample(destinationSample))); + assertThat(container, is(inSample(destinationSample))); } @Test @@ -197,7 +197,7 @@ public class AssignDataSetToSampleTest extends BaseTest perform(anUpdateOf(container).toSample(destinationSample)); - assertThat(serverSays(component), is(inSample(sourceSample))); + assertThat(component, is(inSample(sourceSample))); } Space unrelatedAdmin; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignExperimentToProjectTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignExperimentToProjectTest.java index 03e308e04ef8b5bbee79a43f8362946efbacf464..63a885bf2e70f9ce141a786a85ec9af29daf6b37 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignExperimentToProjectTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignExperimentToProjectTest.java @@ -61,7 +61,7 @@ public class AssignExperimentToProjectTest extends BaseTest perform(anUpdateOf(experiment).toProject(destinationProject)); - assertThat(serverSays(experiment), is(inProject(destinationProject))); + assertThat(experiment, is(inProject(destinationProject))); } @Test @@ -73,7 +73,7 @@ public class AssignExperimentToProjectTest extends BaseTest perform(anUpdateOf(experiment).toProject(destinationProject)); - assertThat(serverSays(sample), is(inSpace(destinationSpace))); + assertThat(sample, is(inSpace(destinationSpace))); } Space unrelatedAdmin; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignProjectToSpaceTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignProjectToSpaceTest.java index 6eb299f754aaa1a7aa5ab961395412fae3e55749..59df894887380594cd3488fc9b15c25534404d78 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignProjectToSpaceTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignProjectToSpaceTest.java @@ -55,7 +55,7 @@ public class AssignProjectToSpaceTest extends BaseTest perform(anUpdateOf(project).toSpace(destinationSpace)); - assertThat(serverSays(project), is(inSpace(destinationSpace))); + assertThat(project, is(inSpace(destinationSpace))); } @Test @@ -68,7 +68,7 @@ public class AssignProjectToSpaceTest extends BaseTest perform(anUpdateOf(project).toSpace(destinationSpace)); - assertThat(serverSays(sample), is(inSpace(destinationSpace))); + assertThat(sample, is(inSpace(destinationSpace))); } Space unrelatedAdmin; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignSampleToExperimentTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignSampleToExperimentTest.java index d04332e8c9b549b6afc8a829e632dd0f620a6717..105cd684a54a5cb40a340e4f0031ba6e087bd57d 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignSampleToExperimentTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignSampleToExperimentTest.java @@ -66,7 +66,7 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(sample).toExperiment(destinationExperiment)); - assertThat(serverSays(sample), is(inExperiment(destinationExperiment))); + assertThat(sample, is(inExperiment(destinationExperiment))); } @Test @@ -77,7 +77,7 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(sample).toExperiment(destinationExperiment)); - assertThat(serverSays(sample), is(inSpace(destinationSpace))); + assertThat(sample, is(inSpace(destinationSpace))); } @Test @@ -88,7 +88,7 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(sample).toExperiment(destinationExperiment)); - assertThat(serverSays(dataSet), is(inExperiment(destinationExperiment))); + assertThat(dataSet, is(inExperiment(destinationExperiment))); } @Test @@ -98,8 +98,8 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(sample).toExperiment(destinationExperiment)); - assertThat(serverSays(sample), is(inExperiment(destinationExperiment))); - assertThat(serverSays(sample), is(inSpace(destinationSpace))); + assertThat(sample, is(inExperiment(destinationExperiment))); + assertThat(sample, is(inSpace(destinationSpace))); } @Test @@ -109,8 +109,8 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(sample).toExperiment(destinationExperiment)); - assertThat(serverSays(sample), is(inExperiment(destinationExperiment))); - assertThat(serverSays(sample), is(inSpace(destinationSpace))); + assertThat(sample, is(inExperiment(destinationExperiment))); + assertThat(sample, is(inSpace(destinationSpace))); } @Test @@ -121,8 +121,8 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(child).toExperiment(destinationExperiment)); - assertThat(serverSays(child), is(inExperiment(destinationExperiment))); - assertThat(serverSays(child), is(inSpace(destinationSpace))); + assertThat(child, is(inExperiment(destinationExperiment))); + assertThat(child, is(inSpace(destinationSpace))); } @Test @@ -134,8 +134,8 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(child).toExperiment(destinationExperiment)); - assertThat(serverSays(parent), is(inExperiment(sourceExperiment))); - assertThat(serverSays(parent), is(inSpace(sourceSpace))); + assertThat(parent, is(inExperiment(sourceExperiment))); + assertThat(parent, is(inSpace(sourceSpace))); } @Test @@ -146,8 +146,8 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(parent).toExperiment(destinationExperiment)); - assertThat(serverSays(parent), is(inExperiment(destinationExperiment))); - assertThat(serverSays(parent), is(inSpace(destinationSpace))); + assertThat(parent, is(inExperiment(destinationExperiment))); + assertThat(parent, is(inSpace(destinationSpace))); } @Test @@ -159,8 +159,8 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(parent).toExperiment(destinationExperiment)); - assertThat(serverSays(child), is(inExperiment(sourceExperiment))); - assertThat(serverSays(child), is(inSpace(sourceSpace))); + assertThat(child, is(inExperiment(sourceExperiment))); + assertThat(child, is(inSpace(sourceSpace))); } @Test @@ -171,8 +171,8 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(component).toExperiment(destinationExperiment)); - assertThat(serverSays(component), is(inExperiment(destinationExperiment))); - assertThat(serverSays(component), is(inSpace(destinationSpace))); + assertThat(component, is(inExperiment(destinationExperiment))); + assertThat(component, is(inSpace(destinationSpace))); } @Test @@ -184,8 +184,8 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(component).toExperiment(destinationExperiment)); - assertThat(serverSays(container), is(inExperiment(sourceExperiment))); - assertThat(serverSays(container), is(inSpace(sourceSpace))); + assertThat(container, is(inExperiment(sourceExperiment))); + assertThat(container, is(inSpace(sourceSpace))); } @Test @@ -196,8 +196,8 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(container).toExperiment(destinationExperiment)); - assertThat(serverSays(container), is(inExperiment(destinationExperiment))); - assertThat(serverSays(container), is(inSpace(destinationSpace))); + assertThat(container, is(inExperiment(destinationExperiment))); + assertThat(container, is(inSpace(destinationSpace))); } @Test @@ -209,8 +209,8 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(container).toExperiment(destinationExperiment)); - assertThat(serverSays(component), is(inExperiment(sourceExperiment))); - assertThat(serverSays(component), is(inSpace(sourceSpace))); + assertThat(component, is(inExperiment(sourceExperiment))); + assertThat(component, is(inSpace(sourceSpace))); } @Test @@ -221,7 +221,7 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(destinationExperiment).withSamples(sample)); - assertThat(serverSays(sample), is(inExperiment(destinationExperiment))); + assertThat(sample, is(inExperiment(destinationExperiment))); } @Test(expectedExceptions = @@ -233,7 +233,7 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(destinationExperiment).withSamples(sample)); - assertThat(serverSays(sample), is(inExperiment(destinationExperiment))); + assertThat(sample, is(inExperiment(destinationExperiment))); } @Test(expectedExceptions = @@ -257,7 +257,7 @@ public class AssignSampleToExperimentTest extends BaseTest perform(anUpdateOf(destinationExperiment).withSamples(sample)); - assertThat(serverSays(sample), is(inExperiment(destinationExperiment))); + assertThat(sample, is(inExperiment(destinationExperiment))); } @Test @@ -268,7 +268,7 @@ public class AssignSampleToExperimentTest extends BaseTest Experiment experiment = create(anExperiment().inProject(sourceProject).withSamples(sample)); - assertThat(serverSays(sample), is(inExperiment(experiment))); + assertThat(sample, is(inExperiment(experiment))); } Space unrelatedAdmin; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignSampleToSpaceTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignSampleToSpaceTest.java index 7842bb08089fa7d5ca78c25c34c0819031bbd948..e21dbc42a36374fb10df7c30885e211134d685b7 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignSampleToSpaceTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AssignSampleToSpaceTest.java @@ -21,7 +21,6 @@ import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.not; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.or; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.rule; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import org.testng.annotations.BeforeClass; @@ -60,7 +59,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(sample).toSpace(destinationSpace)); - assertThat(serverSays(sample), is(inSpace(destinationSpace))); + assertThat(sample, is(inSpace(destinationSpace))); } @Test @@ -71,7 +70,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(sample).toSpace(destinationSpace)); - assertThat(serverSays(sample).getExperiment(), is(nullValue())); + assertThat(sample, hasNoExperiment()); } @Test @@ -81,7 +80,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(sample).toSpace(destinationSpace)); - assertThat(serverSays(sample), is(inSpace(destinationSpace))); + assertThat(sample, is(inSpace(destinationSpace))); } @Test @@ -91,7 +90,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(sample).toSpace(destinationSpace)); - assertThat(serverSays(sample), is(inSpace(destinationSpace))); + assertThat(sample, is(inSpace(destinationSpace))); } @Test @@ -103,7 +102,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(child).toSpace(destinationSpace)); - assertThat(serverSays(child), is(inSpace(destinationSpace))); + assertThat(child, is(inSpace(destinationSpace))); } @Test @@ -115,7 +114,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(child).toSpace(destinationSpace)); - assertThat(serverSays(parent), is(inSpace(sourceSpace))); + assertThat(parent, is(inSpace(sourceSpace))); } @Test @@ -126,7 +125,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(parent).toSpace(destinationSpace)); - assertThat(serverSays(parent), is(inSpace(destinationSpace))); + assertThat(parent, is(inSpace(destinationSpace))); } @Test @@ -138,7 +137,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(parent).toSpace(destinationSpace)); - assertThat(serverSays(child), is(inSpace(sourceSpace))); + assertThat(child, is(inSpace(sourceSpace))); } @Test @@ -149,7 +148,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(component).toSpace(destinationSpace)); - assertThat(serverSays(component), is(inSpace(destinationSpace))); + assertThat(component, is(inSpace(destinationSpace))); } @Test @@ -161,7 +160,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(component).toSpace(destinationSpace)); - assertThat(serverSays(container), is(inSpace(sourceSpace))); + assertThat(container, is(inSpace(sourceSpace))); } @Test @@ -172,7 +171,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(container).toSpace(destinationSpace)); - assertThat(serverSays(container), is(inSpace(destinationSpace))); + assertThat(container, is(inSpace(destinationSpace))); } @Test @@ -184,7 +183,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(container).toSpace(destinationSpace)); - assertThat(serverSays(component), is(inSpace(sourceSpace))); + assertThat(component, is(inSpace(sourceSpace))); } Space unrelatedAdmin; @@ -272,7 +271,7 @@ public class AssignSampleToSpaceTest extends BaseTest perform(anUpdateOf(sample).toSpace(sourceSpace).as(user)); - assertThat(serverSays(sample), is(inSpace(sourceSpace))); + assertThat(sample, is(inSpace(sourceSpace))); } @BeforeClass diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UnassignSampleFromExperimentTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UnassignSampleFromExperimentTest.java index 20ef842b26d483df9aeaec3282de660ee711cd76..90de4d413c5d384b11937f8eb1e9f46e2642ea9c 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UnassignSampleFromExperimentTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UnassignSampleFromExperimentTest.java @@ -21,7 +21,6 @@ import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.not; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.or; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.rule; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import org.testng.annotations.BeforeClass; @@ -59,7 +58,7 @@ public class UnassignSampleFromExperimentTest extends BaseTest perform(anUpdateOf(sample).removingExperiment()); - assertThat(serverSays(sample).getExperiment(), is(nullValue())); + assertThat(sample, hasNoExperiment()); } @Test @@ -69,7 +68,7 @@ public class UnassignSampleFromExperimentTest extends BaseTest perform(anUpdateOf(sample).removingExperiment()); - assertThat(serverSays(sample), is(inSpace(space))); + assertThat(sample, is(inSpace(space))); } @Test(expectedExceptions = @@ -92,7 +91,7 @@ public class UnassignSampleFromExperimentTest extends BaseTest perform(anUpdateOf(child).removingExperiment()); - assertThat(serverSays(child).getExperiment(), is(nullValue())); + assertThat(child, hasNoExperiment()); } @Test @@ -104,7 +103,7 @@ public class UnassignSampleFromExperimentTest extends BaseTest perform(anUpdateOf(child).removingExperiment()); - assertThat(serverSays(parent), is(inExperiment(experiment))); + assertThat(parent, is(inExperiment(experiment))); } @Test @@ -115,7 +114,7 @@ public class UnassignSampleFromExperimentTest extends BaseTest perform(anUpdateOf(parent).removingExperiment()); - assertThat(serverSays(parent).getExperiment(), is(nullValue())); + assertThat(parent, hasNoExperiment()); } @Test @@ -127,7 +126,7 @@ public class UnassignSampleFromExperimentTest extends BaseTest perform(anUpdateOf(parent).removingExperiment()); - assertThat(serverSays(child), is(inExperiment(experiment))); + assertThat(child, is(inExperiment(experiment))); } @Test @@ -138,7 +137,7 @@ public class UnassignSampleFromExperimentTest extends BaseTest perform(anUpdateOf(component).removingExperiment()); - assertThat(serverSays(component).getExperiment(), is(nullValue())); + assertThat(component, hasNoExperiment()); } @Test @@ -150,7 +149,7 @@ public class UnassignSampleFromExperimentTest extends BaseTest perform(anUpdateOf(component).removingExperiment()); - assertThat(serverSays(container), is(inExperiment(experiment))); + assertThat(container, is(inExperiment(experiment))); } @Test @@ -161,7 +160,7 @@ public class UnassignSampleFromExperimentTest extends BaseTest perform(anUpdateOf(container).removingExperiment()); - assertThat(serverSays(container).getExperiment(), is(nullValue())); + assertThat(container, hasNoExperiment()); } @Test @@ -173,7 +172,7 @@ public class UnassignSampleFromExperimentTest extends BaseTest perform(anUpdateOf(container).removingExperiment()); - assertThat(serverSays(component), is(inExperiment(experiment))); + assertThat(component, is(inExperiment(experiment))); } @Test @@ -183,7 +182,7 @@ public class UnassignSampleFromExperimentTest extends BaseTest perform(anUpdateOf(experiment).removingSamples()); - assertThat(serverSays(sample).getExperiment(), is(nullValue())); + assertThat(sample, hasNoExperiment()); } Space unrelatedAdmin; 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 0802515024cbe3bea87c562ec7dc218e9dc1bda2..76ac83db177455721dcfa6355c9645b0efff5e18 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UnassignSampleFromSpaceTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UnassignSampleFromSpaceTest.java @@ -20,7 +20,6 @@ import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.and; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.not; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.rule; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import org.testng.annotations.BeforeClass; @@ -57,7 +56,7 @@ public class UnassignSampleFromSpaceTest extends BaseTest perform(anUpdateOf(sample).removingSpace()); - assertThat(serverSays(sample).getSpace(), is(nullValue())); + assertThat(sample, hasNoSpace()); } @Test @@ -67,7 +66,7 @@ public class UnassignSampleFromSpaceTest extends BaseTest perform(anUpdateOf(sample).removingSpace()); - assertThat(serverSays(sample).getSpace(), is(nullValue())); + assertThat(sample, hasNoSpace()); } @Test @@ -78,7 +77,7 @@ public class UnassignSampleFromSpaceTest extends BaseTest perform(anUpdateOf(sample).removingSpace()); - assertThat(serverSays(sample).getExperiment(), is(nullValue())); + assertThat(sample, hasNoSpace()); } @Test(expectedExceptions = @@ -99,7 +98,7 @@ public class UnassignSampleFromSpaceTest extends BaseTest perform(anUpdateOf(child).removingSpace()); - assertThat(serverSays(child).getSpace(), is(nullValue())); + assertThat(child, hasNoSpace()); } @Test @@ -111,7 +110,7 @@ public class UnassignSampleFromSpaceTest extends BaseTest perform(anUpdateOf(child).removingSpace()); - assertThat(serverSays(parent), is(inSpace(space))); + assertThat(parent, is(inSpace(space))); } @Test @@ -122,7 +121,7 @@ public class UnassignSampleFromSpaceTest extends BaseTest perform(anUpdateOf(parent).removingSpace()); - assertThat(serverSays(parent).getSpace(), is(nullValue())); + assertThat(parent, hasNoSpace()); } @Test @@ -134,7 +133,7 @@ public class UnassignSampleFromSpaceTest extends BaseTest perform(anUpdateOf(parent).removingSpace()); - assertThat(serverSays(child), is(inSpace(space))); + assertThat(child, is(inSpace(space))); } @Test @@ -145,7 +144,7 @@ public class UnassignSampleFromSpaceTest extends BaseTest perform(anUpdateOf(component).removingSpace()); - assertThat(serverSays(component).getSpace(), is(nullValue())); + assertThat(component, hasNoSpace()); } @Test @@ -157,7 +156,7 @@ public class UnassignSampleFromSpaceTest extends BaseTest perform(anUpdateOf(component).removingSpace()); - assertThat(serverSays(container), is(inSpace(space))); + assertThat(container, is(inSpace(space))); } @Test @@ -168,7 +167,7 @@ public class UnassignSampleFromSpaceTest extends BaseTest perform(anUpdateOf(container).removingSpace()); - assertThat(serverSays(container).getSpace(), is(nullValue())); + assertThat(container, hasNoSpace()); } @Test @@ -180,7 +179,7 @@ public class UnassignSampleFromSpaceTest extends BaseTest perform(anUpdateOf(container).removingSpace()); - assertThat(serverSays(component), is(inSpace(space))); + assertThat(component, is(inSpace(space))); } Space unrelatedAdmin; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetContainmentTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetContainmentTest.java index f064974f714cd6b1c43acec091914e99ad6f175e..897274673a9de867bbe8de0a773e40058ebac0d8 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetContainmentTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetContainmentTest.java @@ -18,8 +18,6 @@ package ch.systemsx.cisd.openbis.systemtest; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.not; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.rule; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import org.testng.annotations.BeforeClass; @@ -58,8 +56,7 @@ public class UpdateDataSetContainmentTest extends BaseTest perform(anUpdateOf(container).withComponent(componentCandidate)); - assertThat(serverSays(componentCandidate).tryGetContainer().getCode(), - is(container.getCode())); + assertThat(componentCandidate, hasContainer(container)); } @Test @@ -71,8 +68,7 @@ public class UpdateDataSetContainmentTest extends BaseTest perform(anUpdateOf(componentCandidate).withContainer(container)); - assertThat(serverSays(componentCandidate).tryGetContainer().getCode(), - is(container.getCode())); + assertThat(componentCandidate, hasContainer(container)); } @Test @@ -84,7 +80,7 @@ public class UpdateDataSetContainmentTest extends BaseTest perform(anUpdateOf(container).withComponents()); - assertThat(serverSays(component).tryGetContainer(), is(nullValue())); + assertThat(component, hasNoContainer()); } @Test @@ -96,8 +92,7 @@ public class UpdateDataSetContainmentTest extends BaseTest perform(anUpdateOf(newContainer).withComponent(component)); - assertThat(serverSays(component).tryGetContainer().getCode(), - is(newContainer.getCode())); + assertThat(component, hasContainer(newContainer)); } @Test(expectedExceptions = @@ -117,10 +112,10 @@ public class UpdateDataSetContainmentTest extends BaseTest create(aDataSet().inSample(sample).asContainer().withComponent(component)); ExternalData subcomponent = create(aDataSet().inSample(sample)); - perform(anUpdateOf(serverSays(component)).withComponent(serverSays(subcomponent))); + perform(anUpdateOf(component).withComponent(subcomponent)); - assertThat(serverSays(component).tryGetContainer().getCode(), is(container.getCode())); - assertThat(serverSays(subcomponent).tryGetContainer().getCode(), is(component.getCode())); + assertThat(component, hasContainer(container)); + assertThat(subcomponent, hasContainer(component)); } @Test(expectedExceptions = diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetParentsTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetParentsTest.java index 11927ddf83b1e7a5d619df786e257668c65c3bf3..7a8242a6b1bce0e7de20ded7a4e40a1a033c2687 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetParentsTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateDataSetParentsTest.java @@ -20,7 +20,6 @@ import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.and; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.not; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.or; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.rule; -import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import org.testng.annotations.BeforeClass; @@ -58,8 +57,8 @@ public class UpdateDataSetParentsTest extends BaseTest perform(anUpdateOf(childToBe).withParent(parentToBe)); - assertThat(serverSays(childToBe).getParents(), containsExactly(parentToBe)); - assertThat(serverSays(parentToBe).getChildren(), containsExactly(childToBe)); + assertThat(childToBe, hasParents(parentToBe)); + assertThat(parentToBe, hasChildren(childToBe)); } @Test @@ -71,9 +70,9 @@ public class UpdateDataSetParentsTest extends BaseTest perform(anUpdateOf(child).withParent(newParent)); - assertThat(serverSays(child).getParents(), containsExactly(newParent)); - assertThat(serverSays(parent).getChildren().size(), is(0)); - assertThat(serverSays(newParent).getChildren(), containsExactly(child)); + assertThat(child, hasParents(newParent)); + assertThat(parent, hasNoChildren()); + assertThat(newParent, hasChildren(child)); } @Test @@ -85,9 +84,9 @@ public class UpdateDataSetParentsTest extends BaseTest perform(anUpdateOf(child).withParent(parent1)); - assertThat(serverSays(child).getParents(), containsExactly(parent1)); - assertThat(serverSays(parent1).getChildren(), containsExactly(child)); - assertThat(serverSays(parent2).getChildren().size(), is(0)); + assertThat(child, hasParents(parent1)); + assertThat(parent1, hasChildren(child)); + assertThat(parent2, hasNoChildren()); } @Test @@ -97,11 +96,11 @@ public class UpdateDataSetParentsTest extends BaseTest ExternalData parent2 = create(aDataSet().inSample(sample)); ExternalData child = create(aDataSet().inSample(sample).withParents(parent1, parent2)); - perform(anUpdateOf(child).withParents()); + perform(anUpdateOf(child).removingParents()); - assertThat(serverSays(child).getParents().size(), is(0)); - assertThat(serverSays(parent1).getChildren().size(), is(0)); - assertThat(serverSays(parent2).getChildren().size(), is(0)); + assertThat(child, hasNoParents()); + assertThat(parent1, hasNoChildren()); + assertThat(parent2, hasNoChildren()); } @Test @@ -113,7 +112,7 @@ public class UpdateDataSetParentsTest extends BaseTest perform(anUpdateOf(child).withParents(parent1, parent2, parent1, parent2, parent2)); - assertThat(serverSays(child).getParents(), containsExactly(parent1, parent2)); + assertThat(child, hasParents(parent1, parent2)); } @Test(expectedExceptions = @@ -143,7 +142,7 @@ public class UpdateDataSetParentsTest extends BaseTest perform(anUpdateOf(child).withParent(parent)); - assertThat(serverSays(child).getParents(), containsExactly(parent)); + assertThat(child, hasParents(parent)); } Sample childSample; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateSampleContainmentTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateSampleContainmentTest.java index aba579bf8686bebdd20c4d93660ac84118628e95..bd67f606d6b240b58daabd058150681ee23dd2b2 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateSampleContainmentTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateSampleContainmentTest.java @@ -20,8 +20,6 @@ import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.and; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.not; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.or; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.rule; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import org.testng.annotations.BeforeClass; @@ -56,7 +54,7 @@ public class UpdateSampleContainmentTest extends BaseTest perform(anUpdateOf(componentCandidate).toHaveContainer(container)); - assertThat(serverSays(componentCandidate).getContainer(), is(container)); + assertThat(componentCandidate, hasContainer(container)); } @Test @@ -68,7 +66,7 @@ public class UpdateSampleContainmentTest extends BaseTest perform(anUpdateOf(componentCandidate).toHaveContainer(container)); - assertThat(serverSays(componentCandidate).getContainer(), is(container)); + assertThat(componentCandidate, hasContainer(container)); } @Test @@ -79,7 +77,7 @@ public class UpdateSampleContainmentTest extends BaseTest perform(anUpdateOf(componentCandidate).toHaveContainer(container)); - assertThat(serverSays(componentCandidate).getContainer(), is(container)); + assertThat(componentCandidate, hasContainer(container)); } @Test @@ -90,7 +88,7 @@ public class UpdateSampleContainmentTest extends BaseTest perform(anUpdateOf(componentCandidate).toHaveContainer(container)); - assertThat(serverSays(componentCandidate).getContainer(), is(container)); + assertThat(componentCandidate, hasContainer(container)); } @Test @@ -101,7 +99,7 @@ public class UpdateSampleContainmentTest extends BaseTest perform(anUpdateOf(component).removingContainer()); - assertThat(serverSays(component).getContainer(), is(nullValue())); + assertThat(component, hasNoContainer()); } @Test @@ -113,7 +111,7 @@ public class UpdateSampleContainmentTest extends BaseTest perform(anUpdateOf(component).toHaveContainer(newContainer)); - assertThat(serverSays(component).getContainer(), is(newContainer)); + assertThat(component, hasContainer(newContainer)); } @Test(expectedExceptions = @@ -134,7 +132,7 @@ public class UpdateSampleContainmentTest extends BaseTest perform(anUpdateOf(sample).toHaveContainer(sample)); - assertThat(serverSays(sample).getContainer(), is(serverSays(sample))); + assertThat(sample, hasContainer(sample)); } Space containerSpace; 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 3c70994ea95dbc4e11f026f4815d5e1d210a1b85..9972ef457ec24bd0c5181da93d75e8c1d70b9965 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateSampleParentsTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/UpdateSampleParentsTest.java @@ -20,7 +20,6 @@ import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.and; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.not; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.or; import static ch.systemsx.cisd.openbis.systemtest.base.auth.RuleBuilder.rule; -import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import org.testng.annotations.BeforeClass; @@ -55,7 +54,7 @@ public class UpdateSampleParentsTest extends BaseTest perform(anUpdateOf(childToBe).toHaveParent(parentToBe)); - assertThat(serverSays(childToBe).getParents(), containsExactly(parentToBe)); + assertThat(childToBe, hasParents(parentToBe)); } @Test @@ -67,7 +66,7 @@ public class UpdateSampleParentsTest extends BaseTest perform(anUpdateOf(child).toHaveParent(newParent)); - assertThat(serverSays(child).getParents(), containsExactly(newParent)); + assertThat(child, hasParents(newParent)); } @Test @@ -79,7 +78,7 @@ public class UpdateSampleParentsTest extends BaseTest perform(anUpdateOf(child).toHaveParent(parent1)); - assertThat(serverSays(child).getParents(), containsExactly(parent1)); + assertThat(child, hasParents(parent1)); } @Test @@ -91,7 +90,7 @@ public class UpdateSampleParentsTest extends BaseTest perform(anUpdateOf(child).toHaveParents()); - assertThat(serverSays(child).getParents().size(), is(0)); + assertThat(child, hasNoParents()); } @Test @@ -103,7 +102,7 @@ public class UpdateSampleParentsTest extends BaseTest perform(anUpdateOf(child).toHaveParents(parent1, parent2, parent1, parent2, parent2)); - assertThat(serverSays(child).getParents(), containsExactly(parent1, parent2)); + assertThat(child, hasParents(parent1, parent2)); } @Test @@ -113,7 +112,7 @@ public class UpdateSampleParentsTest extends BaseTest perform(anUpdateOf(sample).toHaveParent(sample)); - assertThat(serverSays(sample).getParents(), containsExactly(sample)); + assertThat(sample, hasParents(sample)); } @Test @@ -125,8 +124,8 @@ public class UpdateSampleParentsTest extends BaseTest perform(anUpdateOf(child).toHaveParent(parent)); perform(anUpdateOf(parent).toHaveParent(child)); - assertThat(serverSays(child).getParents(), containsExactly(parent)); - assertThat(serverSays(parent).getParents(), containsExactly(child)); + assertThat(child, hasParents(parent)); + assertThat(parent, hasParents(child)); } @Test(expectedExceptions = diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/BaseTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/BaseTest.java index 46a65e300f7648fb25379199e92532402def74c2..d8a6a9d6c8d18eebb6c59c6fcbecc783a1642f71 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/BaseTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/BaseTest.java @@ -16,8 +16,6 @@ package ch.systemsx.cisd.openbis.systemtest.base; -import java.util.Collection; - import org.hamcrest.Matcher; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.support.GenericApplicationContext; @@ -37,7 +35,6 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientService; import ch.systemsx.cisd.openbis.generic.server.ICommonServerForInternalUse; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.server.dataaccess.db.search.IndexMode; -import ch.systemsx.cisd.openbis.generic.shared.ICommonServer; import ch.systemsx.cisd.openbis.generic.shared.IETLLIMSService; import ch.systemsx.cisd.openbis.generic.shared.IRelationshipService; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; @@ -69,11 +66,19 @@ import ch.systemsx.cisd.openbis.systemtest.base.builder.SampleUpdateBuilder; import ch.systemsx.cisd.openbis.systemtest.base.builder.SessionBuilder; import ch.systemsx.cisd.openbis.systemtest.base.builder.SpaceBuilder; import ch.systemsx.cisd.openbis.systemtest.base.builder.UpdateBuilder; -import ch.systemsx.cisd.openbis.systemtest.base.matcher.CollectionContainsExactlyMatcher; +import ch.systemsx.cisd.openbis.systemtest.base.matcher.ExternalDataHasChildrenMatcher; +import ch.systemsx.cisd.openbis.systemtest.base.matcher.ExternalDataHasContainerMatcher; +import ch.systemsx.cisd.openbis.systemtest.base.matcher.ExternalDataHasNoSampleMatcher; +import ch.systemsx.cisd.openbis.systemtest.base.matcher.ExternalDataHasParentsMatcher; +import ch.systemsx.cisd.openbis.systemtest.base.matcher.HasNoChildrenMatcher; +import ch.systemsx.cisd.openbis.systemtest.base.matcher.HasNoContainerMatcher; +import ch.systemsx.cisd.openbis.systemtest.base.matcher.HasNoParentMatcher; import ch.systemsx.cisd.openbis.systemtest.base.matcher.InExperimentMatcher; import ch.systemsx.cisd.openbis.systemtest.base.matcher.InProjectMatcher; import ch.systemsx.cisd.openbis.systemtest.base.matcher.InSampleMatcher; import ch.systemsx.cisd.openbis.systemtest.base.matcher.InSpaceMatcher; +import ch.systemsx.cisd.openbis.systemtest.base.matcher.SampleHasContainerMatcher; +import ch.systemsx.cisd.openbis.systemtest.base.matcher.SampleHasParentsMatcher; /** * @author anttil @@ -248,22 +253,22 @@ public abstract class BaseTest extends AbstractTransactionalTestNGSpringContextT protected ProjectUpdateBuilder anUpdateOf(Project project) { - return new ProjectUpdateBuilder(commonServer, genericServer, project); + return new ProjectUpdateBuilder(commonServer, genericServer, refresh(project)); } protected ExperimentUpdateBuilder anUpdateOf(Experiment experiment) { - return new ExperimentUpdateBuilder(commonServer, genericServer, experiment); + return new ExperimentUpdateBuilder(commonServer, genericServer, refresh(experiment)); } protected SampleUpdateBuilder anUpdateOf(Sample sample) { - return new SampleUpdateBuilder(commonServer, genericServer, sample); + return new SampleUpdateBuilder(commonServer, genericServer, refresh(sample)); } protected DataSetUpdateBuilder anUpdateOf(ExternalData dataset) { - return new DataSetUpdateBuilder(commonServer, genericServer, dataset); + return new DataSetUpdateBuilder(commonServer, genericServer, refresh(dataset)); } protected SessionBuilder aSession() @@ -288,60 +293,107 @@ public abstract class BaseTest extends AbstractTransactionalTestNGSpringContextT protected Matcher<Object> inSpace(Space space) { - return new InSpaceMatcher(space); + return RefreshingMatcherProxy.newInstance(new InSpaceMatcher(space), this); + } + + protected Matcher<Object> hasNoSpace() + { + return RefreshingMatcherProxy.newInstance(new InSpaceMatcher(), this); } protected Matcher<Object> inExperiment(Experiment experiment) { - return new InExperimentMatcher(experiment); + return RefreshingMatcherProxy.newInstance(new InExperimentMatcher(refresh(experiment)), + this); + } + + protected Matcher<Object> hasNoExperiment() + { + return RefreshingMatcherProxy.newInstance(new InExperimentMatcher(), this); } protected Matcher<Experiment> inProject(Project project) { - return new InProjectMatcher(project); + return RefreshingMatcherProxy.newInstance(new InProjectMatcher(refresh(project)), this); } protected Matcher<ExternalData> inSample(Sample sample) { - return new InSampleMatcher(sample); + return RefreshingMatcherProxy.newInstance(new InSampleMatcher(refresh(sample)), this); } - protected Matcher<Collection<Sample>> containsExactly(Sample... elements) + protected Matcher<ExternalData> hasParents(ExternalData first, ExternalData... rest) { - return new CollectionContainsExactlyMatcher<Sample>(new StandardEqualityChecker<Sample>(), - elements); + return RefreshingMatcherProxy.newInstance(new ExternalDataHasParentsMatcher(first, rest), + this); } - protected Matcher<Collection<ExternalData>> containsExactly(ExternalData... elements) + protected Matcher<ExternalData> hasChildren(ExternalData first, ExternalData... rest) { - return new CollectionContainsExactlyMatcher<ExternalData>( - new ExternalDataEqualityChecker(), - elements); + return RefreshingMatcherProxy.newInstance(new ExternalDataHasChildrenMatcher(first, rest), + this); } - protected Experiment serverSays(Experiment experiment) + protected Matcher<Object> hasNoParents() { - return commonServer.getExperimentInfo(systemSessionToken, new TechId(experiment.getId())); + return RefreshingMatcherProxy.newInstance(new HasNoParentMatcher(), this); } - protected Project serverSays(Project project) + protected Matcher<ExternalData> hasNoChildren() { - return commonServer.getProjectInfo(systemSessionToken, new TechId(project.getId())); + return RefreshingMatcherProxy.newInstance(new HasNoChildrenMatcher(), this); + } + + protected Matcher<ExternalData> hasNoSample() + { + return RefreshingMatcherProxy.newInstance(new ExternalDataHasNoSampleMatcher(), this); + } + + protected Matcher<Sample> hasParents(Sample first, Sample... rest) + { + return RefreshingMatcherProxy.newInstance(new SampleHasParentsMatcher(first, rest), this); + } + + protected Matcher<Object> hasNoParent() + { + return RefreshingMatcherProxy.newInstance(new HasNoParentMatcher(), this); + } + + protected Matcher<Sample> hasContainer(Sample container) + { + return RefreshingMatcherProxy.newInstance( + new SampleHasContainerMatcher(refresh(container)), this); + } + + protected Matcher<ExternalData> hasContainer(ExternalData container) + { + return RefreshingMatcherProxy.newInstance(new ExternalDataHasContainerMatcher( + refresh(container)), this); } - protected Sample serverSays(Sample sample) + protected Matcher<Object> hasNoContainer() { - return refresh(sample, commonServer, systemSessionToken); + return RefreshingMatcherProxy.newInstance(new HasNoContainerMatcher(), this); + } + + protected Experiment refresh(Experiment experiment) + { + return commonServer.getExperimentInfo(systemSessionToken, new TechId(experiment.getId())); + } + + protected Project refresh(Project project) + { + return commonServer.getProjectInfo(systemSessionToken, new TechId(project.getId())); } - public static Sample refresh(Sample sample, ICommonServer commonServer, String sessionToken) + protected Sample refresh(Sample sample) { SampleParentWithDerived result = - commonServer.getSampleInfo(sessionToken, new TechId(sample.getId())); + commonServer.getSampleInfo(systemSessionToken, new TechId(sample.getId())); return result.getParent(); } - protected ExternalData serverSays(ExternalData data) + protected ExternalData refresh(ExternalData data) { return etlService.tryGetDataSet(systemSessionToken, data.getCode()); } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/RefreshingMatcherProxy.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/RefreshingMatcherProxy.java new file mode 100644 index 0000000000000000000000000000000000000000..cf7c90e55cd0e16b31f97d46a5112c216cbdc521 --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/RefreshingMatcherProxy.java @@ -0,0 +1,85 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.systemtest.base; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.HashSet; + +import org.hamcrest.Matcher; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; + +/** + * @author anttil + */ +public class RefreshingMatcherProxy implements InvocationHandler +{ + + @SuppressWarnings("unchecked") + static <T extends Matcher<?>> T newInstance(T actualMatcher, BaseTest b) + { + + Collection<Class<?>> interfaces = new HashSet<Class<?>>(); + interfaces.add(Matcher.class); + return (T) java.lang.reflect.Proxy.newProxyInstance( + actualMatcher.getClass().getClassLoader(), + interfaces.toArray(new Class<?>[0]), + new RefreshingMatcherProxy(actualMatcher, b)); + } + + private Matcher<?> matcher; + + private BaseTest b; + + public RefreshingMatcherProxy(Matcher<?> matcher, BaseTest b) + { + this.matcher = matcher; + this.b = b; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable + { + if (method.getName().equals("matches") && args.length == 1) + { + Object arg = args[0]; + if (arg instanceof ExternalData) + { + args[0] = b.refresh((ExternalData) arg); + } else if (arg instanceof Sample) + { + args[0] = b.refresh((Sample) arg); + } else if (arg instanceof Experiment) + { + args[0] = b.refresh((Experiment) arg); + } else if (arg instanceof Project) + { + args[0] = b.refresh((Project) arg); + } else + { + throw new IllegalArgumentException("Illegal matching: " + arg); + } + } + + return method.invoke(this.matcher, args); + } +} diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/Builder.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/Builder.java index 92212aac283da0ddd9e6b1280a0fc5a440c4b1f5..f7f66c605d6f9fac2929268acb617c2087c3028d 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/Builder.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/Builder.java @@ -17,9 +17,7 @@ package ch.systemsx.cisd.openbis.systemtest.base.builder; import ch.systemsx.cisd.openbis.generic.server.ICommonServerForInternalUse; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.plugin.generic.shared.IGenericServer; -import ch.systemsx.cisd.openbis.systemtest.base.BaseTest; /** * @author anttil @@ -40,9 +38,4 @@ public abstract class Builder<T> } public abstract T create() throws Exception; - - public Sample refresh(Sample sample) - { - return BaseTest.refresh(sample, this.commonServer, this.systemSession); - } } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/DataSetUpdateBuilder.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/DataSetUpdateBuilder.java index ca6903d46e3729395a6c7ed2e6a4f6cc0b8ed2ee..4a277035ced6f644a260191c5b927044c74b40b8 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/DataSetUpdateBuilder.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/builder/DataSetUpdateBuilder.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.systemtest.base.builder; import static ch.systemsx.cisd.openbis.systemtest.base.BaseTest.id; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.List; @@ -82,13 +83,11 @@ public class DataSetUpdateBuilder extends UpdateBuilder<DataSetUpdatesDTO> return this; } - public DataSetUpdateBuilder withParents(ExternalData... dataSets) + public DataSetUpdateBuilder withParents(ExternalData first, ExternalData... rest) { this.parents = new ArrayList<ExternalData>(); - for (ExternalData parent : dataSets) - { - this.parents.add(parent); - } + this.parents.add(first); + this.parents.addAll(Arrays.asList(rest)); return this; } @@ -97,6 +96,12 @@ public class DataSetUpdateBuilder extends UpdateBuilder<DataSetUpdatesDTO> return this.withParents(dataSet); } + public DataSetUpdateBuilder removingParents() + { + this.parents = new ArrayList<ExternalData>(); + return this; + } + public DataSetUpdateBuilder withContainer(ExternalData dataSet) { this.containerCode = dataSet.getCode(); 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 9b1c9bb651a57283fb84e321361d8721835c2595..18045f062df4a85a2deccd424c8bf7adf167bec1 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 @@ -53,10 +53,9 @@ public class SampleUpdateBuilder extends UpdateBuilder<SampleUpdatesDTO> private Sample container; public SampleUpdateBuilder(ICommonServerForInternalUse commonServer, - IGenericServer genericServer, Sample sampleToBeUpdated) + IGenericServer genericServer, Sample sample) { super(commonServer, genericServer); - Sample sample = refresh(sampleToBeUpdated); this.sampleId = new TechId(sample.getId()); this.sampleCode = sample.getCode(); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasChildrenMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasChildrenMatcher.java new file mode 100644 index 0000000000000000000000000000000000000000..6aff0161d2e366f75c70bc684f750d7b21a81aac --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasChildrenMatcher.java @@ -0,0 +1,64 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.systemtest.base.matcher; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; + +public class ExternalDataHasChildrenMatcher extends TypeSafeMatcher<ExternalData> +{ + + private Set<ExternalData> expectedChildren; + + public ExternalDataHasChildrenMatcher(ExternalData first, ExternalData... rest) + { + this.expectedChildren = new HashSet<ExternalData>(); + expectedChildren.add(first); + expectedChildren.addAll(Arrays.asList(rest)); + } + + @Override + public void describeTo(Description description) + { + description.appendText("A dataset with children " + expectedChildren); + } + + @Override + public boolean matchesSafely(ExternalData actual) + { + if (actual.getChildren().size() != expectedChildren.size()) + { + return false; + } + + for (ExternalData child : actual.getChildren()) + { + if (!expectedChildren.contains(child)) + { + return false; + } + } + + return true; + } +} \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasContainerMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasContainerMatcher.java new file mode 100644 index 0000000000000000000000000000000000000000..881365158d68c20985989c81c7042eab9ea168bd --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasContainerMatcher.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.systemtest.base.matcher; + +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; + +public class ExternalDataHasContainerMatcher extends TypeSafeMatcher<ExternalData> +{ + + private ExternalData expectedContainer; + + public ExternalDataHasContainerMatcher(ExternalData expected) + { + this.expectedContainer = expected; + } + + @Override + public void describeTo(Description description) + { + description.appendText("A dataset with container " + expectedContainer); + } + + @Override + public boolean matchesSafely(ExternalData actual) + { + if (actual.tryGetContainer() == null) + { + return false; + } + + return expectedContainer.getCode().equals(actual.tryGetContainer().getCode()); + } +} \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasNoSampleMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasNoSampleMatcher.java new file mode 100644 index 0000000000000000000000000000000000000000..d4e981798f0af75a7c79f93c63bf0e9e2c0e3122 --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasNoSampleMatcher.java @@ -0,0 +1,42 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.systemtest.base.matcher; + +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; + +public class ExternalDataHasNoSampleMatcher extends TypeSafeMatcher<ExternalData> +{ + + public ExternalDataHasNoSampleMatcher() + { + } + + @Override + public void describeTo(Description description) + { + description.appendText("An data without sample"); + } + + @Override + public boolean matchesSafely(ExternalData actual) + { + return actual.getSample() == null; + } +} \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasParentsMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasParentsMatcher.java new file mode 100644 index 0000000000000000000000000000000000000000..caa9c354e8c0831dfd2a5769e30cc928b12026d4 --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/ExternalDataHasParentsMatcher.java @@ -0,0 +1,66 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.systemtest.base.matcher; + +import java.util.HashSet; +import java.util.Set; + +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; + +public class ExternalDataHasParentsMatcher extends TypeSafeMatcher<ExternalData> +{ + + private Set<String> expectedParents; + + public ExternalDataHasParentsMatcher(ExternalData first, ExternalData... rest) + { + this.expectedParents = new HashSet<String>(); + expectedParents.add(first.getCode()); + for (ExternalData data : rest) + { + expectedParents.add(data.getCode()); + } + } + + @Override + public void describeTo(Description description) + { + description.appendText("A dataset with parents " + expectedParents); + } + + @Override + public boolean matchesSafely(ExternalData actual) + { + if (actual.getParents().size() != expectedParents.size()) + { + return false; + } + + for (ExternalData parent : actual.getParents()) + { + if (!expectedParents.contains(parent.getCode())) + { + return false; + } + } + + return true; + } +} \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/HasNoChildrenMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/HasNoChildrenMatcher.java new file mode 100644 index 0000000000000000000000000000000000000000..0fab266e43b5b02e47e564c381a6bd248b875576 --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/HasNoChildrenMatcher.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.systemtest.base.matcher; + +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; + +public class HasNoChildrenMatcher extends TypeSafeMatcher<ExternalData> +{ + + @Override + public void describeTo(Description description) + { + description.appendText("A dataset without children"); + } + + @Override + public boolean matchesSafely(ExternalData actual) + { + return actual.getChildren().size() == 0; + } +} \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/HasNoContainerMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/HasNoContainerMatcher.java new file mode 100644 index 0000000000000000000000000000000000000000..fafdf6442c990bdbeac63189b6d4d512fedaa17d --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/HasNoContainerMatcher.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.systemtest.base.matcher; + +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; + +public class HasNoContainerMatcher extends TypeSafeMatcher<Object> +{ + + public HasNoContainerMatcher() + { + } + + @Override + public void describeTo(Description description) + { + description.appendText("An entity without container"); + } + + @Override + public boolean matchesSafely(Object actual) + { + Object container; + if (actual instanceof Sample) + { + container = ((Sample) actual).getContainer(); + } else if (actual instanceof ExternalData) + { + container = ((ExternalData) actual).tryGetContainer(); + } else + { + return false; + } + + return container == null; + } +} \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/HasNoParentMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/HasNoParentMatcher.java new file mode 100644 index 0000000000000000000000000000000000000000..a80846e4900eb1be4d01e0f284f7523b5ce7e0f3 --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/HasNoParentMatcher.java @@ -0,0 +1,57 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.systemtest.base.matcher; + +import java.util.Collection; + +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; + +public class HasNoParentMatcher extends TypeSafeMatcher<Object> +{ + + public HasNoParentMatcher() + { + } + + @Override + public void describeTo(Description description) + { + description.appendText("An entity without parent"); + } + + @Override + public boolean matchesSafely(Object actual) + { + Collection<?> parents; + if (actual instanceof Sample) + { + parents = ((Sample) actual).getParents(); + } else if (actual instanceof ExternalData) + { + parents = ((ExternalData) actual).getParents(); + } else + { + return false; + } + + return parents.size() == 0; + } +} \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/InExperimentMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/InExperimentMatcher.java index 302829512170696a30f47b2ec039dec03ca1af94..82ef3ed7251e1cf27b104dcf006553291ff27a83 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/InExperimentMatcher.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/InExperimentMatcher.java @@ -26,28 +26,53 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; public class InExperimentMatcher extends TypeSafeMatcher<Object> { - private Experiment experiment; + private Experiment expectedExperiment; public InExperimentMatcher(Experiment experiment) { - this.experiment = experiment; + this.expectedExperiment = experiment; + } + + public InExperimentMatcher() + { + this(null); } @Override public void describeTo(Description description) { - description.appendText("An entity in experiment " + experiment); + if (expectedExperiment == null) + { + description.appendText("An entity without experiment"); + } else + { + description.appendText("An entity in experiment " + expectedExperiment); + } } @Override public boolean matchesSafely(Object actual) { + Experiment actualExperiment; if (actual instanceof Sample) { - return ((Sample) actual).getExperiment().getId() == experiment.getId(); + actualExperiment = ((Sample) actual).getExperiment(); } else { - return ((DataSet) actual).getExperiment().getId() == experiment.getId(); + actualExperiment = ((DataSet) actual).getExperiment(); } + + if (this.expectedExperiment == null && actualExperiment == null) + { + return true; + } + + if (expectedExperiment == null) + { + return false; + } + + return actualExperiment != null + && expectedExperiment.getId().equals(actualExperiment.getId()); } } \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/InSpaceMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/InSpaceMatcher.java index 062c7f2527169914fc2244265792b997b52fede2..32647c209aeda5fdc20933b0d4ea0bb68e84a8ad 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/InSpaceMatcher.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/InSpaceMatcher.java @@ -25,29 +25,54 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space; public class InSpaceMatcher extends TypeSafeMatcher<Object> { - private Space space; + private Space expectedSpace; public InSpaceMatcher(Space space) { - this.space = space; + this.expectedSpace = space; + } + + public InSpaceMatcher() + { + this(null); } @Override public void describeTo(Description description) { - description.appendText("A project in space " + space.getCode()); + if (expectedSpace == null) + { + description.appendText("An entity without space"); + } else + { + description.appendText("An entity in space " + expectedSpace); + } } @Override public boolean matchesSafely(Object actual) { + Space actualSpace; if (actual instanceof Project) { - return ((Project) actual).getSpace().equals(this.space); + actualSpace = ((Project) actual).getSpace(); } else { - return ((Sample) actual).getSpace().equals(this.space); + actualSpace = ((Sample) actual).getSpace(); } + + if (this.expectedSpace == null && actualSpace == null) + { + return true; + } + + if (expectedSpace == null) + { + return false; + } + + return expectedSpace.equals(actualSpace); + } } \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/SampleHasContainerMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/SampleHasContainerMatcher.java new file mode 100644 index 0000000000000000000000000000000000000000..3d97a3d728ed4823c03493eef5767181279d9546 --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/SampleHasContainerMatcher.java @@ -0,0 +1,45 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.systemtest.base.matcher; + +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; + +public class SampleHasContainerMatcher extends TypeSafeMatcher<Sample> +{ + + private Sample expectedContainer; + + public SampleHasContainerMatcher(Sample expected) + { + this.expectedContainer = expected; + } + + @Override + public void describeTo(Description description) + { + description.appendText("A sample with container " + expectedContainer); + } + + @Override + public boolean matchesSafely(Sample actual) + { + return expectedContainer.equals(actual.getContainer()); + } +} \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/SampleHasParentsMatcher.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/SampleHasParentsMatcher.java new file mode 100644 index 0000000000000000000000000000000000000000..6998e52a10cf800c532ca8ff835723a340b006e1 --- /dev/null +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/base/matcher/SampleHasParentsMatcher.java @@ -0,0 +1,63 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.systemtest.base.matcher; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; + +public class SampleHasParentsMatcher extends TypeSafeMatcher<Sample> +{ + + private Set<Sample> expectedParents; + + public SampleHasParentsMatcher(Sample first, Sample... rest) + { + this.expectedParents = new HashSet<Sample>(); + expectedParents.add(first); + expectedParents.addAll(Arrays.asList(rest)); + } + + @Override + public void describeTo(Description description) + { + description.appendText("A sample with parents " + expectedParents); + } + + @Override + public boolean matchesSafely(Sample actual) + { + if (actual.getParents().size() != expectedParents.size()) + { + return false; + } + + for (Sample parent : actual.getParents()) + { + if (!expectedParents.contains(parent)) + { + return false; + } + } + return true; + } +} \ No newline at end of file