diff --git a/src/main/java/mops/gruppen2/controller/APIController.java b/src/main/java/mops/gruppen2/controller/APIController.java index a6cfeb1..a70b2db 100644 --- a/src/main/java/mops/gruppen2/controller/APIController.java +++ b/src/main/java/mops/gruppen2/controller/APIController.java @@ -22,10 +22,9 @@ import java.util.UUID; import java.util.stream.Collectors; /** - * Ein Beispiel für eine API mit Swagger. + * Api zum Datenabgleich mit Gruppenfindung. */ -//TODO: Testing -//TODO: API-Service +//TODO: API-Service? @RestController @RequestMapping("/gruppen2/api") public class APIController { @@ -40,20 +39,20 @@ public class APIController { this.userService = userService; } - @GetMapping("/updateGroups/{status}") + @GetMapping("/updateGroups/{lastEventId}") @Secured("ROLE_api_user") @ApiOperation("Gibt alle Gruppen zurück, in denen sich etwas geändert hat") - public GroupRequestWrapper updateGroup(@ApiParam("Letzter Status des Anfragestellers") @PathVariable Long status) throws EventException { - List events = eventService.getNewEvents(status); + public GroupRequestWrapper updateGroups(@ApiParam("Letzter Status des Anfragestellers") @PathVariable Long lastEventId) throws EventException { + List events = eventService.getNewEvents(lastEventId); return APIFormatterService.wrap(eventService.getMaxEventId(), groupService.projectEventList(events)); } - @GetMapping("/getGroupIdsOfUser/{teilnehmer}") + @GetMapping("/getGroupIdsOfUser/{userId}") @Secured("ROLE_api_user") @ApiOperation("Gibt alle Gruppen zurück, in denen sich ein Teilnehmer befindet") - public List getGroupsOfUser(@ApiParam("Teilnehmer dessen groupIds zurückgegeben werden sollen") @PathVariable String teilnehmer) { - return userService.getUserGroups(teilnehmer).stream() + public List getGroupIdsOfUser(@ApiParam("Teilnehmer dessen groupIds zurückgegeben werden sollen") @PathVariable String userId) { + return userService.getUserGroups(userId).stream() .map(group -> group.getId().toString()) .collect(Collectors.toList()); } @@ -61,10 +60,14 @@ public class APIController { @GetMapping("/getGroup/{groupId}") @Secured("ROLE_api_user") @ApiOperation("Gibt die Gruppe mit der als Parameter mitgegebenden groupId zurück") - public Group getGroupFromId(@ApiParam("GruppenId der gefordeten Gruppe") @PathVariable String groupId) throws EventException { + public Group getGroupById(@ApiParam("GruppenId der gefordeten Gruppe") @PathVariable String groupId) throws EventException { List eventList = eventService.getEventsOfGroup(UUID.fromString(groupId)); List groups = groupService.projectEventList(eventList); + if (groups.isEmpty()) { + return null; + } + return groups.get(0); } diff --git a/src/main/java/mops/gruppen2/service/APIFormatterService.java b/src/main/java/mops/gruppen2/service/APIFormatterService.java index 4f089c5..2985a4f 100644 --- a/src/main/java/mops/gruppen2/service/APIFormatterService.java +++ b/src/main/java/mops/gruppen2/service/APIFormatterService.java @@ -11,7 +11,7 @@ public final class APIFormatterService { private APIFormatterService() {} - public static GroupRequestWrapper wrap(Long status, List groupList) { + public static GroupRequestWrapper wrap(long status, List groupList) { return new GroupRequestWrapper(status, groupList); } } diff --git a/src/main/java/mops/gruppen2/service/EventService.java b/src/main/java/mops/gruppen2/service/EventService.java index 837d174..5226519 100644 --- a/src/main/java/mops/gruppen2/service/EventService.java +++ b/src/main/java/mops/gruppen2/service/EventService.java @@ -18,11 +18,9 @@ import java.util.stream.Collectors; public class EventService { private static final Logger LOG = LoggerFactory.getLogger(EventService.class); - private final JsonService jsonService; private final EventRepository eventStore; - public EventService(JsonService jsonService, EventRepository eventStore) { - this.jsonService = jsonService; + public EventService(EventRepository eventStore) { this.eventStore = eventStore; } @@ -121,8 +119,16 @@ public class EventService { return events; } - public Long getMaxEventId() { - return eventStore.getHighesEventID(); + public long getMaxEventId() { + long highestEvent = 0; + + try { + highestEvent = eventStore.getHighesEventID(); + } catch (NullPointerException e) { + LOG.debug("Eine maxId von 0 wurde zurückgegeben, da keine Events vorhanden sind."); + } + + return highestEvent; } /** diff --git a/src/main/java/mops/gruppen2/service/UserService.java b/src/main/java/mops/gruppen2/service/UserService.java index d906b3d..dd6d65b 100644 --- a/src/main/java/mops/gruppen2/service/UserService.java +++ b/src/main/java/mops/gruppen2/service/UserService.java @@ -25,7 +25,7 @@ public class UserService { @Cacheable("groups") public List getUserGroups(String userId) throws EventException { - return getUserGroups(new User(userId, null, null, null)); + return getUserGroups(new User(userId, "", "", "")); } /** @@ -35,6 +35,7 @@ public class UserService { * * @return Liste aus Gruppen */ + //TODO: Nur AddUserEvents + DeleteUserEvents betrachten @Cacheable("groups") public List getUserGroups(User user) { List groupIds = eventService.findGroupIdsByUser(user.getId()); diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql deleted file mode 100644 index 942abad..0000000 --- a/src/main/resources/data.sql +++ /dev/null @@ -1,6 +0,0 @@ -insert into event values -(1,'8c15f614-fe04-4ac4-a2d7-d13e62ba8597','orga','CreateGroupEvent','{"type":"CreateGroupEvent","groupId":"8c15f614-fe04-4ac4-a2d7-d13e62ba8597","userId":"orga","groupVisibility":"PUBLIC","groupParent":null,"groupType":"SIMPLE","groupUserMaximum":2}'), -(2,'8c15f614-fe04-4ac4-a2d7-d13e62ba8597','orga','AddUserEvent','{"type":"AddUserEvent","groupId":"8c15f614-fe04-4ac4-a2d7-d13e62ba8597","userId":"orga","givenname":"orga","familyname":"orga","email":"blorga@orga.org"}'), -(3,'8c15f614-fe04-4ac4-a2d7-d13e62ba8597','orga','UpdateGroupTitleEvent','{"type":"UpdateGroupTitleEvent","groupId":"8c15f614-fe04-4ac4-a2d7-d13e62ba8597","userId":"orga","newGroupTitle":"sdsad"}'), -(4,'8c15f614-fe04-4ac4-a2d7-d13e62ba8597','orga','UpdateGroupDescriptionEvent','{"type":"UpdateGroupDescriptionEvent","groupId":"8c15f614-fe04-4ac4-a2d7-d13e62ba8597","userId":"orga","newGroupDescription":"sadsad"}'), -(5,'8c15f614-fe04-4ac4-a2d7-d13e62ba8597','orga','UpdateRoleEvent','{"type":"UpdateRoleEvent","groupId":"8c15f614-fe04-4ac4-a2d7-d13e62ba8597","userId":"orga","newRole":"ADMIN"}'); diff --git a/src/test/java/mops/gruppen2/TestBuilder.java b/src/test/java/mops/gruppen2/TestBuilder.java index 1ca41b2..d79f850 100644 --- a/src/test/java/mops/gruppen2/TestBuilder.java +++ b/src/test/java/mops/gruppen2/TestBuilder.java @@ -55,10 +55,11 @@ public class TestBuilder { * * @return UUID */ - public static UUID uuidFromInt(int id) { + public static UUID uuidMock(int id) { + String idString = String.valueOf(Math.abs(id + 1)); return UUID.fromString("00000000-0000-0000-0000-" - + "0".repeat(11 - String.valueOf(id).length()) - + id); + + "0".repeat(11 - idString.length()) + + idString); } /** diff --git a/src/test/java/mops/gruppen2/controller/APIControllerTest.java b/src/test/java/mops/gruppen2/controller/APIControllerTest.java new file mode 100644 index 0000000..a04386b --- /dev/null +++ b/src/test/java/mops/gruppen2/controller/APIControllerTest.java @@ -0,0 +1,167 @@ +package mops.gruppen2.controller; + +import mops.gruppen2.Gruppen2Application; +import mops.gruppen2.repository.EventRepository; +import mops.gruppen2.service.EventService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.transaction.annotation.Transactional; + +import static mops.gruppen2.TestBuilder.addUserEvent; +import static mops.gruppen2.TestBuilder.createPrivateGroupEvent; +import static mops.gruppen2.TestBuilder.createPublicGroupEvent; +import static mops.gruppen2.TestBuilder.deleteGroupEvent; +import static mops.gruppen2.TestBuilder.deleteUserEvent; +import static mops.gruppen2.TestBuilder.updateGroupTitleEvent; +import static mops.gruppen2.TestBuilder.uuidMock; +import static org.assertj.core.api.Assertions.assertThat; + +@ExtendWith(SpringExtension.class) +@SpringBootTest(classes = Gruppen2Application.class) +@Transactional +@Rollback +class APIControllerTest { + + @Autowired + private EventRepository eventRepository; + @Autowired + private APIController apiController; + private EventService eventService; + @Autowired + private JdbcTemplate template; + + @BeforeEach + void setUp() { + eventService = new EventService(eventRepository); + eventRepository.deleteAll(); + //noinspection SqlResolve + template.execute("ALTER TABLE event ALTER COLUMN event_id RESTART WITH 1"); + } + + @Test + @WithMockUser(username = "api_user", roles = "api_user") + void updateGroup_noGroup() { + assertThat(apiController.updateGroups(0L).getGroupList()).hasSize(0); + assertThat(apiController.updateGroups(4L).getGroupList()).hasSize(0); + assertThat(apiController.updateGroups(10L).getGroupList()).hasSize(0); + assertThat(apiController.updateGroups(0L).getStatus()).isEqualTo(0); + } + + @Test + @WithMockUser(username = "api_user", roles = "api_user") + void updateGroup_singleGroup() { + eventService.saveAll(createPublicGroupEvent(uuidMock(0)), + addUserEvent(uuidMock(0)), + addUserEvent(uuidMock(0)), + addUserEvent(uuidMock(0)), + addUserEvent(uuidMock(0))); + + assertThat(apiController.updateGroups(0L).getGroupList()).hasSize(1); + assertThat(apiController.updateGroups(4L).getGroupList()).hasSize(1); + assertThat(apiController.updateGroups(10L).getGroupList()).hasSize(0); + assertThat(apiController.updateGroups(0L).getStatus()).isEqualTo(5); + } + + + @Test + @WithMockUser(username = "api_user", roles = "api_user") + void updateGroup_multipleGroups() { + eventService.saveAll(createPublicGroupEvent(uuidMock(0)), + addUserEvent(uuidMock(0)), + addUserEvent(uuidMock(0)), + createPrivateGroupEvent(uuidMock(1)), + addUserEvent(uuidMock(1)), + addUserEvent(uuidMock(1)), + addUserEvent(uuidMock(1))); + + assertThat(apiController.updateGroups(0L).getGroupList()).hasSize(2); + assertThat(apiController.updateGroups(4L).getGroupList()).hasSize(1); + assertThat(apiController.updateGroups(6L).getGroupList()).hasSize(1); + assertThat(apiController.updateGroups(7L).getGroupList()).hasSize(0); + assertThat(apiController.updateGroups(0L).getStatus()).isEqualTo(7); + } + + @Test + @WithMockUser(username = "api_user", roles = "api_user") + void getGroupsOfUser_noGroup() { + assertThat(apiController.getGroupIdsOfUser("A")).isEmpty(); + } + + @Test + @WithMockUser(username = "api_user", roles = "api_user") + void getGroupsOfUser_singleGroup() { + eventService.saveAll(createPrivateGroupEvent(uuidMock(0)), + createPrivateGroupEvent(uuidMock(1)), + createPrivateGroupEvent(uuidMock(2)), + addUserEvent(uuidMock(0), "A")); + + assertThat(apiController.getGroupIdsOfUser("A")).hasSize(1); + } + + @Test + @WithMockUser(username = "api_user", roles = "api_user") + void getGroupsOfUser_singleGroupDeletedUser() { + eventService.saveAll(createPrivateGroupEvent(uuidMock(0)), + addUserEvent(uuidMock(0), "A"), + deleteUserEvent(uuidMock(0), "A")); + + assertThat(apiController.getGroupIdsOfUser("A")).isEmpty(); + } + + @Test + @WithMockUser(username = "api_user", roles = "api_user") + void getGroupsOfUser_singleDeletedGroup() { + eventService.saveAll(createPrivateGroupEvent(uuidMock(0)), + addUserEvent(uuidMock(0), "A"), + deleteGroupEvent(uuidMock(0))); + + assertThat(apiController.getGroupIdsOfUser("A")).isEmpty(); + } + + @Test + @WithMockUser(username = "api_user", roles = "api_user") + void getGroupsOfUser_multipleGroups() { + eventService.saveAll(createPrivateGroupEvent(uuidMock(0)), + createPrivateGroupEvent(uuidMock(1)), + createPrivateGroupEvent(uuidMock(2)), + addUserEvent(uuidMock(0), "A"), + addUserEvent(uuidMock(0), "B"), + addUserEvent(uuidMock(1), "A"), + addUserEvent(uuidMock(2), "A"), + addUserEvent(uuidMock(2), "B")); + + assertThat(apiController.getGroupIdsOfUser("A")).hasSize(3); + assertThat(apiController.getGroupIdsOfUser("B")).hasSize(2); + } + + @Test + @WithMockUser(username = "api_user", roles = "api_user") + void getGroupFromId_noGroup() { + assertThat(apiController.getGroupById(uuidMock(0).toString())).isEqualTo(null); + } + + @Test + @WithMockUser(username = "api_user", roles = "api_user") + void getGroupFromId_singleGroup() { + eventService.saveAll(createPrivateGroupEvent(uuidMock(0))); + + assertThat(apiController.getGroupById(uuidMock(0).toString()).getId()).isEqualTo(uuidMock(0)); + } + + @Test + @WithMockUser(username = "api_user", roles = "api_user") + void getGroupFromId_deletedGroup() { + eventService.saveAll(createPrivateGroupEvent(uuidMock(0)), + updateGroupTitleEvent(uuidMock(0)), + deleteGroupEvent(uuidMock(0))); + + assertThat(apiController.getGroupById(uuidMock(0).toString()).getTitle()).isEqualTo(null); + } +} diff --git a/src/test/java/mops/gruppen2/service/ControllerServiceTest.java b/src/test/java/mops/gruppen2/service/ControllerServiceTest.java index 8f5a71d..9cfc762 100644 --- a/src/test/java/mops/gruppen2/service/ControllerServiceTest.java +++ b/src/test/java/mops/gruppen2/service/ControllerServiceTest.java @@ -45,13 +45,11 @@ class ControllerServiceTest { EventRepository eventRepository; GroupService groupService; @Autowired - JsonService jsonService; - @Autowired InviteService inviteService; @BeforeEach void setUp() { - eventService = new EventService(jsonService, eventRepository); + eventService = new EventService(eventRepository); groupService = new GroupService(eventService, eventRepository); userService = new UserService(groupService, eventService); validationService = new ValidationService(userService, groupService); diff --git a/src/test/java/mops/gruppen2/service/EventServiceTest.java b/src/test/java/mops/gruppen2/service/EventServiceTest.java index 540e854..43e105c 100644 --- a/src/test/java/mops/gruppen2/service/EventServiceTest.java +++ b/src/test/java/mops/gruppen2/service/EventServiceTest.java @@ -5,26 +5,23 @@ import mops.gruppen2.domain.dto.EventDTO; import mops.gruppen2.domain.event.Event; import mops.gruppen2.repository.EventRepository; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Transactional; import static mops.gruppen2.TestBuilder.addUserEvent; import static mops.gruppen2.TestBuilder.addUserEvents; -import static mops.gruppen2.TestBuilder.createPrivateGroupEvent; import static mops.gruppen2.TestBuilder.createPrivateGroupEvents; import static mops.gruppen2.TestBuilder.createPublicGroupEvent; import static mops.gruppen2.TestBuilder.createPublicGroupEvents; -import static mops.gruppen2.TestBuilder.updateGroupDescriptionEvent; -import static mops.gruppen2.TestBuilder.uuidFromInt; +import static mops.gruppen2.TestBuilder.uuidMock; import static org.assertj.core.api.Assertions.assertThat; -//TODO: Der ID autocounter wird nicht resettet -> Tests schlagen fehl beim nacheinanderausführen @ExtendWith(SpringExtension.class) @SpringBootTest(classes = Gruppen2Application.class) @Transactional @@ -33,14 +30,16 @@ class EventServiceTest { @Autowired private EventRepository eventRepository; - @Autowired - private JsonService jsonService; private EventService eventService; + @Autowired + private JdbcTemplate template; @BeforeEach void setUp() { - eventService = new EventService(jsonService, eventRepository); + eventService = new EventService(eventRepository); eventRepository.deleteAll(); + //noinspection SqlResolve + template.execute("ALTER TABLE event ALTER COLUMN event_id RESTART WITH 1"); } @Test @@ -79,20 +78,20 @@ class EventServiceTest { @Test void getEventsOfGroup() { - eventService.saveAll(addUserEvents(10, uuidFromInt(0)), - addUserEvents(5, uuidFromInt(1))); + eventService.saveAll(addUserEvents(10, uuidMock(0)), + addUserEvents(5, uuidMock(1))); - assertThat(eventService.getEventsOfGroup(uuidFromInt(0))).hasSize(10); - assertThat(eventService.getEventsOfGroup(uuidFromInt(1))).hasSize(5); + assertThat(eventService.getEventsOfGroup(uuidMock(0))).hasSize(10); + assertThat(eventService.getEventsOfGroup(uuidMock(1))).hasSize(5); } @Test void findGroupIdsByUser() { - eventService.saveAll(addUserEvent(uuidFromInt(0), "A"), - addUserEvent(uuidFromInt(1), "A"), - addUserEvent(uuidFromInt(2), "A"), - addUserEvent(uuidFromInt(3), "A"), - addUserEvent(uuidFromInt(3), "B")); + eventService.saveAll(addUserEvent(uuidMock(0), "A"), + addUserEvent(uuidMock(1), "A"), + addUserEvent(uuidMock(2), "A"), + addUserEvent(uuidMock(3), "A"), + addUserEvent(uuidMock(3), "B")); assertThat(eventService.findGroupIdsByUser("A")).hasSize(4); assertThat(eventService.findGroupIdsByUser("B")).hasSize(1); diff --git a/src/test/java/mops/gruppen2/service/GroupServiceTest.java b/src/test/java/mops/gruppen2/service/GroupServiceTest.java index 3101bf0..641bbd4 100644 --- a/src/test/java/mops/gruppen2/service/GroupServiceTest.java +++ b/src/test/java/mops/gruppen2/service/GroupServiceTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Transactional; @@ -30,7 +31,7 @@ import static mops.gruppen2.TestBuilder.createPublicGroupEvent; import static mops.gruppen2.TestBuilder.deleteGroupEvent; import static mops.gruppen2.TestBuilder.updateGroupDescriptionEvent; import static mops.gruppen2.TestBuilder.updateGroupTitleEvent; -import static mops.gruppen2.TestBuilder.uuidFromInt; +import static mops.gruppen2.TestBuilder.uuidMock; import static org.assertj.core.api.Assertions.assertThat; @ExtendWith(SpringExtension.class) @@ -44,11 +45,15 @@ class GroupServiceTest { @Autowired private EventService eventService; private GroupService groupService; + @Autowired + private JdbcTemplate template; @BeforeEach void setUp() { groupService = new GroupService(eventService, eventRepository); eventRepository.deleteAll(); + //noinspection SqlResolve + template.execute("ALTER TABLE event ALTER COLUMN event_id RESTART WITH 1"); } //TODO: Wofür ist dieser Test? @@ -91,23 +96,23 @@ class GroupServiceTest { //CreateGroupEvent test1 = new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L); //CreateGroupEvent test2 = new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.SIMPLE, Visibility.PUBLIC, 10L); - eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)), - createPublicGroupEvent(uuidFromInt(1)), - createPrivateGroupEvent(uuidFromInt(2))); + eventService.saveAll(createPublicGroupEvent(uuidMock(0)), + createPublicGroupEvent(uuidMock(1)), + createPrivateGroupEvent(uuidMock(2))); - List groupIds = Arrays.asList(uuidFromInt(0), uuidFromInt(1)); + List groupIds = Arrays.asList(uuidMock(0), uuidMock(1)); assertThat(groupService.getGroupEvents(groupIds)).hasSize(2); - assertThat(groupService.getGroupEvents(groupIds).get(0).getGroupId()).isEqualTo(uuidFromInt(0)); - assertThat(groupService.getGroupEvents(groupIds).get(1).getGroupId()).isEqualTo(uuidFromInt(1)); + assertThat(groupService.getGroupEvents(groupIds).get(0).getGroupId()).isEqualTo(uuidMock(0)); + assertThat(groupService.getGroupEvents(groupIds).get(1).getGroupId()).isEqualTo(uuidMock(1)); } @Test void getAllGroupWithVisibilityPublicTestCreateAndDeleteSameGroup() { //CreateGroupEvent test1 = new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L); //DeleteGroupEvent test2 = new DeleteGroupEvent(uuidFromInt(0), "test1"); - Event test1 = createPublicGroupEvent(uuidFromInt(0)); - Event test2 = deleteGroupEvent(uuidFromInt(0)); + Event test1 = createPublicGroupEvent(uuidMock(0)); + Event test2 = deleteGroupEvent(uuidMock(0)); //Group group = new Group(); //test1.apply(group); @@ -127,9 +132,9 @@ class GroupServiceTest { //eventService.saveEvent(new CreateGroupEvent(uuidFromInt(1), "test2", null, GroupType.LECTURE, Visibility.PUBLIC, 10L)); //eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(1), "test2", Role.MEMBER)); //Wofür ist das - eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)), - deleteGroupEvent(uuidFromInt(0)), - createPublicGroupEvent()); + eventService.saveAll(createPublicGroupEvent(uuidMock(0)), + deleteGroupEvent(uuidMock(0)), + createPublicGroupEvent()); assertThat(groupService.getAllGroupWithVisibilityPublic("test1").size()).isEqualTo(1); } @@ -144,12 +149,12 @@ class GroupServiceTest { //eventService.saveEvent(new CreateGroupEvent(uuidFromInt(3), "test4", null, GroupType.LECTURE, Visibility.PUBLIC, 10L)); //eventService.saveEvent(new CreateGroupEvent(uuidFromInt(4), "test5", null, GroupType.LECTURE, Visibility.PUBLIC, 10L)); - eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)), - deleteGroupEvent(uuidFromInt(0)), - createPublicGroupEvent(), - createPublicGroupEvent(), - createPublicGroupEvent(), - createPrivateGroupEvent()); + eventService.saveAll(createPublicGroupEvent(uuidMock(0)), + deleteGroupEvent(uuidMock(0)), + createPublicGroupEvent(), + createPublicGroupEvent(), + createPublicGroupEvent(), + createPrivateGroupEvent()); assertThat(groupService.getAllGroupWithVisibilityPublic("test1").size()).isEqualTo(3); } @@ -159,10 +164,10 @@ class GroupServiceTest { //eventService.saveEvent(new CreateGroupEvent(uuidFromInt(0), "test1", null, GroupType.SIMPLE, Visibility.PUBLIC, 20L)); //eventService.saveEvent(new AddUserEvent(uuidFromInt(0), "test1", "test", "test", "test@test")); - eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)), - addUserEvent(uuidFromInt(0), "kobold"), - createPrivateGroupEvent(), - createPublicGroupEvent()); + eventService.saveAll(createPublicGroupEvent(uuidMock(0)), + addUserEvent(uuidMock(0), "kobold"), + createPrivateGroupEvent(), + createPublicGroupEvent()); //Das kommt glaube ich eher in einen Test für die Projektion //assertThat(groupService.getAllGroupWithVisibilityPublic("test2").get(0).getMembers().size()).isEqualTo(1); @@ -181,10 +186,10 @@ class GroupServiceTest { //eventService.saveEvent(new CreateGroupEvent(uuidFromInt(4), "test5", null, GroupType.LECTURE, Visibility.PUBLIC, 10L)); eventService.saveAll(createLectureEvent(), - createPublicGroupEvent(), - createLectureEvent(), - createLectureEvent(), - createLectureEvent()); + createPublicGroupEvent(), + createLectureEvent(), + createLectureEvent(), + createLectureEvent()); assertThat(groupService.getAllLecturesWithVisibilityPublic().size()).isEqualTo(4); } @@ -197,10 +202,10 @@ class GroupServiceTest { //eventService.saveEvent(new UpdateGroupDescriptionEvent(uuidFromInt(0), "test1", "TestDescription")); //eventService.saveEvent(new UpdateRoleEvent(uuidFromInt(0), "test1", Role.MEMBER)); - eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)), - addUserEvent(uuidFromInt(0), "jens"), - updateGroupTitleEvent(uuidFromInt(0)), - updateGroupDescriptionEvent(uuidFromInt(0))); + eventService.saveAll(createPublicGroupEvent(uuidMock(0)), + addUserEvent(uuidMock(0), "jens"), + updateGroupTitleEvent(uuidMock(0)), + updateGroupDescriptionEvent(uuidMock(0))); //assertThat(groupService.findGroupWith("T", new Account("jens", "a@A", "test", "peter", "mueller", null)).size()).isEqualTo(1); assertThat(groupService.findGroupWith("", account("jens"))).isEmpty(); @@ -209,20 +214,20 @@ class GroupServiceTest { @Test void findGroupWith_UserNoMember_AllGroups() { eventService.saveAll(completePublicGroups(10, 0), - completePrivateGroups(10, 0)); + completePrivateGroups(10, 0)); assertThat(groupService.findGroupWith("", account("jens"))).hasSize(10); } @Test void findGroupWith_FilterGroups() { - eventService.saveAll(createPublicGroupEvent(uuidFromInt(0)), - updateGroupTitleEvent(uuidFromInt(0), "KK"), - updateGroupDescriptionEvent(uuidFromInt(0), "ABCDE"), - createPublicGroupEvent(uuidFromInt(1)), - updateGroupTitleEvent(uuidFromInt(1), "ABCDEFG"), - updateGroupDescriptionEvent(uuidFromInt(1), "KK"), - createPrivateGroupEvent()); + eventService.saveAll(createPublicGroupEvent(uuidMock(0)), + updateGroupTitleEvent(uuidMock(0), "KK"), + updateGroupDescriptionEvent(uuidMock(0), "ABCDE"), + createPublicGroupEvent(uuidMock(1)), + updateGroupTitleEvent(uuidMock(1), "ABCDEFG"), + updateGroupDescriptionEvent(uuidMock(1), "KK"), + createPrivateGroupEvent()); assertThat(groupService.findGroupWith("A", account("jesus"))).hasSize(2); assertThat(groupService.findGroupWith("F", account("jesus"))).hasSize(1);