mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 05:23:14 +00:00
Fix the deletion tests by ensuring they are more independent
This commit is contained in:
@@ -607,13 +607,20 @@ public class CollectionTest extends AbstractDSpaceObjectTest
|
|||||||
{
|
{
|
||||||
new NonStrictExpectations(AuthorizeUtil.class)
|
new NonStrictExpectations(AuthorizeUtil.class)
|
||||||
{{
|
{{
|
||||||
|
// Allow manage AdminGroup perms (needed to possibly create group first)
|
||||||
|
AuthorizeUtil.authorizeManageAdminGroup((Context) any, (Collection) any);
|
||||||
|
result = null;
|
||||||
// Allow remove AdminGroup perms
|
// Allow remove AdminGroup perms
|
||||||
AuthorizeUtil.authorizeRemoveAdminGroup((Context) any, (Collection) any);
|
AuthorizeUtil.authorizeRemoveAdminGroup((Context) any, (Collection) any);
|
||||||
result = null;
|
result = null;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
// Ensure admin group is created first
|
||||||
|
Group result = c.createAdministrators();
|
||||||
|
assertThat("testRemoveAdministratorsAuth 0",c.getAdministrators(), notNullValue());
|
||||||
|
assertThat("testRemoveAdministratorsAuth 1",c.getAdministrators(), equalTo(result));
|
||||||
c.removeAdministrators();
|
c.removeAdministrators();
|
||||||
assertThat("testRemoveAdministratorsAuth 0", c.getAdministrators(), nullValue());
|
assertThat("testRemoveAdministratorsAuth 2", c.getAdministrators(), nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -624,11 +631,18 @@ public class CollectionTest extends AbstractDSpaceObjectTest
|
|||||||
{
|
{
|
||||||
new NonStrictExpectations(AuthorizeUtil.class)
|
new NonStrictExpectations(AuthorizeUtil.class)
|
||||||
{{
|
{{
|
||||||
|
// Allow manage AdminGroup perms (needed to possibly create group first)
|
||||||
|
AuthorizeUtil.authorizeManageAdminGroup((Context) any, (Collection) any);
|
||||||
|
result = null;
|
||||||
// Disallow remove AdminGroup perms
|
// Disallow remove AdminGroup perms
|
||||||
AuthorizeUtil.authorizeRemoveAdminGroup((Context) any, (Collection) any);
|
AuthorizeUtil.authorizeRemoveAdminGroup((Context) any, (Collection) any);
|
||||||
result = new AuthorizeException();
|
result = new AuthorizeException();
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
// Ensure admin group is created first
|
||||||
|
Group result = c.createAdministrators();
|
||||||
|
assertThat("testRemoveAdministratorsAuth 0",c.getAdministrators(), notNullValue());
|
||||||
|
assertThat("testRemoveAdministratorsAuth 1",c.getAdministrators(), equalTo(result));
|
||||||
c.removeAdministrators();
|
c.removeAdministrators();
|
||||||
fail("Exception expected");
|
fail("Exception expected");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user