mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-19 07:53:08 +00:00
add test and fix
This commit is contained in:
@@ -126,7 +126,7 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport {
|
|||||||
* Unset the primary bitstream ID of the bundle
|
* Unset the primary bitstream ID of the bundle
|
||||||
*/
|
*/
|
||||||
public void unsetPrimaryBitstreamID() {
|
public void unsetPrimaryBitstreamID() {
|
||||||
primaryBitstream = null;
|
setPrimaryBitstreamID(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -513,6 +513,38 @@ public class BundleTest extends AbstractDSpaceObjectTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test removeBitstream method and also the unsetPrimaryBitstreamID method, of class Bundle.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testRemoveBitstreamAuthAndUnsetPrimaryBitstreamID() throws IOException, SQLException, AuthorizeException {
|
||||||
|
// Allow Item WRITE permissions
|
||||||
|
doNothing().when(authorizeServiceSpy).authorizeAction(context, item, Constants.WRITE);
|
||||||
|
// Allow Bundle ADD permissions
|
||||||
|
doNothing().when(authorizeServiceSpy).authorizeAction(context, b, Constants.ADD);
|
||||||
|
// Allow Bitstream WRITE permissions
|
||||||
|
doNothing().when(authorizeServiceSpy)
|
||||||
|
.authorizeAction(any(Context.class), any(Bitstream.class), eq(Constants.WRITE));
|
||||||
|
// Allow Bitstream DELETE permissions
|
||||||
|
doNothing().when(authorizeServiceSpy)
|
||||||
|
.authorizeAction(any(Context.class), any(Bitstream.class), eq(Constants.DELETE));
|
||||||
|
|
||||||
|
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
//set a value different than default
|
||||||
|
File f = new File(testProps.get("test.bitstream").toString());
|
||||||
|
Bitstream bs = bitstreamService.create(context, new FileInputStream(f));
|
||||||
|
bundleService.addBitstream(context, b, bs);
|
||||||
|
b.setPrimaryBitstreamID(bs);
|
||||||
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
|
assertThat("testRemoveBitstreamAuthAndUnsetPrimaryBitstreamID 0", b.getPrimaryBitstream(), equalTo(bs));
|
||||||
|
//remove bitstream
|
||||||
|
bundleService.removeBitstream(context, b, bs);
|
||||||
|
//is -1 when not set
|
||||||
|
assertThat("testRemoveBitstreamAuthAndUnsetPrimaryBitstreamID 1", b.getPrimaryBitstream(), equalTo(null));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of update method, of class Bundle.
|
* Test of update method, of class Bundle.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user