diff --git a/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/vocabularies-api/plugin.properties b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/vocabularies-api/plugin.properties new file mode 100644 index 0000000000000000000000000000000000000000..51c2fafc45f0be5a1a24df2cc62525412a2d7aa6 --- /dev/null +++ b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/vocabularies-api/plugin.properties @@ -0,0 +1,6 @@ +incoming-dir = ${root-dir}/incoming-vocabularies-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 = vocabularies-api.py +storage-processor = ch.systemsx.cisd.etlserver.DefaultStorageProcessor diff --git a/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/vocabularies-api/vocabularies-api.py b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/vocabularies-api/vocabularies-api.py new file mode 100644 index 0000000000000000000000000000000000000000..dd65f0378ba97c6798b7c60b57b26649a1e119d9 --- /dev/null +++ b/datastore_server/sourceTest/core-plugins/generic-test/1/dss/drop-boxes/vocabularies-api/vocabularies-api.py @@ -0,0 +1,18 @@ +SPACE_CODE = "VOC" +PROJECT_ID = "/VOC/VOC" +EXPERIMENT_ID = "/VOC/VOC/VOC" + +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) + + sample = transaction.createNewSample("/VOC/CELL_PLATE", "CELL_PLATE") + sample.setPropertyValue("ORGANISM", "RAT") \ No newline at end of file diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/VocabularyDropboxApiSystemTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/VocabularyDropboxApiSystemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a9d3412141546386dd338ccc486a907ab9761cfb --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/VocabularyDropboxApiSystemTest.java @@ -0,0 +1,80 @@ +/* + * 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.IEntityProperty; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; +import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; +import ch.systemsx.cisd.openbis.generic.shared.util.EntityHelper; + +/** + * + * + * @author Jakub Straszewski + */ +public class VocabularyDropboxApiSystemTest extends SystemTestCase +{ + // for jython script locate + // vocabularies-api.py + + @Override + protected File getIncomingDirectory() + { + return new File(rootDir, "incoming-vocabularies-api-test"); + } + + @Test + public void testControlledVocabulariesApi() throws Exception + { + IEncapsulatedOpenBISService openBISService = ServiceProvider.getOpenBISService(); + + runDropbox(); + + Sample sample = + openBISService +.tryGetSampleWithExperiment(SampleIdentifier.create("VOC", + "CELL_PLATE")); + + IEntityProperty property = EntityHelper.tryFindProperty(sample.getProperties(), "ORGANISM"); + + assertEquals("RAT", property.getVocabularyTerm().getCode()); + + } + + 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"); + } + +}