mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +00:00
Adds check for whether source and target collections are the same when moving an item. (#8055)
This commit is contained in:
@@ -19,6 +19,8 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.File;
|
||||
@@ -41,6 +43,7 @@ import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamFormatService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
import org.dspace.content.service.MetadataSchemaService;
|
||||
import org.dspace.core.Constants;
|
||||
@@ -1410,6 +1413,27 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
assertThat("testMove 1", it.getOwningCollection(), equalTo(to));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of move method, of class Item, where both Collections are the same.
|
||||
*/
|
||||
@Test
|
||||
public void testMoveSameCollection() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
while (it.getCollections().size() > 1) {
|
||||
it.removeCollection(it.getCollections().get(0));
|
||||
}
|
||||
|
||||
Collection collection = it.getCollections().get(0);
|
||||
it.setOwningCollection(collection);
|
||||
ItemService itemServiceSpy = spy(itemService);
|
||||
|
||||
itemService.move(context, it, collection, collection);
|
||||
context.restoreAuthSystemState();
|
||||
assertThat("testMoveSameCollection 0", it.getOwningCollection(), notNullValue());
|
||||
assertThat("testMoveSameCollection 1", it.getOwningCollection(), equalTo(collection));
|
||||
verify(itemServiceSpy, times(0)).delete(context, it);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of hasUploadedFiles method, of class Item.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user