diff --git a/common/source/java/ch/systemsx/cisd/common/spring/ExposablePropertyPlaceholderConfigurer.java b/common/source/java/ch/systemsx/cisd/common/spring/ExposablePropertyPlaceholderConfigurer.java index 8fe737b91f516740a854d73513cc4451e03c128a..8dce3f7fc599daf9a468c0427aac278ca7fa6ba8 100644 --- a/common/source/java/ch/systemsx/cisd/common/spring/ExposablePropertyPlaceholderConfigurer.java +++ b/common/source/java/ch/systemsx/cisd/common/spring/ExposablePropertyPlaceholderConfigurer.java @@ -24,6 +24,8 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.core.Constants; +import org.springframework.util.PropertyPlaceholderHelper; +import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; import org.springframework.util.StringUtils; import ch.systemsx.cisd.common.properties.ExtendedProperties; @@ -111,6 +113,16 @@ public class ExposablePropertyPlaceholderConfigurer extends PropertyPlaceholderC private String getResolvedProperty(final Properties props, final String key) { - return resolvePlaceholder(key, props, systemPropertiesMode); + PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper( + placeholderPrefix, placeholderSuffix, valueSeparator, ignoreUnresolvablePlaceholders); + String resolvedPlaceholder = resolvePlaceholder(key, props, systemPropertiesMode); + return helper.replacePlaceholders(resolvedPlaceholder, new PlaceholderResolver() + { + @Override + public String resolvePlaceholder(String placeholderName) + { + return ExposablePropertyPlaceholderConfigurer.this.resolvePlaceholder(placeholderName, props, systemPropertiesMode); + } + }); } } \ No newline at end of file diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/client/api/v1/impl/DssComponentTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/client/api/v1/impl/DssComponentTest.java index 8ab94d1ec734279521a71fcf2bf5187d3264542b..9edca33bbdf825357af3112281b8fe8852ccad5c 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/client/api/v1/impl/DssComponentTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/client/api/v1/impl/DssComponentTest.java @@ -119,6 +119,8 @@ public class DssComponentTest extends AbstractFileSystemTestCase private IShareIdManager shareIdManager; + private StaticListableBeanFactory applicationContext; + @SuppressWarnings("unchecked") private <T extends IRpcService> T getAdvisedDssService(final T service) { @@ -140,6 +142,7 @@ public class DssComponentTest extends AbstractFileSystemTestCase { advisor }; } }; + ((AbstractAutoProxyCreator) processor).setBeanFactory(applicationContext); final Object proxy = processor.postProcessAfterInitialization(service, "proxy of " + service.getClass().getName()); @@ -157,7 +160,7 @@ public class DssComponentTest extends AbstractFileSystemTestCase { super.setUp(); DssSessionAuthorizationHolder.setAuthorizer(new DatasetSessionAuthorizer()); - final StaticListableBeanFactory applicationContext = new StaticListableBeanFactory(); + applicationContext = new StaticListableBeanFactory(); ServiceProviderTestWrapper.setApplicationContext(applicationContext); context = new Mockery(); openBisService = context.mock(IGeneralInformationService.class); diff --git a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/deserializer/JsonTypeAndClassDeserializer.java b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/deserializer/JsonTypeAndClassDeserializer.java index 27059d1aaca16706087b1cd3749986ae52125df9..9fd9eccc1c6c7a678f4fd32597b179078182a3ba 100644 --- a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/deserializer/JsonTypeAndClassDeserializer.java +++ b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/deserializer/JsonTypeAndClassDeserializer.java @@ -161,7 +161,7 @@ public class JsonTypeAndClassDeserializer extends AsPropertyTypeDeserializer { // need to merge id back in JSON input? if (actualTb == null) { - actualTb = new TokenBuffer(null); + actualTb = new TokenBuffer(null, false); } actualTb.writeFieldName(actualJp.getCurrentName()); actualTb.writeString(type); diff --git a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/deserializer/JsonTypeAndClassSerializer.java b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/deserializer/JsonTypeAndClassSerializer.java index 599133b64d34744f6733a0e6b4795385753394b4..fe00ce1c8e16b0d7c0258e02f613e85b62a6c42f 100644 --- a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/deserializer/JsonTypeAndClassSerializer.java +++ b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/deserializer/JsonTypeAndClassSerializer.java @@ -19,7 +19,8 @@ package ch.systemsx.cisd.openbis.common.api.server.json.deserializer; import java.io.IOException; import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.WritableTypeId; import com.fasterxml.jackson.databind.BeanProperty; import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; import com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeSerializer; @@ -46,58 +47,55 @@ public class JsonTypeAndClassSerializer extends AsPropertyTypeSerializer } @Override - public void writeTypePrefixForObject(Object value, JsonGenerator jgen) throws IOException, - JsonProcessingException + public WritableTypeId writeTypePrefix(JsonGenerator g, WritableTypeId idMetadata) throws IOException { - if (isValueWithType(value)) + Object value = idMetadata.forValue; + JsonToken valueShape = idMetadata.valueShape; + if (JsonToken.START_OBJECT == valueShape) { - jgen.writeStartObject(); - jgen.writeStringField(_typePropertyName, idFromValue(value)); + g.writeStartObject(); + if (isValueWithType(value)) + { + g.writeStringField(_typePropertyName, idFromValue(value)); + } + } else if (JsonToken.VALUE_STRING == valueShape) + { + if (isValueWithType(value)) + { + g.writeTypePrefix(idMetadata); + } + } else if (JsonToken.START_ARRAY == valueShape) + { + g.writeStartArray(); } else { - jgen.writeStartObject(); + g.writeTypePrefix(idMetadata); } + return idMetadata; } @Override - public void writeTypeSuffixForObject(Object value, JsonGenerator jgen) throws IOException, - JsonProcessingException - { - jgen.writeEndObject(); - } - - @Override - public void writeTypePrefixForScalar(Object value, JsonGenerator jgen) throws IOException, - JsonProcessingException + public WritableTypeId writeTypeSuffix(JsonGenerator g, WritableTypeId idMetadata) throws IOException { - if (isValueWithType(value)) + Object value = idMetadata.forValue; + JsonToken valueShape = idMetadata.valueShape; + if (JsonToken.START_OBJECT == valueShape) { - super.writeTypePrefixForScalar(value, jgen); - } - } - - @Override - public void writeTypeSuffixForScalar(Object value, JsonGenerator jgen) throws IOException, - JsonProcessingException - { - if (isValueWithType(value)) + g.writeEndObject(); + } else if (JsonToken.VALUE_STRING == valueShape) { - super.writeTypeSuffixForScalar(value, jgen); + if (isValueWithType(value)) + { + g.writeTypeSuffix(idMetadata); + } + } else if (JsonToken.START_ARRAY == valueShape) + { + g.writeEndArray(); + } else + { + g.writeTypeSuffix(idMetadata); } - } - - @Override - public void writeTypePrefixForArray(Object value, JsonGenerator jgen) throws IOException, - JsonProcessingException - { - jgen.writeStartArray(); - } - - @Override - public void writeTypeSuffixForArray(Object value, JsonGenerator jgen) throws IOException, - JsonProcessingException - { - jgen.writeEndArray(); + return idMetadata; } private boolean isValueWithType(Object value) diff --git a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/introspector/JsonTypeAndClassAnnotationIntrospector.java b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/introspector/JsonTypeAndClassAnnotationIntrospector.java index 9b62e3fa8985e66b0f528e0b8d5dcba140647862..b27735b9dda230dd47b91299d230b3ebac4125b6 100644 --- a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/introspector/JsonTypeAndClassAnnotationIntrospector.java +++ b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/introspector/JsonTypeAndClassAnnotationIntrospector.java @@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.cfg.MapperConfig; import com.fasterxml.jackson.databind.introspect.Annotated; import com.fasterxml.jackson.databind.introspect.AnnotatedClass; import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; +import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector; import com.fasterxml.jackson.databind.introspect.ObjectIdInfo; import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; @@ -59,7 +60,7 @@ public class JsonTypeAndClassAnnotationIntrospector extends JacksonAnnotationInt { return null; } - JsonObject tn = ac.getAnnotation(JsonObject.class); + JsonObject tn = _findAnnotation(ac, JsonObject.class); return (tn == null) ? null : tn.value(); } @@ -87,8 +88,7 @@ public class JsonTypeAndClassAnnotationIntrospector extends JacksonAnnotationInt private boolean useCustomResolver(JavaType type) { return type.getRawClass().equals(Object.class) - || (type.getRawClass().isAnnotationPresent(JsonObject.class) && !type.getRawClass() - .isEnum()); + || (type.getRawClass().isAnnotationPresent(JsonObject.class) && false == type.getRawClass().isEnum()); } } diff --git a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/resolver/JsonTypeAndClassResolverBuilder.java b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/resolver/JsonTypeAndClassResolverBuilder.java index deecd77f3ccf7d8add2fd3a5decae43281692949..5f4aeedd8170e6426bb4dfc16994045b1d481f18 100644 --- a/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/resolver/JsonTypeAndClassResolverBuilder.java +++ b/openbis-common/source/java/ch/systemsx/cisd/openbis/common/api/server/json/resolver/JsonTypeAndClassResolverBuilder.java @@ -22,12 +22,16 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo.As; import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; import com.fasterxml.jackson.databind.DeserializationConfig; import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.SerializationConfig; import com.fasterxml.jackson.databind.jsontype.NamedType; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; +import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder; +import ch.systemsx.cisd.openbis.common.api.server.json.common.JsonConstants; import ch.systemsx.cisd.openbis.common.api.server.json.deserializer.JsonTypeAndClassDeserializer; +import ch.systemsx.cisd.openbis.common.api.server.json.deserializer.JsonTypeAndClassSerializer; import ch.systemsx.cisd.openbis.common.api.server.json.mapping.IJsonClassValueToClassObjectsMapping; /** @@ -58,4 +62,11 @@ public class JsonTypeAndClassResolverBuilder extends StdTypeResolverBuilder return deserializer; } + @Override + public TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes) + { + TypeIdResolver resolver = idResolver(config, baseType, subtypes, true, false); + return new JsonTypeAndClassSerializer(resolver, null, JsonConstants.getTypeField()); + } + } diff --git a/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/api/server/json/JsonSerializationTest.java b/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/api/server/json/JsonSerializationTest.java index 8c3922fcf20350551a09d088de0d798d42da62e7..f999b143e24b47f3eca01e64187496730bed94a4 100644 --- a/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/api/server/json/JsonSerializationTest.java +++ b/openbis-common/sourceTest/java/ch/systemsx/cisd/openbis/common/api/server/json/JsonSerializationTest.java @@ -16,6 +16,14 @@ package ch.systemsx.cisd.openbis.common.api.server.json; +import static org.testng.Assert.assertEquals; + +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.testng.Assert; import org.testng.annotations.Test; @@ -48,7 +56,6 @@ import ch.systemsx.cisd.openbis.common.api.server.json.object.ObjectWithTypeFact */ public class JsonSerializationTest { - @Test public void testSerializeRootType() throws Exception { @@ -169,6 +176,19 @@ public class JsonSerializationTest testSerialize(new ObjectWithReusedReferencesFactory()); } + @Test + public void testMapWithValueOfTypeList() throws Exception + { + Map<String, List<String>> map = new LinkedHashMap<>(); + map.put("abc", Arrays.asList("A", "B", "C")); + + String jsonFromObject = new JsonTestObjectMapper().writeValueAsString(map); + + assertEquals(jsonFromObject, "{\"abc\":[\"A\",\"B\",\"C\"]}"); + Map<String, Set<String>> recreatedMap = new JsonTestObjectMapper().readValue(jsonFromObject, LinkedHashMap.class); + assertEquals(recreatedMap.toString(), map.toString()); + } + private void testSerialize(ObjectFactory<?> factory) throws Exception { Object object = factory.createObjectToSerialize(); @@ -177,7 +197,7 @@ public class JsonSerializationTest Object expectedObject = factory.createExpectedMapAfterSerialization(new ObjectCounter()); String jsonFromExpectedMap = new ObjectMapper().writeValueAsString(expectedObject); - Assert.assertEquals(jsonFromObject, jsonFromExpectedMap); + assertEquals(jsonFromObject, jsonFromExpectedMap); } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/DataDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/DataDAO.java index 8a9a8f495f872d5c4e6f1de67931306befd4aecc..0f2f6bd1f0c221d68308b847d28cd5645c671c08 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/DataDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/DataDAO.java @@ -529,7 +529,6 @@ final class DataDAO extends AbstractGenericEntityWithPropertiesDAO<DataPE> imple return entity; } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void updateDataSetStatuses(final List<String> dataSetCodes, final DataSetArchivingStatus status) @@ -558,55 +557,14 @@ final class DataDAO extends AbstractGenericEntityWithPropertiesDAO<DataPE> imple { final int startIndexFinal = startIndex; final int endIndexFinal = endIndex; - updatedRows += (Integer) hibernateTemplate.execute(new HibernateCallback() - { - - // - // HibernateCallback - // - - @Override - public final Object doInHibernate(final Session session) - throws HibernateException - { - // NOTE: 'VERSIONED' makes modification time modified too - return session - .createQuery( - "UPDATE VERSIONED " - + EXTERNAL_DATA_TABLE_NAME - + " SET status = :status WHERE code IN (:codes) ") - .setParameter("status", status) - .setParameterList("codes", - dataSetCodes.subList(startIndexFinal, endIndexFinal)) - .executeUpdate(); - } - }); + List<String> codes = dataSetCodes.subList(startIndexFinal, endIndexFinal); + updatedRows += updateStatus(hibernateTemplate, status, codes); startIndex = endIndex; endIndex = Math.min(endIndex + MAX_BATCH_SIZE, len); } } else { - updatedRows = (Integer) hibernateTemplate.execute(new HibernateCallback() - { - - // - // HibernateCallback - // - - @Override - public final Object doInHibernate(final Session session) - throws HibernateException - { - // NOTE: 'VERSIONED' makes modification time modified too - return session - .createQuery( - "UPDATE VERSIONED " + EXTERNAL_DATA_TABLE_NAME - + " SET status = :status WHERE code IN (:codes) ") - .setParameter("status", status) - .setParameterList("codes", dataSetCodes).executeUpdate(); - } - - }); + updatedRows = updateStatus(hibernateTemplate, status, dataSetCodes); } scheduleDynamicPropertiesEvaluationForDataSets(dataSetCodes); hibernateTemplate.flush(); @@ -619,6 +577,45 @@ final class DataDAO extends AbstractGenericEntityWithPropertiesDAO<DataPE> imple } } + @SuppressWarnings({ "unchecked", "rawtypes" }) + private Integer updateStatus(final HibernateTemplate hibernateTemplate, final DataSetArchivingStatus status, List<String> codes) + { + return (Integer) hibernateTemplate.execute(new HibernateCallback() + { + @Override + public final Object doInHibernate(final Session session) + throws HibernateException + { + int result = session.createQuery( + "UPDATE " + EXTERNAL_DATA_TABLE_NAME + " SET status = :status WHERE code IN (:codes) ") + .setParameter("status", status) + .setParameterList("codes", codes) + .executeUpdate(); + updateVersion(session, codes); + return result; + /* + // NOTE: 'VERSIONED' makes modification time modified too + return session + .createQuery( + "UPDATE VERSIONED " + + EXTERNAL_DATA_TABLE_NAME + + " SET status = :status WHERE code IN (:codes) ") + .setParameter("status", status) + .setParameterList("codes", codes) + .executeUpdate(); + */ + } + }); + } + + private static int updateVersion(final Session session, List<String> codes) + { + return session.createQuery( + "UPDATE " + TABLE_NAME + " SET version = version + 1 WHERE code IN (:codes) ") + .setParameterList("codes", codes) + .executeUpdate(); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void updateSizes(final Map<String, Long> sizeMap) @@ -828,7 +825,7 @@ final class DataDAO extends AbstractGenericEntityWithPropertiesDAO<DataPE> imple { query = session .createQuery( - "UPDATE VERSIONED " + "UPDATE " + EXTERNAL_DATA_TABLE_NAME + " SET status = :status, presentInArchive = :presentInArchive, " + " archivingRequested = 'f'" @@ -837,17 +834,20 @@ final class DataDAO extends AbstractGenericEntityWithPropertiesDAO<DataPE> imple { query = session .createQuery( - "UPDATE VERSIONED " + "UPDATE " + EXTERNAL_DATA_TABLE_NAME + " SET status = :status, presentInArchive = :presentInArchive" + " WHERE code IN (:codes) "); } - return query + int result = query .setParameter("status", status) .setParameter("presentInArchive", presentInArchive) .setParameterList("codes", codes) .executeUpdate(); + System.err.println(result+" UPDATED "+codes); + updateVersion(session, codes); + return result; } } diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/ProjectSampleTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/ProjectSampleTest.java index f6700b590d0c853615e8e9b9ee708b6dc9534a05..47680b279f87ef1bf684374f01276a6819d3b7c0 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/ProjectSampleTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/ProjectSampleTest.java @@ -82,7 +82,7 @@ import ch.systemsx.cisd.openbis.systemtest.base.builder.SessionBuilder; * @author Franz-Josef Elmer */ @Transactional(transactionManager = "transaction-manager") -@Rollback +@Rollback(false) @Test(groups = "project-samples") public class ProjectSampleTest extends BaseTest { 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 f183a91a6816c8e175a260626dd4c62d6ed6ddb9..0fef1ce6322c19949813ba2b79fd19ce94996a57 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractAssignmentSampleToExperimentTestCase.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractAssignmentSampleToExperimentTestCase.java @@ -55,7 +55,7 @@ import ch.systemsx.cisd.openbis.systemtest.base.auth.SpaceDomain; * @author Franz-Josef Elmer */ @Transactional(transactionManager = "transaction-manager") -@Rollback +@Rollback(false) public abstract class AbstractAssignmentSampleToExperimentTestCase extends BaseTest { Experiment sourceExperiment; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractDataSetAssignmentTestCase.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractDataSetAssignmentTestCase.java index cc8875f09c7b610b79cbbfe0dfa674846d9a2855..7454e505038e938f92fc9d92bccc11773493f099 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractDataSetAssignmentTestCase.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractDataSetAssignmentTestCase.java @@ -53,7 +53,7 @@ import ch.systemsx.cisd.openbis.systemtest.base.auth.SpaceDomain; * @author Franz-Josef Elmer */ @Transactional(transactionManager = "transaction-manager") -@Rollback +@Rollback(false) public abstract class AbstractDataSetAssignmentTestCase extends BaseTest { Sample sourceSample; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractEntityDeletionTestCase.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractEntityDeletionTestCase.java index 2c78dd56bd5b878d8352bcb0479345a1f1751185..ec2ae1e37a4e05d0fa87550540eb4b6fbe12c15b 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractEntityDeletionTestCase.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/AbstractEntityDeletionTestCase.java @@ -44,7 +44,7 @@ import ch.systemsx.cisd.openbis.systemtest.base.builder.SessionBuilder; * @author Franz-Josef Elmer */ @Transactional(transactionManager = "transaction-manager") -@Rollback +@Rollback(false) public abstract class AbstractEntityDeletionTestCase extends BaseTest { @Test diff --git a/openbis_standard_technologies/.dynamic_property_evaluator_queue b/openbis_standard_technologies/.dynamic_property_evaluator_queue new file mode 100644 index 0000000000000000000000000000000000000000..2e08dce276e43c677d121d627a250d1710fed824 Binary files /dev/null and b/openbis_standard_technologies/.dynamic_property_evaluator_queue differ diff --git a/openbis_standard_technologies/build.gradle b/openbis_standard_technologies/build.gradle index 5d823361a6a0bdfb21f9b692075006e0e71d75a0..b5cf66c440696ed75b1d0d0140d76b06dbce84db 100644 --- a/openbis_standard_technologies/build.gradle +++ b/openbis_standard_technologies/build.gradle @@ -108,6 +108,19 @@ dependencies { javadoc_compilation project(path:':rtd_phosphonetx'), project(path:':screening') + + testCompile (project(path: ':openbis', configuration: 'tests')) { + exclude group: 'google', module: 'gwt-user' + } + +} + +sourceSets { + test { + resources { + srcDirs = ['source/java', 'sourceTest/java'] + } + } } task compileGwt (dependsOn: classes, type: JavaExec) { diff --git a/openbis_standard_technologies/dist/core-plugins/core-plugins.properties b/openbis_standard_technologies/dist/core-plugins/core-plugins.properties new file mode 100644 index 0000000000000000000000000000000000000000..77fe9f20e507ac4dc02ef2ae23706d7f9f36fb00 --- /dev/null +++ b/openbis_standard_technologies/dist/core-plugins/core-plugins.properties @@ -0,0 +1 @@ +enabled-modules = dev-.* \ No newline at end of file diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js index 25b7daad6b40f0d9659da200406abfc2444bc26a..1b08ef8f11236de7f2248b17025f8cc3ea9a2cba 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js @@ -227,7 +227,7 @@ function AdvancedSearchController(mainController, forceSearch) { this.selectSavedSearch = function(selcetedSavedSearchIndex) { var savedSearch = this._advancedSearchModel.savedSearches[selcetedSavedSearchIndex]; this._advancedSearchModel.selcetedSavedSearchIndex = selcetedSavedSearchIndex; - this._advancedSearchModel.criteria = savedSearch.criteria; + this._advancedSearchModel.criteria = this._clone(savedSearch.criteria); this._advancedSearchModel.forceLoadCriteria = true; this._advancedSearchView.repaintContent(); } @@ -271,6 +271,7 @@ function AdvancedSearchController(mainController, forceSearch) { }, function(success) { if (success) { Util.showSuccess('Search updated.'); + savedSearch.criteria = _this._clone(_this._advancedSearchModel.criteria); } callback(); }); @@ -296,6 +297,11 @@ function AdvancedSearchController(mainController, forceSearch) { ); } + this.clearSelection = function() { + this._advancedSearchModel.selcetedSavedSearchIndex = -1; + this._advancedSearchView.repaintContent(); + } + this._loadSavedSearches = function(callback) { var _this = this; this._mainController.serverFacade.searchSamplesV3('SEARCH_QUERY', function(result) { @@ -399,4 +405,8 @@ function AdvancedSearchController(mainController, forceSearch) { } }); } + + this._clone = function(object) { + return JSON.parse(JSON.stringify(object)); + } } diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchModel.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchModel.js index 0bc09d820013cdd67a1ca9f2a668a6f9bc97fbbc..e75a6608e04d9a94bc05834e8e5753bbc28c2a51 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchModel.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchModel.js @@ -47,7 +47,17 @@ function AdvancedSearchModel(forceSearch) { this.setEntityKind = function(entityKind) { this.criteria.entityKind = entityKind; } - + + // a hidden object type rule is used for the "Search For" dropdown + this.getHiddenRule = function() { + for(var ruleKey in this.criteria.rules) { + if (this.criteria.rules[ruleKey].hidden) { + return this.criteria.rules[ruleKey]; + } + } + return null; + } + this.resetModel = function(entityKind) { this.criteria.entityKind = entityKind; this.criteria.rules = {}; diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchView.js index 643c801d6f82f8d5d6cfb8f81f0080e39370aca5..15505da7ca0ef64fd898aadeb9754f94877147e6 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchView.js @@ -21,6 +21,7 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { this._$andOrDropdownComponent = null; this._$menuPanelContainer = null; this._$searchCriteriaPanelContainer = null; + this._$rulesPanelContainer = null; this._$tbody = null; this._$dataGridContainer = null; this._$saveLoadContainer = null; @@ -67,19 +68,28 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { //Triggers Layout refresh $container.append($mainPanel); - if(this._advancedSearchModel.forceLoadCriteria) { - this._$entityTypeDropdown.val(this._advancedSearchModel.criteria.entityKind); - this._$andOrDropdownComponent.val(this._advancedSearchModel.criteria.logicalOperator); - this._advancedSearchModel.forceLoadCriteria = undefined; - } - + this._updateEntityTypeAndUsingDropdownValues(); } this.repaintContent = function() { this._paintSaveLoadPanel(this._$saveLoadContainer); this._paintCriteriaPanel(this._$searchCriteriaPanelContainer); + this._updateEntityTypeAndUsingDropdownValues(); } + this._updateEntityTypeAndUsingDropdownValues = function() { + if(this._advancedSearchModel.forceLoadCriteria) { + var hiddenRule = this._advancedSearchModel.getHiddenRule(); + if (hiddenRule) { + this._$entityTypeDropdown.val('SAMPLE$' + hiddenRule.value); + } else { + this._$entityTypeDropdown.val(this._advancedSearchModel.criteria.entityKind); + } + this._$andOrDropdownComponent.val(this._advancedSearchModel.criteria.logicalOperator); + this._advancedSearchModel.forceLoadCriteria = undefined; + } + } + // // Repaint Panels Methods // @@ -176,6 +186,13 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { theme: "bootstrap" }); + if (_this._advancedSearchModel.selcetedSavedSearchIndex > -1) { + var $buttonClear = FormUtil.getButtonWithIcon('glyphicon-remove', function() { + _this._advancedSearchController.clearSelection(); + }, null, 'Clear selection'); + $container.append($buttonClear); + } + var $buttonSave = FormUtil.getButtonWithIcon('glyphicon-floppy-disk', function() { _this._save(); }, 'Save'); @@ -227,6 +244,15 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { this._paintTypeSelectionPanel(this._$searchCriteriaPanelContainer); + // TODO put the rest in separate panel + this._$rulesPanelContainer = $("<div>"); + this._paintRulesPanel(this._$rulesPanelContainer); + $searchCriteriaPanelContainer.append(this._$rulesPanelContainer); + } + + + this._paintRulesPanel = function($container) { + $container.empty(); var _this = this; var $table = $("<table>", { class : "table table-bordered"}); $table.css({ 'margin-top': '10px' }); @@ -250,24 +276,31 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { .append($("<th>").text("Field Value")) .append($("<th>", { "style" : "width : 56px !important;" }).append(this._$addButton)) ); - - this._paintInputRow(); - - $searchCriteriaPanelContainer.append($table); + + if ($.isEmptyObject(this._advancedSearchModel.criteria.rules)) { + this._paintInputRow(); + } else { + for(var ruleKey in this._advancedSearchModel.criteria.rules) { + if ( ! this._advancedSearchModel.criteria.rules[ruleKey].hidden) { + this._paintInputRow(ruleKey); + } + } + } + + $container.append($table); } // // Auxiliar Components Methods // - - this._paintInputRow = function() { + + // paints a row for the given ruleKey or a new empty row if no ruleKey is given + this._paintInputRow = function(ruleKey) { var _this = this; - - if(this._advancedSearchModel.forceLoadCriteria) { - var uuidValue = null; - for(var ruleKey in this._advancedSearchModel.criteria.rules) { - uuidValue = ruleKey; - } + + var uuidValue = null; + if (ruleKey) { + uuidValue = ruleKey; } else { var uuidValue = Util.guid(); this._advancedSearchModel.criteria.rules[uuidValue] = { }; @@ -313,13 +346,11 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { } if(this._advancedSearchModel.forceLoadCriteria) { - for(var ruleKey in this._advancedSearchModel.criteria.rules) { - var rule = this._advancedSearchModel.criteria.rules[ruleKey]; - $fieldTypeDropdown.val(rule.type).change(); - $fieldValue.val(rule.value); - var $fieldNameDropdown = $($newFieldNameContainer.children()[0]); - $fieldNameDropdown.val(rule.name); - } + var rule = this._advancedSearchModel.criteria.rules[uuidValue]; + $fieldTypeDropdown.val(rule.type).change(); + $fieldValue.val(rule.value); + var $fieldNameDropdown = $($newFieldNameContainer.children()[0]); + $fieldNameDropdown.val(rule.name); } } @@ -631,7 +662,7 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { } } else { _this._advancedSearchModel.resetModel(kindAndType[0]); //Restart model - _this._paintCriteriaPanel(_this._$searchCriteriaPanelContainer); //Restart view + _this._paintRulesPanel(_this._$rulesPanelContainer); } if(kindAndType.length === 2) { @@ -640,6 +671,7 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { _this._advancedSearchModel.criteria.rules[uuidValue].type = 'Attribute'; _this._advancedSearchModel.criteria.rules[uuidValue].name = 'ATTR.SAMPLE_TYPE'; _this._advancedSearchModel.criteria.rules[uuidValue].value = kindAndType[1]; + _this._advancedSearchModel.criteria.rules[uuidValue].hidden = true; _this._advancedSearchModel.isSampleTypeForced = true; } else { _this._advancedSearchModel.isSampleTypeForced = false; @@ -897,4 +929,4 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { return dataGrid; } -} \ No newline at end of file +} diff --git a/openbis_standard_technologies/source/java/service.properties b/openbis_standard_technologies/source/java/service.properties index e8586097f09ecde472f31d671d52d7dcc0c13ad4..ca515e360564c0f113dea8f8e4d273c487fd2610 100644 --- a/openbis_standard_technologies/source/java/service.properties +++ b/openbis_standard_technologies/source/java/service.properties @@ -77,7 +77,7 @@ hibernate.search.worker.execution=async web-client-configuration-file = etc/web-client.properties -core-plugins-folder=source/core-plugins +core-plugins-folder=dist/core-plugins # Database Configurations for Query module query-databases = 1 diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/AbstractImportTest.java b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/AbstractImportTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f7819e2ba882e4e25e8ecc774bdb685fcaa4d8c7 --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/AbstractImportTest.java @@ -0,0 +1,23 @@ +package ch.ethz.sis.openbis.systemtest.plugin.excelimport; + +import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests; +import org.testng.annotations.BeforeSuite; + +import ch.systemsx.cisd.openbis.generic.server.util.TestInitializer; +import ch.systemsx.cisd.openbis.generic.shared.Constants; +import ch.systemsx.cisd.openbis.generic.shared.coreplugin.CorePluginsUtils; + +public class AbstractImportTest extends AbstractTransactionalTestNGSpringContextTests +{ + + protected String FILES_DIR; + + @BeforeSuite + public void setupSuite() + { + System.setProperty(CorePluginsUtils.CORE_PLUGINS_FOLDER_KEY, "dist/core-plugins"); + System.setProperty(Constants.ENABLED_MODULES_KEY, "xls-import"); + TestInitializer.initEmptyDbNoIndex(); + } + +} diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportDatasetTypesTest.java b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportDatasetTypesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f5436657b69312da800689c90793c6e97a1f372b --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportDatasetTypesTest.java @@ -0,0 +1,107 @@ +package ch.ethz.sis.openbis.systemtest.plugin.excelimport; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.nio.file.Paths; + +import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSetType; +import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +@ContextConfiguration(locations = "classpath:applicationContext.xml") +@Transactional(transactionManager = "transaction-manager") +@Rollback +public class ImportDatasetTypesTest extends AbstractImportTest +{ + + @Autowired + private IApplicationServerInternalApi v3api; + + private static final String TEST_USER = "test"; + + private static final String PASSWORD = "password"; + + private static final String DATASET_TYPES_XLS = "dataset_types/normal_dataset.xls"; + + private static final String DATASET_NO_CODE = "dataset_types/no_code.xls"; + + private static final String DATASET_WITH_VALIDATION_SCRIPT = "dataset_types/with_validation.xls"; + + private static final String DATASET_WITHOUT_PROPERTIES = "dataset_types/no_properties.xls"; + + private static String FILES_DIR; + + private String sessionToken; + + @BeforeClass + public void setupClass() throws IOException + { + String f = ImportDatasetTypesTest.class.getName().replace(".", "/"); + FILES_DIR = f.substring(0, f.length() - ImportDatasetTypesTest.class.getSimpleName().length()) + "/test_files/"; + System.out.println(FILES_DIR); + System.out.println("SEE ME MY DEAR FRIEND"); + } + + @BeforeMethod + public void beforeTest() + { + sessionToken = v3api.login(TEST_USER, PASSWORD); + } + + @Test + @DirtiesContext + public void testNormalDatasetsTypesAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, DATASET_TYPES_XLS))); + // WHEN + DataSetType rawData = TestUtils.getDatasetType(v3api, sessionToken, "RAW_DATA"); + // THEN + assertEquals(rawData.getCode(), "RAW_DATA"); + assertEquals(rawData.getPropertyAssignments().size(), 2); + } + + @Test + @DirtiesContext + public void testDatasetsWithoutPropertiesTypesAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, DATASET_WITHOUT_PROPERTIES))); + // WHEN + DataSetType rawData = TestUtils.getDatasetType(v3api, sessionToken, "RAW_DATA"); + // THEN + assertEquals(rawData.getCode(), "RAW_DATA"); + assertEquals(rawData.getPropertyAssignments().size(), 0); + } + + @Test + @DirtiesContext + public void testSampleTypesWithValidationScript() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, TestUtils.getValidationPluginMap(), + Paths.get(FilenameUtils.concat(FILES_DIR, DATASET_WITH_VALIDATION_SCRIPT))); + // WHEN + DataSetType collection = TestUtils.getDatasetType(v3api, sessionToken, "RAW_DATA"); + // THEN + assertEquals(collection.getValidationPlugin().getName().toUpperCase(), "RAW_DATA.VALID"); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfNoSampleCode() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, DATASET_NO_CODE))); + } + +} diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportExperimentTypesTest.java b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportExperimentTypesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..99010317951ca59f376a98f62e0bed6b8d29e0e0 --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportExperimentTypesTest.java @@ -0,0 +1,88 @@ +package ch.ethz.sis.openbis.systemtest.plugin.excelimport; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.nio.file.Paths; + +import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.ExperimentType; +import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +@ContextConfiguration(locations = "classpath:applicationContext.xml") +@Transactional(transactionManager = "transaction-manager") +@Rollback +public class ImportExperimentTypesTest extends AbstractImportTest +{ + @Autowired + private IApplicationServerInternalApi v3api; + + private static final String TEST_USER = "test"; + + private static final String PASSWORD = "password"; + + private static final String EXPERIMENT_TYPES_XLS = "experiment_types/normal_experiment.xls"; + + private static final String EXPERIMENT_NO_CODE = "experiment_types/no_code.xls"; + + private static final String EXPERIMENT_WITH_VALIDATION_SCRIPT = "experiment_types/with_validation_script.xls"; + + private static String FILES_DIR; + + private String sessionToken; + + @BeforeClass + public void setupClass() throws IOException + { + String f = ImportExperimentTypesTest.class.getName().replace(".", "/"); + FILES_DIR = f.substring(0, f.length() - ImportExperimentTypesTest.class.getSimpleName().length()) + "/test_files/"; + } + + @BeforeMethod + public void beforeTest() + { + sessionToken = v3api.login(TEST_USER, PASSWORD); + } + + @Test + @DirtiesContext + public void testNormalExperimentTypesAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_TYPES_XLS))); + // WHEN + ExperimentType collection = TestUtils.getExperimentType(v3api, sessionToken, "COLLECTION"); + // THEN + assertEquals(collection.getCode(), "COLLECTION"); + } + + @Test + @DirtiesContext + public void testExperimentTypesWithValidationScript() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, TestUtils.getValidationPluginMap(), + Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_WITH_VALIDATION_SCRIPT))); + // WHEN + ExperimentType collection = TestUtils.getExperimentType(v3api, sessionToken, "COLLECTION"); + // THEN + assertEquals(collection.getValidationPlugin().getName().toUpperCase(), "COLLECTION.VALID"); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfNoSampleCode() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_NO_CODE))); + } + +} diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportExperimentsTest.java b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportExperimentsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cbf5a4114bb870ebbbaca669283fc3ac1994d5e5 --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportExperimentsTest.java @@ -0,0 +1,329 @@ +package ch.ethz.sis.openbis.systemtest.plugin.excelimport; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.nio.file.Paths; + +import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.Experiment; +import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +@ContextConfiguration(locations = "classpath:applicationContext.xml") +@Transactional(transactionManager = "transaction-manager") +@Rollback +public class ImportExperimentsTest extends AbstractImportTest +{ + @Autowired + private IApplicationServerInternalApi v3api; + + private static final String TEST_USER = "test"; + + private static final String PASSWORD = "password"; + + private static final String EXPERIMENT_XLS = "experiments/all_inside.xls"; + + private static final String EXPERIMENTS_ALL_ELSEWHERE = "experiments/all_elsewhere.xls"; + + private static final String EXPERIMENTS_WITH_TYPE_ELSEWHERE = "experiments/experiment_type_elsewhere.xls"; + + private static final String EXPERIMENTS_NO_CODE = "experiments/no_code.xls"; + + private static final String EXPERIMENTS_WITH_NON_MANDATORY_PROPERTY_MISSING = "experiments/no_non_mandatory_property.xls"; + + private static final String EXPERIMENTS_NO_PROJECT_ATTRIBUTE = "experiments/no_project.xls"; + + private static final String EXPERIMENTS_WITH_SPACE_AND_PROJECT_ELSEWHERE = "experiments/space_and_project_elsewhere.xls"; + + private static final String EXPERIMENTS_SPACE_ELSEWHERE = "experiments/space_elsewhere.xls"; + + private static final String EXPERIMENTS_WITH_TYPE_AND_SPACE_ELSEWHERE = "experiments/type_and_space_elsewhere.xls"; + + private static final String EXPERIMENTS_WITH_MANDATORY_PROPERTY_MISSING = "experiments/with_mandatory_property_missing.xls"; + + private static final String EXPERIMENTS_WITH_MANDATORY_PROPERTY_PRESENT = "experiments/with_mandatory_property.xls"; + + private static final String EXPERIMENTS_PROPERTIES_COLUMNS_AS_LABELS = "experiments/with_properties_as_labels.xls"; + + private static final String EXPERIMENTS_PROPERTIES_COLUMNS_AS_LABELS_TYPE_ON_SERVER = "experiments/with_properties_as_labels_type_elsewhere.xls"; + + private static final String SPACE = "experiments/space.xls"; + + private static final String PROJECT = "experiments/project.xls"; + + private static final String EXPERIMENT_TYPE = "experiments/experiment_type.xls"; + + private static String FILES_DIR; + + private String sessionToken; + + @BeforeClass + public void setupClass() throws IOException + { + String f = ImportExperimentsTest.class.getName().replace(".", "/"); + FILES_DIR = f.substring(0, f.length() - ImportExperimentsTest.class.getSimpleName().length()) + "/test_files/"; + } + + @BeforeMethod + public void beforeTest() + { + sessionToken = v3api.login(TEST_USER, PASSWORD); + } + + @Test + @DirtiesContext + public void testProjectsAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_XLS))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedSecondExperiment() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_XLS))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT2", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT2"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Other Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "Random string"); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedWithEverythingOnServer() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_TYPE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROJECT))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_ALL_ELSEWHERE))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedWithEverythingOnServerAndInXls() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_TYPE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROJECT))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_XLS))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfExperimentTypeDoesntExist() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROJECT))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_ALL_ELSEWHERE))); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfProjectDoesntExist() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_TYPE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_ALL_ELSEWHERE))); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedWithTypeOnServer() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_TYPE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_WITH_TYPE_ELSEWHERE))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedWithTypeOnServerAndInXls() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_TYPE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROJECT))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_WITH_TYPE_ELSEWHERE))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfExperimentNoCode() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_NO_CODE))); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedWhenNonMandatoryPropertiesAreNotProvided() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_WITH_NON_MANDATORY_PROPERTY_MISSING))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), null); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfExperimentNoProject() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_NO_PROJECT_ATTRIBUTE))); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedWithSpaceAndProjectOnServer() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROJECT))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_WITH_SPACE_AND_PROJECT_ELSEWHERE))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedWithSpaceOnServer() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_SPACE_ELSEWHERE))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedWithTypeAndSpaceOnServer() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_TYPE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_WITH_TYPE_AND_SPACE_ELSEWHERE))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfMandatoryPropertyMissing() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_WITH_MANDATORY_PROPERTY_MISSING))); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedIfMandatoryPropertyArePresent() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_WITH_MANDATORY_PROPERTY_PRESENT))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedWhenPropertiesAreAddressedByLabelsWithTypeInXls() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_PROPERTIES_COLUMNS_AS_LABELS))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedWhenPropertiesAreAddressedByLabelsWithTypeOnServer() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENT_TYPE))); + TestUtils.createFrom(v3api, sessionToken, + Paths.get(FilenameUtils.concat(FILES_DIR, EXPERIMENTS_PROPERTIES_COLUMNS_AS_LABELS_TYPE_ON_SERVER))); + // WHEN + Experiment experiment = TestUtils.getExperiment(v3api, sessionToken, "TEST_EXPERIMENT", "TEST_PROJECT", "TEST_SPACE"); + // THEN + assertEquals(experiment.getCode(), "TEST_EXPERIMENT"); + assertEquals(experiment.getProject().getCode(), "TEST_PROJECT"); + assertEquals(experiment.getProperties().get("$NAME"), "Value"); + assertEquals(experiment.getProperties().get("DEFAULT_OBJECT_TYPE"), "OBJECT_TYPE"); + } + +} diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportProjectsTest.java b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportProjectsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7b06530d87c6fa5575741a913414f78c8937692d --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportProjectsTest.java @@ -0,0 +1,132 @@ +package ch.ethz.sis.openbis.systemtest.plugin.excelimport; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.nio.file.Paths; + +import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.project.Project; +import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +@ContextConfiguration(locations = "classpath:applicationContext.xml") +@Transactional(transactionManager = "transaction-manager") +@Rollback +public class ImportProjectsTest extends AbstractImportTest +{ + @Autowired + private IApplicationServerInternalApi v3api; + + private static final String TEST_USER = "test"; + + private static final String PASSWORD = "password"; + + private static final String PROJECTS_XLS = "projects/with_spaces.xls"; + + private static final String PROJECTS_NO_CODE = "projects/no_code.xls"; + + private static final String PROJECTS_NO_DESCRIPTION = "projects/no_desc.xls"; + + private static final String PROJECTS_NO_SPACE = "projects/no_space.xls"; + + private static final String PROJECTS_WITH_SPACES_ON_SERVER = "projects/with_spaces_on_server.xls"; + + private static final String SPACES = "projects/spaces.xls"; + + private static String FILES_DIR; + + private String sessionToken; + + @BeforeClass + public void setupClass() throws IOException + { + String f = ImportProjectsTest.class.getName().replace(".", "/"); + FILES_DIR = f.substring(0, f.length() - ImportProjectsTest.class.getSimpleName().length()) + "/test_files/"; + } + + @BeforeMethod + public void beforeTest() + { + sessionToken = v3api.login(TEST_USER, PASSWORD); + } + + @Test + @DirtiesContext + public void testProjectsAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROJECTS_XLS))); + // WHEN + Project project = TestUtils.getProject(v3api, sessionToken, "TEST_PROJECT"); + // THEN + assertEquals(project.getCode(), "TEST_PROJECT"); + assertEquals(project.getDescription(), "TEST"); + assertEquals(project.getSpace().getCode(), "TEST_SPACE"); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedSecondProject() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROJECTS_XLS))); + // WHEN + Project project = TestUtils.getProject(v3api, sessionToken, "TEST_PROJECT2"); + // THEN + assertEquals(project.getCode(), "TEST_PROJECT2"); + assertEquals(project.getDescription(), "description of another project"); + assertEquals(project.getSpace().getCode(), "TEST_SPACE2"); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfNoProjectCode() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROJECTS_NO_CODE))); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedNoDescription() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROJECTS_NO_DESCRIPTION))); + // WHEN + Project project = TestUtils.getProject(v3api, sessionToken, "TEST_PROJECT"); + // THEN + assertEquals(project.getCode(), "TEST_PROJECT"); + assertEquals(project.getDescription(), null); + assertEquals(project.getSpace().getCode(), "TEST_SPACE"); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfNoProjectSpace() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROJECTS_NO_SPACE))); + } + + @Test + @DirtiesContext + public void testProjectsAreCreatedSpaceOnServer() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACES))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROJECTS_WITH_SPACES_ON_SERVER))); + // WHEN + Project project = TestUtils.getProject(v3api, sessionToken, "TEST_PROJECT"); + // THEN + assertEquals(project.getCode(), "TEST_PROJECT"); + assertEquals(project.getDescription(), "TEST"); + assertEquals(project.getSpace().getCode(), "TEST_SPACE"); + } + +} diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportPropertyTypesTest.java b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportPropertyTypesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8b0def35d27e07b085af53fe2dce981ace80eb7d --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportPropertyTypesTest.java @@ -0,0 +1,148 @@ +package ch.ethz.sis.openbis.systemtest.plugin.excelimport; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.io.IOException; +import java.nio.file.Paths; + +import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.DataType; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.PropertyType; +import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +@ContextConfiguration(locations = "classpath:applicationContext.xml") +@Transactional(transactionManager = "transaction-manager") +@Rollback +public class ImportPropertyTypesTest extends AbstractImportTest +{ + + @Autowired + private IApplicationServerInternalApi v3api; + + private static final String TEST_USER = "test"; + + private static final String PASSWORD = "password"; + + private static final String PROPERTY_TYPES_XLS = "property_types/normal_property_type.xls"; + + private static final String PROPERTY_NO_CODE = "property_types/no_code.xls"; + + private static final String PROPERTY_NO_DATA_TYPE = "property_types/no_data_type.xls"; + + private static final String PROPERTY_NO_DESCRIPTION = "property_types/no_desc.xls"; + + private static final String PROPERTY_NO_LABEL = "property_types/no_label.xls"; + + private static final String PROPERTY_VOCAB_TYPE_NO_VOCABULARY_CODE = "property_types/no_vocab_code.xls"; + + private static final String PROPERTY_NON_VOCAB_TYPE_VOCABULARY_CODE = "property_types/vocabcode_when_not_vocabtype.xls"; + + private static final String PROPERTY_VOCABULARY_ON_SERVER = "property_types/with_vocab_on_server.xls"; + + private static final String PROPERTY_VOCAB_TYPE = "property_types/with_vocab.xls"; + + private static final String VOCABULARY_DETECTION = "property_types/vocabulary_detection.xls"; + + private static String FILES_DIR; + + private String sessionToken; + + @BeforeClass + public void setupClass() throws IOException + { + String f = ImportPropertyTypesTest.class.getName().replace(".", "/"); + FILES_DIR = f.substring(0, f.length() - ImportPropertyTypesTest.class.getSimpleName().length()) + "/test_files/"; + } + + @BeforeMethod + public void beforeTest() + { + sessionToken = v3api.login(TEST_USER, PASSWORD); + } + + @Test + @DirtiesContext + public void testNormalPropertyTypesAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROPERTY_TYPES_XLS))); + // WHEN + PropertyType notes = TestUtils.getPropertyType(v3api, sessionToken, "NOTES"); + // THEN + assertEquals(notes.getCode(), "NOTES"); + assertEquals(notes.getLabel(), "Notes"); + assertEquals(notes.getDataType(), DataType.MULTILINE_VARCHAR); + assertEquals(notes.getDescription(), "Notes Descripton"); + assertFalse(notes.isInternalNameSpace()); + assertFalse(notes.isManagedInternally()); + assertNull(notes.getVocabulary()); + } + + @Test + @DirtiesContext + public void testInternalPropertyTypesAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROPERTY_TYPES_XLS))); + // WHEN + PropertyType notes = TestUtils.getPropertyType(v3api, sessionToken, "$INTERNAL_PROP"); + // THEN + assertEquals(notes.getCode(), "$INTERNAL_PROP"); + assertEquals(notes.getLabel(), "Name"); + assertEquals(notes.getDataType(), DataType.VARCHAR); + assertEquals(notes.getDescription(), "Name"); + assertTrue(notes.isInternalNameSpace()); + assertFalse(notes.isManagedInternally()); + assertNull(notes.getVocabulary()); + } + + @Test(expectedExceptions = UserFailureException.class) + public void testPropertyTypeNoCode() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROPERTY_NO_CODE))); + } + + @Test(expectedExceptions = UserFailureException.class) + public void testPropertyTypeNoLabel() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROPERTY_NO_LABEL))); + } + + @Test(expectedExceptions = UserFailureException.class) + public void testPropertyTypeNoVocabularyCodeWhenVocabularyType() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROPERTY_VOCAB_TYPE_NO_VOCABULARY_CODE))); + } + + @Test(expectedExceptions = UserFailureException.class) + public void testPropertyTypeNoDataType() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROPERTY_NO_DATA_TYPE))); + } + + @Test(expectedExceptions = UserFailureException.class) + public void testPropertyTypeNoDescription() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROPERTY_NO_DESCRIPTION))); + } + + @Test(expectedExceptions = UserFailureException.class) + public void testPropertyTypeVocabularyCodeToNonVocabularyType() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, PROPERTY_NON_VOCAB_TYPE_VOCABULARY_CODE))); + } + +} diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportSampleTypesTest.java b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportSampleTypesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..78c3538bf5c6fcc708c07b90dfd5d8c569b93112 --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportSampleTypesTest.java @@ -0,0 +1,233 @@ +package ch.ethz.sis.openbis.systemtest.plugin.excelimport; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.io.IOException; +import java.nio.file.Paths; + +import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.plugin.Plugin; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.plugin.PluginType; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.PropertyAssignment; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.SampleType; +import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +@ContextConfiguration(locations = "classpath:applicationContext.xml") +@Transactional(transactionManager = "transaction-manager") +@Rollback +public class ImportSampleTypesTest extends AbstractImportTest +{ + + private static final String SAMPLE_TYPES_XLS = "sample_types/normal_samples.xls"; + + private static final String SAMPLE_TYPES_XLS_DIFFERENT_PROPERTY_ASSIGN = "sample_types/normal_samples_v2.xls"; + + private static final String SAMPLE_TYPES_WITH_DYNAMIC_SCRIPT = "sample_types/with_dynamic_script.xls"; + + private static final String SAMPLE_TYPES_WITH_VALIDATION_SCRIPT = "sample_types/with_validation_script.xls"; + + private static final String SAMPLE_TYPES_WITH_VOCABULARY = "sample_types/with_vocabulary_in_xls.xls"; + + private static final String SAMPLE_TYPES_WITH_VOCABULARY_ON_SERVER = "sample_types/with_vocabulary_on_server.xls"; + + private static final String VOCABULARY_DETECTION = "sample_types/vocabulary_detection.xls"; + + private static final String SAMPLE_TYPES_WITH_AUTO_GENERATED_CODES = "sample_types/with_auto_generated_codes.xls"; + + private static final String SAMPLE_TYPE_NO_CODE = "sample_types/no_code.xls"; + + @Autowired + private IApplicationServerInternalApi v3api; + + private static final String TEST_USER = "test"; + + private static final String PASSWORD = "password"; + + private static String FILES_DIR; + + private String sessionToken; + + @BeforeClass + public void setupClass() throws IOException + { + String f = ImportSampleTypesTest.class.getName().replace(".", "/"); + FILES_DIR = f.substring(0, f.length() - ImportSampleTypesTest.class.getSimpleName().length()) + "/test_files/"; + } + + @BeforeMethod + public void beforeTest() + { + sessionToken = v3api.login(TEST_USER, PASSWORD); + } + + @Test + @DirtiesContext + public void testNormalSampleTypesAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPES_XLS))); + // WHEN + SampleType antibody = TestUtils.getSampleType(v3api, sessionToken, "ANTIBODY"); + // THEN + assertFalse(antibody.isAutoGeneratedCode()); + } + + @Test + @DirtiesContext + public void testPropertyTypeAssignmentsFromNormalSampleTypesAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPES_XLS))); + // WHEN + SampleType antibody = TestUtils.getSampleType(v3api, sessionToken, "ANTIBODY"); + // THEN + boolean allMandatory = antibody.getPropertyAssignments().stream().allMatch(propAssignment -> propAssignment.isMandatory() == true); + boolean allShownInEditView = + antibody.getPropertyAssignments().stream().allMatch(propAssignment -> propAssignment.isShowInEditView() == true); + boolean generalInformationExists = + antibody.getPropertyAssignments().stream().anyMatch(propAssignment -> propAssignment.getSection().equals("General information")); + boolean someOtherSectionExists = + antibody.getPropertyAssignments().stream().anyMatch(propAssignment -> propAssignment.getSection().equals("Some other section")); + boolean threePropertyAssignments = antibody.getPropertyAssignments().size() == 3; + assertTrue(threePropertyAssignments); + assertTrue(generalInformationExists); + assertTrue(someOtherSectionExists); + assertTrue(allShownInEditView); + assertTrue(allMandatory); + } + + @Test + @DirtiesContext + public void testPropertyTypeAssignmentsFromNormalv2SampleTypesAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPES_XLS_DIFFERENT_PROPERTY_ASSIGN))); + // WHEN + SampleType antibody = TestUtils.getSampleType(v3api, sessionToken, "ANTIBODY"); + // THEN + boolean allNotMandatory = antibody.getPropertyAssignments().stream().allMatch(propAssignment -> propAssignment.isMandatory() == false); + boolean allNotShownInEditView = + antibody.getPropertyAssignments().stream().allMatch(propAssignment -> propAssignment.isShowInEditView() == false); + boolean threePropertyAssignments = antibody.getPropertyAssignments().size() == 3; + assertTrue(threePropertyAssignments); + assertTrue(allNotShownInEditView); + assertTrue(allNotMandatory); + } + + @Test + @DirtiesContext + public void testPropertyTypesFromNormalSampleTypesAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPES_XLS))); + // WHEN + SampleType antibody = TestUtils.getSampleType(v3api, sessionToken, "ANTIBODY"); + // THEN + boolean namePropertyExists = + antibody.getPropertyAssignments().stream().anyMatch(propAssignment -> propAssignment.getPropertyType().getCode().equals("$NAME")); + boolean forWhatPropertyExists = + antibody.getPropertyAssignments().stream().anyMatch(propAssignment -> propAssignment.getPropertyType().getCode().equals("FOR_WHAT")); + boolean epitopePropertyExists = + antibody.getPropertyAssignments().stream().anyMatch(propAssignment -> propAssignment.getPropertyType().getCode().equals("EPITOPE")); + + assertNotNull(antibody); + assertTrue(namePropertyExists); + assertTrue(forWhatPropertyExists); + assertTrue(epitopePropertyExists); + } + + @Test + @DirtiesContext + public void testSampleTypesWithPropertyHavingDynamicScript() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, TestUtils.getDynamicPluginMap(), + Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPES_WITH_DYNAMIC_SCRIPT))); + // WHEN + SampleType antibody = TestUtils.getSampleType(v3api, sessionToken, "ANTIBODY"); + // THEN + Plugin dynamicScript = antibody.getPropertyAssignments().get(0).getPlugin(); + assertNotNull(dynamicScript); + assertEquals(dynamicScript.getName().toUpperCase(), "$NAME.DYNAMIC"); + assertEquals(dynamicScript.getScript(), TestUtils.getDynamicScript()); + assertEquals(dynamicScript.getPluginType(), PluginType.DYNAMIC_PROPERTY); + } + + @Test + @DirtiesContext + public void testSampleTypesWithPropertyHavingValidationScript() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, TestUtils.getValidationPluginMap(), + Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPES_WITH_VALIDATION_SCRIPT))); + // WHEN + SampleType antibody = TestUtils.getSampleType(v3api, sessionToken, "ANTIBODY"); + // THEN + Plugin validationScript = antibody.getValidationPlugin(); + assertNotNull(validationScript); + assertEquals(validationScript.getName().toUpperCase(), "ANTIBODY.VALID"); + assertEquals(validationScript.getScript(), TestUtils.getValidationScript()); + assertEquals(validationScript.getPluginType(), PluginType.ENTITY_VALIDATION); + } + + @Test + @DirtiesContext + public void testSampleTypesWithVocabularyInXls() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPES_WITH_VOCABULARY))); + // WHEN + SampleType antibody = TestUtils.getSampleType(v3api, sessionToken, "ANTIBODY"); + // THEN + PropertyAssignment propertyAssignment = antibody.getPropertyAssignments().get(0); + assertNotNull(propertyAssignment); + assertEquals(propertyAssignment.getPropertyType().getVocabulary().getCode(), "DETECTION"); + } + + @Test + @DirtiesContext + public void testSampleTypesWithVocabularyOnServer() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARY_DETECTION))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPES_WITH_VOCABULARY_ON_SERVER))); + // WHEN + SampleType antibody = TestUtils.getSampleType(v3api, sessionToken, "ANTIBODY"); + // THEN + PropertyAssignment propertyAssignment = antibody.getPropertyAssignments().get(0); + assertNotNull(propertyAssignment); + assertEquals(propertyAssignment.getPropertyType().getVocabulary().getCode(), "DETECTION"); + } + + @Test + @DirtiesContext + public void testSampleTypesWithAutoGeneratedCodeAttribute() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPES_WITH_AUTO_GENERATED_CODES))); + // WHEN + SampleType antibody = TestUtils.getSampleType(v3api, sessionToken, "SECONDBODY"); + // THEN + assertTrue(antibody.isAutoGeneratedCode()); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfNoSampleCode() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPE_NO_CODE))); + } + +} diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportSamplesTest.java b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportSamplesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f83fb7839c5e85bc3e832ed6d54b4e3ee3802752 --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportSamplesTest.java @@ -0,0 +1,313 @@ +package ch.ethz.sis.openbis.systemtest.plugin.excelimport; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.io.IOException; +import java.nio.file.Paths; + +import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.Sample; +import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +@ContextConfiguration(locations = "classpath:applicationContext.xml") +@Transactional(transactionManager = "transaction-manager") +@Rollback +public class ImportSamplesTest extends AbstractImportTest +{ + @Autowired + private IApplicationServerInternalApi v3api; + + private static final String TEST_USER = "test"; + + private static final String PASSWORD = "password"; + + private static final String SAMPLES_XLS = "samples/all_in.xls"; + + private static final String SAMPLES_SPACE_ELSEWHERE = "samples/space_elsewhere.xls"; + + private static final String SAMPLES_SAMPLE_TYPE_ELSWHERE = "samples/sample_type_elsewhere.xls"; + + private static final String SAMPLES_SPACE_PROJECT_EXPERIMENT_ELSEWHERE = "samples/space_project_experiment_elsewhere.xls"; + + private static final String SPACE = "samples/space.xls"; + + private static final String SAMPLE_TYPE = "samples/sample_type.xls"; + + private static final String VOCABULARY_TYPE = "samples/vocab_type.xls"; + + private static final String CHILD_AS_CODE = "samples/child_as_code.xls"; + + private static final String CHILD_AS_DOLLARTAG = "samples/child_as_dollartag.xls"; + + private static final String PARENT_AS_CODE = "samples/parent_as_code.xls"; + + private static final String PARENT_AS_DOLLARTAG = "samples/parent_as_dollartag.xls"; + + private static final String MANDATORY_FIELD_MISSING = "samples/mandatory_field_missing.xls"; + + private static final String NON_MANDATORY_FIELD_MISSING = "samples/non_mandatory_field_missing.xls"; + + private static final String AUTO_GENERATED_SAMPLE_LEVEL = "samples/with_auto_generated_code_sample_level.xls"; + + private static final String AUTO_GENERATED_SAMPLE_TYPE_LEVEL = "samples/with_auto_generated_code_sampletype_level.xls"; + + private static String FILES_DIR; + + private String sessionToken; + + @BeforeClass + public void setupClass() throws IOException + { + String f = ImportSamplesTest.class.getName().replace(".", "/"); + FILES_DIR = f.substring(0, f.length() - ImportSamplesTest.class.getSimpleName().length()) + "/test_files/"; + } + + @BeforeMethod + public void beforeTest() + { + sessionToken = v3api.login(TEST_USER, PASSWORD); + } + + @Test + @DirtiesContext + public void testSamplesAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLES_XLS))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "AAA", "TEST_SPACE"); + // THEN + assertEquals(sample.getCode(), "AAA"); + assertEquals(sample.getProject(), null); + assertEquals(sample.getExperiment().getCode(), "TEST_EXPERIMENT2"); + assertEquals(sample.getSpace().getCode(), "TEST_SPACE"); + } + + @Test + @DirtiesContext + public void testSamplesAreCreatedSecondSample() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLES_XLS))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "VVV", "TEST_SPACE"); + // THEN + assertEquals(sample.getCode(), "VVV"); + assertEquals(sample.getProject(), null); + assertEquals(sample.getExperiment().getCode(), "TEST_EXPERIMENT"); + assertEquals(sample.getSpace().getCode(), "TEST_SPACE"); + } + + @Test + @DirtiesContext + public void testSamplesAreCreatedThirdSample() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLES_XLS))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "S1", "TEST_SPACE"); + // THEN + assertEquals(sample.getCode(), "S1"); + assertEquals(sample.getProject(), null); + assertEquals(sample.getExperiment().getCode(), "TEST_EXPERIMENT"); + assertEquals(sample.getSpace().getCode(), "TEST_SPACE"); + } + + @Test + @DirtiesContext + public void testSamplesAreCreatedWhenSpaceOnServer() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLES_SPACE_ELSEWHERE))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "VVV", "TEST_SPACE"); + // THEN + assertNotNull(sample); + } + + @Test + @DirtiesContext + public void testSamplesAreCreatedWhenSpaceInSeparateXls() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, + Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLES_SPACE_ELSEWHERE)), + Paths.get(FilenameUtils.concat(FILES_DIR, SPACE))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "VVV", "TEST_SPACE"); + // THEN + assertNotNull(sample); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfSpaceDoesntExist() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLES_SPACE_ELSEWHERE))); + } + + @Test + @DirtiesContext + public void testSamplesAreCreatedWhenSampleTypeOnServer() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, + Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARY_TYPE)), + Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPE))); + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLES_SAMPLE_TYPE_ELSWHERE))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "VVV", "TEST_SPACE"); + // THEN + assertNotNull(sample); + } + + @Test + @DirtiesContext + public void testSamplesAreCreatedWhenSampleTypeInSeparateXls() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, + Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLES_SAMPLE_TYPE_ELSWHERE)), + Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLE_TYPE))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "VVV", "TEST_SPACE"); + // THEN + assertNotNull(sample); + } + + @Test + @DirtiesContext + public void testSamplesChildrenAreAssignedWhenAddressedByCodeInXls() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, + Paths.get(FilenameUtils.concat(FILES_DIR, CHILD_AS_CODE))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "VVV", "TEST_SPACE"); + // THEN + assertNotNull(sample); + assertEquals(sample.getChildren().size(), 1); + assertEquals(sample.getChildren().get(0).getCode(), "AAA"); + assertEquals(sample.getChildren().get(0).getSpace().getCode(), "TEST_SPACE"); + assertEquals(sample.getChildren().get(0).getExperiment().getCode(), "TEST_EXPERIMENT2"); + } + + @Test + @DirtiesContext + public void testSamplesParentsAreAssignedWhenAddressedByCodeInXls() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, + Paths.get(FilenameUtils.concat(FILES_DIR, PARENT_AS_CODE))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "VVV", "TEST_SPACE"); + // THEN + assertNotNull(sample); + assertEquals(sample.getParents().size(), 1); + assertEquals(sample.getParents().get(0).getCode(), "AAA"); + assertEquals(sample.getParents().get(0).getSpace().getCode(), "TEST_SPACE"); + assertEquals(sample.getParents().get(0).getExperiment().getCode(), "TEST_EXPERIMENT2"); + } + + @Test + @DirtiesContext + public void testSamplesChildrenAreAssignedWhenAddressedByDollartagInXls() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, + Paths.get(FilenameUtils.concat(FILES_DIR, CHILD_AS_DOLLARTAG))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "VVV", "TEST_SPACE"); + // THEN + assertNotNull(sample); + assertEquals(sample.getChildren().size(), 1); + assertEquals(sample.getChildren().get(0).getCode(), "AAA"); + assertEquals(sample.getChildren().get(0).getSpace().getCode(), "TEST_SPACE"); + assertEquals(sample.getChildren().get(0).getExperiment().getCode(), "TEST_EXPERIMENT2"); + } + + @Test + @DirtiesContext + public void testSamplesParentsAreAssignedWhenAddressedByDollartagInXls() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, + Paths.get(FilenameUtils.concat(FILES_DIR, PARENT_AS_DOLLARTAG))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "VVV", "TEST_SPACE"); + // THEN + assertNotNull(sample); + assertEquals(sample.getParents().size(), 1); + assertEquals(sample.getParents().get(0).getCode(), "AAA"); + assertEquals(sample.getParents().get(0).getSpace().getCode(), "TEST_SPACE"); + assertEquals(sample.getParents().get(0).getExperiment().getCode(), "TEST_EXPERIMENT2"); + } + + @Test + @DirtiesContext + public void testCreatesSampleWithNonMandatoryFieldsMissing() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, + Paths.get(FilenameUtils.concat(FILES_DIR, NON_MANDATORY_FIELD_MISSING))); + // WHEN + Sample sample = TestUtils.getSample(v3api, sessionToken, "AAA", "TEST_SPACE"); + // THEN + assertNotNull(sample); + assertEquals(sample.getProperties().get("FOR_WHAT"), null); + } + + @Test + @DirtiesContext + public void testCreatesSampleWithAutogeneratedCodeWhenOnPerSampleLevel() throws IOException + { + // GIVEN + String result = TestUtils.createFrom(v3api, sessionToken, + Paths.get(FilenameUtils.concat(FILES_DIR, AUTO_GENERATED_SAMPLE_LEVEL))); + String permId = TestUtils.extractSamplePermIdFromResults(result); + // WHEN + Sample sample = TestUtils.getSampleByPermId(v3api, sessionToken, permId); + // THEN + assertNotNull(sample.getCode()); + assertEquals(sample.getType().getCode(), "ANTIBODY"); + } + + @Test + @DirtiesContext + public void testCreatesSampleWithAutogeneratedCodeWhenOnSampleTypeLevel() throws IOException + { + // GIVEN + String result = TestUtils.createFrom(v3api, sessionToken, + Paths.get(FilenameUtils.concat(FILES_DIR, AUTO_GENERATED_SAMPLE_TYPE_LEVEL))); + String permId = TestUtils.extractSamplePermIdFromResults(result); + // WHEN + Sample sample = TestUtils.getSampleByPermId(v3api, sessionToken, permId); + // THEN + assertNotNull(sample); + assertEquals(sample.getType().getCode(), "ANTIBODY"); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfSamplesSpaceProjectDoesntExist() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SAMPLES_SPACE_PROJECT_EXPERIMENT_ELSEWHERE))); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfMandatoryPropertyIsMissing() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, MANDATORY_FIELD_MISSING))); + } + +} diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportSpacesTest.java b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportSpacesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c76bf95b2505429d0711af6453ffebf7dbdd9fc8 --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportSpacesTest.java @@ -0,0 +1,102 @@ +package ch.ethz.sis.openbis.systemtest.plugin.excelimport; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.nio.file.Paths; + +import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.Space; +import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +@ContextConfiguration(locations = "classpath:applicationContext.xml") +@Transactional(transactionManager = "transaction-manager") +@Rollback +public class ImportSpacesTest extends AbstractImportTest +{ + @Autowired + private IApplicationServerInternalApi v3api; + + private static final String TEST_USER = "test"; + + private static final String PASSWORD = "password"; + + private static final String SPACES_XLS = "spaces/normal_spaces.xls"; + + private static final String SPACES_NO_CODE = "spaces/no_code.xls"; + + private static final String SPACES_NO_DESCRIPTION = "spaces/no_desc.xls"; + + private static String FILES_DIR; + + private String sessionToken; + + @BeforeClass + public void setupClass() throws IOException + { + String f = ImportSpacesTest.class.getName().replace(".", "/"); + FILES_DIR = f.substring(0, f.length() - ImportSpacesTest.class.getSimpleName().length()) + "/test_files/"; + } + + @BeforeMethod + public void beforeTest() + { + sessionToken = v3api.login(TEST_USER, PASSWORD); + } + + @Test + @DirtiesContext + public void testNormalSpacesAreCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACES_XLS))); + // WHEN + Space rawData = TestUtils.getSpace(v3api, sessionToken, "TEST_SPACE"); + // THEN + assertEquals(rawData.getCode(), "TEST_SPACE"); + assertEquals(rawData.getDescription(), "TEST"); + } + + @Test + @DirtiesContext + public void testNormalSpacesAreCreatedSecondSpace() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACES_XLS))); + // WHEN + Space space = TestUtils.getSpace(v3api, sessionToken, "TEST_SPACE2"); + // THEN + assertEquals(space.getCode(), "TEST_SPACE2"); + assertEquals(space.getDescription(), "TEST desc"); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfNoSpaceCode() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACES_NO_CODE))); + } + + @Test + @DirtiesContext + public void shouldCreateSpaceWhenNoDescription() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, SPACES_NO_DESCRIPTION))); + // WHEN + Space space = TestUtils.getSpace(v3api, sessionToken, "TEST_SPACE"); + // THEN + assertEquals(space.getCode(), "TEST_SPACE"); + assertEquals(space.getDescription(), null); + } + +} diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportVocabularyTypesTest.java b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportVocabularyTypesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4a8f9088f44b3de91fbf0614bb0d1f088b6556d3 --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/ImportVocabularyTypesTest.java @@ -0,0 +1,205 @@ +/* + * Copyright 2015 ETH Zuerich, SIS + * + * 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.ethz.sis.openbis.systemtest.plugin.excelimport; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; + +import java.io.IOException; +import java.nio.file.Paths; +import java.util.List; + +import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.Vocabulary; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.VocabularyTerm; +import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi; +import ch.systemsx.cisd.common.exceptions.UserFailureException; + +@ContextConfiguration(locations = "classpath:applicationContext.xml") +@Transactional(transactionManager = "transaction-manager") +@Rollback +public class ImportVocabularyTypesTest extends AbstractImportTest +{ + + private static final String VOCABULARIES_TYPES_XLS = "vocabularies/normal_vocab.xls"; + + private static final String VOCABULARIES_NO_CODE = "vocabularies/vocab_no_code.xlsx"; + + private static final String VOCABULARIES_NO_DESCRIPTION = "vocabularies/vocab_no_desc.xlsx"; + + private static final String VOCABULARIES_NO_TERM_CODE = "vocabularies/vocab_no_term_code.xlsx"; + + private static final String VOCABULARIES_NO_TERM_DESCRIPTION = "vocabularies/vocab_no_term_desc.xlsx"; + + private static final String VOCABULARIES_NO_TERM_LABEL = "vocabularies/vocab_no_term_label.xlsx"; + + private static final String VOCABULARIES_NO_TERMS = "vocabularies/vocab_no_term_label.xlsx"; + + @Autowired + private IApplicationServerInternalApi v3api; + + private static final String TEST_USER = "test"; + + private static final String PASSWORD = "password"; + + private static String FILES_DIR; + + private String sessionToken; + + @BeforeClass + public void setupClass() throws IOException + { + String f = ImportVocabularyTypesTest.class.getName().replace(".", "/"); + FILES_DIR = f.substring(0, f.length() - ImportVocabularyTypesTest.class.getSimpleName().length()) + "/test_files/"; + + } + + @BeforeMethod + public void beforeTest() + { + sessionToken = v3api.login(TEST_USER, PASSWORD); + } + + @Test + @DirtiesContext + public void testNormalVocabularyCreationIsCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARIES_TYPES_XLS))); + // WHEN + Vocabulary detection = TestUtils.getVocabulary(v3api, sessionToken, "DETECTION"); + // THEN + assertNotNull(detection); + assertEquals(detection.getDescription(), "Protein detection system"); + } + + @Test + @DirtiesContext + public void testNormalVocabularyHasFirstTermCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARIES_TYPES_XLS))); + // WHEN + Vocabulary detection = TestUtils.getVocabulary(v3api, sessionToken, "DETECTION"); + // THEN + VocabularyTerm term = detection.getTerms().get(0); + assertEquals(term.getCode(), "HRP"); + assertEquals(term.getDescription(), "The antibody is conjugated with the horseradish peroxydase"); + assertEquals(term.getLabel(), "horseradish peroxydase"); + } + + @Test + @DirtiesContext + public void testNormalVocabularyCreatedNoExtraVocabulary() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARIES_TYPES_XLS))); + // WHEN + List<Vocabulary> vocabularies = TestUtils.getAllVocabularies(v3api, sessionToken); + // THEN + assertEquals(vocabularies.size(), 3); // 2 created + 1 default + } + + @Test + @DirtiesContext + public void testNormalVocabularyHasSecondTermCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARIES_TYPES_XLS))); + // WHEN + Vocabulary detection = TestUtils.getVocabulary(v3api, sessionToken, "DETECTION"); + // THEN + VocabularyTerm term = detection.getTerms().get(1); + assertEquals(term.getCode(), "TEST_VOC"); + assertEquals(term.getDescription(), "some focabulary that is used in tests and nothing else"); + assertEquals(term.getLabel(), "vocabulary for tests"); + } + + @Test + @DirtiesContext + public void testVocabularyWithNoTermDescriptionShouldBeCreated() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARIES_NO_TERM_DESCRIPTION))); + // WHEN + Vocabulary detection = TestUtils.getVocabulary(v3api, sessionToken, "DETECTION"); + // THEN + assertNotNull(detection); + assertNull(detection.getTerms().get(0).getDescription()); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfNoVocabularyCode() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARIES_NO_CODE))); + } + + @Test(expectedExceptions = UserFailureException.class) + public void shouldThrowExceptionIfNoTermCode() throws IOException + { + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARIES_NO_TERM_CODE))); + } + + @Test + @DirtiesContext + public void shouldNotThrowExceptionIfNoVocabularyDescription() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARIES_NO_DESCRIPTION))); + // WHEN + Vocabulary detection = TestUtils.getVocabulary(v3api, sessionToken, "DETECTION"); + // THEN + assertNotNull(detection); + assertNull(detection.getDescription()); + } + + @Test + @DirtiesContext + public void shouldNotThrowExceptionIfNoTermLabel() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARIES_NO_TERM_LABEL))); + // WHEN + Vocabulary detection = TestUtils.getVocabulary(v3api, sessionToken, "DETECTION"); + // THEN + assertNotNull(detection); + assertNull(detection.getTerms().get(0).getLabel()); + } + + @Test + @DirtiesContext + public void shouldNotThrowExceptionIfNoTerms() throws IOException + { + // GIVEN + TestUtils.createFrom(v3api, sessionToken, Paths.get(FilenameUtils.concat(FILES_DIR, VOCABULARIES_NO_TERMS))); + // WHEN + Vocabulary detection = TestUtils.getVocabulary(v3api, sessionToken, "DETECTION"); + // THEN + assertNotNull(detection); + } + +} \ No newline at end of file diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/TestUtils.java b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/TestUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..cd10c5cf5514ca8d6935c14eb09f88e47b10f905 --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/TestUtils.java @@ -0,0 +1,366 @@ +package ch.ethz.sis.openbis.systemtest.plugin.excelimport; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; + +import ch.ethz.sis.openbis.generic.asapi.v3.dto.common.search.SearchResult; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.DataSetType; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions.DataSetTypeFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.search.DataSetTypeSearchCriteria; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.Experiment; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.ExperimentType; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.fetchoptions.ExperimentTypeFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.ExperimentIdentifier; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.IExperimentId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.search.ExperimentTypeSearchCriteria; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.project.Project; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.project.fetchoptions.ProjectFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.project.search.ProjectSearchCriteria; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.PropertyType; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.fetchoptions.PropertyAssignmentFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.fetchoptions.PropertyTypeFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.property.search.PropertyTypeSearchCriteria; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.Sample; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.SampleType; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.fetchoptions.SampleFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.fetchoptions.SampleTypeFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.id.ISampleId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.id.SampleIdentifier; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.id.SamplePermId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.search.SampleTypeSearchCriteria; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.CustomASServiceExecutionOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.service.id.CustomASServiceCode; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.Space; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.fetchoptions.SpaceFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.search.SpaceSearchCriteria; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.Vocabulary; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.fetchoptions.VocabularyFetchOptions; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.id.VocabularyPermId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.search.VocabularySearchCriteria; +import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi; + +public class TestUtils +{ + + public static final String XLS_PARAM = "xls"; + + public static final String SCRIPTS_PARAM = "scripts"; + + public static final String XLS_IMPORT_API = "xls-import-api"; + + static Vocabulary getVocabulary(IApplicationServerInternalApi v3api, String sessionToken, String code) + { + VocabularySearchCriteria criteria = new VocabularySearchCriteria(); + criteria.withId().thatEquals(new VocabularyPermId(code)); + + VocabularyFetchOptions fo = new VocabularyFetchOptions(); + fo.withTerms(); + + SearchResult<Vocabulary> result = v3api.searchVocabularies(sessionToken, criteria, fo); + + if (result.getObjects().size() > 0) + { + return result.getObjects().get(0); + } else + { + return null; + } + } + + static List<Vocabulary> getAllVocabularies(IApplicationServerInternalApi v3api, String sessionToken) + { + VocabularySearchCriteria criteria = new VocabularySearchCriteria(); + VocabularyFetchOptions fo = new VocabularyFetchOptions(); + fo.withTerms(); + + SearchResult<Vocabulary> result = v3api.searchVocabularies(sessionToken, criteria, fo); + + if (result.getObjects().size() > 0) + { + return result.getObjects(); + } else + { + return null; + } + } + + static SampleType getSampleType(IApplicationServerInternalApi v3api, String sessionToken, String code) + { + SampleTypeSearchCriteria criteria = new SampleTypeSearchCriteria(); + criteria.withCode().thatEquals(code); + + SampleTypeFetchOptions fo = new SampleTypeFetchOptions(); + fo.withValidationPlugin().withScript(); + PropertyAssignmentFetchOptions propCriteria = fo.withPropertyAssignments(); + propCriteria.withPlugin().withScript(); + propCriteria.withPropertyType().withVocabulary(); + + SearchResult<SampleType> result = v3api.searchSampleTypes(sessionToken, criteria, fo); + + if (result.getObjects().size() > 0) + { + return result.getObjects().get(0); + } else + { + return null; + } + } + + static ExperimentType getExperimentType(IApplicationServerInternalApi v3api, String sessionToken, String code) + { + ExperimentTypeSearchCriteria criteria = new ExperimentTypeSearchCriteria(); + criteria.withCode().thatEquals(code); + + ExperimentTypeFetchOptions fo = new ExperimentTypeFetchOptions(); + fo.withValidationPlugin().withScript(); + PropertyAssignmentFetchOptions propCriteria = fo.withPropertyAssignments(); + propCriteria.withPlugin().withScript(); + propCriteria.withPropertyType().withVocabulary(); + + SearchResult<ExperimentType> result = v3api.searchExperimentTypes(sessionToken, criteria, fo); + + if (result.getObjects().size() > 0) + { + return result.getObjects().get(0); + } else + { + return null; + } + } + + static DataSetType getDatasetType(IApplicationServerInternalApi v3api, String sessionToken, String code) + { + DataSetTypeSearchCriteria criteria = new DataSetTypeSearchCriteria(); + criteria.withCode().thatEquals(code); + + DataSetTypeFetchOptions fo = new DataSetTypeFetchOptions(); + fo.withValidationPlugin().withScript(); + PropertyAssignmentFetchOptions propCriteria = fo.withPropertyAssignments(); + propCriteria.withPlugin().withScript(); + propCriteria.withPropertyType().withVocabulary(); + + SearchResult<DataSetType> result = v3api.searchDataSetTypes(sessionToken, criteria, fo); + + if (result.getObjects().size() > 0) + { + return result.getObjects().get(0); + } else + { + return null; + } + } + + static PropertyType getPropertyType(IApplicationServerInternalApi v3api, String sessionToken, String code) + { + PropertyTypeSearchCriteria criteria = new PropertyTypeSearchCriteria(); + criteria.withCode().thatEquals(code); + + PropertyTypeFetchOptions fo = new PropertyTypeFetchOptions(); + fo.withVocabulary(); + + SearchResult<PropertyType> result = v3api.searchPropertyTypes(sessionToken, criteria, fo); + + if (result.getObjects().size() > 0) + { + return result.getObjects().get(0); + } else + { + return null; + } + } + + static Space getSpace(IApplicationServerInternalApi v3api, String sessionToken, String code) + { + SpaceSearchCriteria criteria = new SpaceSearchCriteria(); + criteria.withCode().thatEquals(code); + + SpaceFetchOptions fo = new SpaceFetchOptions(); + + SearchResult<Space> result = v3api.searchSpaces(sessionToken, criteria, fo); + + if (result.getObjects().size() > 0) + { + return result.getObjects().get(0); + } else + { + return null; + } + } + + static Project getProject(IApplicationServerInternalApi v3api, String sessionToken, String code) + { + ProjectSearchCriteria criteria = new ProjectSearchCriteria(); + criteria.withCode().thatEquals(code); + + ProjectFetchOptions fo = new ProjectFetchOptions(); + fo.withSpace(); + + SearchResult<Project> result = v3api.searchProjects(sessionToken, criteria, fo); + + if (result.getObjects().size() > 0) + { + return result.getObjects().get(0); + } else + { + return null; + } + } + + static Experiment getExperiment(IApplicationServerInternalApi v3api, String sessionToken, String experimentCode, String projectCode, + String spaceCode) + { + List<IExperimentId> ids = new ArrayList<>(); + ids.add(new ExperimentIdentifier(spaceCode, projectCode, experimentCode)); + + ExperimentFetchOptions fo = new ExperimentFetchOptions(); + fo.withProject(); + fo.withProperties(); + fo.withType(); + + List<Experiment> result = v3api.getExperiments(sessionToken, ids, fo).values().stream().collect(Collectors.toList()); + + if (result.size() > 0) + { + return result.get(0); + } else + { + return null; + } + } + + static Sample getSample(IApplicationServerInternalApi v3api, String sessionToken, String sampleCode, String spaceCode) + { + List<ISampleId> ids = new ArrayList<>(); + ids.add(new SampleIdentifier(spaceCode, null, null, sampleCode)); + + return getSamples(v3api, sessionToken, ids); + } + + static Sample getSampleByPermId(IApplicationServerInternalApi v3api, String sessionToken, String permId) + { + List<ISampleId> ids = new ArrayList<>(); + ids.add(new SamplePermId(permId)); + + return getSamples(v3api, sessionToken, ids); + } + + private static Sample getSamples(IApplicationServerInternalApi v3api, String sessionToken, List<ISampleId> ids) + { + SampleFetchOptions fo = new SampleFetchOptions(); + SampleFetchOptions childrenFo = fo.withChildren(); + childrenFo.withSpace(); + childrenFo.withExperiment(); + SampleFetchOptions parentsFo = fo.withParents(); + parentsFo.withSpace(); + parentsFo.withExperiment(); + fo.withExperiment(); + fo.withProject(); + fo.withProperties(); + fo.withSpace(); + fo.withType(); + + List<Sample> result = v3api.getSamples(sessionToken, ids, fo).values().stream().collect(Collectors.toList()); + + if (result.size() > 0) + { + return result.get(0); + } else + { + return null; + } + } + + static String createFrom(IApplicationServerInternalApi v3api, String sessionToken, Path... xls_paths) throws IOException + { + List<byte[]> excels = new ArrayList<>(); + for (Path xls_path : xls_paths) + { + byte[] xls = readData(xls_path); + excels.add(xls); + } + CustomASServiceExecutionOptions options = new CustomASServiceExecutionOptions(); + options.withParameter(XLS_PARAM, excels); + return (String) v3api.executeCustomASService(sessionToken, new CustomASServiceCode(XLS_IMPORT_API), options); + } + + static String createFrom(IApplicationServerInternalApi v3api, String sessionToken, Map<String, String> scripts, Path... xls_paths) + throws IOException + { + List<byte[]> excels = new ArrayList<>(); + for (Path xls_path : xls_paths) + { + byte[] xls = readData(xls_path); + excels.add(xls); + } + CustomASServiceExecutionOptions options = new CustomASServiceExecutionOptions(); + options.withParameter(XLS_PARAM, excels); + options.withParameter(SCRIPTS_PARAM, scripts); + return (String) v3api.executeCustomASService(sessionToken, new CustomASServiceCode(XLS_IMPORT_API), options); + } + + static String getValidationScript() + { + return "def validate(entity, isNew):\n if isNew:\n return"; + } + + static String getDynamicScript() + { + return "def calculate():\n return 1"; + } + + static Map<String, String> getValidationPluginMap() + { + String dynamicScriptString = getValidationScript(); + Map<String, String> scriptsMap = new HashMap<>(); + scriptsMap.put("valid.py", dynamicScriptString); + + return scriptsMap; + } + + static Map<String, String> getDynamicPluginMap() + { + String dynamicScriptString = getDynamicScript(); + Map<String, String> scriptsMap = new HashMap<>(); + scriptsMap.put("dynamic/dynamic.py", dynamicScriptString); + + return scriptsMap; + } + + static String extractSamplePermIdFromResults(String result) + { + // Note this will work only if we created single sample!! + String permId = result.substring(result.indexOf("CreateSamplesOperationResult") + "CreateSamplesOperationResult".length()); + permId = StringUtils.strip(permId, "[]"); + return permId; + } + + private static byte[] readData(Path xls_path) throws IOException + { + String path = xls_path.toString(); + InputStream resourceAsStream = TestUtils.class.getClassLoader().getResourceAsStream(path); + try + { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + IOUtils.copy(resourceAsStream, byteArrayOutputStream); + return byteArrayOutputStream.toByteArray(); + } finally + { + if (resourceAsStream != null) + { + resourceAsStream.close(); + } + } + } + +} diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/no_code.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/no_code.xls new file mode 100644 index 0000000000000000000000000000000000000000..d54b992af7d5ef3497b591b71b0a937aeecee4c6 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/no_code.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/no_properties.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/no_properties.xls new file mode 100644 index 0000000000000000000000000000000000000000..5a4648215981dec891c3791194051c2e247ddbfd Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/no_properties.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/normal_dataset.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/normal_dataset.xls new file mode 100644 index 0000000000000000000000000000000000000000..d72039c8ae394e9954c07af64559e7d34a812961 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/normal_dataset.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/with_validation.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/with_validation.xls new file mode 100644 index 0000000000000000000000000000000000000000..cdee2cb18599a074ff8c34a4666c7a46027d080c Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/dataset_types/with_validation.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiment_types/no_code.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiment_types/no_code.xls new file mode 100644 index 0000000000000000000000000000000000000000..bcae94a211270a70536fbeb0c0128e35813f4d76 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiment_types/no_code.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiment_types/normal_experiment.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiment_types/normal_experiment.xls new file mode 100644 index 0000000000000000000000000000000000000000..d3c3dda61bd16fa12d7ab9bbaf65cba6ba70caa2 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiment_types/normal_experiment.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiment_types/with_validation_script.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiment_types/with_validation_script.xls new file mode 100644 index 0000000000000000000000000000000000000000..20daeadf5af7c7a35d34185b165cb95a6decfc23 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiment_types/with_validation_script.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/all_elsewhere.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/all_elsewhere.xls new file mode 100644 index 0000000000000000000000000000000000000000..fa502e8210ac48b660a275973dd373cabdbc351a Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/all_elsewhere.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/all_inside.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/all_inside.xls new file mode 100644 index 0000000000000000000000000000000000000000..48fe7da35a0f258b912a5449d61a69dab46ebc64 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/all_inside.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/experiment_type.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/experiment_type.xls new file mode 100644 index 0000000000000000000000000000000000000000..79d7b595f514ef121fb09f982c5e9ec1f50efe05 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/experiment_type.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/experiment_type_elsewhere.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/experiment_type_elsewhere.xls new file mode 100644 index 0000000000000000000000000000000000000000..5b5939c6d0491056bdd0f551c2df7bbade805f1c Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/experiment_type_elsewhere.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/no_code.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/no_code.xls new file mode 100644 index 0000000000000000000000000000000000000000..e768de099fb1028c3c631e60384f6a6037d2075d Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/no_code.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/no_non_mandatory_property.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/no_non_mandatory_property.xls new file mode 100644 index 0000000000000000000000000000000000000000..f6f9c73a5872c901a041afe139ca6097153a81e8 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/no_non_mandatory_property.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/no_project.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/no_project.xls new file mode 100644 index 0000000000000000000000000000000000000000..b10a360b48af59ead2b011f4697a55e325679f64 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/no_project.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/project.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/project.xls new file mode 100644 index 0000000000000000000000000000000000000000..22fe9892d7d761ca40f1007c3ad4d257c1eedf6e Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/project.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/space.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/space.xls new file mode 100644 index 0000000000000000000000000000000000000000..f38abaf801838e24b49534c7e95ec11d69a5733d Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/space.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/space_and_project_elsewhere.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/space_and_project_elsewhere.xls new file mode 100644 index 0000000000000000000000000000000000000000..662154538b1d733036d6d7ae60cc5e6948175f7a Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/space_and_project_elsewhere.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/space_elsewhere.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/space_elsewhere.xls new file mode 100644 index 0000000000000000000000000000000000000000..002041a89a52c99a4b3334778eca0e2e715a317d Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/space_elsewhere.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/type_and_space_elsewhere.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/type_and_space_elsewhere.xls new file mode 100644 index 0000000000000000000000000000000000000000..ca53bd70919b60029dcf4876ff0a65571c3f9224 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/type_and_space_elsewhere.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_mandatory_property.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_mandatory_property.xls new file mode 100644 index 0000000000000000000000000000000000000000..bb9a38e731caee28ea3164d7735da5a8c3aee1fc Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_mandatory_property.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_mandatory_property_missing.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_mandatory_property_missing.xls new file mode 100644 index 0000000000000000000000000000000000000000..2232c73fd30a0d85ffb21a4146f818f333fa6989 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_mandatory_property_missing.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_properties_as_labels.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_properties_as_labels.xls new file mode 100644 index 0000000000000000000000000000000000000000..2cd522d4a96d4eda75587ba4878e561e26fe5085 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_properties_as_labels.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_properties_as_labels_type_elsewhere.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_properties_as_labels_type_elsewhere.xls new file mode 100644 index 0000000000000000000000000000000000000000..05a162bffb0ed5d4a768e0414d1b5c7c64a3c860 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/experiments/with_properties_as_labels_type_elsewhere.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/full/scripts/dynamic/dynamic.py b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/full/scripts/dynamic/dynamic.py new file mode 100644 index 0000000000000000000000000000000000000000..187583711b0b2d81f1ad5525763cae8d23561239 --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/full/scripts/dynamic/dynamic.py @@ -0,0 +1,2 @@ +def calculate(): + return 1 \ No newline at end of file diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/full/scripts/valid.py b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/full/scripts/valid.py new file mode 100644 index 0000000000000000000000000000000000000000..d87950f600d11b50b96dcedef36fe8f36971140c --- /dev/null +++ b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/full/scripts/valid.py @@ -0,0 +1,3 @@ +def validate(entity, isNew): + if isNew: + return \ No newline at end of file diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/full/types.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/full/types.xls new file mode 100644 index 0000000000000000000000000000000000000000..c29c0e6d2f1c6586b770f3e6e2d5291784c9bbb6 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/full/types.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/no_code.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/no_code.xls new file mode 100644 index 0000000000000000000000000000000000000000..40565df30dd0a1cbab6b9fd1bf8e98cc37d98713 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/no_code.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/no_desc.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/no_desc.xls new file mode 100644 index 0000000000000000000000000000000000000000..256aff470a2c0e67bf6e8ca7c0574b57bfd9384a Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/no_desc.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/no_space.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/no_space.xls new file mode 100644 index 0000000000000000000000000000000000000000..be1a6f5b673089c4d40f17c3f79ed055202e3736 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/no_space.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/spaces.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/spaces.xls new file mode 100644 index 0000000000000000000000000000000000000000..ee521c4efcf08b1f3263ffbf239d07a1f784ab2b Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/spaces.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/with_spaces.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/with_spaces.xls new file mode 100644 index 0000000000000000000000000000000000000000..124040d0a40c49d88cec4de77dab2616c88e355f Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/with_spaces.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/with_spaces_on_server.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/with_spaces_on_server.xls new file mode 100644 index 0000000000000000000000000000000000000000..c372754c23f24f7491ca9e20132dd151d05a881f Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/projects/with_spaces_on_server.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_code.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_code.xls new file mode 100644 index 0000000000000000000000000000000000000000..0495c967c5583cdd003fa7db0d9e03bd3ac53660 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_code.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_data_type.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_data_type.xls new file mode 100644 index 0000000000000000000000000000000000000000..ea8c86ae63ab1cd00c3925c7ad483bad33f98918 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_data_type.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_desc.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_desc.xls new file mode 100644 index 0000000000000000000000000000000000000000..a93f2d1d00f5c469c84e476b82264e5f35b7df95 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_desc.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_label.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_label.xls new file mode 100644 index 0000000000000000000000000000000000000000..2920993c13829a6ef699a562d4d1df250ae36226 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_label.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_vocab_code.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_vocab_code.xls new file mode 100644 index 0000000000000000000000000000000000000000..30f6effc706cf7eaa62952b3477469eedfda1a36 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/no_vocab_code.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/normal_property_type.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/normal_property_type.xls new file mode 100644 index 0000000000000000000000000000000000000000..b60b0d1af6c8bcc493e04f7ab025c2f30bcba1b4 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/normal_property_type.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/vocabcode_when_not_vocabtype.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/vocabcode_when_not_vocabtype.xls new file mode 100644 index 0000000000000000000000000000000000000000..07b06775fb363a9c78ca6845927f0ce4d1baf16e Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/vocabcode_when_not_vocabtype.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/vocabulary_detection.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/vocabulary_detection.xls new file mode 100644 index 0000000000000000000000000000000000000000..9dbed1010de4ae51769dcd5dc3f427bbcda4cc50 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/vocabulary_detection.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/with_vocab.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/with_vocab.xls new file mode 100644 index 0000000000000000000000000000000000000000..c11888fc27960ed5f93d193e2d8e5c4e50e398e7 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/with_vocab.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/with_vocab_on_server.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/with_vocab_on_server.xls new file mode 100644 index 0000000000000000000000000000000000000000..97378724a33e3c75a66a7e7b98343673fdd57991 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/property_types/with_vocab_on_server.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/no_code.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/no_code.xls new file mode 100644 index 0000000000000000000000000000000000000000..a20c2669d8420cc4f14dd1e7f570d97344fd8a0c Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/no_code.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/normal_samples.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/normal_samples.xls new file mode 100644 index 0000000000000000000000000000000000000000..26f1ce1b3d41182ad5ee0b16def5a35afd8ced4a Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/normal_samples.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/normal_samples_v2.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/normal_samples_v2.xls new file mode 100644 index 0000000000000000000000000000000000000000..9ca2cccef1e90d0d169369dcb19e04e8a9584685 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/normal_samples_v2.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/vocabulary_detection.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/vocabulary_detection.xls new file mode 100644 index 0000000000000000000000000000000000000000..778cead50ffb0439af049dfeed92324f4c52acd0 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/vocabulary_detection.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_auto_generated_codes.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_auto_generated_codes.xls new file mode 100644 index 0000000000000000000000000000000000000000..53fa161043a304cc4b506dadc5cfdf6d61d88946 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_auto_generated_codes.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_dynamic_script.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_dynamic_script.xls new file mode 100644 index 0000000000000000000000000000000000000000..f6dbb88115880f4ff23e23dec6bb325db9b97573 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_dynamic_script.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_validation_script.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_validation_script.xls new file mode 100644 index 0000000000000000000000000000000000000000..745fab798e0d9a94093918215080479a6a05e4ac Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_validation_script.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_vocabulary_in_xls.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_vocabulary_in_xls.xls new file mode 100644 index 0000000000000000000000000000000000000000..513d56b4c83351e59f7a8de2a68cd54e80d1440e Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_vocabulary_in_xls.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_vocabulary_on_server.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_vocabulary_on_server.xls new file mode 100644 index 0000000000000000000000000000000000000000..e8c32928586b43ab4803e601408e4eb45812fb5e Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/sample_types/with_vocabulary_on_server.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/all_elsewhere.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/all_elsewhere.xls new file mode 100644 index 0000000000000000000000000000000000000000..4749694789683c3bc418946c887fd6671f9aa1f1 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/all_elsewhere.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/all_in.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/all_in.xls new file mode 100644 index 0000000000000000000000000000000000000000..dd6d161dee473e898ceb5a6e6bf0c54127cb3cb9 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/all_in.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/child_as_code.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/child_as_code.xls new file mode 100644 index 0000000000000000000000000000000000000000..86310e82f98edb136517f67e5059f4d04eefe25c Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/child_as_code.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/child_as_dollartag.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/child_as_dollartag.xls new file mode 100644 index 0000000000000000000000000000000000000000..bf0460d53939ddbbf2977398336f22fee53188d3 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/child_as_dollartag.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/experiment.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/experiment.xls new file mode 100644 index 0000000000000000000000000000000000000000..c9ab2810593b69711331702f3e2c081581b8db4e Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/experiment.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/experiment_type.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/experiment_type.xls new file mode 100644 index 0000000000000000000000000000000000000000..90d5b40a5dc26d4c7861e4027493d63056f0d1c7 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/experiment_type.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/mandatory_field_missing.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/mandatory_field_missing.xls new file mode 100644 index 0000000000000000000000000000000000000000..68c815bd31b7cebaf063f6edba675c10089e2a3f Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/mandatory_field_missing.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/non_mandatory_field_missing.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/non_mandatory_field_missing.xls new file mode 100644 index 0000000000000000000000000000000000000000..b4304796f0a7f970e34b90257498586ea06cd4c5 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/non_mandatory_field_missing.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/parent_as_code.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/parent_as_code.xls new file mode 100644 index 0000000000000000000000000000000000000000..df1496108946d62bc7cf40f013ed1202e612487e Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/parent_as_code.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/parent_as_dollartag.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/parent_as_dollartag.xls new file mode 100644 index 0000000000000000000000000000000000000000..84eddade405ea5e2730193575dcad653fbe9aa8f Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/parent_as_dollartag.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/project.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/project.xls new file mode 100644 index 0000000000000000000000000000000000000000..8a075fdf2f6f5907ebc85b2e42fadd5d2c89f402 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/project.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/sample_type.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/sample_type.xls new file mode 100644 index 0000000000000000000000000000000000000000..191b054327cd829c1b497f5492c02fbcb6748811 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/sample_type.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/sample_type_elsewhere.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/sample_type_elsewhere.xls new file mode 100644 index 0000000000000000000000000000000000000000..cae6691312385b98caa13d04e59a18f8ef0b5350 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/sample_type_elsewhere.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/space.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/space.xls new file mode 100644 index 0000000000000000000000000000000000000000..7184089ea5a51ad491f02f3940e0bb33c3f2eceb Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/space.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/space_elsewhere.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/space_elsewhere.xls new file mode 100644 index 0000000000000000000000000000000000000000..684cfcf3e39a832f8176340492c62e97ee867d78 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/space_elsewhere.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/space_project_experiment_elsewhere.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/space_project_experiment_elsewhere.xls new file mode 100644 index 0000000000000000000000000000000000000000..174b541bb4a23cf4dac1dc2a987577974f2216e6 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/space_project_experiment_elsewhere.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/vocab_type.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/vocab_type.xls new file mode 100644 index 0000000000000000000000000000000000000000..2798f91d6081a200fa1521726e8f466b37d23e26 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/vocab_type.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/vocab_type_elsewhere.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/vocab_type_elsewhere.xls new file mode 100644 index 0000000000000000000000000000000000000000..4deec4455c64c7895f2864a6667ca3199b40a326 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/vocab_type_elsewhere.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_ambiguous_code.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_ambiguous_code.xls new file mode 100644 index 0000000000000000000000000000000000000000..56c21ac4eb5641ff8eaad5dd6db6e88e0714c1bb Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_ambiguous_code.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_ambiguous_code_but_with$.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_ambiguous_code_but_with$.xls new file mode 100644 index 0000000000000000000000000000000000000000..744ae3ea4b84432acbd15f1a7e5aadac5c906a11 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_ambiguous_code_but_with$.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_auto_generated_code_sample_level.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_auto_generated_code_sample_level.xls new file mode 100644 index 0000000000000000000000000000000000000000..abf26b6a42a6ed8d54b035b15c6a17124e701d63 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_auto_generated_code_sample_level.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_auto_generated_code_sampletype_level.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_auto_generated_code_sampletype_level.xls new file mode 100644 index 0000000000000000000000000000000000000000..4cbb931ed0b6e5e9d53c8b590a5d7a617ca72640 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_auto_generated_code_sampletype_level.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_no_such_child.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_no_such_child.xls new file mode 100644 index 0000000000000000000000000000000000000000..71c45c3e02b29a2cab48e9234eaad90ab5fe20b6 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_no_such_child.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_no_such_parent.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_no_such_parent.xls new file mode 100644 index 0000000000000000000000000000000000000000..a63d1b6c4e297640462f3c241d2bd900843f84b2 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/samples/with_no_such_parent.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/spaces/no_code.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/spaces/no_code.xls new file mode 100644 index 0000000000000000000000000000000000000000..66b359e91807e8236803f18014f10d6065b2a41f Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/spaces/no_code.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/spaces/no_desc.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/spaces/no_desc.xls new file mode 100644 index 0000000000000000000000000000000000000000..bd91bf15e2faa913d5ba3585a2e2038795e577b9 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/spaces/no_desc.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/spaces/normal_spaces.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/spaces/normal_spaces.xls new file mode 100644 index 0000000000000000000000000000000000000000..13967a518d6a7491eac13ef97c2e23f603e7a738 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/spaces/normal_spaces.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/normal_vocab.xls b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/normal_vocab.xls new file mode 100644 index 0000000000000000000000000000000000000000..1012b0c10cbb0b0a2126c01bc9e51634840bb300 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/normal_vocab.xls differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_code.xlsx b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_code.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..327e9952a7cc9b025bb491abb3faf88c9b28fcc2 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_code.xlsx differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_desc.xlsx b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_desc.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..63cbf942b4efa579282c864e0ad1ae76b120c050 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_desc.xlsx differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_term_code.xlsx b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_term_code.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..78d4d0ce9a6fee95cc7686ef661d0627926ddd8b Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_term_code.xlsx differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_term_desc.xlsx b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_term_desc.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..2237ea8613c1a7e1a61268704b3ad320aa40cc63 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_term_desc.xlsx differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_term_label.xlsx b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_term_label.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..db47fe26e67e19819b649ee6b27cdfc9b91c2e00 Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_term_label.xlsx differ diff --git a/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_terms.xlsx b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_terms.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..0fa1b978f1ca7eae53c5d2108de04333e6d3dc3e Binary files /dev/null and b/openbis_standard_technologies/sourceTest/java/ch/ethz/sis/openbis/systemtest/plugin/excelimport/test_files/vocabularies/vocab_no_terms.xlsx differ diff --git a/openbis_standard_technologies/sourceTest/java/tests.xml b/openbis_standard_technologies/sourceTest/java/tests.xml index 63c73169b0852cdd4fb77366cccf07c26ba3b6e0..a198fbcfdb1da92cb07df9f7fcc71c7bf4b604f4 100644 --- a/openbis_standard_technologies/sourceTest/java/tests.xml +++ b/openbis_standard_technologies/sourceTest/java/tests.xml @@ -1,11 +1,12 @@ -<suite name="All" verbose="2" > - <test name="All" annotations="JDK"> - <groups> - <run> - <exclude name="broken" /> - </run> - </groups> - <packages> - </packages> - </test> +<suite name="All" verbose="2"> + <test name="All" annotations="JDK"> + <groups> + <run> + <exclude name="broken" /> + </run> + </groups> + <packages> + <package name="ch.ethz.sis.openbis.systemtest.plugin.*" /> + </packages> + </test> </suite>