diff --git a/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/metaproject-api/metaproject-api.py b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/metaproject-api/metaproject-api.py new file mode 100644 index 0000000000000000000000000000000000000000..c6e666974690128adf7fa45bf664fb596815d083 --- /dev/null +++ b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/metaproject-api/metaproject-api.py @@ -0,0 +1,27 @@ +SPACE_CODE = "META" +PROJECT_ID = "/META/META" +EXPERIMENT_ID = "/META/META/META" + +def create_project_and_experiment(transaction): + space = transaction.createNewSpace(SPACE_CODE, None) + space.setDescription("A demo space") + project = transaction.createNewProject(PROJECT_ID) + project.setDescription("A demo project") + exp = transaction.createNewExperiment(EXPERIMENT_ID, 'SIRNA_HCS') + exp.setPropertyValue("DESCRIPTION", "A sample experiment") + return exp + +def process(transaction): + create_project_and_experiment(transaction) + + existing_metaproject = transaction.getMetaproject("TEST_METAPROJECTS", "test") + copy_metaproject = transaction.createNewMetaproject("COPY_TEST_METAPROJCTS", existing_metaproject.getDescription(), "test") + + print existing_metaproject.getDescription() + + # existing_attached_sample = transaction.getSample("TEST-SPACE/EV-TEST") + + new_metaproject = transaction.createNewMetaproject("TEST_META", "description", "test") + + sample = transaction.createNewSample("/META/METASAMPLE", "NORMAL") + new_metaproject.addEntity(sample) diff --git a/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/metaproject-api/plugin.properties b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/metaproject-api/plugin.properties new file mode 100644 index 0000000000000000000000000000000000000000..a547a3e4c0bb0c2bb52435cea5c087e91f2aee53 --- /dev/null +++ b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/metaproject-api/plugin.properties @@ -0,0 +1,6 @@ +incoming-dir = ${root-dir}/incoming-metaproject-api-test +incoming-dir-create = true +incoming-data-completeness-condition = auto-detection +top-level-data-set-handler = ch.systemsx.cisd.etlserver.registrator.api.v2.JythonTopLevelDataSetHandlerV2 +script-path = metaproject-api.py +storage-processor = ch.systemsx.cisd.etlserver.DefaultStorageProcessor diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/MetaprojectDropboxApiSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/MetaprojectDropboxApiSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f4344715f13906f3698a172cc6666605bac84077 --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/MetaprojectDropboxApiSystemTest.java @@ -0,0 +1,75 @@ +/* + * 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.datastoreserver.systemtests; + +import java.io.File; +import java.io.IOException; + +import org.testng.annotations.Test; + +import ch.systemsx.cisd.common.filesystem.FileUtilities; +import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; +import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Metaproject; + +/** + * @author Jakub Straszewski + */ +public class MetaprojectDropboxApiSystemTest extends SystemTestCase +{ + // for jython script locate + // metaproject-api-data-set-handler.py + + @Override + protected File getIncomingDirectory() + { + return new File(rootDir, "incoming-metaproject-api-test"); + } + + @Test + public void testCreateMetaproject() throws Exception + { + IEncapsulatedOpenBISService openBISService = ServiceProvider.getOpenBISService(); + + runDropbox(); + + assertMetaprojectCreated(openBISService); + } + + private void assertMetaprojectCreated(IEncapsulatedOpenBISService openBISService) + { + Metaproject oldProject = openBISService.tryGetMetaproject("TEST_METAPROJECTS", "test"); + Metaproject newProject = openBISService.tryGetMetaproject("COPY_TEST_METAPROJCTS", "test"); + + assertEquals(oldProject.getDescription(), newProject.getDescription()); + } + + private void runDropbox() throws IOException, Exception + { + File exampleDataSet = new File(workingDirectory, "my-data"); + createExampleDataSet(exampleDataSet); + moveFileToIncoming(exampleDataSet); + waitUntilDataSetImported(); + } + + private void createExampleDataSet(File exampleDataSet) + { + exampleDataSet.mkdirs(); + FileUtilities.writeToFile(new File(exampleDataSet, "file.txt"), "hello world"); + } + +}