From b81016e9fcae886f516a18ad72c75e332827c36f Mon Sep 17 00:00:00 2001 From: Yves Noirjean <yves.noirjean@id.ethz.ch> Date: Tue, 10 Apr 2018 11:24:18 +0200 Subject: [PATCH] SSDM-5259: added test --- .../systemtest/asapi/v3/GetDataSetTest.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetDataSetTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetDataSetTest.java index c2d2af5454e..744ba27a4c2 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetDataSetTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/GetDataSetTest.java @@ -38,6 +38,9 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.LinkedData; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.LocatorType; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.PhysicalData; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.StorageFormat; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.create.ContentCopyCreation; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.create.DataSetCreation; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.create.LinkedDataCreation; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions.DataSetFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions.LinkedDataFetchOptions; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions.PhysicalDataFetchOptions; @@ -45,8 +48,13 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.history.DataSetRelationT import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.DataSetPermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id.IDataSetId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.update.DataSetUpdate; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.update.LinkedDataUpdate; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.datastore.id.DataStorePermId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.entitytype.id.EntityTypePermId; import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.ExperimentIdentifier; import ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id.ExperimentPermId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.externaldms.id.ExternalDmsPermId; +import ch.ethz.sis.openbis.generic.asapi.v3.dto.history.ContentCopyHistoryEntry; import ch.ethz.sis.openbis.generic.asapi.v3.dto.history.HistoryEntry; import ch.ethz.sis.openbis.generic.asapi.v3.dto.history.PropertyHistoryEntry; import ch.ethz.sis.openbis.generic.asapi.v3.dto.history.RelationHistoryEntry; @@ -888,6 +896,66 @@ public class GetDataSetTest extends AbstractDataSetTest v3api.logout(sessionToken); } + @Test + public void testGetWithHistoryContentCopy() + { + String sessionToken = v3api.login(TEST_USER, PASSWORD); + + // given - data set with content copy + DataSetCreation dataSetCreation = new DataSetCreation(); + LinkedDataCreation linkedData = new LinkedDataCreation(); + ContentCopyCreation contentCopyCreation = new ContentCopyCreation(); + contentCopyCreation.setExternalDmsId(new ExternalDmsPermId("DMS_3")); + contentCopyCreation.setPath("/path"); + contentCopyCreation.setGitCommitHash("0"); + contentCopyCreation.setGitRepositoryId("0"); + linkedData.setContentCopies(Arrays.asList(contentCopyCreation)); + dataSetCreation.setCode("testGetWithHistoryContentCopy-01"); + dataSetCreation.setLinkedData(linkedData); + dataSetCreation.setDataSetKind(DataSetKind.LINK); + dataSetCreation.setTypeId(new EntityTypePermId("UNKNOWN")); + dataSetCreation.setSampleId(new SampleIdentifier("//CL1:A01")); + dataSetCreation.setDataStoreId(new DataStorePermId("STANDARD")); + + List<DataSetPermId> dataSetIds = v3api.createDataSets(sessionToken, Arrays.asList(dataSetCreation)); + assertEquals(dataSetIds.size(), 1); + + DataSetFetchOptions fetchOptions = new DataSetFetchOptions(); + fetchOptions.withHistory(); + fetchOptions.withLinkedData(); + + IDataSetId id = dataSetIds.get(0); + + Map<IDataSetId, DataSet> map = v3api.getDataSets(sessionToken, Arrays.asList(id), fetchOptions); + DataSet dataSet = map.get(id); + + assertEquals(dataSet.getHistory().size(), 0); + assertEquals(dataSet.getLinkedData().getContentCopies().size(), 1); + + // when - remove content copy + DataSetUpdate update = new DataSetUpdate(); + update.setDataSetId(id); + + LinkedDataUpdate linkedDataUpdate = new LinkedDataUpdate(); + linkedDataUpdate.getContentCopies().remove(dataSet.getLinkedData().getContentCopies().get(0).getId()); + + update.setLinkedData(linkedDataUpdate); + + v3api.updateDataSets(sessionToken, Arrays.asList(update)); + + // then - content copy is in history + map = v3api.getDataSets(sessionToken, Arrays.asList(id), fetchOptions); + dataSet = map.get(id); + + assertEquals(dataSet.getHistory().size(), 1); + assertEquals(dataSet.getLinkedData().getContentCopies().size(), 0); + ContentCopyHistoryEntry historyEntry = (ContentCopyHistoryEntry) dataSet.getHistory().get(0); + assertEquals(historyEntry.getPath(), contentCopyCreation.getPath()); + assertEquals(historyEntry.getGitCommitHash(), contentCopyCreation.getGitCommitHash()); + + v3api.logout(sessionToken); + } + @Test public void testGetWithHistoryExperiment() { -- GitLab