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