1

Merge remote-tracking branch 'origin/master' into group-invite-links

# Conflicts:
#	src/main/java/mops/gruppen2/controller/Gruppen2Controller.java
#	src/main/java/mops/gruppen2/repository/EventRepository.java
#	src/main/java/mops/gruppen2/service/ControllerService.java
#	src/main/java/mops/gruppen2/service/GroupService.java
This commit is contained in:
[Mahgs]
2020-03-18 13:18:34 +01:00
25 changed files with 303 additions and 301 deletions

View File

@ -1,6 +1,5 @@
package mops.gruppen2.service;
import mops.gruppen2.domain.Exceptions.GroupDoesNotExistException;
import mops.gruppen2.domain.Group;
import mops.gruppen2.domain.GroupType;
import mops.gruppen2.domain.Visibility;
@ -29,36 +28,6 @@ class GroupServiceTest {
groupService = new GroupService(mock(EventService.class), eventRepository);
}
@Disabled
@Test
void applyEventOnGroupThatIsDeleted() throws Exception {
List<Event> eventList = new ArrayList<>();
eventList.add(new CreateGroupEvent(1L,"Ulli", null, GroupType.LECTURE, Visibility.PRIVATE));
eventList.add(new DeleteGroupEvent(44, 10, "loescher78"));
eventList.add(new AddUserEvent(900L, 10L, "Ulli", "Ulli", "Honnis", "FC@B.de"));
Assertions.assertThrows(GroupDoesNotExistException.class, () -> {
groupService.projectEventList(eventList);
});
}
@Disabled
@Test
void returnDeletedGroup() throws Exception {
List<Event> eventList = new ArrayList<>();
eventList.add(new CreateGroupEvent(1L, "Prof", null, GroupType.LECTURE, Visibility.PRIVATE));
eventList.add(new DeleteGroupEvent(44, 1L, "loescher78"));
List<Group> list = new ArrayList<>();
assertThat(groupService.projectEventList(eventList)).isEqualTo(list);
}
@Test
void rightClassForSucsessfulGroup() throws Exception {
@ -66,7 +35,7 @@ class GroupServiceTest {
eventList.add(new CreateGroupEvent(1L, "Prof", null, GroupType.LECTURE, Visibility.PRIVATE));
eventList.add(new AddUserEvent(900L, 1L, "Ulli", "Ulli", "Honnis", "FC@B.de"));
eventList.add(new AddUserEvent(1L, "Ulli", "Ulli", "Honnis", "FC@B.de"));
assertThat(groupService.projectEventList(eventList).get(0)).isInstanceOf(Group.class);
}

View File

@ -23,65 +23,8 @@ class SerializationServiceTest {
@Test
void serializeEventTest() throws JsonProcessingException {
Event event = new Event(1L,1L,"1");
Event event = new Event(1L,"1");
assertThat(serializationService.serializeEvent(event)).isEqualTo("{\"type\":\"Event\",\"event_id\":1,\"group_id\":1,\"user_id\":\"1\"}");
}
@Test
void deserializeAddUserEventToRightClass() throws JsonProcessingException {
String json = "{\"type\":\"AddUserEvent\",\"event_id\":1,\"group_id\":1,\"user_id\":\"1\"}";
Event event = serializationService.deserializeEvent(json);
assertThat(event).isInstanceOf(AddUserEvent.class);
}
@Test
void deserializeDeleteUserEventToRightClass() throws JsonProcessingException {
String json = "{\"type\":\"DeleteUserEvent\",\"event_id\":1,\"group_id\":1,\"user_id\":\"1\"}";
Event event = serializationService.deserializeEvent(json);
assertThat(event).isInstanceOf(DeleteUserEvent.class);
}
@Test
void deserializeUpdateGroupDescriptionEventToRightClass() throws JsonProcessingException {
String json = "{\"type\":\"UpdateGroupDescriptionEvent\",\"event_id\":1,\"group_id\":1,\"user_id\":\"1\",\"newGroupDescription\":\"test\"}";
Event event = serializationService.deserializeEvent(json);
assertThat(event).isInstanceOf(UpdateGroupDescriptionEvent.class);
}
@Test
void deserializeUpdateGroupTitleEventToRightClass() throws JsonProcessingException {
String json = "{\"type\":\"UpdateGroupTitleEvent\",\"event_id\":1,\"group_id\":1,\"user_id\":\"1\",\"newGroupTitle\":\"test\"}";
Event event = serializationService.deserializeEvent(json);
assertThat(event).isInstanceOf(UpdateGroupTitleEvent.class);
}
@Test
void deserializeUpdateRoleEventToRightClass() throws JsonProcessingException {
System.out.println(serializationService.serializeEvent(new UpdateRoleEvent(1L, 1L, "1", Role.ADMIN)));
String json = "{\"type\":\"UpdateRoleEvent\",\"event_id\":1,\"group_id\":1,\"user_id\":1,\"newRole\":\"ADMIN\"}";
Event event = serializationService.deserializeEvent(json);
assertThat(event).isInstanceOf(UpdateRoleEvent.class);
}
@Disabled
@Test
void deserializeCreateGroupEventToRightClass() throws JsonProcessingException {
String json = "{\"type\":\"CreateGroupEvent\",\"event_id\":1,\"group_id\":1,\"user_id\":\"1\",\"type\":\"test\",\"visibility\":\"test\"}";
Event event = serializationService.deserializeEvent(json);
assertThat(event).isInstanceOf(CreateGroupEvent.class);
assertThat(serializationService.serializeEvent(event)).isEqualTo("{\"type\":\"Event\",\"group_id\":1,\"user_id\":\"1\"}");
}
}