diff --git a/bds/source/java/ch/systemsx/cisd/bds/DataSet.java b/bds/source/java/ch/systemsx/cisd/bds/DataSet.java index 5f61879ea11f3870b2bdcf6044702abbaa01df7e..f0e3055812ef18b9c91c8e5001bc3a8ba596ac23 100644 --- a/bds/source/java/ch/systemsx/cisd/bds/DataSet.java +++ b/bds/source/java/ch/systemsx/cisd/bds/DataSet.java @@ -33,8 +33,11 @@ import ch.systemsx.cisd.common.collections.CollectionIO; */ public final class DataSet implements IStorable { - static final String NO_PARENT_FOR_DERIVED_DATA_ASSERTION = - "No parent can be specified for derived data."; + static final String NO_PARENT_FOR_MEASURED_DATA = + "No parent could be specified for measured data."; + + static final String PARENT_FOR_DERIVED_DATA = + "At least one parent must be specified for derived data."; static final String FOLDER = "data_set"; @@ -104,11 +107,17 @@ public final class DataSet implements IStorable this.observableTypeCode = observableType; if (isMeasured == false) { - assert parentCodesOrNull != null && parentCodesOrNull.size() > 0 : "Unspecified parent codes."; + if (parentCodesOrNull == null || parentCodesOrNull.size() == 0) + { + throw new IllegalArgumentException(PARENT_FOR_DERIVED_DATA); + } this.parentCodes = parentCodesOrNull; } else { - assert parentCodesOrNull == null || parentCodesOrNull.size() == 0 : NO_PARENT_FOR_DERIVED_DATA_ASSERTION; + if (parentCodesOrNull != null && parentCodesOrNull.size() > 0) + { + throw new IllegalArgumentException(String.format(NO_PARENT_FOR_MEASURED_DATA)); + } this.parentCodes = Collections.<String> emptyList(); } this.producerCode = producerCodeOrNull; diff --git a/bds/sourceTest/java/ch/systemsx/cisd/bds/DataSetFileSystemTestCase.java b/bds/sourceTest/java/ch/systemsx/cisd/bds/DataSetFileSystemTestCase.java index 1542ee2bd32dfdae9ac376874da5441dda395e9e..d246a3cfeb4b3ace8f797c1da7d3bde32528c7f5 100644 --- a/bds/sourceTest/java/ch/systemsx/cisd/bds/DataSetFileSystemTestCase.java +++ b/bds/sourceTest/java/ch/systemsx/cisd/bds/DataSetFileSystemTestCase.java @@ -98,10 +98,10 @@ public final class DataSetFileSystemTestCase extends AbstractFileSystemTestCase try { new DataSet(dataSetCode, observableType, true, null, null, parentCodes); - fail(DataSet.NO_PARENT_FOR_DERIVED_DATA_ASSERTION); - } catch (final AssertionError ex) + fail(DataSet.NO_PARENT_FOR_MEASURED_DATA); + } catch (final IllegalArgumentException ex) { - assertEquals(DataSet.NO_PARENT_FOR_DERIVED_DATA_ASSERTION, ex.getMessage()); + assertEquals(DataSet.NO_PARENT_FOR_MEASURED_DATA, ex.getMessage()); } final DataSet dataSet = new DataSet(dataSetCode, observableType, false, null, null, parentCodes);