Skip to content
Snippets Groups Projects
Commit 31b2e901 authored by felmer's avatar felmer
Browse files

SSDM-4912: UpdateLinkDataSetTest.removeAllCopies() added. Bug in...

SSDM-4912: UpdateLinkDataSetTest.removeAllCopies() added. Bug in UpdateDataSetLinkedDataExecutor (revealed by the added test) fixed

SVN: 37924
parent fb437624
No related branches found
No related tags found
No related merge requests found
...@@ -114,18 +114,7 @@ public class UpdateDataSetLinkedDataExecutor implements IUpdateDataSetLinkedData ...@@ -114,18 +114,7 @@ public class UpdateDataSetLinkedDataExecutor implements IUpdateDataSetLinkedData
} }
} }
outer: for (IContentCopyId iid : update.getContentCopies().getRemoved()) assertAllRemovalsExists(entity, update);
{
ContentCopyPermId id = (ContentCopyPermId) iid;
for (ContentCopyPE cc : entity.getContentCopies())
{
if (id.getPermId().equals(cc.getId().toString()))
{
continue outer;
}
throw new UserFailureException("Trying to remove non-existing content copy " + id.getPermId());
}
}
entity.getContentCopies().removeAll(remove); entity.getContentCopies().removeAll(remove);
for (ContentCopyPE cc : remove) for (ContentCopyPE cc : remove)
...@@ -136,4 +125,20 @@ public class UpdateDataSetLinkedDataExecutor implements IUpdateDataSetLinkedData ...@@ -136,4 +125,20 @@ public class UpdateDataSetLinkedDataExecutor implements IUpdateDataSetLinkedData
addContentCopiesToLinkedDataExecutor.add(context, entity, update.getContentCopies().getAdded()); addContentCopiesToLinkedDataExecutor.add(context, entity, update.getContentCopies().getAdded());
} }
} }
private void assertAllRemovalsExists(LinkDataPE entity, LinkedDataUpdate update)
{
outer: for (IContentCopyId iid : update.getContentCopies().getRemoved())
{
ContentCopyPermId id = (ContentCopyPermId) iid;
for (ContentCopyPE cc : entity.getContentCopies())
{
if (id.getPermId().equals(cc.getId().toString()))
{
continue outer;
}
}
throw new UserFailureException("Trying to remove non-existing content copy " + id.getPermId());
}
}
} }
...@@ -384,6 +384,7 @@ public abstract class AbstractLinkDataSetTest extends AbstractExternalDmsTest ...@@ -384,6 +384,7 @@ public abstract class AbstractLinkDataSetTest extends AbstractExternalDmsTest
{ ExternalDmsAddressType.FILE_SYSTEM, null, null, null }, { ExternalDmsAddressType.FILE_SYSTEM, null, null, null },
{ ExternalDmsAddressType.FILE_SYSTEM, "code", null, null }, { ExternalDmsAddressType.FILE_SYSTEM, "code", null, null },
{ ExternalDmsAddressType.FILE_SYSTEM, "code", "/path", null },
{ ExternalDmsAddressType.FILE_SYSTEM, "code", "/path", "hash" }, { ExternalDmsAddressType.FILE_SYSTEM, "code", "/path", "hash" },
{ ExternalDmsAddressType.FILE_SYSTEM, "code", null, "hash" }, { ExternalDmsAddressType.FILE_SYSTEM, "code", null, "hash" },
{ ExternalDmsAddressType.FILE_SYSTEM, null, null, "hash" } { ExternalDmsAddressType.FILE_SYSTEM, null, null, "hash" }
......
...@@ -127,6 +127,19 @@ public class UpdateLinkDataSetTest extends AbstractLinkDataSetTest ...@@ -127,6 +127,19 @@ public class UpdateLinkDataSetTest extends AbstractLinkDataSetTest
ContentCopyPermId ccid = new ContentCopyPermId(uuid()); ContentCopyPermId ccid = new ContentCopyPermId(uuid());
update(dataset(id).without(ccid)); update(dataset(id).without(ccid));
} }
@Test
void removeAllCopies()
{
ExternalDmsPermId dms = create(externalDms());
DataSetPermId id = create(linkDataSet().with(copyAt(dms)).with(copyAt(dms)));
List<ContentCopy> contentCopies = get(id).getLinkedData().getContentCopies();
update(dataset(id).without(contentCopies.get(0).getId(), contentCopies.get(1).getId()));
DataSet dataset = get(id);
assertThat(dataset.getLinkedData().getContentCopies().size(), is(0));
}
@Test @Test
void legacyExternalCodeCanBeSetOnSingleCopyOpenBISDms() void legacyExternalCodeCanBeSetOnSingleCopyOpenBISDms()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment