@ -32,11 +32,13 @@ public class ControllerService {
|
||||
|
||||
private final EventService eventService;
|
||||
private final UserService userService;
|
||||
private final InviteService inviteService;
|
||||
private final Logger logger;
|
||||
|
||||
public ControllerService(EventService eventService, UserService userService) {
|
||||
public ControllerService(EventService eventService, UserService userService, InviteService inviteService) {
|
||||
this.eventService = eventService;
|
||||
this.userService = userService;
|
||||
this.inviteService = inviteService;
|
||||
this.logger = Logger.getLogger("controllerServiceLogger");
|
||||
}
|
||||
|
||||
@ -49,6 +51,8 @@ public class ControllerService {
|
||||
* @param title Gruppentitel
|
||||
* @param description Gruppenbeschreibung
|
||||
*/
|
||||
//TODO: better assignments
|
||||
//TODO: createGroup + createOrga auslagern
|
||||
public void createGroup(Account account, String title, String description, Boolean visibility, Boolean maxInfiniteUsers, Long userMaximum, UUID parent) throws EventException {
|
||||
Visibility visibility1;
|
||||
maxInfiniteUsers = maxInfiniteUsers != null;
|
||||
@ -69,6 +73,8 @@ public class ControllerService {
|
||||
CreateGroupEvent createGroupEvent = new CreateGroupEvent(groupId, account.getName(), parent, GroupType.SIMPLE, visibility1, userMaximum);
|
||||
eventService.saveEvent(createGroupEvent);
|
||||
|
||||
inviteService.createLink(groupId);
|
||||
|
||||
addUser(account, groupId);
|
||||
updateTitle(account, groupId, title);
|
||||
updateDescription(account, groupId, description);
|
||||
@ -92,6 +98,8 @@ public class ControllerService {
|
||||
visibility1 = Visibility.PRIVATE;
|
||||
}
|
||||
|
||||
inviteService.createLink(groupId);
|
||||
|
||||
GroupType groupType;
|
||||
if (lecture) {
|
||||
groupType = GroupType.LECTURE;
|
||||
@ -143,6 +151,7 @@ public class ControllerService {
|
||||
eventService.saveEvent(updateUserMaxEvent);
|
||||
}
|
||||
|
||||
//TODO: updateRole + deleteUser, teilweise auslagern zu userInGroup oder sowas
|
||||
public void updateRole(String userId, UUID groupId) throws EventException {
|
||||
UpdateRoleEvent updateRoleEvent;
|
||||
Group group = userService.getGroupById(groupId);
|
||||
@ -184,6 +193,7 @@ public class ControllerService {
|
||||
|
||||
public void deleteGroupEvent(String userId, UUID groupId) {
|
||||
DeleteGroupEvent deleteGroupEvent = new DeleteGroupEvent(groupId, userId);
|
||||
inviteService.destroyLink(groupId);
|
||||
eventService.saveEvent(deleteGroupEvent);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package mops.gruppen2.service;
|
||||
|
||||
import com.github.javafaker.Faker;
|
||||
import mops.gruppen2.repository.EventRepository;
|
||||
import mops.gruppen2.repository.InviteRepository;
|
||||
import mops.gruppen2.security.Account;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -12,6 +13,7 @@ import java.util.Set;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
class ControllerServiceTest {
|
||||
|
||||
Faker faker;
|
||||
Account account;
|
||||
ControllerService controllerService;
|
||||
@ -20,7 +22,8 @@ class ControllerServiceTest {
|
||||
EventRepository eventRepository;
|
||||
GroupService groupService;
|
||||
JsonService jsonService;
|
||||
|
||||
InviteRepository inviteRepository;
|
||||
InviteService inviteService;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@ -30,7 +33,9 @@ class ControllerServiceTest {
|
||||
eventService = new EventService(jsonService, eventRepository);
|
||||
groupService = new GroupService(eventService, eventRepository);
|
||||
userService = new UserService(groupService, eventService);
|
||||
controllerService = new ControllerService(eventService, userService);
|
||||
inviteRepository = mock(InviteRepository.class);
|
||||
inviteService = new InviteService(inviteRepository);
|
||||
controllerService = new ControllerService(eventService, userService, inviteService);
|
||||
Set<String> roles = new HashSet<>();
|
||||
roles.add("l");
|
||||
account = new Account("ich", "ich@hhu.de", "l", "ichdude", "jap", roles);
|
||||
|
Reference in New Issue
Block a user