mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
Replace GroupService by GroupBuilder in a couple tests
This commit is contained in:
@@ -1640,72 +1640,52 @@ public class GroupRestRepositoryIT extends AbstractControllerIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deleteGroupTest() throws Exception {
|
public void deleteGroupTest() throws Exception {
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
|
Group parentGroup = GroupBuilder.createGroup(context)
|
||||||
|
.withName("test group")
|
||||||
|
.build();
|
||||||
|
|
||||||
Group parentGroup = null;
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
try {
|
String authToken = getAuthToken(admin.getEmail(), password);
|
||||||
context.turnOffAuthorisationSystem();
|
|
||||||
|
|
||||||
parentGroup = groupService.create(context);
|
getClient(authToken).perform(
|
||||||
|
get("/api/eperson/groups/" + parentGroup.getID())
|
||||||
|
).andExpect(status().isOk());
|
||||||
|
|
||||||
context.restoreAuthSystemState();
|
getClient(authToken).perform(
|
||||||
|
delete("/api/eperson/groups/" + parentGroup.getID())
|
||||||
|
).andExpect(status().isNoContent());
|
||||||
|
|
||||||
String authToken = getAuthToken(admin.getEmail(), password);
|
getClient(authToken).perform(
|
||||||
|
get("/api/eperson/groups/" + parentGroup.getID())
|
||||||
getClient(authToken).perform(
|
).andExpect(status().isNotFound());
|
||||||
get("/api/eperson/groups/" + parentGroup.getID())
|
|
||||||
).andExpect(status().isOk());
|
|
||||||
|
|
||||||
getClient(authToken).perform(
|
|
||||||
delete("/api/eperson/groups/" + parentGroup.getID())
|
|
||||||
).andExpect(status().isNoContent());
|
|
||||||
|
|
||||||
getClient(authToken).perform(
|
|
||||||
get("/api/eperson/groups/" + parentGroup.getID())
|
|
||||||
).andExpect(status().isNotFound());
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (parentGroup != null) {
|
|
||||||
GroupBuilder.deleteGroup(parentGroup.getID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deleteGroupUnauthorizedTest() throws Exception {
|
public void deleteGroupUnauthorizedTest() throws Exception {
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
|
Group parentGroup = GroupBuilder.createGroup(context)
|
||||||
|
.withName("test group")
|
||||||
|
.build();
|
||||||
|
|
||||||
Group parentGroup = null;
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
try {
|
String authToken = getAuthToken(admin.getEmail(), password);
|
||||||
context.turnOffAuthorisationSystem();
|
|
||||||
|
|
||||||
parentGroup = groupService.create(context);
|
getClient(authToken).perform(
|
||||||
|
get("/api/eperson/groups/" + parentGroup.getID())
|
||||||
|
).andExpect(status().isOk());
|
||||||
|
|
||||||
context.restoreAuthSystemState();
|
getClient().perform(
|
||||||
|
delete("/api/eperson/groups/" + parentGroup.getID())
|
||||||
|
).andExpect(status().isUnauthorized());
|
||||||
|
|
||||||
String authToken = getAuthToken(admin.getEmail(), password);
|
getClient(authToken).perform(
|
||||||
|
get("/api/eperson/groups/" + parentGroup.getID())
|
||||||
getClient(authToken).perform(
|
).andExpect(status().isOk());
|
||||||
get("/api/eperson/groups/" + parentGroup.getID())
|
|
||||||
).andExpect(status().isOk());
|
|
||||||
|
|
||||||
getClient().perform(
|
|
||||||
delete("/api/eperson/groups/" + parentGroup.getID())
|
|
||||||
).andExpect(status().isUnauthorized());
|
|
||||||
|
|
||||||
getClient(authToken).perform(
|
|
||||||
get("/api/eperson/groups/" + parentGroup.getID())
|
|
||||||
).andExpect(status().isOk());
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (parentGroup != null) {
|
|
||||||
GroupBuilder.deleteGroup(parentGroup.getID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user