1

loggers replaced with lombok, additional logging, further general service refactoring

This commit is contained in:
Christoph
2020-04-07 01:32:40 +02:00
parent 952b32a86c
commit 9c6732d2d2
19 changed files with 139 additions and 75 deletions

View File

@ -1,6 +1,7 @@
package mops.gruppen2.controller;
import mops.gruppen2.Gruppen2Application;
import mops.gruppen2.domain.exception.GroupNotFoundException;
import mops.gruppen2.repository.EventRepository;
import mops.gruppen2.service.EventStoreService;
import org.junit.jupiter.api.BeforeEach;
@ -23,6 +24,7 @@ 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;
import static org.junit.jupiter.api.Assertions.assertThrows;
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Gruppen2Application.class)
@ -146,7 +148,7 @@ class APIControllerTest {
@Test
@WithMockUser(username = "api_user", roles = "api_user")
void getGroupFromId_noGroup() {
assertThat(apiController.getGroupById(uuidMock(0).toString())).isEqualTo(null);
assertThrows(GroupNotFoundException.class, () -> apiController.getGroupById(uuidMock(0).toString()));
}
@Test

View File

@ -68,7 +68,7 @@ class EventStoreServiceTest {
void getDTO() {
Event event = createPublicGroupEvent();
EventDTO dto = eventStoreService.getDTOFromEvent(event);
EventDTO dto = EventStoreService.getDTOFromEvent(event);
assertThat(dto.getGroup_id()).isEqualTo(event.getGroupId().toString());
assertThat(dto.getUser_id()).isEqualTo(event.getUserId());
@ -81,8 +81,8 @@ class EventStoreServiceTest {
eventStoreService.saveAll(addUserEvents(10, uuidMock(0)),
addUserEvents(5, uuidMock(1)));
assertThat(eventStoreService.getEventsOfGroup(uuidMock(0))).hasSize(10);
assertThat(eventStoreService.getEventsOfGroup(uuidMock(1))).hasSize(5);
assertThat(eventStoreService.findGroupEvents(uuidMock(0))).hasSize(10);
assertThat(eventStoreService.findGroupEvents(uuidMock(1))).hasSize(5);
}
@Test
@ -93,7 +93,7 @@ class EventStoreServiceTest {
addUserEvent(uuidMock(3), "A"),
addUserEvent(uuidMock(3), "B"));
assertThat(eventStoreService.findGroupIdsByUser("A")).hasSize(4);
assertThat(eventStoreService.findGroupIdsByUser("B")).hasSize(1);
assertThat(eventStoreService.findExistingUserGroups("A")).hasSize(4);
assertThat(eventStoreService.findExistingUserGroups("B")).hasSize(1);
}
}

View File

@ -107,9 +107,9 @@ class GroupServiceTest {
List<UUID> groupIds = Arrays.asList(uuidMock(0), uuidMock(1));
assertThat(eventStoreService.getGroupEvents(groupIds)).hasSize(2);
assertThat(eventStoreService.getGroupEvents(groupIds).get(0).getGroupId()).isEqualTo(uuidMock(0));
assertThat(eventStoreService.getGroupEvents(groupIds).get(1).getGroupId()).isEqualTo(uuidMock(1));
assertThat(eventStoreService.findGroupEvents(groupIds)).hasSize(2);
assertThat(eventStoreService.findGroupEvents(groupIds).get(0).getGroupId()).isEqualTo(uuidMock(0));
assertThat(eventStoreService.findGroupEvents(groupIds).get(1).getGroupId()).isEqualTo(uuidMock(1));
}
//TODO: ProjectionServiceTest